1 | const program = require('commander');
|
2 | const { build } = require('../src/commands/build');
|
3 | const config = require('../src/commands/config');
|
4 | const init = require('../src/commands/init');
|
5 | const publish = require('../src/commands/publish');
|
6 | const dbg = require("../src/debugger/lib.js");
|
7 |
|
8 |
|
9 | const debuggerIp = "debugger.ialicdn.com";
|
10 |
|
11 | program
|
12 | .version('0.1.2', '-v, --version')
|
13 | .on('--help', function () {
|
14 | console.log('');
|
15 | console.log('Examples:');
|
16 | console.log(' 0. mkdir yourProject & cd yourProject Prepare an empty directory');
|
17 | console.log(' 1. edgeroutine-cli init Initialize and coding with edge.js');
|
18 | console.log(' 2. edgeroutine-cli config Config with your alicloud access');
|
19 | console.log(' 3. edgeroutine-cli build Build code and you can test with gray env');
|
20 | console.log(' 4. edgeroutine-cli publish Publish code only when you are ready online');
|
21 | });
|
22 |
|
23 | program
|
24 | .command('init')
|
25 | .description('Initialize project with the default sample')
|
26 | .action(init);
|
27 |
|
28 | program
|
29 | .command('config')
|
30 | .option('-s, --show', 'show existed config')
|
31 | .description('Config project before build and publish')
|
32 | .action(config)
|
33 |
|
34 | program
|
35 | .command('build')
|
36 | .option('-s, --show', 'show build configs')
|
37 | .option('-d, --delete', 'delete existed build')
|
38 | .option('-r, --rollback', 'rollback existed build')
|
39 | .description('Build code, check synax and publish to remote gray environment')
|
40 | .action(build)
|
41 |
|
42 | program
|
43 | .command('publish')
|
44 | .option('-s, --show', 'show published code')
|
45 | .option('-d, --delete', 'delete published code')
|
46 | .description('Publish code to remote environment')
|
47 | .action(publish)
|
48 |
|
49 | program
|
50 | .command('debugger [url] [id] [path] [origin]')
|
51 | .option('-u, --url', 'specify debugger endpoint', undefined, debuggerIp)
|
52 | .option('-i, --id', 'specify debugger user id', undefined, "debug")
|
53 | .option('-p, --path', 'specify debugged script path', undefined, undefined)
|
54 | .option('-o, --origin', 'specify debugged script origin', undefined, undefined)
|
55 | .description("launch edgeroutine interactive debugger")
|
56 | .action(function (url, id, path, origin, opt) {
|
57 | dbg({
|
58 | url: url || debuggerIp,
|
59 | uid: id || "debug",
|
60 | sourcePath: path,
|
61 | origin: origin
|
62 | });
|
63 | })
|
64 |
|
65 | program.parse(process.argv);
|