From 128fb96bdcb9b0a6479916ede2aa277332a8e747 Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Thu, 19 Jun 2025 23:31:00 +0530 Subject: [PATCH 01/21] gen: nodemon added for dev serve --- bin/express-cli.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/express-cli.js b/bin/express-cli.js index 380a447d..7626e46d 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -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' + }, + devDependencies: { + nodemon: '~3.1.10' } } From 887611b5a32fc47cc483e6cc9767ba0eb0fb36e3 Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Thu, 19 Jun 2025 23:33:12 +0530 Subject: [PATCH 02/21] gen: update var with const --- templates/js/app.js.ejs | 12 ++++++------ templates/js/www.ejs | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/templates/js/app.js.ejs b/templates/js/app.js.ejs index 2ef75aec..e9104a6a 100644 --- a/templates/js/app.js.ejs +++ b/templates/js/app.js.ejs @@ -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 diff --git a/templates/js/www.ejs b/templates/js/www.ejs index 690fc488..a309083e 100644 --- a/templates/js/www.ejs +++ b/templates/js/www.ejs @@ -4,22 +4,22 @@ * 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. @@ -34,7 +34,7 @@ server.on('listening', onListening); */ function normalizePort(val) { - var port = parseInt(val, 10); + const port = parseInt(val, 10); if (isNaN(port)) { // named pipe @@ -58,7 +58,7 @@ function onError(error) { throw error; } - var bind = typeof port === 'string' + const bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port; @@ -82,8 +82,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); From 1865d1cab2eb2db8776a35c4f64155d11881f01c Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Thu, 19 Jun 2025 23:35:44 +0530 Subject: [PATCH 03/21] gen: rename stylesheet directory to css --- bin/express-cli.js | 14 ++++++++------ templates/js/index.html | 2 +- templates/views/error.dust | 2 +- templates/views/index.dust | 2 +- templates/views/index.ejs | 2 +- templates/views/index.hjs | 2 +- templates/views/layout.hbs | 2 +- templates/views/layout.jade | 2 +- templates/views/layout.pug | 2 +- templates/views/layout.twig | 2 +- templates/views/layout.vash | 2 +- 11 files changed, 18 insertions(+), 16 deletions(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index 7626e46d..86fa7742 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -141,24 +141,26 @@ function createApplication (name, dir, options, done) { mkdir(dir, 'public') mkdir(dir, 'public/javascripts') mkdir(dir, 'public/images') - mkdir(dir, 'public/stylesheets') + 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 } diff --git a/templates/js/index.html b/templates/js/index.html index ab1ad8a9..a79e94c5 100644 --- a/templates/js/index.html +++ b/templates/js/index.html @@ -2,7 +2,7 @@ Express - + diff --git a/templates/views/error.dust b/templates/views/error.dust index 32a93665..948518ef 100644 --- a/templates/views/error.dust +++ b/templates/views/error.dust @@ -2,7 +2,7 @@ {title} - +

{message}

diff --git a/templates/views/index.dust b/templates/views/index.dust index 7170cffa..73d2a73e 100644 --- a/templates/views/index.dust +++ b/templates/views/index.dust @@ -2,7 +2,7 @@ {title} - +

{title}

diff --git a/templates/views/index.ejs b/templates/views/index.ejs index 7b7a1d6d..4ada1771 100644 --- a/templates/views/index.ejs +++ b/templates/views/index.ejs @@ -2,7 +2,7 @@ <%= title %> - +

<%= title %>

diff --git a/templates/views/index.hjs b/templates/views/index.hjs index 821a8dee..af12d7e5 100644 --- a/templates/views/index.hjs +++ b/templates/views/index.hjs @@ -2,7 +2,7 @@ {{ title }} - +

{{ title }}

diff --git a/templates/views/layout.hbs b/templates/views/layout.hbs index 068eb6be..bbb1cee8 100644 --- a/templates/views/layout.hbs +++ b/templates/views/layout.hbs @@ -2,7 +2,7 @@ {{title}} - + {{{body}}} diff --git a/templates/views/layout.jade b/templates/views/layout.jade index 15af079b..215cbc6c 100644 --- a/templates/views/layout.jade +++ b/templates/views/layout.jade @@ -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 diff --git a/templates/views/layout.pug b/templates/views/layout.pug index 15af079b..215cbc6c 100644 --- a/templates/views/layout.pug +++ b/templates/views/layout.pug @@ -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 diff --git a/templates/views/layout.twig b/templates/views/layout.twig index bce6dd55..0d70694a 100644 --- a/templates/views/layout.twig +++ b/templates/views/layout.twig @@ -2,7 +2,7 @@ {{ title }} - + {% block body %}{% endblock %} diff --git a/templates/views/layout.vash b/templates/views/layout.vash index ab67afb9..dff45f69 100644 --- a/templates/views/layout.vash +++ b/templates/views/layout.vash @@ -3,7 +3,7 @@ @model.title - + @html.block('content') From d92d778c84d36456ca3647686189404309b9218c Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Thu, 19 Jun 2025 23:38:36 +0530 Subject: [PATCH 04/21] gen: update express to ~5.1.0 --- bin/express-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index 86fa7742..d29b62d7 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -100,7 +100,7 @@ function createApplication (name, dir, options, done) { }, dependencies: { debug: '~2.6.9', - express: '~4.17.1' + express: '~5.1.0' }, devDependencies: { nodemon: '~3.1.10' From 781645a73986c5020da4a606d06101531df86a97 Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Thu, 19 Jun 2025 23:39:09 +0530 Subject: [PATCH 05/21] gen: update debug to ~4.4.1 --- bin/express-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index d29b62d7..86e5e094 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -99,7 +99,7 @@ function createApplication (name, dir, options, done) { start: 'node ./bin/www' }, dependencies: { - debug: '~2.6.9', + debug: '~4.4.1', express: '~5.1.0' }, devDependencies: { From 535d2017321573f1c3dced2a071d4148254dcc5d Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Thu, 19 Jun 2025 23:56:53 +0530 Subject: [PATCH 06/21] gen: remove cookieParser if no view --- bin/express-cli.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index 86e5e094..be03ee45 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -129,10 +129,12 @@ 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' + } if (dir !== '.') { mkdir(dir, '.') From 9c40091d7b6392c2e75e63b9d0abe7bea639c6ea Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Thu, 19 Jun 2025 23:57:39 +0530 Subject: [PATCH 07/21] gen: port replaced with server uri --- templates/js/www.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/js/www.ejs b/templates/js/www.ejs index a309083e..7567e7dd 100644 --- a/templates/js/www.ejs +++ b/templates/js/www.ejs @@ -85,6 +85,6 @@ function onListening() { const addr = server.address(); const bind = typeof addr === 'string' ? 'pipe ' + addr - : 'port ' + addr.port; + : 'http://localhost:' + addr.port; debug('Listening on ' + bind); } From edb3119829a0df67ff1f2872ff7a03d09f138471 Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Thu, 19 Jun 2025 23:58:37 +0530 Subject: [PATCH 08/21] gen: add express-response-rest ~1.0.1 if no view --- bin/express-cli.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/express-cli.js b/bin/express-cli.js index be03ee45..d1056bc4 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -134,6 +134,10 @@ function createApplication (name, dir, options, done) { 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 !== '.') { From 27834e4fb9ffcd2f7b4800844468df3595dd0c88 Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Thu, 19 Jun 2025 23:59:57 +0530 Subject: [PATCH 09/21] gen: rename directory javascripts to js --- bin/express-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index d1056bc4..066555da 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -145,7 +145,7 @@ function createApplication (name, dir, options, done) { } mkdir(dir, 'public') - mkdir(dir, 'public/javascripts') + mkdir(dir, 'public/js') mkdir(dir, 'public/images') if (options.css) { mkdir(dir, 'public/css') From 99e061e5225a3ec39cac938baa0c3248c1b3e8d9 Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Fri, 20 Jun 2025 00:00:44 +0530 Subject: [PATCH 10/21] gen: include additional directories --- bin/express-cli.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/express-cli.js b/bin/express-cli.js index 066555da..5323ed59 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -147,6 +147,11 @@ function createApplication (name, dir, options, done) { mkdir(dir, 'public') mkdir(dir, 'public/js') mkdir(dir, 'public/images') + mkdir(dir, 'controllers') + mkdir(dir, 'models') + mkdir(dir, 'utils') + mkdir(dir, 'middleware') + if (options.css) { mkdir(dir, 'public/css') } From 27a3e906ec494f1213d480f3f0d0b6a06cabb2f7 Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Fri, 20 Jun 2025 00:01:20 +0530 Subject: [PATCH 11/21] gen: update http-errors to ~2.0.0 --- bin/express-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index 5323ed59..f562391a 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -182,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') From 00a36d4fbdab5c07c8327dee5d8f9a1d1560b01f Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Fri, 20 Jun 2025 00:01:47 +0530 Subject: [PATCH 12/21] gen: update node-compass to 0.2.4 --- bin/express-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index f562391a..2b1caa20 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -219,7 +219,7 @@ 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' From 02f0d9033306c739882cfe99e0c64656463a6e27 Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Fri, 20 Jun 2025 00:02:14 +0530 Subject: [PATCH 13/21] gen: update less-middleware to ~3.1.0 --- bin/express-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index 2b1caa20..98c8ae10 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -224,7 +224,7 @@ function createApplication (name, dir, options, done) { 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' From 261d54818be5d7b17743a30a6d57e11447f7274f Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Fri, 20 Jun 2025 00:03:04 +0530 Subject: [PATCH 14/21] gen: update node-sass-middleware to 1.1.0 --- bin/express-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index 98c8ae10..9a5efd4e 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -229,7 +229,7 @@ function createApplication (name, dir, options, done) { 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' From ede1a3aef4a5c16c67961266996e76ae6cc67a18 Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Fri, 20 Jun 2025 00:03:29 +0530 Subject: [PATCH 15/21] gen: update stylus to 0.64.0 --- bin/express-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index 9a5efd4e..0bf52cce 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -234,7 +234,7 @@ function createApplication (name, dir, options, done) { 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 } From 41e42b196bebb82310abd01c9780b20ade294da8 Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Fri, 20 Jun 2025 00:04:02 +0530 Subject: [PATCH 16/21] gen: update ejs to ~3.1.10 --- bin/express-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index 0bf52cce..028e3a64 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -258,7 +258,7 @@ 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' } From 3ee07041dc306982316253e844c0b7595791338d Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Fri, 20 Jun 2025 00:04:26 +0530 Subject: [PATCH 17/21] gen: update hbs to ~4.2.0 --- bin/express-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index 028e3a64..21039254 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -262,7 +262,7 @@ function createApplication (name, dir, options, done) { 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' } From b4929a716047237ba0122b9e982b5563ea03513f Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Fri, 20 Jun 2025 00:04:45 +0530 Subject: [PATCH 18/21] gen: update pug to 3.0.3 --- bin/express-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index 21039254..c779a611 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -274,7 +274,7 @@ 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' } From 973cca3132a3e6371f223022dbda9a7fd11cb293 Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Fri, 20 Jun 2025 00:05:07 +0530 Subject: [PATCH 19/21] gen: update twig to ~1.17.1 --- bin/express-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index c779a611..1786e021 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -278,7 +278,7 @@ function createApplication (name, dir, options, done) { 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' } From bbfb8176f6ab73a01a0eed74f0cef458d67aac96 Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Fri, 20 Jun 2025 00:05:30 +0530 Subject: [PATCH 20/21] gen: update vash to ~0.13.0 --- bin/express-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/express-cli.js b/bin/express-cli.js index 1786e021..1530975e 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -282,7 +282,7 @@ function createApplication (name, dir, options, done) { 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 From 009f298cd4d8c1ce601acfc38d44134addcf177a Mon Sep 17 00:00:00 2001 From: Harshal Khairnar Date: Fri, 20 Jun 2025 00:23:29 +0530 Subject: [PATCH 21/21] gen: print listening uri --- templates/js/www.ejs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/templates/js/www.ejs b/templates/js/www.ejs index 7567e7dd..1364ec15 100644 --- a/templates/js/www.ejs +++ b/templates/js/www.ejs @@ -25,7 +25,9 @@ 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); @@ -85,6 +87,6 @@ function onListening() { const addr = server.address(); const bind = typeof addr === 'string' ? 'pipe ' + addr - : 'http://localhost:' + addr.port; + : 'port ' + addr.port; debug('Listening on ' + bind); }