-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.js
34 lines (28 loc) · 928 Bytes
/
index.js
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
#!/usr/bin/env node
const program = require('commander');
const createProject = require('./src/create');
const { commands, preHook } = require('./src/scripts');
const { log, colorize } = require('./src/util');
const { version } = require('./package.json');
program
.version(version)
.description('Create client + server apps with one CLI command. Easy. Unobstrusive. Powerful.');
program
.command('init <projectName> [projectFolderName]')
.description('Initialize a project.')
.action((projectName, projectFolderName) => {
createProject({ projectName, projectFolderName });
});
commands.forEach(({ name, fn, description = '' }) => {
program
.command(name)
.description(description)
.action(async () => {
const { error } = await preHook();
if (!error)
fn();
else
log({ text: colorize(error).FgRed(), type: 'error' });
});
});
program.parse(process.argv);