diff --git a/docs/generators/app.md b/docs/generators/app.md index 95cb5cc4b..df966aa57 100644 --- a/docs/generators/app.md +++ b/docs/generators/app.md @@ -11,6 +11,9 @@ Options: --skip-cache # Do not remember prompt answers Default: false --skip-install # Do not install dependencies Default: false --app-suffix # Allow a custom suffix to be added to the module name Default: App + --dev-port # Port to use for the development HTTP server Default: 9000 + --debug-port # Port to use for the server debugger Default: 5858 + --prod-port # Port to use for the production HTTP Server Default: 8080 Arguments: name Type: String Required: false diff --git a/src/generators/app/index.js b/src/generators/app/index.js index c237dab69..a6d2c5543 100644 --- a/src/generators/app/index.js +++ b/src/generators/app/index.js @@ -31,6 +31,24 @@ export class Generator extends Base { type: String, defaults: 'App' }); + + this.option('dev-port', { + desc: 'Port to use for the development HTTP server', + type: String, + defaults: '9000' + }); + + this.option('debug-port', { + desc: 'Port to use for the server debugger', + type: String, + defaults: '5858' + }); + + this.option('prod-port', { + desc: 'Port to use for the production HTTP Server', + type: String, + defaults: '8080' + }); } get initializing() { @@ -90,9 +108,9 @@ export class Generator extends Base { this.scriptExt = this.filters.ts ? 'ts' : 'js'; this.templateExt = this.filters.jade ? 'jade' : 'html'; - this.styleExt = this.filters.sass ? 'scss' : - this.filters.less ? 'less' : - this.filters.stylus ? 'styl' : + this.styleExt = this.filters.sass ? 'scss' : + this.filters.less ? 'less' : + this.filters.stylus ? 'styl' : 'css'; } else { insight.track('skipConfig', 'false'); @@ -103,6 +121,11 @@ export class Generator extends Base { } }); } + }, + assignPorts() { + this.devPort = this.options['dev-port']; + this.debugPort = this.options['debug-port']; + this.prodPort = this.options['prod-port']; } }; } diff --git a/templates/app/Gruntfile(grunt).js b/templates/app/Gruntfile(grunt).js index cf335b970..1a280fe86 100644 --- a/templates/app/Gruntfile(grunt).js +++ b/templates/app/Gruntfile(grunt).js @@ -36,7 +36,7 @@ module.exports = function(grunt) { }, express: { options: { - port: process.env.PORT || 9000 + port: process.env.PORT || <%= devPort %> }, dev: { options: { @@ -239,7 +239,7 @@ module.exports = function(grunt) { options: { nodeArgs: ['--debug-brk'], env: { - PORT: process.env.PORT || 9000 + PORT: process.env.PORT || <%= devPort %> }, callback: function(nodemon) { nodemon.on('log', function(event) { @@ -249,7 +249,7 @@ module.exports = function(grunt) { // opens browser on initial server start nodemon.on('config:update', function() { setTimeout(function() { - require('open')('http://localhost:8080/debug?port=5858'); + require('open')('http://localhost:<%= devPort %>/debug?port=<%= debugPort %>'); }, 500); }); } diff --git a/templates/app/gulpfile.babel(gulp).js b/templates/app/gulpfile.babel(gulp).js index 16582400f..c732a72e7 100644 --- a/templates/app/gulpfile.babel(gulp).js +++ b/templates/app/gulpfile.babel(gulp).js @@ -247,7 +247,7 @@ gulp.task('inject:tsconfig', () => { `${clientPath}/**/!(*.spec|*.mock).ts`, `!${clientPath}/bower_components/**/*`, `typings/main.d.ts` - ], + ], './tsconfig.client.json'); }); @@ -256,7 +256,7 @@ gulp.task('inject:tsconfigTest', () => { `${clientPath}/**/+(*.spec|*.mock).ts`, `!${clientPath}/bower_components/**/*`, `typings/main.d.ts` - ], + ], './tsconfig.client.test.json'); });<% } %> @@ -401,13 +401,15 @@ gulp.task('start:server:prod', () => { gulp.task('start:inspector', () => { gulp.src([]) - .pipe(plugins.nodeInspector()); + .pipe(plugins.nodeInspector({ + debugPort: <%= debugPort %> + })); }); gulp.task('start:server:debug', () => { process.env.NODE_ENV = process.env.NODE_ENV || 'development'; - config = require(`./${serverPath}/config/environment`); - nodemon(`-w ${serverPath} --debug-brk ${serverPath}`) + config = require(`./${serverPath}/config/environment`); + nodemon(`-w ${serverPath} --debug=<%= debugPort %> --debug-brk ${serverPath}`) .on('log', onServerLog); }); diff --git a/templates/app/karma.conf.js b/templates/app/karma.conf.js index 35190d50e..9b19748c8 100644 --- a/templates/app/karma.conf.js +++ b/templates/app/karma.conf.js @@ -61,7 +61,7 @@ module.exports = function(config) { exclude: [], // web server port - port: 8080, + port: <%= devPort %>, // level of logging // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG diff --git a/templates/app/protractor.conf.js b/templates/app/protractor.conf.js index 8e297bb67..4f3e10eef 100644 --- a/templates/app/protractor.conf.js +++ b/templates/app/protractor.conf.js @@ -10,7 +10,7 @@ var config = { // A base URL for your application under test. Calls to protractor.get() // with relative paths will be prepended with this. - baseUrl: 'http://localhost:' + (process.env.PORT || '9000'), + baseUrl: 'http://localhost:' + (process.env.PORT || '<%= devPort %>'), // Credientials for Saucelabs sauceUser: process.env.SAUCE_USERNAME, diff --git a/templates/app/server/config/_local.env.js b/templates/app/server/config/_local.env.js index 82195c471..0d915248b 100644 --- a/templates/app/server/config/_local.env.js +++ b/templates/app/server/config/_local.env.js @@ -6,7 +6,7 @@ // You will need to set these on the server you deploy to. module.exports = { - DOMAIN: 'http://localhost:9000', + DOMAIN: 'http://localhost:<%= devPort %>', SESSION_SECRET: '<%= lodash.slugify(appname) + "-secret" %>',<% if (filters.facebookAuth) { %> FACEBOOK_ID: 'app-id', diff --git a/templates/app/server/config/_local.env.sample.js b/templates/app/server/config/_local.env.sample.js index 8106cf731..f13d11c3a 100644 --- a/templates/app/server/config/_local.env.sample.js +++ b/templates/app/server/config/_local.env.sample.js @@ -6,7 +6,7 @@ // You will need to set these on the server you deploy to. module.exports = { - DOMAIN: 'http://localhost:9000', + DOMAIN: 'http://localhost:<%= devPort %>', SESSION_SECRET: '<%= lodash.slugify(appname) + "-secret" %>',<% if (filters.facebookAuth) { %> FACEBOOK_ID: 'app-id', diff --git a/templates/app/server/config/environment/index.js b/templates/app/server/config/environment/index.js index c6115a06d..9b0efa232 100644 --- a/templates/app/server/config/environment/index.js +++ b/templates/app/server/config/environment/index.js @@ -19,7 +19,7 @@ var all = { root: path.normalize(__dirname + '/../../..'), // Server port - port: process.env.PORT || 9000, + port: process.env.PORT || <%= devPort %>, // Server IP ip: process.env.IP || '0.0.0.0', diff --git a/templates/app/server/config/environment/production.js b/templates/app/server/config/environment/production.js index 791dfb4a1..2bd6fe761 100644 --- a/templates/app/server/config/environment/production.js +++ b/templates/app/server/config/environment/production.js @@ -11,7 +11,7 @@ module.exports = { // Server port port: process.env.OPENSHIFT_NODEJS_PORT || process.env.PORT || - 8080<% if (filters.mongoose) { %>, + <%= prodPort %><% if (filters.mongoose) { %>, // MongoDB connection options mongo: {