MCPcopy Create free account
hub / github.com/acode/cli / DownCommand

Class DownCommand

cli/commands/down.js:11–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9const serviceConfig = require('../service_config');
10
11class DownCommand extends Command {
12
13 constructor() {
14
15 super('down');
16
17 }
18
19 help() {
20
21 return {
22 description: 'Removes Autocode package from registry and cloud environment',
23 args: [
24 'environment'
25 ],
26 flags: {
27 r: 'Remove a release version (provide number)',
28 },
29 vflags: {
30 release: 'Remove a release version (provide number)',
31 }
32 };
33
34 }
35
36 run(params, callback) {
37
38 let environment = params.args[0];
39 let version;
40 let release = params.flags.r || params.vflags.release;
41
42 if (release && environment) {
43 return callback(new Error('Can not remove an release with an environment'));
44 }
45
46 if (!release && !environment) {
47 return callback(new Error('Please specify an environment'));
48 }
49
50 if (release) {
51 version = release[0];
52 environment = null;
53 }
54
55 let host = 'packages.stdlib.com';
56 let port = 443;
57
58 let hostname = (params.flags.h && params.flags.h[0]) || '';
59 let matches = hostname.match(/^(https?:\/\/)?(.*?)(:\d+)?$/);
60
61 if (hostname && matches) {
62 host = matches[2];
63 port = parseInt((matches[3] || '').substr(1) || (hostname.indexOf('https') === 0 ? 443 : 80));
64 }
65
66 let pkg;
67
68 try {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected