forked from balderdashy/sails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61e56d1
commit 3c7b3b4
Showing
38 changed files
with
1,183 additions
and
1,118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
/** | ||
* Module dependencies | ||
*/ | ||
var _ = require('lodash') | ||
, program = require('commander'); | ||
|
||
var _ = require('lodash'); | ||
var program = require('commander'); | ||
|
||
|
||
// | ||
// | ||
// Monkey-patch commander | ||
// | ||
// | ||
// | ||
// | ||
|
||
// Allow us to display help(), but omit the wildcard (*) command. | ||
program.Command.prototype.usageMinusWildcard = | ||
program.usageMinusWildcard =function () { | ||
program.commands = _.reject(program.commands, {_name: '*'}); | ||
program.help(); | ||
program.usageMinusWildcard = function() { | ||
program.commands = _.reject(program.commands, { | ||
_name: '*' | ||
}); | ||
program.help(); | ||
}; | ||
|
||
// Force commander to display version information. | ||
program.Command.prototype.versionInformation = | ||
program.versionInformation = | ||
function () { | ||
program.emit('version'); | ||
program.versionInformation = | ||
function() { | ||
program.emit('version'); | ||
}; | ||
|
||
module.exports = program; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,56 @@ | ||
/** | ||
* Module dependencies | ||
*/ | ||
var async = require('async') | ||
, sailsgen = require('sails-generate') | ||
, STRINGFILE = require('sails-stringfile') | ||
, _ = require('lodash'); | ||
|
||
|
||
// | ||
// Run both the controller and model generators and add in a couple | ||
// of extra log messages. | ||
// (todo: pull this out into a simple generator) | ||
module.exports = function generateAPI (scope, cb) { | ||
|
||
console.log(); | ||
|
||
// Create the controller and model | ||
async.parallel(_.map(['controller', 'model'], subGen), function(err) { | ||
|
||
// As long as there were no errors, add some logs about how to call the new API | ||
if (!err) { | ||
console.log(); | ||
cb.log.info('REST API generated @ ' + ('http://localhost:1337/' + scope.args[0]).underline); | ||
cb.log.info('and will be available the next time you run `sails lift`.'); | ||
} | ||
}); | ||
|
||
// Create a function suitable for use with async.parallel to run a generator. | ||
// Uses "cb.log" b/c it has that nice log format. | ||
function subGen(generatorType) { | ||
var _scope = _.extend({}, _.cloneDeep(scope), {generatorType: generatorType}); | ||
return function(_cb) { | ||
sailsgen (_scope, { | ||
success: function() { | ||
cb.log('Generated a new '+_scope.generatorType+' `'+_scope.id+'` at '+_scope.destDir+_scope.globalID+'.js!'); | ||
return _cb(); | ||
}, | ||
error: function(err) { | ||
cb.error(err); | ||
return _cb(err); | ||
}, | ||
|
||
var _ = require('lodash'); | ||
var async = require('async'); | ||
var sailsgen = require('sails-generate'); | ||
|
||
|
||
/** | ||
* | ||
* Run both the controller and model generators and add in a couple | ||
* of extra log messages. | ||
* | ||
* TODO: Pull this out into a simple generator | ||
* @param {[type]} scope [description] | ||
* @param {Function} cb [description] | ||
* @return {[type]} [description] | ||
*/ | ||
|
||
module.exports = function generateAPI(scope, cb) { | ||
|
||
console.log(); | ||
|
||
// Create the controller and model | ||
async.parallel(_.map(['controller', 'model'], subGen), function(err) { | ||
|
||
// As long as there were no errors, add some logs about how to call the new API | ||
if (!err) { | ||
console.log(); | ||
cb.log.info('REST API generated @ ' + ('http://localhost:1337/' + scope.args[0]).underline); | ||
cb.log.info('and will be available the next time you run `sails lift`.'); | ||
} | ||
}); | ||
|
||
// Create a function suitable for use with async.parallel to run a generator. | ||
// Uses "cb.log" b/c it has that nice log format. | ||
function subGen(generatorType) { | ||
var _scope = _.extend({}, _.cloneDeep(scope), { | ||
generatorType: generatorType | ||
}); | ||
return function(_cb) { | ||
sailsgen(_scope, { | ||
success: function() { | ||
cb.log('Generated a new ' + _scope.generatorType + ' `' + _scope.id + '` at ' + _scope.destDir + _scope.globalID + '.js!'); | ||
return _cb(); | ||
}, | ||
error: function(err) { | ||
cb.error(err); | ||
return _cb(err); | ||
}, | ||
invalid: 'error' | ||
}); | ||
}; | ||
} | ||
}); | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.