1 | #!/usr/bin/env node --harmony
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | var path = require('path');
|
10 | var program = require('commander');
|
11 | var _ = require('lodash');
|
12 | var glob = require('glob');
|
13 | var verifyNodeVersion = require('../util/verifyNodeVersion');
|
14 | verifyNodeVersion();
|
15 | require('../polyfills/endswith');
|
16 |
|
17 | var cliVersion = require(path.resolve(__dirname + '/../package.json')).version;
|
18 |
|
19 | program
|
20 | .version(cliVersion, '-v, --version')
|
21 | .option('-w, --watch', '[DEPRECATED] publish Custom App design every time a file changes')
|
22 | .option('-vb, --verbose', 'log more details including XHR responses, useful for troubleshooting')
|
23 | .option('-m, --manifest [type]', 'use a specific manifest file');
|
24 |
|
25 |
|
26 | glob
|
27 | .sync(path.resolve(__dirname + "/../commands/*.js"))
|
28 | .forEach(function(command){
|
29 | require(command)(program);
|
30 | });
|
31 |
|
32 | if (!process.argv.slice(2).length) {
|
33 | program.help();
|
34 | } else {
|
35 | program.parse(process.argv);
|
36 |
|
37 | var has_command = false;
|
38 |
|
39 | if (!program.args) {
|
40 | program.args = [];
|
41 | }
|
42 |
|
43 | for (var i = 0, len = program.args.length; i < len; i++) {
|
44 | if (program.args[i] instanceof program.Command) {
|
45 | has_command = true;
|
46 | break;
|
47 | }
|
48 | }
|
49 |
|
50 | if (!has_command) {
|
51 | console.log(' Invalid option "%s"', program.args.join(' '));
|
52 | program.help();
|
53 | }
|
54 | }
|