generator-swaggerize
Advanced tools
Comparing version 1.0.0-rc.2 to 1.0.0-rc.3
@@ -24,3 +24,3 @@ 'use strict'; | ||
askFor: function () { | ||
var self, done; | ||
var self, done, pkg; | ||
@@ -30,2 +30,4 @@ self = this; | ||
this.only = this.options.only; | ||
this.framework = this.options.framework; | ||
this.apiPath = this.options.apiPath && path.resolve(this.options.apiPath); | ||
this.appname = path.basename(process.cwd()); | ||
@@ -40,2 +42,11 @@ | ||
if (this.only.length > 0) { | ||
if (fs.existsSync(path.resolve('package.json'))) { | ||
pkg = yeoman.file.readJSON(path.resolve('package.json')); | ||
if (pkg.dependencies.hapi) { | ||
this.framework = 'hapi'; | ||
} | ||
} | ||
} | ||
function all() { | ||
@@ -72,3 +83,4 @@ return self.only.length === 0; | ||
message: 'Path (or URL) to swagger document:', | ||
required: true | ||
required: true, | ||
default: this.apiPath | ||
}, | ||
@@ -78,4 +90,3 @@ { | ||
message: 'Express or Hapi:', | ||
default: 'express', | ||
when: all | ||
default: this.framework || 'express', | ||
} | ||
@@ -85,3 +96,3 @@ ]; | ||
this.prompt(prompts, function (props) { | ||
var self, pkg; | ||
var self; | ||
@@ -94,15 +105,5 @@ self = this; | ||
this.email = props.email; | ||
this.framework = props.framework || 'express'; | ||
this.framework = props.framework && props.framework.toLowerCase() || 'express'; | ||
this.appRoot = path.basename(process.cwd()) === this.appname ? this.destinationRoot() : path.join(this.destinationRoot(), this.appname); | ||
if (this.only.length > 0) { | ||
if (fs.existsSync(path.join(this.appRoot, 'package.json'))) { | ||
pkg = yeoman.file.readJSON(path.join(this.appRoot, 'package.json')); | ||
if (pkg.dependencies.hapi) { | ||
this.framework = 'hapi'; | ||
} | ||
} | ||
} | ||
if (this.framework !== 'express' && this.framework !== 'hapi') { | ||
@@ -109,0 +110,0 @@ done(new Error('Unrecognized framework: ' + this.framework)); |
@@ -17,3 +17,3 @@ 'use strict'; | ||
app.use(swaggerize({ | ||
api: require('<%=apiPath%>'), | ||
api: require('./<%=apiPath%>'), | ||
handlers: path.join(__dirname, '<%=handlers%>') | ||
@@ -20,0 +20,0 @@ })); |
@@ -20,3 +20,3 @@ 'use strict'; | ||
options: { | ||
api: require('<%=apiPath%>'), | ||
api: require('./<%=apiPath%>'), | ||
handlers: Path.join(__dirname, '<%=handlers%>') | ||
@@ -23,0 +23,0 @@ } |
@@ -19,3 +19,3 @@ 'use strict'; | ||
app.use(swaggerize({ | ||
api: require('<%=apiPath%>'), | ||
api: require('./<%=apiPath%>'), | ||
handlers: './handlers' | ||
@@ -22,0 +22,0 @@ })); |
{ | ||
"name": "generator-swaggerize", | ||
"description": "Yeoman generator for swagger application with krakenjs/swaggerize tools.", | ||
"version": "1.0.0-rc.2", | ||
"version": "1.0.0-rc.3", | ||
"author": "Trevor Livingston <tlivings@gmail.com>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -42,1 +42,6 @@ [![Build Status](https://travis-ci.org/krakenjs/generator-swaggerize.png)](https://travis-ci.org/krakenjs/generator-swaggerize) [![NPM version](https://badge.fury.io/js/generator-swaggerize.png)](http://badge.fury.io/js/generator-swaggerize) | ||
``` | ||
### Other CLI Options | ||
- `--framework` - specify the framework (`hapi` or `express`). | ||
- `--apiPath` - specify the path to the swagger document. |
27803
508
47