Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const generatorList = _.chain(globalConfig.getAll()).map((val, key) => {
let prettyName = '';
let sort = 0;
// Remove version from generator name
const name = key.split(':')[0];
const generator = app.generators[name];
if (generator) {
({prettyName} = generator);
sort = -app.conf.get('generatorRunCount')[namespaceToName(generator.namespace)] || 0;
} else {
prettyName = name.replace(/^generator-/, '') + chalk.red(' (not installed anymore)');
sort = 0;
}
return {
name: prettyName,
sort,
value: key
};
}).compact().sortBy(generatorName => generatorName.sort).value();
module.exports = (app, name) => {
const baseName = namespaceToName(name);
app.insight.track('yoyo', 'run', baseName);
console.log(
chalk.yellow('\nMake sure you are in the directory you want to scaffold into.') +
chalk.dim('\nThis generator can also be run with: ') +
chalk.blue(`yo ${baseName}\n`)
);
// Save the generator run count
const generatorRunCount = app.conf.get('generatorRunCount');
generatorRunCount[baseName] = generatorRunCount[baseName] + 1 || 1;
app.conf.set('generatorRunCount', generatorRunCount);
app.env.run(name);
};
const resolveGenerators = generator => {
// Skip sub generators
if (!/:(app|all)$/.test(generator.namespace)) {
return;
}
const {pkg} = readPkgUp.sync({cwd: path.dirname(generator.resolved)});
if (!pkg) {
return;
}
pkg.namespace = generator.namespace;
pkg.appGenerator = true;
pkg.prettyName = titleize(humanizeString(namespaceToName(generator.namespace)));
pkg.update = updateNotifier({pkg}).update;
if (pkg.update && pkg.version !== pkg.update.latest) {
pkg.updateAvailable = true;
}
this.generators[pkg.name] = pkg;
};
module.exports = function invoke(namespace, options, cb) {
cb = cb || function () {};
options = options || {};
options.args = options.args || [];
// Hack: create a clone of the environment because we don't want to share
// the runLoop
var env = require('yeoman-environment').util.duplicateEnv(this.env);
var generator = env.create(namespace, options);
this.log.emit('up');
this.log.invoke(namespace);
this.log.emit('up');
generator.once('end', function () {
this.log.emit('down');
this.log.emit('down');
}.bind(this));
return generator.run(cb);
};
var config = require('../config')(), // TODO: config
napi = config.napiUrl,
shell = require('shelljs'),
fs = require('fs'),
chalk = require('chalk'),
utils = require('./utils'),
mongoCtrl = require('./controllers/mongo'), // TODO: mongoCtrl
users = require('./controllers/users'), // TODO: user
series = require('async-series'),
request = require('request'),
qs = require('querystring'),
inquirer = require('inquirer'),
prompt = require('prompt'),
yeoman = require('yeoman-environment'),
env = yeoman.createEnv();
var progress = new utils.Progress();
exports.init = function(options) {
progress.start();
series([
checkPermissions,
function(done) {
cloneVulgar(options, done);
},
const createYeomanEnv = () => {
const env = yeoman.createEnv();
/* Register yeoman generators */
Object.keys(SUB_GENERATORS)
.filter(command => !SUB_GENERATORS[command].cliOnly)
.forEach(generator => {
if (SUB_GENERATORS[generator].blueprint) {
/* eslint-disable prettier/prettier */
env.register(require.resolve(`${SUB_GENERATORS[generator].blueprint}/generators/${generator}`), `${CLI_NAME}:${generator}`);
} else {
env.register(require.resolve(`../generators/${generator}`), `${CLI_NAME}:${generator}`);
}
});
return env;
};
});
this.option('skip-install', {
type: Boolean,
desc: 'Do not automatically install dependencies',
default: false
});
// checks required paramaters
assert(this.options.env, 'You must provide the environment object. Use env#create() to create a new generator.');
assert(this.options.resolved, 'You must provide the resolved path value. Use env#create() to create a new generator.');
this.env = this.options.env;
this.resolved = this.options.resolved;
// Ensure the environment support features this yeoman-generator version require.
require('yeoman-environment').enforceUpdate(this.env);
this.description = this.description || '';
this.async = function () {
return function () {};
};
this.fs = FileEditor.create(this.env.sharedFs);
this.conflicter = new Conflicter(this.env.adapter, this.options.force);
// Mirror the adapter log method on the generator.
//
// example:
// this.log('foo');
// this.log.error('bar');
this.log = this.env.adapter.log;
});
// Checks required parameters
assert(
this.options.env,
'You must provide the environment object. Use env#create() to create a new generator.'
);
assert(
this.options.resolved,
'You must provide the resolved path value. Use env#create() to create a new generator.'
);
this.env = this.options.env;
this.resolved = this.options.resolved;
// Ensure the environment support features this yeoman-generator version require.
require('yeoman-environment').enforceUpdate(this.env);
this.description = this.description || '';
this.async = () => () => {};
this.fs = FileEditor.create(this.env.sharedFs);
this.conflicter = new Conflicter(this.env.adapter, this.options.force, {
bail: this.options.bail,
ignoreWhitespace: this.options.whitespace,
skipRegenerate: this.options.skipRegenerate,
dryRun: this.options.dryRun
});
// Mirror the adapter log method on the generator.
//
it('exposes the wiring interface', function () {
var Dummy = generators.Base.extend({
exec: function () {}
});
var dummy = new Dummy([], {
resolved: 'foo',
namespace: 'bar',
env: yeoman.createEnv()
});
assert.implement(dummy, wiring);
});
});
beforeEach(function() {
this.beforeDir = process.cwd();
this.storePath = path.join(tmpdir, 'new-config.json');
this.memFs = env.createEnv().sharedFs;
this.fs = FileEditor.create(this.memFs);
this.store = new Storage('test', this.fs, this.storePath);
this.store.set('foo', 'bar');
});