-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·110 lines (89 loc) · 2.63 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env node
'use strict'
const program = require('commander')
const chalk = require('chalk')
global.print = require('./core/print')
const checkUpdate = require('./core/check-update')
const workflow = require('./core/workflow')
const killPort = require('./core/kill-port')
const localConfig = require('./core/local-config')
const { version } = require('./package.json')
global.util = require('legoflow-engine/util');
(async () => {
program
.version(version)
.option('-v, --version', 'output the version number')
.description(`${chalk.blue.bold('LegoFlow-CLI')}, ${chalk.underline('https://legoflow.com')}`)
program
.command('init')
.option('--name <name>')
.option('--type <type>')
.option('--description <description>')
.option('--isSourcePath <isSourcePath>')
.option('--git <git>')
.description('init new project')
.action(require('./core/init-project'))
program
.command('init:type')
.description('get init project type')
.action(require('./core/init-project-type'))
program
.command('set <name> <value>')
.description('set config <name> <value>')
.action(localConfig.set)
program
.command('get <name>')
.description('get config <name>')
.action(localConfig.get)
program
.command('clean')
.description('clean config')
.action(localConfig.clean)
program
.command('path')
.description('install path')
.action(() => console.log(__dirname))
program
.command('migrate:v2')
.description('migrate project to v2')
.action(require('./core/migrate-v2'))
program
.command('kill:port <port>')
.description('kill thread by port')
.action(killPort)
program
.command('check:update')
.description('check update')
.action(checkUpdate)
program
.command('dev [env]')
.option('-e, --env', 'env list')
.description(chalk.yellow('run dev workflow in project'))
.action(
(env, cmd) => {
checkUpdate().then(() => workflow('dev', env, cmd))
}
)
program
.command('build [env]')
.option('-e, --env', 'env list')
.description(chalk.yellow('run build workflow in project'))
.action(
(env, cmd) => {
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.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)
})()