diff --git a/app/index.js b/app/index.js index 38286a1..fbd0651 100644 --- a/app/index.js +++ b/app/index.js @@ -28,10 +28,6 @@ module.exports = class extends Generator { constructor(args, opts) { super(args, opts); - - if ( typeof opts.bluemix.quiet == "undefined" || ! opts.bluemix.quiet ) { - logger.info("Package info ::", Bundle.name, Bundle.version); - } // bluemix option for YaaS integration this.argument(OPTION_BLUEMIX, { @@ -55,10 +51,15 @@ module.exports = class extends Generator { let bluemix_ok= this._sanitizeOption(this.options, OPTION_BLUEMIX); let spec_ok= this._sanitizeOption(this.options, OPTION_SPEC); if ( ! (bluemix_ok || spec_ok )) throw ("Must specify either bluemix or spec parameter"); + + if ( typeof this.options.bluemix.quiet == "undefined" || ! this.options.bluemix.quiet ) { + logger.info("Package info ::", Bundle.name, Bundle.version); + } + let appName = this.options.bluemix.name || this.options.spec.appname; this.options.sanitizedAppName = this._sanitizeAppName(appName); - this.options.openApiFileType= "yaml"; // default this.options.genSwagger= false; + this.options.openApiFileType= "yaml"; // default this.options.parsedSwagger = undefined; let formatters = { @@ -74,7 +75,7 @@ module.exports = class extends Generator { .then(response => { this.options.loadedApi = response.loaded; this.options.parsedSwagger = response.parsed; - if ( this.options.loadedApi ) this.options.openApiFileType= "json"; + this.options.openApiFileType= response.type; this.options.genSwagger= true; }) .catch(err => { @@ -119,8 +120,11 @@ module.exports = class extends Generator { if ( this.options.genSwagger ) { this.fs.copy(this.templatePath('public/swagger-ui'), this.destinationPath('public/swagger-ui')); // if open api doc provided, write it else write default + if ( this.options.loadedApi ) { - this.fs.writeJSON('public/swagger.json', this.options.loadedApi); + let yaml= this.options.bluemix.openApiServers[0].spec; + //this.fs.writeJSON('public/swagger.'+this.options.openApiFileType, this.options.loadedApi); + this.fs.write('public/swagger.'+this.options.openApiFileType, yaml); } else { this.fs.copyTpl(this.templatePath('public/swagger.yaml'), this.destinationPath('public/swagger.yaml'), this.options); diff --git a/app/templates/package.json b/app/templates/package.json index 41bc54b..aa16e38 100644 --- a/app/templates/package.json +++ b/app/templates/package.json @@ -8,6 +8,7 @@ }, "scripts": { "start": "node server/server.js", + "start:cluster": "sl-run server/server.js", "debug": "node --debug server/server.js", "test": "nyc mocha" }, @@ -15,6 +16,7 @@ "appmetrics-dash": "^3.3.2", "body-parser": "^1.17.2", "express": "^4.15.3", + "strong-supervisor": "^6.2.0", "log4js": "^1.1.1" }, "devDependencies": { diff --git a/package-lock.json b/package-lock.json index 32d6b08..9fa5077 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "generator-ibm-core-node-express", - "version": "0.0.57", + "version": "0.0.60", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index f32bcde..e418892 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "generator-ibm-core-node-express", - "version": "0.0.57", + "version": "0.0.60", "description": "Yeoman generator for core node express application", "license": "Apache-2.0", "keywords": [ @@ -11,7 +11,7 @@ "lib" ], "dependencies": { - "ibm-openapi-support": "0.0.4", + "ibm-openapi-support": "^0.0.8", "chalk": "^1.1.3", "log4js": "^1.1.1", "yeoman-generator": "^1.1.0", diff --git a/test/integration.js b/test/integration.js index f9a9d4f..0d90c0b 100644 --- a/test/integration.js +++ b/test/integration.js @@ -68,12 +68,14 @@ describe('core-node-express:app integration test with custom spec', function () }, "scripts": { "start": "node server/server.js", + "start:cluster": "sl-run server/server.js", "test": "nyc mocha" }, "dependencies": { "appmetrics-dash": "^3.3.2", "body-parser": "^1.17.2", "express": "^4.15.3", + "strong-supervisor": "^6.2.0", "log4js": "^1.1.1" }, "devDependencies": { @@ -316,4 +318,4 @@ describe('core-node-express:app integration test with openApiServices', function assert.file('server/routers/dinosaurs.js') assert.fileContent('server/routers/dinosaurs.js', 'router.get(\'/dinosaurs\', function (req, res, next) {'); }); -}); \ No newline at end of file +});