@chabokan.net/cli 0.8.8 → 0.8.10

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