Skip to content
This repository has been archived by the owner on Jan 25, 2020. It is now read-only.

Commit

Permalink
Merge pull request #97 from subeeshcbabu/secoption
Browse files Browse the repository at this point in the history
Add generator swaggerize version to the generated app for meta details
  • Loading branch information
subeeshcbabu authored Nov 2, 2016
2 parents f134576 + 2d5bbea commit 41b1d8b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

- Add the useful meta information, generator version, to the generated app's package.json.
- Add `security` option by default to the unit test files generated for all the frameworks.

# v3.0.0
Expand Down
3 changes: 3 additions & 0 deletions generators/app/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@
"lint": "eslint .",
"regenerate": "yo swaggerize:test --framework <%=framework%> --apiPath '<%=apiPathRel.replace(/\\/g,'/')%>'"
},
"generator-swaggerize": {
"version": "<%=generatorVersion%>"
},
"main": "./server"
}
2 changes: 2 additions & 0 deletions lib/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
var Path = require('path');
var Fs = require('fs');
var Parser = require('swagger-parser');
var Pkg = require('../../package.json');
/**
* List of supported frameworks
*/
Expand Down Expand Up @@ -87,6 +88,7 @@ function setDefaults (generator) {
&& Object.keys(generator.api.securityDefinitions).length > 0) {
generator.security = true;
}
generator.generatorVersion = Pkg.version;
}

/**
Expand Down
13 changes: 7 additions & 6 deletions test/util/testsuite.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,13 @@ function appTest(tester, options, security) {
//Package content
tester.test('test package file content', function(t) {
Assert.fileContent([
['package.json', new RegExp(/\"name\"\: \"mockapp\"/)],
['package.json', new RegExp(/\"author\"\: \"lorem ipsum <loremipsum@awesome\.com>\"/)],
['package.json', new RegExp(/\"url\"\: \"git\:\/\/github\.com\/loremipsum\/mockapp\.git\"/)],
['package.json', new RegExp('\"' + options.framework + '\"\:')],
['package.json', new RegExp('--framework ' + options.framework+ ' --apiPath \'' + options.apiRelPath.replace(/\\/g,'/') + '\'')],
['README.md', new RegExp(/# mockapp/)]
['package.json', new RegExp(/\"generator-swaggerize\"/)],
['package.json', new RegExp(/\"name\"\: \"mockapp\"/)],
['package.json', new RegExp(/\"author\"\: \"lorem ipsum <loremipsum@awesome\.com>\"/)],
['package.json', new RegExp(/\"url\"\: \"git\:\/\/github\.com\/loremipsum\/mockapp\.git\"/)],
['package.json', new RegExp('\"' + options.framework + '\"\:')],
['package.json', new RegExp('--framework ' + options.framework+ ' --apiPath \'' + options.apiRelPath.replace(/\\/g,'/') + '\'')],
['README.md', new RegExp(/# mockapp/)]
]);
t.end();
});
Expand Down

0 comments on commit 41b1d8b

Please sign in to comment.