-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·73 lines (72 loc) · 2.08 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env node
'use strict'
const program = require('commander')
const chalk = require('chalk')
global.print = require('./core/print')
const localConfig = require('./core/local_config')
const checkUpdate = require('./core/check_update')
const workflow = require('./core/workflow')
const lint = require('./core/lint')
const { version } = require('./package.json')
program
.version(version)
.option('-v, --version', 'output the version number')
.description(`${chalk.blue.bold('GoFlow CLI')}`)
program
.command('set <name> <value>')
.description('set config <name> <value>')
.action(localConfig.set)
program
.command('get <name>')
.description('get config <name>')
.action(env => {
let value = localConfig.get(env)
print.success(`get ${env}: ${value}`)
})
program
.command('init')
.description('init new project')
.action(require('./core/new_project'))
program
.command('serve')
.description(chalk.yellow('run dev workflow in project'))
.action((cmd) => {
checkUpdate().then(() => workflow('dev', '', cmd))
})
program
.command('build [env]')
.option('-a, --analyzer', 'build with analyzer')
.description(chalk.yellow('run build workflow in project'))
.action((env, cmd) => {
if (!env) {
env = 'prod'
}
if (env !== 'prod' && env !== 'testing') {
console.log(chalk.red(`! The env parameter only supports prod or testing.`))
} else {
checkUpdate().then(() => workflow('build', env, cmd))
}
})
program
.command('build:dll')
.description(chalk.yellow('run build dll'))
.action((cmd) => {
checkUpdate().then(() => workflow('dll', void 0, cmd))
})
program
.command('build:play')
.description(chalk.yellow('run build play'))
.action((cmd) => {
checkUpdate().then(() => workflow('play', void 0, cmd))
})
program
.command('lint')
.description(chalk.yellow('run lint workflow in project'))
.action((cmd) => {
lint(cmd)
})
program.on('command:*', function () {
console.log(chalk.yellow(`! Command not found. Please try to use ${chalk.yellow.bold('-h')}`))
process.exit(1)
})
program.parse(process.argv)