UNPKG

4.99 kBPlain TextView Raw
1#!/usr/bin/env node
2/****************************************************************************
3 The MIT License (MIT)
4
5 Copyright (c) 2014 Apigee Corporation
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 THE SOFTWARE.
24 ****************************************************************************/
25'use strict';
26
27var app = require('commander');
28var project = require('../lib/commands/project/project');
29var cli = require('../lib/util/cli');
30var execute = cli.execute;
31
32app
33 .command('create <name>')
34 .description('Create a subdirectory containing a project')
35 .action(execute(project.create));
36
37app
38 .command('start [directory]')
39 .description('Start the project locally')
40 .option('-d, --debug <port>', 'start in remote debug mode')
41 .option('-b, --debug-brk <port>', 'start in remote debug mode, wait for debugger connect')
42 .option('-m, --mock', 'start in mock mode')
43 .option('-o, --open', 'open in browser')
44 .option('-a, --account <account>', 'use specified account')
45 .option('-p, --print', 'print configuration')
46 .option('-n, --nocors', 'omit cors headers')
47 .action(execute(project.start));
48
49app
50 .command('verify [directory]')
51 .description('Verify that the project is correct (swagger, config, etc)')
52 .option('-j, --json', 'output as JSON')
53 .action(execute(project.verify));
54
55app
56 .command('edit [directory]')
57 .description('Open swagger editor')
58 .option('-s --silent', 'do not open the browser')
59 .action(execute(project.edit));
60
61app
62 .command('open [directory]')
63 .description('Open project in a browser')
64 .action(execute(project.open));
65
66app
67 .command('docs [directory]')
68 .description('Open project docs (if configured) in browser')
69 .action(execute(project.showDocs));
70
71app
72 .command('logs [directory]')
73 .option('-a, --account <account>', 'use specified account')
74 .option('-f, --follow', 'follow (tail -f) the logs')
75 .option('-t, --timezone <timezone>', 'convert the log times from UTC to specified timezone (eg. PST)')
76 .description('Print the logs for a project')
77 .action(execute(project.logs));
78
79app
80 .command('bind [service] [directory]')
81 .description('Bind the project to a service')
82 .action(execute(project.bind));
83
84app
85 .command('unbind [service] [directory]')
86 .description('Unbind the project from a service')
87 .action(execute(project.unbind));
88
89app
90 .command('bindings [directory]')
91 .alias('services')
92 .description('List services bound to the project')
93 .action(execute(project.bindings, 'Service Bindings'));
94
95app
96 .command('deploy [directory]')
97 .description('Deploy project')
98 .option('-a, --account <account>', 'use specified account')
99 .option('-b, --base <path>', 'override deployment base path (default is /<projectName>)')
100 .option('-m, --main <main>', 'override deployment main file')
101 .option('-n, --name <name>', 'override deployment name')
102 .option('-i, --import-only', "Apigee only: import project to provider, but don't deploy")
103 .option('-u, --upload', 'Apigee only: upload node_modules instead of resolving on server')
104 .action(execute(project.deploy));
105
106app
107 .command('undeploy [directory]')
108 .description('Undeploy project')
109 .option('-a, --account <account>', 'use specified account')
110 .option('-n, --name <name>', 'use specified deployment name')
111 .action(execute(project.undeploy));
112
113app
114 .command('config [directory]')
115 .description('Show all project configuration elements given current account')
116 .option('-a, --account <account>', 'use specified account for configuration')
117 .action(execute(project.showConfig));
118
119app
120 .command('test [directory_or_file]')
121 .description('Run project tests')
122 .option('-d, --debug [port]', 'start in remote debug mode')
123 .option('-b, --debug-brk [port]', 'start in remote debug mode, wait for debugger connect')
124 .option('-a, --account <account>', 'use specified account')
125 .option('-m, --mock', 'run in mock mode')
126 .option('-p, --print', 'print configuration')
127 .action(execute(project.test));
128
129app.parse(process.argv);
130cli.validate(app);