@chabokan.net/cli 0.7.7 → 0.8.0

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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +182 -84
  3. package/bin/dev +17 -0
  4. package/bin/dev.cmd +3 -0
  5. package/bin/run +3 -3
  6. package/lib/base.d.ts +8 -38
  7. package/lib/base.js +12 -15
  8. package/lib/commands/account/list.d.ts +8 -0
  9. package/lib/commands/account/list.js +30 -0
  10. package/lib/commands/account/remove.d.ts +8 -0
  11. package/lib/commands/account/remove.js +36 -0
  12. package/lib/commands/account/use.d.ts +9 -0
  13. package/lib/commands/{change-user.js → account/use.js} +14 -16
  14. package/lib/commands/deploy.d.ts +3 -4
  15. package/lib/commands/deploy.js +17 -17
  16. package/lib/commands/login.d.ts +7 -5
  17. package/lib/commands/login.js +12 -11
  18. package/lib/commands/service/list.d.ts +8 -0
  19. package/lib/commands/service/list.js +34 -0
  20. package/lib/commands/service/logs.d.ts +10 -0
  21. package/lib/commands/{logs.js → service/logs.js} +13 -13
  22. package/lib/commands/service/resize.d.ts +13 -0
  23. package/lib/commands/{resize.js → service/resize.js} +15 -15
  24. package/lib/commands/service/restart.d.ts +10 -0
  25. package/lib/commands/{restart.js → service/restart.js} +12 -12
  26. package/lib/commands/service/start.d.ts +10 -0
  27. package/lib/commands/{start.js → service/start.js} +12 -12
  28. package/lib/commands/service/stop.d.ts +10 -0
  29. package/lib/commands/{stop.js → service/stop.js} +12 -12
  30. package/lib/constants.js +1 -1
  31. package/lib/helper.d.ts +2 -2
  32. package/lib/helper.js +11 -10
  33. package/lib/index.d.ts +1 -1
  34. package/lib/index.js +3 -2
  35. package/oclif.manifest.json +1 -1
  36. package/package.json +83 -59
  37. package/lib/commands/change-user.d.ts +0 -9
  38. package/lib/commands/config-clear.d.ts +0 -8
  39. package/lib/commands/config-clear.js +0 -17
  40. package/lib/commands/logs.d.ts +0 -11
  41. package/lib/commands/resize.d.ts +0 -14
  42. package/lib/commands/restart.d.ts +0 -11
  43. package/lib/commands/start.d.ts +0 -11
  44. package/lib/commands/stop.d.ts +0 -11
@@ -1,24 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
5
- const helper_1 = require("../helper");
6
- const inquirer = tslib_1.__importStar(require("inquirer"));
7
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
4
+ const core_1 = require("@oclif/core");
5
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
8
6
  const fs = tslib_1.__importStar(require("fs"));
9
- const constants_1 = require("../constants");
10
- class ChangeUser extends command_1.Command {
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 {
11
12
  async run() {
12
13
  const cli = this;
13
- const { args, flags } = this.parse(ChangeUser);
14
- const config_json = helper_1.read_config_file();
14
+ const { args, flags } = await this.parse(AccountUse);
15
+ const config_json = (0, helper_1.read_config_file)();
15
16
  let default_user = flags.user;
16
- if (helper_1.isEmptyObject(config_json.users)) {
17
+ if ((0, helper_1.isEmptyObject)(config_json.users)) {
17
18
  cli.log(`${chalk_1.default.red('[Error]')} first you should login!`);
18
19
  return;
19
20
  }
20
21
  if (!flags.user) {
21
- let { user } = await inquirer.prompt({
22
+ let { user } = await inquirer_1.default.prompt({
22
23
  type: 'list',
23
24
  message: 'Please select a user:',
24
25
  name: 'user',
@@ -36,9 +37,6 @@ class ChangeUser extends command_1.Command {
36
37
  }
37
38
  }
38
39
  }
39
- exports.default = ChangeUser;
40
- ChangeUser.description = 'switch your default user between logged in users';
41
- ChangeUser.flags = {
42
- help: command_1.flags.help({ char: 'h' }),
43
- user: command_1.flags.string({ char: 'u', description: 'default user' }),
44
- };
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' }) });
@@ -1,11 +1,10 @@
1
- import { flags } from '@oclif/command';
2
1
  import Command from "../base";
3
2
  export default class Deploy extends Command {
4
3
  static description: string;
5
4
  static flags: {
6
- path: flags.IOptionFlag<string | undefined>;
7
- service: flags.IOptionFlag<string | undefined>;
8
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
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>;
9
8
  };
10
9
  run(): Promise<void>;
11
10
  prepare_archive(project_path: any): Promise<string>;
@@ -1,36 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
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"));
5
7
  const base_1 = tslib_1.__importDefault(require("../base"));
6
- const tar_1 = tslib_1.__importDefault(require("tar"));
7
- const path_1 = require("path");
8
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"));
9
11
  const ignore_1 = tslib_1.__importDefault(require("ignore"));
12
+ const path_1 = require("path");
10
13
  const path = tslib_1.__importStar(require("path"));
11
14
  const os = tslib_1.__importStar(require("os"));
12
15
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
14
- const inquirer = tslib_1.__importStar(require("inquirer"));
15
- const progress_1 = tslib_1.__importDefault(require("progress"));
16
- const form_data_1 = tslib_1.__importDefault(require("form-data"));
17
- const MAX_SOURCE_SIZE = 200 * 1024 * 1024; // 200 MB
16
+ const tar_1 = tslib_1.__importDefault(require("tar"));
17
+ const MAX_SOURCE_SIZE = 100 * 1024 * 1024; // 100 MB
18
18
  class Deploy extends base_1.default {
19
19
  async run() {
20
- const { args, flags } = this.parse(Deploy);
20
+ const { args, flags } = await this.parse(Deploy);
21
21
  const cli = this;
22
22
  this.init_run();
23
- const config_json = this.read_config();
23
+ const config_json = await this.read_config();
24
24
  let selected_service = flags.service;
25
25
  let project_path = flags.path ? flags.path : process.cwd();
26
- if (helper_1.isEmptyObject(config_json.users)) {
26
+ if ((0, helper_1.isEmptyObject)(config_json.users)) {
27
27
  cli.log(`${chalk_1.default.red('[Error]')} first you should login!`);
28
28
  return;
29
29
  }
30
30
  if (!flags.service) {
31
31
  let all_services = await this.get_services({ "has_deploy": "true", "status": "on" });
32
32
  if (all_services.length > 0) {
33
- let { service } = await inquirer.prompt({
33
+ let { service } = await inquirer_1.default.prompt({
34
34
  type: 'list',
35
35
  message: 'Please select a service:',
36
36
  name: 'service',
@@ -71,12 +71,12 @@ class Deploy extends base_1.default {
71
71
  '*.log',
72
72
  ];
73
73
  const ignoreCache = {};
74
- const ignoreInstance = ignore_1.default({ ignorecase: false });
74
+ const ignoreInstance = (0, ignore_1.default)({ ignorecase: false });
75
75
  ignoreInstance.add(defaultIgnores);
76
76
  const ignoreFN = (f) => {
77
- const dir = path_1.dirname(f);
77
+ const dir = (0, path_1.dirname)(f);
78
78
  if (!ignoreCache[dir]) {
79
- helper_1.addIgnorePatterns(ignoreInstance, project_path, dir);
79
+ (0, helper_1.addIgnorePatterns)(ignoreInstance, project_path, dir);
80
80
  ignoreCache[dir] = true;
81
81
  }
82
82
  if (!ignoreInstance.ignores(f)) {
@@ -110,7 +110,7 @@ class Deploy extends base_1.default {
110
110
  body.append('file', fs_extra_1.default.createReadStream(archive_path));
111
111
  const { size: sourceSize } = fs_extra_1.default.statSync(archive_path);
112
112
  if (sourceSize > MAX_SOURCE_SIZE) {
113
- upload_response.message = "Source is too large. (max: 200MB)";
113
+ upload_response.message = "Source is too large. (max: 100MB)";
114
114
  return upload_response;
115
115
  }
116
116
  const bar = new progress_1.default('Uploading [:bar] :percent :etas', {
@@ -151,4 +151,4 @@ class Deploy extends base_1.default {
151
151
  }
152
152
  exports.default = Deploy;
153
153
  Deploy.description = 'this command help you build and deploy your service to chabokan in easy way.';
154
- Deploy.flags = Object.assign(Object.assign({}, base_1.default.flags), { path: command_1.flags.string({ char: 'p', description: 'service path in your computer' }), service: command_1.flags.string({ char: 's', description: 'service name' }) });
154
+ 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' }) });
@@ -1,12 +1,14 @@
1
- import { flags } from '@oclif/command';
2
1
  import Command from "../base";
3
2
  export default class Login extends Command {
4
3
  static description: string;
5
4
  static flags: {
6
- username: flags.IOptionFlag<string | undefined>;
7
- password: flags.IOptionFlag<string | undefined>;
8
- token: flags.IOptionFlag<string | undefined>;
9
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
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>;
10
9
  };
10
+ static args: {
11
+ name: string;
12
+ }[];
11
13
  run(): Promise<void>;
12
14
  }
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
5
- const inquirer = tslib_1.__importStar(require("inquirer"));
4
+ const core_1 = require("@oclif/core");
5
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
6
6
  const axios_1 = tslib_1.__importDefault(require("axios"));
7
7
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
8
  const helper_1 = require("../helper");
9
9
  const base_1 = tslib_1.__importDefault(require("../base"));
10
10
  class Login extends base_1.default {
11
11
  async run() {
12
- const { args, flags } = this.parse(Login);
12
+ const { args, flags } = await this.parse(Login);
13
13
  const cli = this;
14
- this.init_run();
15
- const config_json = this.read_config();
14
+ await this.init_run();
15
+ const config_json = await this.read_config();
16
16
  const body = { username: flags.username, password: flags.password };
17
17
  if (!flags.token) {
18
18
  if (!flags.username) {
19
- let { username } = await inquirer.prompt({
19
+ let { username } = await inquirer_1.default.prompt({
20
20
  type: 'input',
21
21
  message: 'Enter your username:',
22
22
  name: 'username',
@@ -30,7 +30,7 @@ class Login extends base_1.default {
30
30
  body.username = username;
31
31
  }
32
32
  if (!flags.password) {
33
- let { password } = await inquirer.prompt({
33
+ let { password } = await inquirer_1.default.prompt({
34
34
  type: 'password',
35
35
  name: 'password',
36
36
  message: 'Enter your password:',
@@ -45,7 +45,7 @@ class Login extends base_1.default {
45
45
  }
46
46
  const { data } = await axios_1.default.post("accounts/login/", body, this.axiosConfig);
47
47
  if (data.success) {
48
- if (!helper_1.isObject(config_json.users)) {
48
+ if (!(0, helper_1.isObject)(config_json.users)) {
49
49
  config_json.users = {};
50
50
  }
51
51
  // @ts-ignore
@@ -64,7 +64,7 @@ class Login extends base_1.default {
64
64
  try {
65
65
  this.axiosConfig.headers.Authorization = `Token ${flags.token}`;
66
66
  const { data } = await axios_1.default.get("accounts/info/", this.axiosConfig);
67
- if (!helper_1.isObject(config_json.users)) {
67
+ if (!(0, helper_1.isObject)(config_json.users)) {
68
68
  config_json.users = {};
69
69
  }
70
70
  // @ts-ignore
@@ -72,7 +72,7 @@ class Login extends base_1.default {
72
72
  "token": flags.token
73
73
  };
74
74
  config_json["default_user"] = data.user.email;
75
- this.write_config(config_json);
75
+ await this.write_config(config_json);
76
76
  cli.log(`${chalk_1.default.green('[Success]')} you are logged in successfully.`);
77
77
  }
78
78
  catch (e) {
@@ -83,4 +83,5 @@ class Login extends base_1.default {
83
83
  }
84
84
  exports.default = Login;
85
85
  Login.description = 'login to hub.chabokan.net account';
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' }) });
86
+ 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' }) });
87
+ Login.args = [{ name: 'file' }];
@@ -0,0 +1,8 @@
1
+ import Command from "../../base";
2
+ export default class ServiceList extends Command {
3
+ static description: string;
4
+ static flags: {
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
+ };
7
+ run(): Promise<void>;
8
+ }
@@ -0,0 +1,34 @@
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);
@@ -0,0 +1,10 @@
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,27 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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");
4
+ const core_1 = require("@oclif/core");
5
+ const base_1 = tslib_1.__importDefault(require("../../base"));
6
+ const helper_1 = require("../../helper");
7
7
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
- const inquirer = tslib_1.__importStar(require("inquirer"));
8
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
9
9
  const axios_1 = tslib_1.__importDefault(require("axios"));
10
- class Logs extends base_1.default {
10
+ class ServiceLogs extends base_1.default {
11
11
  async run() {
12
- const { args, flags } = this.parse(Logs);
12
+ const { args, flags } = await this.parse(ServiceLogs);
13
13
  const cli = this;
14
- this.init_run();
15
- const config_json = this.read_config();
14
+ await this.init_run();
15
+ const config_json = await this.read_config();
16
16
  let selected_service = flags.service;
17
- if (helper_1.isEmptyObject(config_json.users)) {
17
+ if ((0, helper_1.isEmptyObject)(config_json.users)) {
18
18
  cli.log(`${chalk_1.default.red('[Error]')} first you should login!`);
19
19
  return;
20
20
  }
21
21
  if (!flags.service) {
22
22
  let all_services = await this.get_services();
23
23
  if (all_services.length > 0) {
24
- let { service } = await inquirer.prompt({
24
+ let { service } = await inquirer_1.default.prompt({
25
25
  type: 'list',
26
26
  message: 'Please select a service:',
27
27
  name: 'service',
@@ -55,6 +55,6 @@ class Logs extends base_1.default {
55
55
  }
56
56
  }
57
57
  }
58
- exports.default = Logs;
59
- Logs.description = 'read latest logs from service';
60
- Logs.flags = Object.assign(Object.assign({}, base_1.default.flags), { service: command_1.flags.string({ char: 's', description: 'service name' }) });
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' }) });
@@ -0,0 +1,13 @@
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,30 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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");
4
+ const core_1 = require("@oclif/core");
5
+ const base_1 = tslib_1.__importDefault(require("../../base"));
6
+ const helper_1 = require("../../helper");
7
7
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
- const inquirer = tslib_1.__importStar(require("inquirer"));
8
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
9
9
  const axios_1 = tslib_1.__importDefault(require("axios"));
10
- class Resize extends base_1.default {
10
+ class ServiceResize extends base_1.default {
11
11
  async run() {
12
- const { args, flags } = this.parse(Resize);
12
+ const { args, flags } = await this.parse(ServiceResize);
13
13
  const cli = this;
14
14
  this.init_run();
15
- const config_json = this.read_config();
15
+ const config_json = await this.read_config();
16
16
  let selected_service = flags.service;
17
17
  let selected_ram = flags.ram;
18
18
  let selected_cpu = flags.cpu;
19
19
  let selected_disk = flags.disk;
20
- if (helper_1.isEmptyObject(config_json.users)) {
20
+ if ((0, helper_1.isEmptyObject)(config_json.users)) {
21
21
  cli.log(`${chalk_1.default.red('[Error]')} first you should login!`);
22
22
  return;
23
23
  }
24
24
  if (!selected_service) {
25
25
  let all_services = await this.get_services({ 'not_status': 'pending', 'has_custom_plan': 'true' });
26
26
  if (all_services) {
27
- let { service } = await inquirer.prompt({
27
+ let { service } = await inquirer_1.default.prompt({
28
28
  type: 'list',
29
29
  message: 'Please select a service:',
30
30
  name: 'service',
@@ -34,7 +34,7 @@ class Resize extends base_1.default {
34
34
  }
35
35
  }
36
36
  if (!selected_ram) {
37
- let { ram } = await inquirer.prompt({
37
+ let { ram } = await inquirer_1.default.prompt({
38
38
  type: 'list',
39
39
  message: 'Please select service ram:',
40
40
  name: 'ram',
@@ -50,7 +50,7 @@ class Resize extends base_1.default {
50
50
  selected_ram = ram;
51
51
  }
52
52
  if (!selected_cpu) {
53
- let { cpu } = await inquirer.prompt({
53
+ let { cpu } = await inquirer_1.default.prompt({
54
54
  type: 'list',
55
55
  message: 'Please select service cpu:',
56
56
  name: 'cpu',
@@ -65,7 +65,7 @@ class Resize extends base_1.default {
65
65
  selected_cpu = cpu;
66
66
  }
67
67
  if (!selected_disk) {
68
- let { disk } = await inquirer.prompt({
68
+ let { disk } = await inquirer_1.default.prompt({
69
69
  type: 'list',
70
70
  message: 'Please select service disk:',
71
71
  name: 'disk',
@@ -123,6 +123,6 @@ class Resize extends base_1.default {
123
123
  }
124
124
  }
125
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' }) });
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' }) });
@@ -0,0 +1,10 @@
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
+ }
@@ -1,27 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
5
- const inquirer = tslib_1.__importStar(require("inquirer"));
4
+ const core_1 = require("@oclif/core");
5
+ const base_1 = tslib_1.__importDefault(require("../../base"));
6
+ const helper_1 = require("../../helper");
6
7
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
7
9
  const axios_1 = tslib_1.__importDefault(require("axios"));
8
- const helper_1 = require("../helper");
9
- const base_1 = tslib_1.__importDefault(require("../base"));
10
- class Restart extends base_1.default {
10
+ class ServiceRestart extends base_1.default {
11
11
  async run() {
12
- const { args, flags } = this.parse(Restart);
12
+ const { args, flags } = await this.parse(ServiceRestart);
13
13
  const cli = this;
14
14
  this.init_run();
15
- const config_json = this.read_config();
15
+ const config_json = await this.read_config();
16
16
  let selected_service = flags.service;
17
- if (helper_1.isEmptyObject(config_json.users)) {
17
+ if ((0, helper_1.isEmptyObject)(config_json.users)) {
18
18
  cli.log(`${chalk_1.default.red('[Error]')} first you should login!`);
19
19
  return;
20
20
  }
21
21
  if (!flags.service) {
22
22
  let all_services = await this.get_services({ 'not_status': 'pending' });
23
23
  if (all_services) {
24
- let { service } = await inquirer.prompt({
24
+ let { service } = await inquirer_1.default.prompt({
25
25
  type: 'list',
26
26
  message: 'Please select a service:',
27
27
  name: 'service',
@@ -51,6 +51,6 @@ class Restart extends base_1.default {
51
51
  }
52
52
  }
53
53
  }
54
- exports.default = Restart;
55
- Restart.description = 'restart a service';
56
- Restart.flags = Object.assign(Object.assign({}, base_1.default.flags), { service: command_1.flags.string({ char: 's', description: 'service name' }) });
54
+ exports.default = ServiceRestart;
55
+ ServiceRestart.description = 'restart a service';
56
+ ServiceRestart.flags = Object.assign(Object.assign({}, base_1.default.flags), { service: core_1.Flags.string({ char: 's', description: 'service name' }) });
@@ -0,0 +1,10 @@
1
+ import Command from "../../base";
2
+ export default class ServiceStart 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,27 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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");
4
+ const core_1 = require("@oclif/core");
5
+ const base_1 = tslib_1.__importDefault(require("../../base"));
6
+ const helper_1 = require("../../helper");
7
7
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
- const inquirer = tslib_1.__importStar(require("inquirer"));
8
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
9
9
  const axios_1 = tslib_1.__importDefault(require("axios"));
10
- class Start extends base_1.default {
10
+ class ServiceStart extends base_1.default {
11
11
  async run() {
12
- const { args, flags } = this.parse(Start);
12
+ const { args, flags } = await this.parse(ServiceStart);
13
13
  const cli = this;
14
14
  this.init_run();
15
- const config_json = this.read_config();
15
+ const config_json = await this.read_config();
16
16
  let selected_service = flags.service;
17
- if (helper_1.isEmptyObject(config_json.users)) {
17
+ if ((0, helper_1.isEmptyObject)(config_json.users)) {
18
18
  cli.log(`${chalk_1.default.red('[Error]')} first you should login!`);
19
19
  return;
20
20
  }
21
21
  if (!flags.service) {
22
22
  let all_services = await this.get_services({ 'not_status': 'pending' });
23
23
  if (all_services) {
24
- let { service } = await inquirer.prompt({
24
+ let { service } = await inquirer_1.default.prompt({
25
25
  type: 'list',
26
26
  message: 'Please select a service:',
27
27
  name: 'service',
@@ -51,6 +51,6 @@ class Start extends base_1.default {
51
51
  }
52
52
  }
53
53
  }
54
- exports.default = Start;
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' }) });
54
+ exports.default = ServiceStart;
55
+ ServiceStart.description = 'start a service';
56
+ ServiceStart.flags = Object.assign(Object.assign({}, base_1.default.flags), { service: core_1.Flags.string({ char: 's', description: 'service name' }) });
@@ -0,0 +1,10 @@
1
+ import Command from "../../base";
2
+ export default class ServiceStop 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,27 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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");
4
+ const core_1 = require("@oclif/core");
5
+ const base_1 = tslib_1.__importDefault(require("../../base"));
6
+ const helper_1 = require("../../helper");
7
7
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
- const inquirer = tslib_1.__importStar(require("inquirer"));
8
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
9
9
  const axios_1 = tslib_1.__importDefault(require("axios"));
10
- class Stop extends base_1.default {
10
+ class ServiceStop extends base_1.default {
11
11
  async run() {
12
- const { args, flags } = this.parse(Stop);
12
+ const { args, flags } = await this.parse(ServiceStop);
13
13
  const cli = this;
14
14
  this.init_run();
15
- const config_json = this.read_config();
15
+ const config_json = await this.read_config();
16
16
  let selected_service = flags.service;
17
- if (helper_1.isEmptyObject(config_json.users)) {
17
+ if ((0, helper_1.isEmptyObject)(config_json.users)) {
18
18
  cli.log(`${chalk_1.default.red('[Error]')} first you should login!`);
19
19
  return;
20
20
  }
21
21
  if (!flags.service) {
22
22
  let all_services = await this.get_services({ 'not_status': 'pending' });
23
23
  if (all_services) {
24
- let { service } = await inquirer.prompt({
24
+ let { service } = await inquirer_1.default.prompt({
25
25
  type: 'list',
26
26
  message: 'Please select a service:',
27
27
  name: 'service',
@@ -51,6 +51,6 @@ class Stop extends base_1.default {
51
51
  }
52
52
  }
53
53
  }
54
- exports.default = Stop;
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' }) });
54
+ exports.default = ServiceStop;
55
+ ServiceStop.description = 'stop a service';
56
+ ServiceStop.flags = Object.assign(Object.assign({}, base_1.default.flags), { service: core_1.Flags.string({ char: 's', description: 'service name' }) });
package/lib/constants.js CHANGED
@@ -5,4 +5,4 @@ const tslib_1 = require("tslib");
5
5
  const path = tslib_1.__importStar(require("path"));
6
6
  const os = tslib_1.__importStar(require("os"));
7
7
  exports.GLOBAL_CONF_PATH = path.join(os.homedir(), '.chabok.json');
8
- exports.BASE_API_URL = "https://hub.chabokan.net/fa/api/v1/";
8
+ exports.BASE_API_URL = 'https://hub.chabokan.net/fa/api/v1/';
package/lib/helper.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Ignore } from "ignore";
1
+ import { Ignore } from 'ignore';
2
2
  export declare function isObject(obj: any): boolean;
3
- export declare function isEmptyObject(obj: any): boolean;
3
+ export declare function isEmptyObject(obj: any): any;
4
4
  export declare function read_config_file(): {
5
5
  users: {};
6
6
  default_user: string;