@chabokan.net/cli 0.8.6 → 0.8.8
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 +225 -116
- package/bin/dev.cmd +1 -1
- package/bin/dev.js +6 -0
- package/bin/run.js +5 -0
- package/oclif.manifest.json +2 -310
- package/package.json +57 -55
- package/LICENSE +0 -21
- package/bin/dev +0 -17
- package/bin/run +0 -5
- package/lib/base.d.ts +0 -15
- package/lib/base.js +0 -65
- package/lib/commands/account/list.d.ts +0 -8
- package/lib/commands/account/list.js +0 -30
- package/lib/commands/account/remove.d.ts +0 -8
- package/lib/commands/account/remove.js +0 -36
- package/lib/commands/account/use.d.ts +0 -9
- package/lib/commands/account/use.js +0 -42
- package/lib/commands/deploy.d.ts +0 -15
- package/lib/commands/deploy.js +0 -164
- package/lib/commands/login.d.ts +0 -11
- package/lib/commands/login.js +0 -90
- package/lib/commands/service/list.d.ts +0 -8
- package/lib/commands/service/list.js +0 -34
- package/lib/commands/service/logs.d.ts +0 -10
- package/lib/commands/service/logs.js +0 -60
- package/lib/commands/service/resize.d.ts +0 -13
- package/lib/commands/service/resize.js +0 -128
- package/lib/commands/service/restart.d.ts +0 -10
- package/lib/commands/service/restart.js +0 -56
- package/lib/commands/service/start.d.ts +0 -10
- package/lib/commands/service/start.js +0 -56
- package/lib/commands/service/stop.d.ts +0 -10
- package/lib/commands/service/stop.js +0 -56
- package/lib/constants.d.ts +0 -2
- package/lib/constants.js +0 -11
- package/lib/helper.d.ts +0 -12
- package/lib/helper.js +0 -125
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -5
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
5
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
-
const helper_1 = require("../../helper");
|
|
7
|
-
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
8
|
-
const constants_1 = require("../../constants");
|
|
9
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
10
|
-
class AccountRemove extends base_1.default {
|
|
11
|
-
async run() {
|
|
12
|
-
const cli = this;
|
|
13
|
-
const { args, flags } = await this.parse(AccountRemove);
|
|
14
|
-
const config_json = (0, helper_1.read_config_file)();
|
|
15
|
-
if ((0, helper_1.isEmptyObject)(config_json.users)) {
|
|
16
|
-
cli.log(`${chalk_1.default.red('[Error]')} first you should login!`);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
let { user } = await inquirer_1.default.prompt({
|
|
20
|
-
type: 'list',
|
|
21
|
-
message: 'Please select a user:',
|
|
22
|
-
name: 'user',
|
|
23
|
-
choices: Object.keys(config_json.users)
|
|
24
|
-
});
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
delete config_json.users[user];
|
|
27
|
-
if (config_json["default_user"] == user) {
|
|
28
|
-
config_json["default_user"] = "";
|
|
29
|
-
}
|
|
30
|
-
fs_1.default.writeFileSync(constants_1.GLOBAL_CONF_PATH, JSON.stringify(config_json));
|
|
31
|
-
cli.log(`${chalk_1.default.green('[Success]')} user deleted successfully.`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.default = AccountRemove;
|
|
35
|
-
AccountRemove.description = 'remove account from list';
|
|
36
|
-
AccountRemove.flags = Object.assign({}, base_1.default.flags);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import Command from "../../base";
|
|
2
|
-
export default class AccountUse extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static flags: {
|
|
5
|
-
user: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
6
|
-
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
7
|
-
};
|
|
8
|
-
run(): Promise<void>;
|
|
9
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const core_1 = require("@oclif/core");
|
|
5
|
-
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
7
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
-
const helper_1 = require("../../helper");
|
|
9
|
-
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
10
|
-
const constants_1 = require("../../constants");
|
|
11
|
-
class AccountUse extends base_1.default {
|
|
12
|
-
async run() {
|
|
13
|
-
const cli = this;
|
|
14
|
-
const { args, flags } = await this.parse(AccountUse);
|
|
15
|
-
const config_json = (0, helper_1.read_config_file)();
|
|
16
|
-
let default_user = flags.user;
|
|
17
|
-
if ((0, helper_1.isEmptyObject)(config_json.users)) {
|
|
18
|
-
cli.log(`${chalk_1.default.red('[Error]')} first you should login!`);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (!flags.user) {
|
|
22
|
-
let { user } = await inquirer_1.default.prompt({
|
|
23
|
-
type: 'list',
|
|
24
|
-
message: 'Please select a user:',
|
|
25
|
-
name: 'user',
|
|
26
|
-
choices: Object.keys(config_json.users)
|
|
27
|
-
});
|
|
28
|
-
default_user = user;
|
|
29
|
-
}
|
|
30
|
-
if (default_user in config_json.users) {
|
|
31
|
-
config_json["default_user"] = default_user;
|
|
32
|
-
fs.writeFileSync(constants_1.GLOBAL_CONF_PATH, JSON.stringify(config_json));
|
|
33
|
-
cli.log(`${chalk_1.default.green('[Success]')} user changed successfully.`);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
cli.log(`${chalk_1.default.red('[Error]')} selected user not exist!`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.default = AccountUse;
|
|
41
|
-
AccountUse.description = 'switch your default user between logged in users';
|
|
42
|
-
AccountUse.flags = Object.assign(Object.assign({}, base_1.default.flags), { user: core_1.Flags.string({ char: 'u', description: 'default user' }) });
|
package/lib/commands/deploy.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import Command from "../base";
|
|
2
|
-
export default class Deploy extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static flags: {
|
|
5
|
-
path: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
6
|
-
service: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
7
|
-
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
8
|
-
};
|
|
9
|
-
run(): Promise<void>;
|
|
10
|
-
prepare_archive(project_path: any): Promise<string>;
|
|
11
|
-
upload(archive_path: any, selected_service: any, cli: any, chabok_file: any): Promise<{
|
|
12
|
-
success: boolean;
|
|
13
|
-
message: string;
|
|
14
|
-
}>;
|
|
15
|
-
}
|
package/lib/commands/deploy.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const core_1 = require("@oclif/core");
|
|
5
|
-
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
-
const base_1 = tslib_1.__importDefault(require("../base"));
|
|
8
|
-
const helper_1 = require("../helper");
|
|
9
|
-
const progress_1 = tslib_1.__importDefault(require("progress"));
|
|
10
|
-
const form_data_1 = tslib_1.__importDefault(require("form-data"));
|
|
11
|
-
const ignore_1 = tslib_1.__importDefault(require("ignore"));
|
|
12
|
-
const path_1 = require("path");
|
|
13
|
-
const path = tslib_1.__importStar(require("path"));
|
|
14
|
-
const os = tslib_1.__importStar(require("os"));
|
|
15
|
-
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
16
|
-
const tar_1 = tslib_1.__importDefault(require("tar"));
|
|
17
|
-
const MAX_SOURCE_SIZE = 100 * 1024 * 1024; // 100 MB
|
|
18
|
-
class Deploy extends base_1.default {
|
|
19
|
-
async run() {
|
|
20
|
-
const { args, flags } = await this.parse(Deploy);
|
|
21
|
-
const cli = this;
|
|
22
|
-
await this.init_run();
|
|
23
|
-
const config_json = await this.read_config();
|
|
24
|
-
let selected_service = flags.service;
|
|
25
|
-
let project_path = flags.path ? flags.path : process.cwd();
|
|
26
|
-
let chabok_file = { service: "" };
|
|
27
|
-
try {
|
|
28
|
-
chabok_file = JSON.parse(fs_extra_1.default.readFileSync(path.join(project_path, 'chabok.json')).toString('utf-8')) || {};
|
|
29
|
-
cli.log("Reading Config from chabok.json ...");
|
|
30
|
-
}
|
|
31
|
-
catch (_a) {
|
|
32
|
-
}
|
|
33
|
-
if (chabok_file.service) {
|
|
34
|
-
selected_service = chabok_file.service;
|
|
35
|
-
}
|
|
36
|
-
if ((0, helper_1.isEmptyObject)(config_json.users)) {
|
|
37
|
-
cli.log(`${chalk_1.default.red('[Error]')} first you should login!`);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (!selected_service) {
|
|
41
|
-
let all_services = await this.get_services({ "has_deploy": "true", "status": "on" });
|
|
42
|
-
if (all_services.length > 0) {
|
|
43
|
-
let { service } = await inquirer_1.default.prompt({
|
|
44
|
-
type: 'list',
|
|
45
|
-
message: 'Please select a service:',
|
|
46
|
-
name: 'service',
|
|
47
|
-
choices: all_services
|
|
48
|
-
});
|
|
49
|
-
selected_service = service;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
cli.log("first you should create service");
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
let archive_path = await this.prepare_archive(project_path);
|
|
57
|
-
let upload_response = await this.upload(archive_path, selected_service, cli, chabok_file);
|
|
58
|
-
if (upload_response.success) {
|
|
59
|
-
cli.log(chalk_1.default.green(upload_response.message));
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
cli.log(chalk_1.default.red("[Error] " + upload_response.message));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async prepare_archive(project_path) {
|
|
66
|
-
const defaultIgnores = [
|
|
67
|
-
'.npm',
|
|
68
|
-
'.git',
|
|
69
|
-
'.idea',
|
|
70
|
-
'.DS_Store',
|
|
71
|
-
'.vscode',
|
|
72
|
-
'__pycache__',
|
|
73
|
-
'.next',
|
|
74
|
-
'.nuxt',
|
|
75
|
-
'*.*~',
|
|
76
|
-
'node_modules',
|
|
77
|
-
'bower_components',
|
|
78
|
-
'venv',
|
|
79
|
-
'/vendor',
|
|
80
|
-
'*.log',
|
|
81
|
-
];
|
|
82
|
-
const ignoreCache = {};
|
|
83
|
-
const ignoreInstance = (0, ignore_1.default)({ ignorecase: false });
|
|
84
|
-
ignoreInstance.add(defaultIgnores);
|
|
85
|
-
const ignoreFN = (f) => {
|
|
86
|
-
const dir = (0, path_1.dirname)(f);
|
|
87
|
-
if (!ignoreCache[dir]) {
|
|
88
|
-
(0, helper_1.addIgnorePatterns)(ignoreInstance, project_path, dir);
|
|
89
|
-
ignoreCache[dir] = true;
|
|
90
|
-
}
|
|
91
|
-
if (!ignoreInstance.ignores(f)) {
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
console.log(`ignoring ${f}`);
|
|
95
|
-
return false;
|
|
96
|
-
};
|
|
97
|
-
const tmpDir = path.join(os.tmpdir(), '/chabok-cli');
|
|
98
|
-
const archivePath = path.join(tmpDir, `${Date.now()}.tar.gz`);
|
|
99
|
-
fs_extra_1.default.ensureDirSync(tmpDir);
|
|
100
|
-
const fileList = fs_extra_1.default.readdirSync(project_path).filter(ignoreFN);
|
|
101
|
-
tar_1.default.c({
|
|
102
|
-
gzip: {
|
|
103
|
-
level: 9,
|
|
104
|
-
},
|
|
105
|
-
sync: true,
|
|
106
|
-
cwd: project_path,
|
|
107
|
-
filter: ignoreFN,
|
|
108
|
-
file: archivePath,
|
|
109
|
-
}, fileList);
|
|
110
|
-
return archivePath;
|
|
111
|
-
}
|
|
112
|
-
async upload(archive_path, selected_service, cli, chabok_file) {
|
|
113
|
-
let upload_response = {
|
|
114
|
-
success: false,
|
|
115
|
-
message: "some problem"
|
|
116
|
-
};
|
|
117
|
-
const body = new form_data_1.default();
|
|
118
|
-
// @ts-ignore
|
|
119
|
-
body.append('file', fs_extra_1.default.createReadStream(archive_path));
|
|
120
|
-
body.append('options', JSON.stringify(chabok_file));
|
|
121
|
-
const { size: sourceSize } = fs_extra_1.default.statSync(archive_path);
|
|
122
|
-
if (sourceSize > MAX_SOURCE_SIZE) {
|
|
123
|
-
upload_response.message = "Source is too large. (max: 100MB)";
|
|
124
|
-
return upload_response;
|
|
125
|
-
}
|
|
126
|
-
const bar = new progress_1.default('Uploading [:bar] :percent :etas', {
|
|
127
|
-
total: sourceSize,
|
|
128
|
-
width: 20,
|
|
129
|
-
complete: '=',
|
|
130
|
-
incomplete: '',
|
|
131
|
-
clear: true,
|
|
132
|
-
});
|
|
133
|
-
try {
|
|
134
|
-
const response = await this.got.post(`services/${selected_service}/deploy/`, { body })
|
|
135
|
-
.on('uploadProgress', progress => {
|
|
136
|
-
bar.tick(progress.transferred - bar.curr);
|
|
137
|
-
}).json();
|
|
138
|
-
if (response.success) {
|
|
139
|
-
upload_response.success = true;
|
|
140
|
-
upload_response.message = "Deployment finished successfully.";
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
if (process.env.CHABOK_DEBUG == "true") {
|
|
144
|
-
cli.log(response);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return upload_response;
|
|
148
|
-
}
|
|
149
|
-
catch (error) {
|
|
150
|
-
if (process.env.CHABOK_DEBUG == "true") {
|
|
151
|
-
cli.log(error);
|
|
152
|
-
}
|
|
153
|
-
return upload_response;
|
|
154
|
-
}
|
|
155
|
-
finally {
|
|
156
|
-
// cleanup
|
|
157
|
-
fs_extra_1.default.unlink(archive_path).catch(() => {
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
exports.default = Deploy;
|
|
163
|
-
Deploy.description = 'this command help you build and deploy your service to chabokan in easy way.';
|
|
164
|
-
Deploy.flags = Object.assign(Object.assign({}, base_1.default.flags), { path: core_1.Flags.string({ char: 'p', description: 'service path in your computer' }), service: core_1.Flags.string({ char: 's', description: 'service name' }) });
|
package/lib/commands/login.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import Command from "../base";
|
|
2
|
-
export default class Login extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static flags: {
|
|
5
|
-
username: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
6
|
-
password: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
7
|
-
token: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
8
|
-
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
9
|
-
};
|
|
10
|
-
run(): Promise<void>;
|
|
11
|
-
}
|
package/lib/commands/login.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const core_1 = require("@oclif/core");
|
|
5
|
-
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
|
-
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
7
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
-
const helper_1 = require("../helper");
|
|
9
|
-
const base_1 = tslib_1.__importDefault(require("../base"));
|
|
10
|
-
class Login extends base_1.default {
|
|
11
|
-
async run() {
|
|
12
|
-
const { args, flags } = await this.parse(Login);
|
|
13
|
-
const cli = this;
|
|
14
|
-
await this.init_run();
|
|
15
|
-
const config_json = await this.read_config();
|
|
16
|
-
const body = { username: flags.username, password: flags.password };
|
|
17
|
-
if (!flags.token) {
|
|
18
|
-
if (!flags.username) {
|
|
19
|
-
let { username } = await inquirer_1.default.prompt({
|
|
20
|
-
type: 'input',
|
|
21
|
-
message: 'Enter your username:',
|
|
22
|
-
name: 'username',
|
|
23
|
-
validate(input) {
|
|
24
|
-
if (input.length === 0) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
body.username = username;
|
|
31
|
-
}
|
|
32
|
-
if (!flags.password) {
|
|
33
|
-
let { password } = await inquirer_1.default.prompt({
|
|
34
|
-
type: 'password',
|
|
35
|
-
name: 'password',
|
|
36
|
-
message: 'Enter your password:',
|
|
37
|
-
validate(input) {
|
|
38
|
-
if (input.length === 0) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
body.password = password;
|
|
45
|
-
}
|
|
46
|
-
const { data } = await axios_1.default.post("accounts/login/", body, this.axiosConfig);
|
|
47
|
-
if (data.success) {
|
|
48
|
-
if (!(0, helper_1.isObject)(config_json.users)) {
|
|
49
|
-
config_json.users = {};
|
|
50
|
-
}
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
config_json.users[body.username] = {
|
|
53
|
-
"token": data.token
|
|
54
|
-
};
|
|
55
|
-
config_json["default_user"] = body.username;
|
|
56
|
-
this.write_config(config_json);
|
|
57
|
-
cli.log(`${chalk_1.default.green('[Success]')} you are logged in successfully.`);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
cli.log(`${chalk_1.default.red('[Error]')} your username or password is wrong!`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
try {
|
|
65
|
-
this.axiosConfig.headers.Authorization = `Token ${flags.token}`;
|
|
66
|
-
const { data } = await axios_1.default.get("accounts/info/", this.axiosConfig);
|
|
67
|
-
if (!(0, helper_1.isObject)(config_json.users)) {
|
|
68
|
-
config_json.users = {};
|
|
69
|
-
}
|
|
70
|
-
// @ts-ignore
|
|
71
|
-
config_json.users[data.user.email] = {
|
|
72
|
-
"token": flags.token
|
|
73
|
-
};
|
|
74
|
-
config_json["default_user"] = data.user.email;
|
|
75
|
-
await this.write_config(config_json);
|
|
76
|
-
cli.log(`${chalk_1.default.green('[Success]')} you are logged in successfully.`);
|
|
77
|
-
}
|
|
78
|
-
catch (e) {
|
|
79
|
-
if (process.env.CHABOK_DEBUG == "true") {
|
|
80
|
-
// @ts-ignore
|
|
81
|
-
cli.log(e);
|
|
82
|
-
}
|
|
83
|
-
cli.log(`${chalk_1.default.red('[Error]')} your token is wrong!`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.default = Login;
|
|
89
|
-
Login.description = 'login to hub.chabokan.net account';
|
|
90
|
-
Login.flags = Object.assign(Object.assign({}, base_1.default.flags), { username: core_1.Flags.string({ char: 'u', description: 'your username' }), password: core_1.Flags.string({ char: 'p', description: 'your password' }), token: core_1.Flags.string({ char: 't', description: 'login with api token' }) });
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
5
|
-
const core_1 = require("@oclif/core");
|
|
6
|
-
class ServiceList extends base_1.default {
|
|
7
|
-
async run() {
|
|
8
|
-
const { args, flags } = await this.parse(ServiceList);
|
|
9
|
-
const cli = this;
|
|
10
|
-
await this.init_run();
|
|
11
|
-
const config_json = await this.read_config();
|
|
12
|
-
let all_services = await this.get_services();
|
|
13
|
-
if (all_services.length > 0) {
|
|
14
|
-
const services_data = all_services.map((service) => {
|
|
15
|
-
// const shamshiate = shamsi.gregorianToJalali(
|
|
16
|
-
// new Date(project.created)
|
|
17
|
-
// );
|
|
18
|
-
return {
|
|
19
|
-
Name: service.name,
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
core_1.CliUx.ux.table(services_data, {
|
|
23
|
-
Name: {},
|
|
24
|
-
}, flags);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
cli.log("first you should create service");
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.default = ServiceList;
|
|
33
|
-
ServiceList.description = 'show account services list';
|
|
34
|
-
ServiceList.flags = Object.assign({}, base_1.default.flags);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import Command from "../../base";
|
|
2
|
-
export default class ServiceLogs extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static flags: {
|
|
5
|
-
service: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
6
|
-
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
7
|
-
};
|
|
8
|
-
run(): Promise<void>;
|
|
9
|
-
send_request(cli: any, selected_service: any): Promise<void>;
|
|
10
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const core_1 = require("@oclif/core");
|
|
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_1 = tslib_1.__importDefault(require("inquirer"));
|
|
9
|
-
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
10
|
-
class ServiceLogs extends base_1.default {
|
|
11
|
-
async run() {
|
|
12
|
-
const { args, flags } = await this.parse(ServiceLogs);
|
|
13
|
-
const cli = this;
|
|
14
|
-
await this.init_run();
|
|
15
|
-
const config_json = await this.read_config();
|
|
16
|
-
let selected_service = flags.service;
|
|
17
|
-
if ((0, 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();
|
|
23
|
-
if (all_services.length > 0) {
|
|
24
|
-
let { service } = await inquirer_1.default.prompt({
|
|
25
|
-
type: 'list',
|
|
26
|
-
message: 'Please select a service:',
|
|
27
|
-
name: 'service',
|
|
28
|
-
choices: all_services
|
|
29
|
-
});
|
|
30
|
-
selected_service = service;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
cli.log("first you should create service");
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
await this.send_request(cli, selected_service);
|
|
38
|
-
}
|
|
39
|
-
async send_request(cli, selected_service) {
|
|
40
|
-
try {
|
|
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
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
if (e.response.status == 404) {
|
|
50
|
-
cli.log(chalk_1.default.blue("Selected Service Not Founded."));
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
console.log(e.data);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.default = ServiceLogs;
|
|
59
|
-
ServiceLogs.description = 'read latest logs from service';
|
|
60
|
-
ServiceLogs.flags = Object.assign(Object.assign({}, base_1.default.flags), { service: core_1.Flags.string({ char: 's', description: 'service name' }) });
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import Command from "../../base";
|
|
2
|
-
export default class ServiceResize extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static flags: {
|
|
5
|
-
service: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
6
|
-
ram: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
7
|
-
cpu: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
8
|
-
disk: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
9
|
-
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
10
|
-
};
|
|
11
|
-
run(): Promise<void>;
|
|
12
|
-
send_request(cli: any, selected_service: any, ram: any, cpu: any, disk: any): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const core_1 = require("@oclif/core");
|
|
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_1 = tslib_1.__importDefault(require("inquirer"));
|
|
9
|
-
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
10
|
-
class ServiceResize extends base_1.default {
|
|
11
|
-
async run() {
|
|
12
|
-
const { args, flags } = await this.parse(ServiceResize);
|
|
13
|
-
const cli = this;
|
|
14
|
-
await this.init_run();
|
|
15
|
-
const config_json = await 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 ((0, 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_1.default.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_1.default.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_1.default.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_1.default.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 = ServiceResize;
|
|
127
|
-
ServiceResize.description = 'resize a service';
|
|
128
|
-
ServiceResize.flags = Object.assign(Object.assign({}, base_1.default.flags), { service: core_1.Flags.string({ char: 's', description: 'service name' }), ram: core_1.Flags.string({ char: 'r', description: 'RAM' }), cpu: core_1.Flags.string({ char: 'c', description: 'CPU' }), disk: core_1.Flags.string({ char: 'd', description: 'DISK' }) });
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import Command from "../../base";
|
|
2
|
-
export default class ServiceRestart extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static flags: {
|
|
5
|
-
service: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
6
|
-
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
7
|
-
};
|
|
8
|
-
run(): Promise<void>;
|
|
9
|
-
send_request(cli: any, selected_service: any): Promise<void>;
|
|
10
|
-
}
|