Skip to content
This repository was archived by the owner on Feb 28, 2020. It is now read-only.
Merged
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
18 changes: 11 additions & 7 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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 = {
Expand All @@ -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 => {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions app/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
},
"scripts": {
"start": "node server/server.js",
"start:cluster": "sl-run server/server.js",
"debug": "node --debug 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": {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion test/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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) {');
});
});
});