-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathgenerate.js
More file actions
35 lines (29 loc) · 1002 Bytes
/
generate.js
File metadata and controls
35 lines (29 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import program from 'commander';
import chalk from 'chalk';
import Generate from '../tasks/generate';
import getMernConfig from '../tasks/getMernConfig';
program
.description('Generate components, routes, controllers, models using mern generator')
.arguments('<generator> [args]')
.parse(process.argv);
/**
* Generate string output for a single blueprint
* @param blueprint
*/
const printBlueprint = (blueprint) => {
console.log(` ${chalk.yellow(blueprint.name)} - ${blueprint.description}`);
console.log(` Usage: ${blueprint.usage}`);
console.log('');
};
program.on('--help', () => {
// Get available blueprints from the current mern project
const { blueprints } = getMernConfig();
console.log(chalk.yellow('Available Generators'));
console.log(chalk.yellow('____________________'));
console.log('');
blueprints.forEach(b => printBlueprint(b));
});
if (!program.args.length) {
program.help();
}
new Generate([...program.args]).run();