@chabokan.net/cli 0.5.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -28
- package/lib/base.js +13 -3
- package/lib/commands/change-user.js +1 -1
- package/lib/commands/config-clear.js +1 -1
- package/lib/commands/deploy.js +1 -4
- package/lib/commands/login.js +1 -1
- package/lib/commands/logs.d.ts +1 -0
- package/lib/commands/logs.js +9 -4
- package/lib/commands/resize.d.ts +14 -0
- package/lib/commands/resize.js +128 -0
- package/lib/commands/restart.d.ts +1 -0
- package/lib/commands/restart.js +19 -6
- package/lib/commands/start.d.ts +4 -6
- package/lib/commands/start.js +47 -15
- package/lib/commands/stop.d.ts +4 -6
- package/lib/commands/stop.js +47 -15
- package/lib/helper.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ $ npm install -g @chabokan.net/cli
|
|
|
19
19
|
$ chabok COMMAND
|
|
20
20
|
running command...
|
|
21
21
|
$ chabok (-v|--version|version)
|
|
22
|
-
@chabokan.net/cli/0.
|
|
22
|
+
@chabokan.net/cli/0.7.2 darwin-x64 node-v14.17.5
|
|
23
23
|
$ chabok --help [COMMAND]
|
|
24
24
|
USAGE
|
|
25
25
|
$ chabok COMMAND
|
|
@@ -34,13 +34,14 @@ USAGE
|
|
|
34
34
|
* [`chabok help [COMMAND]`](#chabok-help-command)
|
|
35
35
|
* [`chabok login`](#chabok-login)
|
|
36
36
|
* [`chabok logs`](#chabok-logs)
|
|
37
|
+
* [`chabok resize`](#chabok-resize)
|
|
37
38
|
* [`chabok restart`](#chabok-restart)
|
|
38
|
-
* [`chabok start
|
|
39
|
-
* [`chabok stop
|
|
39
|
+
* [`chabok start`](#chabok-start)
|
|
40
|
+
* [`chabok stop`](#chabok-stop)
|
|
40
41
|
|
|
41
42
|
## `chabok change-user`
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
switch your default user between logged in users
|
|
44
45
|
|
|
45
46
|
```
|
|
46
47
|
USAGE
|
|
@@ -51,11 +52,11 @@ OPTIONS
|
|
|
51
52
|
-u, --user=user default user
|
|
52
53
|
```
|
|
53
54
|
|
|
54
|
-
_See code: [src/commands/change-user.ts](https://github.com/chabokan/cli/blob/v0.
|
|
55
|
+
_See code: [src/commands/change-user.ts](https://github.com/chabokan/cli/blob/v0.7.2/src/commands/change-user.ts)_
|
|
55
56
|
|
|
56
57
|
## `chabok config-clear`
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
clear config file, data such as auth will be removed.
|
|
59
60
|
|
|
60
61
|
```
|
|
61
62
|
USAGE
|
|
@@ -65,7 +66,7 @@ OPTIONS
|
|
|
65
66
|
-h, --help show CLI help
|
|
66
67
|
```
|
|
67
68
|
|
|
68
|
-
_See code: [src/commands/config-clear.ts](https://github.com/chabokan/cli/blob/v0.
|
|
69
|
+
_See code: [src/commands/config-clear.ts](https://github.com/chabokan/cli/blob/v0.7.2/src/commands/config-clear.ts)_
|
|
69
70
|
|
|
70
71
|
## `chabok deploy`
|
|
71
72
|
|
|
@@ -81,7 +82,7 @@ OPTIONS
|
|
|
81
82
|
-s, --service=service service name
|
|
82
83
|
```
|
|
83
84
|
|
|
84
|
-
_See code: [src/commands/deploy.ts](https://github.com/chabokan/cli/blob/v0.
|
|
85
|
+
_See code: [src/commands/deploy.ts](https://github.com/chabokan/cli/blob/v0.7.2/src/commands/deploy.ts)_
|
|
85
86
|
|
|
86
87
|
## `chabok help [COMMAND]`
|
|
87
88
|
|
|
@@ -102,7 +103,7 @@ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.2
|
|
|
102
103
|
|
|
103
104
|
## `chabok login`
|
|
104
105
|
|
|
105
|
-
|
|
106
|
+
login to hub.chabokan.net account
|
|
106
107
|
|
|
107
108
|
```
|
|
108
109
|
USAGE
|
|
@@ -115,11 +116,11 @@ OPTIONS
|
|
|
115
116
|
-u, --username=username your username
|
|
116
117
|
```
|
|
117
118
|
|
|
118
|
-
_See code: [src/commands/login.ts](https://github.com/chabokan/cli/blob/v0.
|
|
119
|
+
_See code: [src/commands/login.ts](https://github.com/chabokan/cli/blob/v0.7.2/src/commands/login.ts)_
|
|
119
120
|
|
|
120
121
|
## `chabok logs`
|
|
121
122
|
|
|
122
|
-
|
|
123
|
+
read latest logs from service
|
|
123
124
|
|
|
124
125
|
```
|
|
125
126
|
USAGE
|
|
@@ -130,11 +131,29 @@ OPTIONS
|
|
|
130
131
|
-s, --service=service service name
|
|
131
132
|
```
|
|
132
133
|
|
|
133
|
-
_See code: [src/commands/logs.ts](https://github.com/chabokan/cli/blob/v0.
|
|
134
|
+
_See code: [src/commands/logs.ts](https://github.com/chabokan/cli/blob/v0.7.2/src/commands/logs.ts)_
|
|
135
|
+
|
|
136
|
+
## `chabok resize`
|
|
137
|
+
|
|
138
|
+
resize a service
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
USAGE
|
|
142
|
+
$ chabok resize
|
|
143
|
+
|
|
144
|
+
OPTIONS
|
|
145
|
+
-c, --cpu=cpu CPU
|
|
146
|
+
-d, --disk=disk DISK
|
|
147
|
+
-h, --help show CLI help
|
|
148
|
+
-r, --ram=ram RAM
|
|
149
|
+
-s, --service=service service name
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
_See code: [src/commands/resize.ts](https://github.com/chabokan/cli/blob/v0.7.2/src/commands/resize.ts)_
|
|
134
153
|
|
|
135
154
|
## `chabok restart`
|
|
136
155
|
|
|
137
|
-
|
|
156
|
+
restart a service
|
|
138
157
|
|
|
139
158
|
```
|
|
140
159
|
USAGE
|
|
@@ -145,37 +164,35 @@ OPTIONS
|
|
|
145
164
|
-s, --service=service service name
|
|
146
165
|
```
|
|
147
166
|
|
|
148
|
-
_See code: [src/commands/restart.ts](https://github.com/chabokan/cli/blob/v0.
|
|
167
|
+
_See code: [src/commands/restart.ts](https://github.com/chabokan/cli/blob/v0.7.2/src/commands/restart.ts)_
|
|
149
168
|
|
|
150
|
-
## `chabok start
|
|
169
|
+
## `chabok start`
|
|
151
170
|
|
|
152
|
-
|
|
171
|
+
start a service
|
|
153
172
|
|
|
154
173
|
```
|
|
155
174
|
USAGE
|
|
156
|
-
$ chabok start
|
|
175
|
+
$ chabok start
|
|
157
176
|
|
|
158
177
|
OPTIONS
|
|
159
|
-
-
|
|
160
|
-
-
|
|
161
|
-
-n, --name=name name to print
|
|
178
|
+
-h, --help show CLI help
|
|
179
|
+
-s, --service=service service name
|
|
162
180
|
```
|
|
163
181
|
|
|
164
|
-
_See code: [src/commands/start.ts](https://github.com/chabokan/cli/blob/v0.
|
|
182
|
+
_See code: [src/commands/start.ts](https://github.com/chabokan/cli/blob/v0.7.2/src/commands/start.ts)_
|
|
165
183
|
|
|
166
|
-
## `chabok stop
|
|
184
|
+
## `chabok stop`
|
|
167
185
|
|
|
168
|
-
|
|
186
|
+
stop a service
|
|
169
187
|
|
|
170
188
|
```
|
|
171
189
|
USAGE
|
|
172
|
-
$ chabok stop
|
|
190
|
+
$ chabok stop
|
|
173
191
|
|
|
174
192
|
OPTIONS
|
|
175
|
-
-
|
|
176
|
-
-
|
|
177
|
-
-n, --name=name name to print
|
|
193
|
+
-h, --help show CLI help
|
|
194
|
+
-s, --service=service service name
|
|
178
195
|
```
|
|
179
196
|
|
|
180
|
-
_See code: [src/commands/stop.ts](https://github.com/chabokan/cli/blob/v0.
|
|
197
|
+
_See code: [src/commands/stop.ts](https://github.com/chabokan/cli/blob/v0.7.2/src/commands/stop.ts)_
|
|
181
198
|
<!-- commandsstop -->
|
package/lib/base.js
CHANGED
|
@@ -5,9 +5,10 @@ const command_1 = tslib_1.__importStar(require("@oclif/command"));
|
|
|
5
5
|
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
6
|
const constants_1 = require("./constants");
|
|
7
7
|
const helper_1 = require("./helper");
|
|
8
|
-
const
|
|
8
|
+
const proxy_http_agent_1 = require("proxy-http-agent");
|
|
9
9
|
const fs = tslib_1.__importStar(require("fs"));
|
|
10
10
|
const got_1 = tslib_1.__importDefault(require("got"));
|
|
11
|
+
const https = tslib_1.__importStar(require("https"));
|
|
11
12
|
class default_1 extends command_1.default {
|
|
12
13
|
constructor() {
|
|
13
14
|
super(...arguments);
|
|
@@ -24,16 +25,25 @@ class default_1 extends command_1.default {
|
|
|
24
25
|
return await helper_1.get_all_services(filter, this.axiosConfig);
|
|
25
26
|
}
|
|
26
27
|
init_run() {
|
|
27
|
-
const
|
|
28
|
+
const main_agent = new https.Agent({
|
|
29
|
+
rejectUnauthorized: false
|
|
30
|
+
});
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
const gotConfig = { https: main_agent };
|
|
33
|
+
this.axiosConfig.httpsAgent = main_agent;
|
|
28
34
|
this.axiosConfig.baseURL = constants_1.BASE_API_URL;
|
|
29
35
|
gotConfig.prefixUrl = this.axiosConfig.baseURL;
|
|
30
36
|
const proxy = process.env.http_proxy || process.env.https_proxy;
|
|
31
37
|
if (proxy) {
|
|
32
38
|
this.log(`Using proxy server ${proxy}`);
|
|
33
39
|
// @ts-ignore
|
|
34
|
-
const agent =
|
|
40
|
+
const agent = proxy_http_agent_1.getProxyHttpAgent({
|
|
41
|
+
proxy: proxy,
|
|
42
|
+
rejectUnauthorized: false
|
|
43
|
+
});
|
|
35
44
|
this.axiosConfig.httpsAgent = agent;
|
|
36
45
|
this.axiosConfig.proxy = false;
|
|
46
|
+
// @ts-ignore
|
|
37
47
|
gotConfig.agent = { https: agent };
|
|
38
48
|
}
|
|
39
49
|
const config_json = helper_1.read_config_file();
|
|
@@ -37,7 +37,7 @@ class ChangeUser extends command_1.Command {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
exports.default = ChangeUser;
|
|
40
|
-
ChangeUser.description = '
|
|
40
|
+
ChangeUser.description = 'switch your default user between logged in users';
|
|
41
41
|
ChangeUser.flags = {
|
|
42
42
|
help: command_1.flags.help({ char: 'h' }),
|
|
43
43
|
user: command_1.flags.string({ char: 'u', description: 'default user' }),
|
|
@@ -13,5 +13,5 @@ class ConfigClear extends base_1.default {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
exports.default = ConfigClear;
|
|
16
|
-
ConfigClear.description = '
|
|
16
|
+
ConfigClear.description = 'clear config file, data such as auth will be removed.';
|
|
17
17
|
ConfigClear.flags = Object.assign({}, base_1.default.flags);
|
package/lib/commands/deploy.js
CHANGED
|
@@ -14,7 +14,7 @@ const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
|
14
14
|
const inquirer = tslib_1.__importStar(require("inquirer"));
|
|
15
15
|
const progress_1 = tslib_1.__importDefault(require("progress"));
|
|
16
16
|
const form_data_1 = tslib_1.__importDefault(require("form-data"));
|
|
17
|
-
const MAX_SOURCE_SIZE =
|
|
17
|
+
const MAX_SOURCE_SIZE = 200 * 1024 * 1024; // 200 MB
|
|
18
18
|
class Deploy extends base_1.default {
|
|
19
19
|
async run() {
|
|
20
20
|
const { args, flags } = this.parse(Deploy);
|
|
@@ -49,7 +49,6 @@ class Deploy extends base_1.default {
|
|
|
49
49
|
cli.log(chalk_1.default.green(upload_response.message));
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
|
-
console.clear();
|
|
53
52
|
cli.log(chalk_1.default.red("[Error] " + upload_response.message));
|
|
54
53
|
}
|
|
55
54
|
}
|
|
@@ -120,7 +119,6 @@ class Deploy extends base_1.default {
|
|
|
120
119
|
.on('uploadProgress', progress => {
|
|
121
120
|
bar.tick(progress.transferred - bar.curr);
|
|
122
121
|
}).json();
|
|
123
|
-
// this.spinner.succeed('Upload finished.')
|
|
124
122
|
if (response.success) {
|
|
125
123
|
upload_response.success = true;
|
|
126
124
|
upload_response.message = "Deployment finished successfully.";
|
|
@@ -128,7 +126,6 @@ class Deploy extends base_1.default {
|
|
|
128
126
|
return upload_response;
|
|
129
127
|
}
|
|
130
128
|
catch (error) {
|
|
131
|
-
// this.spinner.fail('Upload failed.')
|
|
132
129
|
return upload_response;
|
|
133
130
|
}
|
|
134
131
|
finally {
|
package/lib/commands/login.js
CHANGED
|
@@ -82,5 +82,5 @@ class Login extends base_1.default {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
exports.default = Login;
|
|
85
|
-
Login.description = '
|
|
85
|
+
Login.description = 'login to hub.chabokan.net account';
|
|
86
86
|
Login.flags = Object.assign(Object.assign({}, base_1.default.flags), { username: command_1.flags.string({ char: 'u', description: 'your username' }), password: command_1.flags.string({ char: 'p', description: 'your password' }), token: command_1.flags.string({ char: 't', description: 'login with api token' }) });
|
package/lib/commands/logs.d.ts
CHANGED
package/lib/commands/logs.js
CHANGED
|
@@ -34,10 +34,15 @@ class Logs extends base_1.default {
|
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
await this.send_request(cli, selected_service);
|
|
38
|
+
}
|
|
39
|
+
async send_request(cli, selected_service) {
|
|
37
40
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
if (selected_service) {
|
|
42
|
+
const { data } = await axios_1.default.get("services/" + selected_service + "/logs/", this.axiosConfig);
|
|
43
|
+
if (data.success) {
|
|
44
|
+
cli.log(data.logs);
|
|
45
|
+
}
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
catch (e) {
|
|
@@ -51,5 +56,5 @@ class Logs extends base_1.default {
|
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
58
|
exports.default = Logs;
|
|
54
|
-
Logs.description = '
|
|
59
|
+
Logs.description = 'read latest logs from service';
|
|
55
60
|
Logs.flags = Object.assign(Object.assign({}, base_1.default.flags), { service: command_1.flags.string({ char: 's', description: 'service name' }) });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import Command from "../base";
|
|
3
|
+
export default class Resize extends Command {
|
|
4
|
+
static description: string;
|
|
5
|
+
static flags: {
|
|
6
|
+
service: flags.IOptionFlag<string | undefined>;
|
|
7
|
+
ram: flags.IOptionFlag<string | undefined>;
|
|
8
|
+
cpu: flags.IOptionFlag<string | undefined>;
|
|
9
|
+
disk: flags.IOptionFlag<string | undefined>;
|
|
10
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
send_request(cli: any, selected_service: any, ram: any, cpu: any, disk: any): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const command_1 = require("@oclif/command");
|
|
5
|
+
const base_1 = tslib_1.__importDefault(require("../base"));
|
|
6
|
+
const helper_1 = require("../helper");
|
|
7
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
+
const inquirer = tslib_1.__importStar(require("inquirer"));
|
|
9
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
10
|
+
class Resize extends base_1.default {
|
|
11
|
+
async run() {
|
|
12
|
+
const { args, flags } = this.parse(Resize);
|
|
13
|
+
const cli = this;
|
|
14
|
+
this.init_run();
|
|
15
|
+
const config_json = this.read_config();
|
|
16
|
+
let selected_service = flags.service;
|
|
17
|
+
let selected_ram = flags.ram;
|
|
18
|
+
let selected_cpu = flags.cpu;
|
|
19
|
+
let selected_disk = flags.disk;
|
|
20
|
+
if (helper_1.isEmptyObject(config_json.users)) {
|
|
21
|
+
cli.log(`${chalk_1.default.red('[Error]')} first you should login!`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!selected_service) {
|
|
25
|
+
let all_services = await this.get_services({ 'not_status': 'pending', 'has_custom_plan': 'true' });
|
|
26
|
+
if (all_services) {
|
|
27
|
+
let { service } = await inquirer.prompt({
|
|
28
|
+
type: 'list',
|
|
29
|
+
message: 'Please select a service:',
|
|
30
|
+
name: 'service',
|
|
31
|
+
choices: all_services
|
|
32
|
+
});
|
|
33
|
+
selected_service = service;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!selected_ram) {
|
|
37
|
+
let { ram } = await inquirer.prompt({
|
|
38
|
+
type: 'list',
|
|
39
|
+
message: 'Please select service ram:',
|
|
40
|
+
name: 'ram',
|
|
41
|
+
choices: [
|
|
42
|
+
{ value: "0.5", name: "0.5G" },
|
|
43
|
+
{ value: "1", name: "1G" },
|
|
44
|
+
{ value: "2", name: "2G" },
|
|
45
|
+
{ value: "4", name: "4G" },
|
|
46
|
+
{ value: "6", name: "6G" },
|
|
47
|
+
{ value: "8", name: "8G" },
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
selected_ram = ram;
|
|
51
|
+
}
|
|
52
|
+
if (!selected_cpu) {
|
|
53
|
+
let { cpu } = await inquirer.prompt({
|
|
54
|
+
type: 'list',
|
|
55
|
+
message: 'Please select service cpu:',
|
|
56
|
+
name: 'cpu',
|
|
57
|
+
choices: [
|
|
58
|
+
{ value: "0.5", name: "0.5 Core" },
|
|
59
|
+
{ value: "1", name: "1 Core" },
|
|
60
|
+
{ value: "2", name: "2 Core" },
|
|
61
|
+
{ value: "3", name: "3 Core" },
|
|
62
|
+
{ value: "4", name: "4 Core" },
|
|
63
|
+
]
|
|
64
|
+
});
|
|
65
|
+
selected_cpu = cpu;
|
|
66
|
+
}
|
|
67
|
+
if (!selected_disk) {
|
|
68
|
+
let { disk } = await inquirer.prompt({
|
|
69
|
+
type: 'list',
|
|
70
|
+
message: 'Please select service disk:',
|
|
71
|
+
name: 'disk',
|
|
72
|
+
choices: [
|
|
73
|
+
{ value: "5", name: "5G" },
|
|
74
|
+
{ value: "10", name: "10G" },
|
|
75
|
+
{ value: "15", name: "15G" },
|
|
76
|
+
{ value: "30", name: "30G" },
|
|
77
|
+
{ value: "40", name: "40G" },
|
|
78
|
+
{ value: "50", name: "50G" },
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
selected_disk = disk;
|
|
82
|
+
}
|
|
83
|
+
let wrong_value = false;
|
|
84
|
+
if (selected_ram % 0.5 != 0) {
|
|
85
|
+
cli.log(`${chalk_1.default.red('[Error]')} ram amount should coefficient of 0.5`);
|
|
86
|
+
wrong_value = true;
|
|
87
|
+
}
|
|
88
|
+
if (selected_cpu % 0.5 != 0) {
|
|
89
|
+
cli.log(`${chalk_1.default.red('[Error]')} cpu amount should coefficient of 0.5`);
|
|
90
|
+
wrong_value = true;
|
|
91
|
+
}
|
|
92
|
+
if (selected_disk % 5 != 0) {
|
|
93
|
+
cli.log(`${chalk_1.default.red('[Error]')} disk amount should coefficient of 5`);
|
|
94
|
+
wrong_value = true;
|
|
95
|
+
}
|
|
96
|
+
if (selected_service && selected_ram && selected_cpu && selected_disk && !wrong_value) {
|
|
97
|
+
await this.send_request(cli, selected_service, selected_ram, selected_cpu, selected_disk);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async send_request(cli, selected_service, ram, cpu, disk) {
|
|
101
|
+
try {
|
|
102
|
+
if (selected_service) {
|
|
103
|
+
const { data } = await axios_1.default.post("services/" + selected_service + "/resize/", {
|
|
104
|
+
"ram": ram,
|
|
105
|
+
"cpu": cpu,
|
|
106
|
+
"disk": disk,
|
|
107
|
+
}, this.axiosConfig);
|
|
108
|
+
if (data.success) {
|
|
109
|
+
cli.log(`${chalk_1.default.green('[Success]')} service resized successfully.`);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
cli.log(`${chalk_1.default.red('[Error]')} some problem in resize.`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
if (e.response.status == 404) {
|
|
118
|
+
cli.log(chalk_1.default.blue("Selected Service Not Founded."));
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
console.log(e.data);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.default = Resize;
|
|
127
|
+
Resize.description = 'resize a service';
|
|
128
|
+
Resize.flags = Object.assign(Object.assign({}, base_1.default.flags), { service: command_1.flags.string({ char: 's', description: 'service name' }), ram: command_1.flags.string({ char: 'r', description: 'RAM' }), cpu: command_1.flags.string({ char: 'c', description: 'CPU' }), disk: command_1.flags.string({ char: 'd', description: 'DISK' }) });
|
package/lib/commands/restart.js
CHANGED
|
@@ -19,7 +19,7 @@ class Restart extends base_1.default {
|
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
if (!flags.service) {
|
|
22
|
-
let all_services = await this.get_services();
|
|
22
|
+
let all_services = await this.get_services({ 'not_status': 'pending' });
|
|
23
23
|
if (all_services) {
|
|
24
24
|
let { service } = await inquirer.prompt({
|
|
25
25
|
type: 'list',
|
|
@@ -30,14 +30,27 @@ class Restart extends base_1.default {
|
|
|
30
30
|
selected_service = service;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
await this.send_request(cli, selected_service);
|
|
34
|
+
}
|
|
35
|
+
async send_request(cli, selected_service) {
|
|
36
|
+
try {
|
|
37
|
+
if (selected_service) {
|
|
38
|
+
const { data } = await axios_1.default.get("services/" + selected_service + "/restart/", this.axiosConfig);
|
|
39
|
+
if (data.success) {
|
|
40
|
+
cli.log(`${chalk_1.default.green('[Success]')} service restarted successfully.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
if (e.response.status == 404) {
|
|
46
|
+
cli.log(chalk_1.default.blue("Selected Service Not Founded."));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.log(e.data);
|
|
37
50
|
}
|
|
38
51
|
}
|
|
39
52
|
}
|
|
40
53
|
}
|
|
41
54
|
exports.default = Restart;
|
|
42
|
-
Restart.description = '
|
|
55
|
+
Restart.description = 'restart a service';
|
|
43
56
|
Restart.flags = Object.assign(Object.assign({}, base_1.default.flags), { service: command_1.flags.string({ char: 's', description: 'service name' }) });
|
package/lib/commands/start.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import Command from "../base";
|
|
2
3
|
export default class Start extends Command {
|
|
3
4
|
static description: string;
|
|
4
5
|
static flags: {
|
|
6
|
+
service: flags.IOptionFlag<string | undefined>;
|
|
5
7
|
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
6
|
-
name: flags.IOptionFlag<string | undefined>;
|
|
7
|
-
force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
8
8
|
};
|
|
9
|
-
static args: {
|
|
10
|
-
name: string;
|
|
11
|
-
}[];
|
|
12
9
|
run(): Promise<void>;
|
|
10
|
+
send_request(cli: any, selected_service: any): Promise<void>;
|
|
13
11
|
}
|
package/lib/commands/start.js
CHANGED
|
@@ -1,24 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
3
4
|
const command_1 = require("@oclif/command");
|
|
4
|
-
|
|
5
|
+
const base_1 = tslib_1.__importDefault(require("../base"));
|
|
6
|
+
const helper_1 = require("../helper");
|
|
7
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
+
const inquirer = tslib_1.__importStar(require("inquirer"));
|
|
9
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
10
|
+
class Start extends base_1.default {
|
|
5
11
|
async run() {
|
|
6
|
-
var _a;
|
|
7
12
|
const { args, flags } = this.parse(Start);
|
|
8
|
-
const
|
|
9
|
-
this.
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
const cli = this;
|
|
14
|
+
this.init_run();
|
|
15
|
+
const config_json = this.read_config();
|
|
16
|
+
let selected_service = flags.service;
|
|
17
|
+
if (helper_1.isEmptyObject(config_json.users)) {
|
|
18
|
+
cli.log(`${chalk_1.default.red('[Error]')} first you should login!`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (!flags.service) {
|
|
22
|
+
let all_services = await this.get_services({ 'not_status': 'pending' });
|
|
23
|
+
if (all_services) {
|
|
24
|
+
let { service } = await inquirer.prompt({
|
|
25
|
+
type: 'list',
|
|
26
|
+
message: 'Please select a service:',
|
|
27
|
+
name: 'service',
|
|
28
|
+
choices: all_services
|
|
29
|
+
});
|
|
30
|
+
selected_service = service;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
await this.send_request(cli, selected_service);
|
|
34
|
+
}
|
|
35
|
+
async send_request(cli, selected_service) {
|
|
36
|
+
try {
|
|
37
|
+
if (selected_service) {
|
|
38
|
+
const { data } = await axios_1.default.get("services/" + selected_service + "/start/", this.axiosConfig);
|
|
39
|
+
if (data.success) {
|
|
40
|
+
cli.log(`${chalk_1.default.green('[Success]')} service start successfully.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
if (e.response.status == 404) {
|
|
46
|
+
cli.log(chalk_1.default.blue("Selected Service Not Founded."));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.log(e.data);
|
|
50
|
+
}
|
|
12
51
|
}
|
|
13
52
|
}
|
|
14
53
|
}
|
|
15
54
|
exports.default = Start;
|
|
16
|
-
Start.description = '
|
|
17
|
-
Start.flags = {
|
|
18
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
19
|
-
// flag with a value (-n, --name=VALUE)
|
|
20
|
-
name: command_1.flags.string({ char: 'n', description: 'name to print' }),
|
|
21
|
-
// flag with no value (-f, --force)
|
|
22
|
-
force: command_1.flags.boolean({ char: 'f' }),
|
|
23
|
-
};
|
|
24
|
-
Start.args = [{ name: 'file' }];
|
|
55
|
+
Start.description = 'start a service';
|
|
56
|
+
Start.flags = Object.assign(Object.assign({}, base_1.default.flags), { service: command_1.flags.string({ char: 's', description: 'service name' }) });
|
package/lib/commands/stop.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import Command from "../base";
|
|
2
3
|
export default class Stop extends Command {
|
|
3
4
|
static description: string;
|
|
4
5
|
static flags: {
|
|
6
|
+
service: flags.IOptionFlag<string | undefined>;
|
|
5
7
|
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
6
|
-
name: flags.IOptionFlag<string | undefined>;
|
|
7
|
-
force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
8
8
|
};
|
|
9
|
-
static args: {
|
|
10
|
-
name: string;
|
|
11
|
-
}[];
|
|
12
9
|
run(): Promise<void>;
|
|
10
|
+
send_request(cli: any, selected_service: any): Promise<void>;
|
|
13
11
|
}
|
package/lib/commands/stop.js
CHANGED
|
@@ -1,24 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
3
4
|
const command_1 = require("@oclif/command");
|
|
4
|
-
|
|
5
|
+
const base_1 = tslib_1.__importDefault(require("../base"));
|
|
6
|
+
const helper_1 = require("../helper");
|
|
7
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
+
const inquirer = tslib_1.__importStar(require("inquirer"));
|
|
9
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
10
|
+
class Stop extends base_1.default {
|
|
5
11
|
async run() {
|
|
6
|
-
var _a;
|
|
7
12
|
const { args, flags } = this.parse(Stop);
|
|
8
|
-
const
|
|
9
|
-
this.
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
const cli = this;
|
|
14
|
+
this.init_run();
|
|
15
|
+
const config_json = this.read_config();
|
|
16
|
+
let selected_service = flags.service;
|
|
17
|
+
if (helper_1.isEmptyObject(config_json.users)) {
|
|
18
|
+
cli.log(`${chalk_1.default.red('[Error]')} first you should login!`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (!flags.service) {
|
|
22
|
+
let all_services = await this.get_services({ 'not_status': 'pending' });
|
|
23
|
+
if (all_services) {
|
|
24
|
+
let { service } = await inquirer.prompt({
|
|
25
|
+
type: 'list',
|
|
26
|
+
message: 'Please select a service:',
|
|
27
|
+
name: 'service',
|
|
28
|
+
choices: all_services
|
|
29
|
+
});
|
|
30
|
+
selected_service = service;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
await this.send_request(cli, selected_service);
|
|
34
|
+
}
|
|
35
|
+
async send_request(cli, selected_service) {
|
|
36
|
+
try {
|
|
37
|
+
if (selected_service) {
|
|
38
|
+
const { data } = await axios_1.default.get("services/" + selected_service + "/stop/", this.axiosConfig);
|
|
39
|
+
if (data.success) {
|
|
40
|
+
cli.log(`${chalk_1.default.green('[Success]')} service stop successfully.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
if (e.response.status == 404) {
|
|
46
|
+
cli.log(chalk_1.default.blue("Selected Service Not Founded."));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.log(e.data);
|
|
50
|
+
}
|
|
12
51
|
}
|
|
13
52
|
}
|
|
14
53
|
}
|
|
15
54
|
exports.default = Stop;
|
|
16
|
-
Stop.description = '
|
|
17
|
-
Stop.flags = {
|
|
18
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
19
|
-
// flag with a value (-n, --name=VALUE)
|
|
20
|
-
name: command_1.flags.string({ char: 'n', description: 'name to print' }),
|
|
21
|
-
// flag with no value (-f, --force)
|
|
22
|
-
force: command_1.flags.boolean({ char: 'f' }),
|
|
23
|
-
};
|
|
24
|
-
Stop.args = [{ name: 'file' }];
|
|
55
|
+
Stop.description = 'stop a service';
|
|
56
|
+
Stop.flags = Object.assign(Object.assign({}, base_1.default.flags), { service: command_1.flags.string({ char: 's', description: 'service name' }) });
|
package/lib/helper.js
CHANGED
|
@@ -45,7 +45,7 @@ async function get_all_services(filter = {}, axiosConfig) {
|
|
|
45
45
|
const { data } = await axios_1.default.get("services/" + url_filter, axiosConfig);
|
|
46
46
|
data.services.forEach(function (item) {
|
|
47
47
|
// @ts-ignore
|
|
48
|
-
all_services.push(item.main_name);
|
|
48
|
+
all_services.push({ "value": item.main_name, "name": `${item.main_name} (${item.platform.name})` });
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
catch (e) {
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.
|
|
1
|
+
{"version":"0.7.2","commands":{"change-user":{"id":"change-user","description":"switch your default user between logged in users","pluginName":"@chabokan.net/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"user":{"name":"user","type":"option","char":"u","description":"default user"}},"args":[]},"config-clear":{"id":"config-clear","description":"clear config file, data such as auth will be removed.","pluginName":"@chabokan.net/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"deploy":{"id":"deploy","description":"this command help you build and deploy your service to chabokan in easy way.","pluginName":"@chabokan.net/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","char":"p","description":"service path in your computer"},"service":{"name":"service","type":"option","char":"s","description":"service name"}},"args":[]},"login":{"id":"login","description":"login to hub.chabokan.net account","pluginName":"@chabokan.net/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"username":{"name":"username","type":"option","char":"u","description":"your username"},"password":{"name":"password","type":"option","char":"p","description":"your password"},"token":{"name":"token","type":"option","char":"t","description":"login with api token"}},"args":[]},"logs":{"id":"logs","description":"read latest logs from service","pluginName":"@chabokan.net/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"service":{"name":"service","type":"option","char":"s","description":"service name"}},"args":[]},"resize":{"id":"resize","description":"resize a service","pluginName":"@chabokan.net/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"service":{"name":"service","type":"option","char":"s","description":"service name"},"ram":{"name":"ram","type":"option","char":"r","description":"RAM"},"cpu":{"name":"cpu","type":"option","char":"c","description":"CPU"},"disk":{"name":"disk","type":"option","char":"d","description":"DISK"}},"args":[]},"restart":{"id":"restart","description":"restart a service","pluginName":"@chabokan.net/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"service":{"name":"service","type":"option","char":"s","description":"service name"}},"args":[]},"start":{"id":"start","description":"start a service","pluginName":"@chabokan.net/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"service":{"name":"service","type":"option","char":"s","description":"service name"}},"args":[]},"stop":{"id":"stop","description":"stop a service","pluginName":"@chabokan.net/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"service":{"name":"service","type":"option","char":"s","description":"service name"}},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chabokan.net/cli",
|
|
3
3
|
"description": "Chabokan Cli for PaaS Services",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.2",
|
|
5
5
|
"author": "Mohammad Abdi",
|
|
6
6
|
"bin": {
|
|
7
7
|
"chabok": "./bin/run"
|
|
@@ -34,7 +34,10 @@
|
|
|
34
34
|
],
|
|
35
35
|
"homepage": "https://github.com/chabokan/cli",
|
|
36
36
|
"keywords": [
|
|
37
|
-
"
|
|
37
|
+
"chabokan",
|
|
38
|
+
"paas",
|
|
39
|
+
"hosting",
|
|
40
|
+
"cloud"
|
|
38
41
|
],
|
|
39
42
|
"license": "MIT",
|
|
40
43
|
"main": "lib/index.js",
|
|
@@ -70,6 +73,7 @@
|
|
|
70
73
|
"inquirer": "^6.5.2",
|
|
71
74
|
"progress": "^2.0.3",
|
|
72
75
|
"tar": "^6.1.2",
|
|
73
|
-
"tslib": "^1.14.1"
|
|
76
|
+
"tslib": "^1.14.1",
|
|
77
|
+
"proxy-http-agent": "latest"
|
|
74
78
|
}
|
|
75
79
|
}
|