yeoman-generator
Advanced tools
Comparing version 0.15.0 to 0.16.0
@@ -24,3 +24,2 @@ { | ||
"disallowMultipleLineBreaks": true, | ||
"validateLineBreaks": "LF", | ||
"disallowKeywordsOnNewLine": ["else"], | ||
@@ -27,0 +26,0 @@ "requireLineFeedAtFileEnd": true, |
@@ -0,0 +0,0 @@ /*global suite, bench */ |
@@ -0,0 +0,0 @@ /*global suite, bench */ |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -13,2 +13,6 @@ 'use strict'; | ||
/** | ||
* @mixin | ||
* @alias actions/actions | ||
*/ | ||
var actions = module.exports; | ||
@@ -15,0 +19,0 @@ |
@@ -8,4 +8,2 @@ 'use strict'; | ||
var fetch = module.exports; | ||
var proxy = process.env.http_proxy || process.env.HTTP_PROXY || | ||
@@ -15,2 +13,8 @@ process.env.https_proxy || process.env.HTTPS_PROXY || ''; | ||
/** | ||
* @mixin | ||
* @alias actions/fetch | ||
*/ | ||
var fetch = module.exports; | ||
/** | ||
* Download a string or an array of files to a given destination. | ||
@@ -17,0 +21,0 @@ * |
@@ -7,2 +7,6 @@ 'use strict'; | ||
/** | ||
* @mixin | ||
* @alias actions/file | ||
*/ | ||
var file = module.exports; | ||
@@ -9,0 +13,0 @@ |
@@ -7,2 +7,6 @@ 'use strict'; | ||
/** | ||
* @mixin | ||
* @alias actions/install | ||
*/ | ||
var install = module.exports; | ||
@@ -9,0 +13,0 @@ |
@@ -0,1 +1,2 @@ | ||
/** @module actions/invoke */ | ||
'use strict'; | ||
@@ -2,0 +3,0 @@ var path = require('path'); |
@@ -0,1 +1,2 @@ | ||
/** @module actions/prompt */ | ||
'use strict'; | ||
@@ -2,0 +3,0 @@ |
@@ -0,1 +1,2 @@ | ||
/** @module actions/spawn_command */ | ||
'use strict'; | ||
@@ -2,0 +3,0 @@ var _ = require('lodash'); |
'use strict'; | ||
var _ = require('lodash'); | ||
_.str = require('underscore.string'); | ||
_.mixin(_.str.exports()); | ||
/** | ||
* @mixin | ||
* @alias actions/string | ||
*/ | ||
var string = module.exports; | ||
/** | ||
* Mix in non-conflicting functions to underscore namespace and generators. | ||
* | ||
* ### Examples: | ||
* @mixes lodash | ||
* @mixes underscore.string | ||
* @example | ||
* | ||
@@ -14,5 +23,2 @@ * this._.humanize('stuff-dash'); | ||
_.mixin(_.str.exports()); | ||
// and expose that | ||
module.exports._ = _; | ||
string._ = _; |
@@ -5,15 +5,20 @@ 'use strict'; | ||
var usernameCache = {}; | ||
var emailCache = {}; | ||
/** | ||
* @mixin | ||
* @alias actions/user | ||
*/ | ||
var user = module.exports; | ||
/** | ||
* Git related method | ||
* Git related properties | ||
* | ||
* The value will come from the global scope or the project scope (it'll take | ||
* what git will use in the current context) | ||
* @prop username {String|undefined} - Current git username | ||
* @prop email {String|undefined} - Current git email | ||
*/ | ||
var usernameCache = {}; | ||
var emailCache = {}; | ||
user.git = { | ||
// current git user.name | ||
get username() { | ||
@@ -31,3 +36,3 @@ var username = usernameCache[process.cwd()]; | ||
}, | ||
// current git user.email | ||
get email() { | ||
@@ -34,0 +39,0 @@ var email = emailCache[process.cwd()]; |
@@ -7,2 +7,6 @@ 'use strict'; | ||
/** | ||
* @mixin | ||
* @alias actions/wiring | ||
*/ | ||
var wiring = module.exports; | ||
@@ -9,0 +13,0 @@ |
@@ -28,2 +28,15 @@ 'use strict'; | ||
* | ||
* @constructor | ||
* @mixes util/common | ||
* @mixes actions/actions | ||
* @mixes actions/fetch | ||
* @mixes actions/file | ||
* @mixes actions/install | ||
* @mixes actions/invoke | ||
* @mixes actions/prompt | ||
* @mixes actions/spawn_command | ||
* @mixes actions/string | ||
* @mixes actions/user | ||
* @mixes actions/wiring | ||
* | ||
* @param {String|Array} args | ||
@@ -621,2 +634,3 @@ * @param {Object} options | ||
* Setup a storage instance. | ||
* @private | ||
*/ | ||
@@ -623,0 +637,0 @@ |
@@ -13,2 +13,4 @@ 'use strict'; | ||
* It provides a CLI interaction | ||
* | ||
* @constructor | ||
*/ | ||
@@ -15,0 +17,0 @@ var TerminalAdapter = module.exports = function TerminalAdapter() {}; |
@@ -33,3 +33,4 @@ 'use strict'; | ||
* | ||
* | ||
* @constructor | ||
* @mixes env/resolver | ||
* @param {String|Array} args | ||
@@ -52,5 +53,2 @@ * @param {Object} opts | ||
this.aliases = []; | ||
this.paths = []; | ||
this.appendDefaultPaths(); | ||
}; | ||
@@ -81,46 +79,2 @@ | ||
/** | ||
* Appends a `filepath` to the list of loadpaths. | ||
* | ||
* @param {String} filepath | ||
*/ | ||
Environment.prototype.appendPath = function appendPath(filepath) { | ||
if (!filepath) { | ||
return this.error(new Error('Missing filepath.')); | ||
} | ||
this.paths.push(path.resolve(filepath)); | ||
return this; | ||
}; | ||
/** | ||
* Appends the defaults node modules paths to the Environment load paths. | ||
*/ | ||
Environment.prototype.appendDefaultPaths = function () { | ||
this.appendPath(process.cwd()); | ||
// We tried using NPM to get the global modules path, but it haven't work out | ||
// because of bugs in the parseable implementation of `ls` command and mostly | ||
// performance issues. So, we go with our best bet for now. | ||
if (process.env.NODE_PATH) { | ||
_.compact(process.env.NODE_PATH.split(/[;:]/g)).forEach(this.appendPath, this); | ||
return; | ||
} | ||
// global node_modules should be 5 directory up this one (most of the time) | ||
this.appendPath(path.join(__dirname, '../../../../..')); | ||
// adds support for generator resolving when yeoman-generator has been linked | ||
this.appendPath(path.join(path.dirname(process.argv[1]), '../..')); | ||
// Default paths for each system | ||
if (win32) { | ||
this.appendPath(path.join(process.env.APPDATA, 'npm/node_modules')); | ||
} else { | ||
this.appendPath('/usr/lib/node_modules'); | ||
} | ||
}; | ||
/** | ||
* Outputs the general help and usage. Optionally, if generators have been | ||
@@ -127,0 +81,0 @@ * registered, the list of available generators is also displayed. |
@@ -9,3 +9,11 @@ 'use strict'; | ||
var win32 = process.platform === 'win32'; | ||
/** | ||
* @mixin | ||
* @alias env/resolver | ||
*/ | ||
var resolver = module.exports; | ||
/** | ||
* Search for generators and their sub generators. | ||
@@ -24,4 +32,4 @@ * | ||
exports.lookup = function () { | ||
var generatorsModules = this._getNpmGenerators(); | ||
resolver.lookup = function () { | ||
var generatorsModules = this.findGeneratorsIn(this.getNpmPaths()); | ||
var patterns = []; | ||
@@ -47,18 +55,10 @@ | ||
* | ||
* @return {Array} List of the generators path | ||
* @param {Array} List of search paths | ||
* @return {Array} List of the generator modules path | ||
*/ | ||
exports._getNpmGenerators = function () { | ||
resolver.findGeneratorsIn = function (searchPaths) { | ||
var modules = []; | ||
var nodeModules = []; | ||
this.paths.forEach(function (root) { | ||
var found = findup('node_modules/', { cwd: root }); | ||
while (found && found !== path.dirname(found)) { | ||
nodeModules.push(found); | ||
found = findup('node_modules/', { cwd: path.dirname(path.dirname(found)) }); | ||
} | ||
}); | ||
nodeModules.forEach(function (root) { | ||
searchPaths.forEach(function (root) { | ||
if (!root) return; | ||
@@ -79,3 +79,3 @@ var found = glob.sync('generator-*', { cwd: root, stat: true }).map(function (match) { | ||
exports._tryRegistering = function (generatorReference) { | ||
resolver._tryRegistering = function (generatorReference) { | ||
try { | ||
@@ -90,2 +90,42 @@ debug('found %s, trying to register', generatorReference); | ||
/** | ||
* Get the NPM lookup directories (`node_modules/`) | ||
* @return {Array} lookup paths | ||
*/ | ||
resolver.getNpmPaths = function () { | ||
var paths = []; | ||
// Walk up the CWD and add `node_modules/` folder lookup on each level | ||
process.cwd().split(path.sep).forEach(function (part, i, parts) { | ||
var lookup = path.join.apply(path, parts.slice(0, i + 1).concat(['node_modules'])); | ||
if (!win32) { | ||
lookup = '/' + lookup; | ||
} | ||
paths.push(lookup); | ||
}); | ||
// Adding global NPM directories | ||
// We tried using NPM to get the global modules path, but it haven't work out | ||
// because of bugs in the parseable implementation of `ls` command and mostly | ||
// performance issues. So, we go with our best bet for now. | ||
if (process.env.NODE_PATH) { | ||
paths = _.compact(process.env.NODE_PATH.split(path.delimiter)).concat(paths); | ||
} else { | ||
// global node_modules should be 5 directory up this one (most of the time) | ||
paths.push(path.join(__dirname, '../../../../..')); | ||
// adds support for generator resolving when yeoman-generator has been linked | ||
paths.push(path.join(path.dirname(process.argv[1]), '../..')); | ||
// Default paths for each system | ||
if (win32) { | ||
paths.push(path.join(process.env.APPDATA, 'npm/node_modules')); | ||
} else { | ||
paths.push('/usr/lib/node_modules'); | ||
} | ||
} | ||
return paths.reverse(); | ||
}; | ||
/** | ||
* Get or create an alias. | ||
@@ -108,4 +148,7 @@ * | ||
* | ||
* ### Examples: | ||
* @param {String|RegExp} match | ||
* @param {String} value | ||
* | ||
* @example | ||
* | ||
* env.alias(/^([a-zA-Z0-9:\*]+)$/, 'generator-$1'); | ||
@@ -116,8 +159,5 @@ * env.alias(/^([^:]+)$/, '$1:app'); | ||
* // => generator-foo:all | ||
* | ||
* @param {String|RegExp} match | ||
* @param {String} value | ||
*/ | ||
exports.alias = function alias(match, value) { | ||
resolver.alias = function alias(match, value) { | ||
if (match && value) { | ||
@@ -124,0 +164,0 @@ this.aliases.push({ |
@@ -103,2 +103,3 @@ 'use strict'; | ||
* @param {Generator|Function} generator | ||
* @private | ||
* @return {Boolean} | ||
@@ -105,0 +106,0 @@ */ |
@@ -10,2 +10,5 @@ 'use strict'; | ||
* | ||
* @constructor | ||
* @augments Base | ||
* @alias NamedBase | ||
* @param {String|Array} args [description] | ||
@@ -12,0 +15,0 @@ * @param {Object} options [description] |
@@ -0,1 +1,6 @@ | ||
/** | ||
* Collection of unit test helpers. (mostly related to Mocha syntax) | ||
* @module test/helpers | ||
*/ | ||
'use strict'; | ||
@@ -7,27 +12,21 @@ var fs = require('fs'); | ||
var util = require('util'); | ||
var assert = require('assert'); | ||
var assert = require('./assert'); | ||
var _ = require('lodash'); | ||
var generators = require('../..'); | ||
// Mocha helpers | ||
var helpers = module.exports; | ||
exports.decorated = []; | ||
helpers.stubs = []; | ||
/** | ||
* Create a function that will clean up the test directory, | ||
* cd into it, and create a dummy gruntfile inside. Intended for use | ||
* as a callback for the mocha `before` hook. | ||
* | ||
* @param {String} dir - path to the test directory | ||
* @returns {Function} mocha callback | ||
*/ | ||
// cleanup the test dir, and cd into it | ||
helpers.before = function before(dir) { | ||
if (!dir) { | ||
throw new Error('Missing directory'); | ||
} | ||
dir = path.resolve(dir); | ||
exports.setUpTestDirectory = function before(dir) { | ||
return function (done) { | ||
rimraf(dir, function (err) { | ||
if (err) { | ||
return done(err); | ||
} | ||
mkdirp.sync(dir); | ||
process.chdir(dir); | ||
helpers.gruntfile({ dummy: true }, done); | ||
exports.testDirectory(dir, function () { | ||
exports.gruntfile({ dummy: true }, done); | ||
}); | ||
@@ -37,9 +36,27 @@ }; | ||
// Wrap a method with custom functionality. | ||
// | ||
// - context - (object) context to find the original method | ||
// - method - (string) name of the method to wrap | ||
// - replacement - (function) executes before the original method | ||
// - options - (opt) (object) config settings | ||
helpers.decorate = function decorate(context, method, replacement, options) { | ||
/** | ||
* Create a function that will clean up the test directory, | ||
* cd into it, and create a dummy gruntfile inside. Intended for use | ||
* as a callback for the mocha `before` hook. | ||
* | ||
* @deprecated use helpers.setUpDirectory instead | ||
* @param {String} dir - path to the test directory | ||
* @returns {Function} mocha callback | ||
*/ | ||
exports.before = function (dir) { | ||
console.log('before is deprecated. Use setUpTestDirectory instead'); | ||
return exports.setUpTestDirectory(dir); | ||
}; | ||
/** | ||
* Wrap a method with custom functionality. | ||
* | ||
* @param {Object} context - context to find the original method | ||
* @param {String} method - name of the method to wrap | ||
* @param {Function} replacement - executes before the original method | ||
* @param {Object} options - config settings | ||
*/ | ||
exports.decorate = function decorate(context, method, replacement, options) { | ||
options = options || {}; | ||
@@ -50,3 +67,3 @@ replacement = replacement || function () {}; | ||
helpers.stubs.push({ | ||
exports.decorated.push({ | ||
context: context, | ||
@@ -68,35 +85,38 @@ method: method, | ||
// Override a method with custom functionality. | ||
// | ||
// - context - (object) context to find the original method | ||
// - method - (string) name of the method to wrap | ||
// - replacement - (function) executes before the original method | ||
helpers.stub = function stub(context, method, replacement) { | ||
helpers.decorate(context, method, replacement, { stub: true }); | ||
/** | ||
* Override a method with custom functionality. | ||
* @param {Object} context - context to find the original method | ||
* @param {String} method - name of the method to wrap | ||
* @param {Function} replacement - executes before the original method | ||
*/ | ||
exports.stub = function stub(context, method, replacement) { | ||
exports.decorate(context, method, replacement, { stub: true }); | ||
}; | ||
// Restore all stubs with original behavior. | ||
helpers.restore = function restore() { | ||
helpers.stubs.forEach(function (stub) { | ||
stub.context[stub.method] = stub.naturalMethod; | ||
/** | ||
* Restore the original behavior of all decorated and stubbed methods | ||
*/ | ||
exports.restore = function restore() { | ||
exports.decorated.forEach(function (dec) { | ||
dec.context[dec.method] = dec.naturalMethod; | ||
}); | ||
}; | ||
// Generates a new Gruntfile.js in the current working directory based on | ||
// `options` hash passed in. Same as other helpers, meant to be use as a mocha | ||
// handler. | ||
// | ||
// - options - Grunt configuration | ||
// - done - callback to call on completion | ||
// | ||
// Example | ||
// | ||
// before(helpers.gruntfile({ | ||
// foo: { | ||
// bar: '<config.baz>' | ||
// } | ||
// })); | ||
// | ||
// Returns a function suitable to use with mocha hooks. | ||
helpers.gruntfile = function (options, done) { | ||
/** | ||
* | ||
* Generates a new Gruntfile.js in the current working directory based on | ||
* options hash passed in. | ||
* | ||
* @param {Object} options - Grunt configuration | ||
* @param {Function} done - callback to call on completion | ||
* @example | ||
* before(helpers.gruntfile({ | ||
* foo: { | ||
* bar: '<config.baz>' | ||
* } | ||
* })); | ||
* | ||
*/ | ||
exports.gruntfile = function (options, done) { | ||
var config = 'grunt.initConfig(' + JSON.stringify(options, null, 2) + ');'; | ||
@@ -116,61 +136,23 @@ config = config.split('\n').map(function (line) { | ||
helpers.assertFile = function (file, reg) { | ||
var here = fs.existsSync(file); | ||
assert.ok(here, file + ', no such file or directory'); | ||
// Façade assert module for backward compatibility | ||
exports.assertFile = assert.file; | ||
exports.assertNoFile = assert.noFile; | ||
exports.assertFiles = assert.files; | ||
exports.assertFileContent = assert.fileContent; | ||
exports.assertNoFileContent = assert.noFileContent; | ||
exports.assertTextEqual = assert.textEqual; | ||
exports.assertImplement = assert.implement; | ||
if (!reg) { | ||
return assert.ok(here); | ||
} | ||
var body = fs.readFileSync(file, 'utf8'); | ||
assert.ok(reg.test(body), file + ' did not match \'' + reg + '\'.'); | ||
}; | ||
// Check all files present in the array are existing. | ||
// If the item is an array first item is the file path, 2nd a regexp | ||
// to check file content with | ||
// | ||
// helpers.assertFiles(['foo.js', 'bar.js', ['baz.js', /function baz/]]); | ||
// | ||
helpers.assertFiles = function (files) { | ||
files.forEach(function (item) { | ||
var file = item; | ||
var rx; | ||
if (item instanceof Array) { | ||
file = item[0]; | ||
rx = item[1]; | ||
} | ||
helpers.assertFile(file, rx); | ||
}); | ||
}; | ||
helpers.assertTextEqual = function (value, expected) { | ||
function eol(str) { | ||
return str.replace(/\r\n/g, '\n'); | ||
} | ||
assert.equal(eol(value), eol(expected)); | ||
}; | ||
/** | ||
* Assert an Object implement an interface | ||
* @param {Object} obj - subject implementing the façade | ||
* @param {Object|Array} methods - a façace, hash or array of keys to be implemented | ||
* Clean-up the test directory and cd into it. | ||
* Call given callback after entering the test directory. | ||
* @param {String} dir - path to the test directory | ||
* @param {Function} cb - callback executed after setting working directory to dir | ||
* @example | ||
* testDirectory(path.join(__dirname, './temp'), function () { | ||
* fs.writeFileSync('testfile', 'Roses are red.'); | ||
* ); | ||
*/ | ||
helpers.assertImplement = function (obj, methods) { | ||
methods = _.isArray(methods) ? methods : Object.keys(methods); | ||
var pass = methods.reduce(function (rest, method) { | ||
if (obj[method] != null) return true; | ||
return rest; | ||
}, false); | ||
assert.ok(pass); | ||
}; | ||
// Clean-up the test directory and ce into it. | ||
// Call given callback when you're there. | ||
// | ||
helpers.testDirectory = function (dir, cb) { | ||
exports.testDirectory = function (dir, cb) { | ||
if (!dir) { | ||
@@ -182,2 +164,6 @@ throw new Error('Missing directory'); | ||
// Make sure we're not deleting CWD by moving to top level folder. As we `cd` in the | ||
// test dir after cleaning up, this shouldn't be perceivable. | ||
process.chdir('/'); | ||
rimraf(dir, function (err) { | ||
@@ -193,8 +179,13 @@ if (err) { | ||
// Will answer to the questions for the furnished generator | ||
// | ||
// Example: | ||
// mockPrompt(angular, {'bootstrap': 'Y', 'compassBoostrap': 'Y'}); | ||
// | ||
helpers.mockPrompt = function (generator, answers) { | ||
/** | ||
* Answer prompt questions for the passed-in generator | ||
* @param {Generator} generator - a Yeoman generator | ||
* @param {Object} answers - an object where keys are the | ||
* generators prompt names and values are the answers to | ||
* the prompt questions | ||
* @example | ||
* mockPrompt(angular, {'bootstrap': 'Y', 'compassBoostrap': 'Y'}); | ||
*/ | ||
exports.mockPrompt = function (generator, answers) { | ||
var origPrompt = generator.prompt; | ||
@@ -207,6 +198,7 @@ generator.prompt = function (prompts, done) { | ||
// | ||
// Create a simple, dummy generator | ||
// | ||
helpers.createDummyGenerator = function () { | ||
/** | ||
* Create a simple, dummy generator | ||
*/ | ||
exports.createDummyGenerator = function () { | ||
return generators.Base.extend({ | ||
@@ -219,15 +211,22 @@ test: function () { | ||
// Create a generator, using the given dependencies and controller arguments | ||
// Dependecies can be path (autodiscovery) or an array [<generator>, <name>] | ||
// | ||
// Example: | ||
// var deps = ['../../app', | ||
// '../../common', | ||
// '../../controller', | ||
// '../../main', | ||
// [createDummyGenerator(), 'testacular:app'] | ||
// ]; | ||
// var angular = createGenerator('angular:app', deps); | ||
// | ||
helpers.createGenerator = function (name, dependencies, args, options) { | ||
/** | ||
* Create a generator, using the given dependencies and controller arguments | ||
* Dependecies can be path (autodiscovery) or an array [<generator>, <name>] | ||
* | ||
* @param {String} name - the name of the generator | ||
* @param {Array} dependencies - paths to the generators dependencies | ||
* @param {Array|String} args - arguments to the generator; | ||
* if String, will be split on spaces to create an Array | ||
* @param {Object} options - configuration for the generator | ||
* @example | ||
* var deps = ['../../app', | ||
* '../../common', | ||
* '../../controller', | ||
* '../../main', | ||
* [createDummyGenerator(), 'testacular:app'] | ||
* ]; | ||
* var angular = createGenerator('angular:app', deps); | ||
*/ | ||
exports.createGenerator = function (name, dependencies, args, options) { | ||
var env = generators(); | ||
@@ -234,0 +233,0 @@ dependencies.forEach(function (d) { |
'use strict'; | ||
var chalk = require('chalk'); | ||
module.exports.yeoman = | ||
/** | ||
* Common/General utilities | ||
* | ||
* @mixin util/common | ||
*/ | ||
var common = module.exports; | ||
/** | ||
* 'Welcome to Yeoman' prompt intro | ||
* @type {String} | ||
* @memberof util/common | ||
*/ | ||
common.yeoman = | ||
'\n _-----_' + | ||
@@ -6,0 +18,0 @@ '\n | |' + |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -10,2 +10,3 @@ 'use strict'; | ||
* Storage instances handle a json file where Generator authors can store data. | ||
* @constructor | ||
* @param {String} name The name of the new storage (this is a namespace) | ||
@@ -12,0 +13,0 @@ * @param {String} configPath The filepath used as a storage. `.yo-rc.json` is used |
111
main.js
@@ -0,47 +1,86 @@ | ||
/** | ||
* @module | ||
* @alias yeoman-generator | ||
*/ | ||
'use strict'; | ||
// The generator system is a framework for node to author reusable and | ||
// composable Generators, for a vast majority of use-case. | ||
// | ||
// Inspired and based off the work done on Thor and Rails 3 Generators, we try | ||
// to provide the same kind of infrastructure. | ||
// | ||
// var generators = require('yeoman-generators'); | ||
// | ||
// var env = generators('angular:model') | ||
// .run(function(err) { | ||
// console.log('done!'); | ||
// }); | ||
// | ||
// Generators are registered by namespace, where namespaces are mapping the | ||
// structure of the file system with `:` being simply converted to `/`. | ||
// | ||
// Generators are standard node modules, they are simply required as usual, and | ||
// they can be shipped into reusable npm packages. | ||
// | ||
// The lookup is done depending on the configured load path, which is by | ||
// default `lib/generators` in every generators package installed (ie. | ||
// node_modules/yeoman-backbone/lib/generators) | ||
var Environment = require('./lib/env'); | ||
var generators = module.exports = function createEnv(args, opts, adapter) { | ||
/** | ||
* The generator system is a framework for node to author reusable and | ||
* composable Generators, for a vast majority of use-case. | ||
* | ||
* Inspired and based off the work done on Thor and Rails 3 Generators, we try | ||
* to provide the same kind of infrastructure. | ||
* | ||
* Generators are registered by namespace, where namespaces are mapping the | ||
* structure of the file system with `:` being simply converted to `/`. | ||
* | ||
* Generators are standard node modules, they are simply required as usual, and | ||
* they can be shipped into reusable npm packages. | ||
* | ||
* The lookup is done depending on the configured load path, which is by | ||
* default `lib/generators` in every generators package installed (ie. | ||
* `node_modules/yeoman-backbone/lib/generators`) | ||
* | ||
* @example | ||
* var yeoman = require('yeoman-generators'); | ||
* | ||
* var env = yeoman('angular:model') | ||
* .run(function(err) { | ||
* console.log('done!'); | ||
* }); | ||
* | ||
*/ | ||
var yeoman = module.exports = function createEnv(args, opts, adapter) { | ||
return new Environment(args, opts, adapter); | ||
}; | ||
// Reference general dependencies on the top level object | ||
generators.inquirer = require('inquirer'); | ||
/** | ||
* Reference to the inquirer module | ||
* @deprecated Require your own copy of the module, this one will be removed after 1.0 | ||
*/ | ||
yeoman.inquirer = require('inquirer'); | ||
// Set global file utility | ||
generators.file = require('file-utils'); | ||
/** | ||
* Global file helpers methods | ||
* {@link https://github.com/SBoudrias/file-utils} | ||
*/ | ||
yeoman.file = require('file-utils'); | ||
// hoist up top level class the generator extend | ||
generators.Base = require('./lib/base'); | ||
generators.NamedBase = require('./lib/named-base'); | ||
yeoman.Base = require('./lib/base'); | ||
yeoman.NamedBase = require('./lib/named-base'); | ||
// expose test helpers for generators. | ||
generators.test = require('./lib/test/helpers'); | ||
/** | ||
* Test helpers | ||
* {@link module:test/helpers} | ||
*/ | ||
yeoman.test = require('./lib/test/helpers'); | ||
// backward compat, make them available as generators.generators.Base & | ||
// NamedBase (as most of generators use yeoman.generators.Stuff) | ||
generators.generators = {}; | ||
generators.generators.Base = generators.Base; | ||
generators.generators.NamedBase = generators.NamedBase; | ||
/** | ||
* Test assertions helpers | ||
* {@link module:test/assert} | ||
*/ | ||
yeoman.assert = require('./lib/test/assert'); | ||
/** | ||
* Yeoman base's generators | ||
* @enum generators | ||
*/ | ||
yeoman.generators = { | ||
/** | ||
* Base Generator | ||
* {@link Base} | ||
*/ | ||
Base: yeoman.Base, | ||
/** | ||
* Named Base Generator | ||
* {@link NamedBase} | ||
*/ | ||
NamedBase: yeoman.NamedBase | ||
}; |
{ | ||
"name": "yeoman-generator", | ||
"version": "0.15.0", | ||
"version": "0.16.0", | ||
"description": "Rails-inspired generator system that provides scaffolding for your apps", | ||
@@ -25,2 +25,3 @@ "license": "BSD", | ||
"test": "gulp", | ||
"doc": "jsdoc -c ./jsdoc.json", | ||
"legacy": "mocha test/legacy.js --reporter dot --timeout 100000", | ||
@@ -56,3 +57,2 @@ "test-generator": "mocha test/generators/*.js --reporter spec --timeout 100000" | ||
"sinon": "~1.7.3", | ||
"markdox": "~0.1.2", | ||
"coveralls": "~2.6.0", | ||
@@ -59,0 +59,0 @@ "gulp": "~3.2.1", |
@@ -0,0 +0,0 @@ # Generator [![Build Status](https://secure.travis-ci.org/yeoman/generator.png?branch=master)](http://travis-ci.org/yeoman/generator) [![Coverage Status](https://coveralls.io/repos/yeoman/generator/badge.png)](https://coveralls.io/r/yeoman/generator) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9
66
3395
868158
25