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