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;
};
}).compact().sortBy(el => {
const generatorName = namespaceToName(el.value.generator);
return -app.conf.get('generatorRunCount')[generatorName] || 0;
}).value();