Skip to content

upgraded to use latest versions and some minor bugfix #348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 40 additions & 23 deletions bin/express-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,15 @@ function createApplication (name, dir, options, done) {
version: '0.0.0',
private: true,
scripts: {
dev: 'nodemon ./bin/www',
start: 'node ./bin/www'
},
dependencies: {
debug: '~2.6.9',
express: '~4.17.1'
debug: '~4.4.1',
express: '~5.1.0'
},
devDependencies: {
nodemon: '~3.1.10'
}
}

Expand All @@ -125,36 +129,49 @@ function createApplication (name, dir, options, done) {
app.locals.uses.push('express.json()')
app.locals.uses.push('express.urlencoded({ extended: false })')

// Cookie parser
app.locals.modules.cookieParser = 'cookie-parser'
app.locals.uses.push('cookieParser()')
pkg.dependencies['cookie-parser'] = '~1.4.5'
if (options.view !== false) {
// Cookie parser
app.locals.modules.cookieParser = 'cookie-parser'
app.locals.uses.push('cookieParser()')
pkg.dependencies['cookie-parser'] = '~1.4.7'
} else {
app.locals.modules['{ responseMiddleware }'] = 'express-response-rest'
app.locals.uses.push('responseMiddleware')
pkg.dependencies['express-response-rest'] = '~1.0.1'
}

if (dir !== '.') {
mkdir(dir, '.')
}

mkdir(dir, 'public')
mkdir(dir, 'public/javascripts')
mkdir(dir, 'public/js')
mkdir(dir, 'public/images')
mkdir(dir, 'public/stylesheets')
mkdir(dir, 'controllers')
mkdir(dir, 'models')
mkdir(dir, 'utils')
mkdir(dir, 'middleware')

if (options.css) {
mkdir(dir, 'public/css')
}

// copy css templates
switch (options.css) {
case 'less':
copyTemplateMulti('css', dir + '/public/stylesheets', '*.less')
copyTemplateMulti('css', dir + '/public/css', '*.less')
break
case 'stylus':
copyTemplateMulti('css', dir + '/public/stylesheets', '*.styl')
copyTemplateMulti('css', dir + '/public/css', '*.styl')
break
case 'compass':
copyTemplateMulti('css', dir + '/public/stylesheets', '*.scss')
copyTemplateMulti('css', dir + '/public/css', '*.scss')
break
case 'sass':
copyTemplateMulti('css', dir + '/public/stylesheets', '*.sass')
copyTemplateMulti('css', dir + '/public/css', '*.sass')
break
default:
copyTemplateMulti('css', dir + '/public/stylesheets', '*.css')
copyTemplateMulti('css', dir + '/public/css', '*.css')
break
}

Expand All @@ -165,7 +182,7 @@ function createApplication (name, dir, options, done) {
if (options.view) {
// Copy view templates
mkdir(dir, 'views')
pkg.dependencies['http-errors'] = '~1.7.2'
pkg.dependencies['http-errors'] = '~2.0.0'
switch (options.view) {
case 'dust':
copyTemplateMulti('views', dir + '/views', '*.dust')
Expand Down Expand Up @@ -202,22 +219,22 @@ function createApplication (name, dir, options, done) {
case 'compass':
app.locals.modules.compass = 'node-compass'
app.locals.uses.push("compass({ mode: 'expanded' })")
pkg.dependencies['node-compass'] = '0.2.3'
pkg.dependencies['node-compass'] = '0.2.4'
break
case 'less':
app.locals.modules.lessMiddleware = 'less-middleware'
app.locals.uses.push("lessMiddleware(path.join(__dirname, 'public'))")
pkg.dependencies['less-middleware'] = '~2.2.1'
pkg.dependencies['less-middleware'] = '~3.1.0'
break
case 'sass':
app.locals.modules.sassMiddleware = 'node-sass-middleware'
app.locals.uses.push("sassMiddleware({\n src: path.join(__dirname, 'public'),\n dest: path.join(__dirname, 'public'),\n indentedSyntax: true, // true = .sass and false = .scss\n sourceMap: true\n})")
pkg.dependencies['node-sass-middleware'] = '0.11.0'
pkg.dependencies['node-sass-middleware'] = '1.1.0'
break
case 'stylus':
app.locals.modules.stylus = 'stylus'
app.locals.uses.push("stylus.middleware(path.join(__dirname, 'public'))")
pkg.dependencies.stylus = '0.54.5'
pkg.dependencies.stylus = '0.64.0'
break
}

Expand All @@ -241,11 +258,11 @@ function createApplication (name, dir, options, done) {
break
case 'ejs':
app.locals.view = { engine: 'ejs' }
pkg.dependencies.ejs = '~2.6.1'
pkg.dependencies.ejs = '~3.1.10'
break
case 'hbs':
app.locals.view = { engine: 'hbs' }
pkg.dependencies.hbs = '~4.0.4'
pkg.dependencies.hbs = '~4.2.0'
break
case 'hjs':
app.locals.view = { engine: 'hjs' }
Expand All @@ -257,15 +274,15 @@ function createApplication (name, dir, options, done) {
break
case 'pug':
app.locals.view = { engine: 'pug' }
pkg.dependencies.pug = '2.0.0-beta11'
pkg.dependencies.pug = '3.0.3'
break
case 'twig':
app.locals.view = { engine: 'twig' }
pkg.dependencies.twig = '~0.10.3'
pkg.dependencies.twig = '~1.17.1'
break
case 'vash':
app.locals.view = { engine: 'vash' }
pkg.dependencies.vash = '~0.12.6'
pkg.dependencies.vash = '~0.13.0'
break
default:
app.locals.view = false
Expand Down
12 changes: 6 additions & 6 deletions templates/js/app.js.ejs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<% if (view) { -%>
var createError = require('http-errors');
const createError = require('http-errors');
<% } -%>
var express = require('express');
var path = require('path');
const express = require('express');
const path = require('path');
<% Object.keys(modules).sort().forEach(function (variable) { -%>
var <%- variable %> = require('<%- modules[variable] %>');
const <%- variable %> = require('<%- modules[variable] %>');
<% }); -%>

<% Object.keys(localModules).sort().forEach(function (variable) { -%>
var <%- variable %> = require('<%- localModules[variable] %>');
const <%- variable %> = require('<%- localModules[variable] %>');
<% }); -%>

var app = express();
const app = express();

<% if (view) { -%>
// view engine setup
Expand Down
2 changes: 1 addition & 1 deletion templates/js/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<head>
<title>Express</title>
<link rel="stylesheet" href="/stylesheets/style.css">
<link rel="stylesheet" href="/css/style.css">
</head>

<body>
Expand Down
22 changes: 12 additions & 10 deletions templates/js/www.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@
* Module dependencies.
*/

var app = require('../app');
var debug = require('debug')('<%- name %>:server');
var http = require('http');
const app = require('../app');
const debug = require('debug')('<%- name %>:server');
const http = require('http');

/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '3000');
const port = normalizePort(process.env.PORT || '3000');
app.set('port', port);

/**
* Create HTTP server.
*/

var server = http.createServer(app);
const server = http.createServer(app);

/**
* Listen on provided port, on all network interfaces.
*/

server.listen(port);
server.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
server.on('error', onError);
server.on('listening', onListening);

Expand All @@ -34,7 +36,7 @@ server.on('listening', onListening);
*/

function normalizePort(val) {
var port = parseInt(val, 10);
const port = parseInt(val, 10);

if (isNaN(port)) {
// named pipe
Expand All @@ -58,7 +60,7 @@ function onError(error) {
throw error;
}

var bind = typeof port === 'string'
const bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;

Expand All @@ -82,8 +84,8 @@ function onError(error) {
*/

function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
const addr = server.address();
const bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
Expand Down
2 changes: 1 addition & 1 deletion templates/views/error.dust
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>{title}</title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<link rel='stylesheet' href='/css/style.css' />
</head>
<body>
<h1>{message}</h1>
Expand Down
2 changes: 1 addition & 1 deletion templates/views/index.dust
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>{title}</title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<link rel='stylesheet' href='/css/style.css' />
</head>
<body>
<h1>{title}</h1>
Expand Down
2 changes: 1 addition & 1 deletion templates/views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<link rel='stylesheet' href='/css/style.css' />
</head>
<body>
<h1><%= title %></h1>
Expand Down
2 changes: 1 addition & 1 deletion templates/views/index.hjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>{{ title }}</title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<link rel='stylesheet' href='/css/style.css' />
</head>
<body>
<h1>{{ title }}</h1>
Expand Down
2 changes: 1 addition & 1 deletion templates/views/layout.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>{{title}}</title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<link rel='stylesheet' href='/css/style.css' />
</head>
<body>
{{{body}}}
Expand Down
2 changes: 1 addition & 1 deletion templates/views/layout.jade
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ doctype html
html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
link(rel='stylesheet', href='/css/style.css')
body
block content
2 changes: 1 addition & 1 deletion templates/views/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ doctype html
html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
link(rel='stylesheet', href='/css/style.css')
body
block content
2 changes: 1 addition & 1 deletion templates/views/layout.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>{{ title }}</title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<link rel='stylesheet' href='/css/style.css' />
</head>
<body>
{% block body %}{% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion templates/views/layout.vash
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta>
<title>@model.title</title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<link rel='stylesheet' href='/css/style.css' />
</head>
<body>
@html.block('content')
Expand Down