-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathstart.ts
49 lines (38 loc) · 1.21 KB
/
start.ts
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
import Command from '../../base.js';
import { Flags } from '@oclif/core';
import { createDebugLogger } from '../../utils/output.js';
export default class AppStart extends Command {
static description = 'start an app';
static flags = {
...Command.flags,
app: Flags.string({
char: 'a',
description: 'app id',
}),
};
static aliases = ['start'];
async run() {
const { flags } = await this.parse(AppStart);
const debug = createDebugLogger(flags.debug);
await this.setGotConfig(flags);
const app = flags.app || (await this.promptProject());
try {
await this.got.post(`v1/projects/${app}/actions/scale`, {
json: { scale: 1 },
});
this.log(`App ${app} started.`);
} catch (error) {
debug(error.message);
if (error.response && error.response.data) {
debug(JSON.stringify(error.response.data));
}
if (error.response && error.response.status === 404) {
this.error(`Could not find the app.`);
}
if (error.response && error.response.status === 409) {
this.error(`Another operation is already running. Please wait.`);
}
this.error(`Could not start the app. Please try again.`);
}
}
}