@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.
package/README.md CHANGED
@@ -20,7 +20,7 @@ $ npm install -g @chabokan.net/cli
20
20
  $ chabok COMMAND
21
21
  running command...
22
22
  $ chabok (--version|-v)
23
- @chabokan.net/cli/0.8.8 darwin-arm64 node-v20.13.1
23
+ @chabokan.net/cli/0.8.10 darwin-arm64 node-v20.13.1
24
24
  $ chabok --help [COMMAND]
25
25
  USAGE
26
26
  $ chabok COMMAND
@@ -29,8 +29,13 @@ USAGE
29
29
  <!-- usagestop -->
30
30
  # Commands
31
31
  <!-- commands -->
32
+ * [`chabok account list`](#chabok-account-list)
33
+ * [`chabok account remove`](#chabok-account-remove)
34
+ * [`chabok account use`](#chabok-account-use)
32
35
  * [`chabok autocomplete [SHELL]`](#chabok-autocomplete-shell)
36
+ * [`chabok deploy`](#chabok-deploy)
33
37
  * [`chabok help [COMMAND]`](#chabok-help-command)
38
+ * [`chabok login`](#chabok-login)
34
39
  * [`chabok plugins`](#chabok-plugins)
35
40
  * [`chabok plugins add PLUGIN`](#chabok-plugins-add-plugin)
36
41
  * [`chabok plugins:inspect PLUGIN...`](#chabok-pluginsinspect-plugin)
@@ -41,8 +46,66 @@ USAGE
41
46
  * [`chabok plugins uninstall [PLUGIN]`](#chabok-plugins-uninstall-plugin)
42
47
  * [`chabok plugins unlink [PLUGIN]`](#chabok-plugins-unlink-plugin)
43
48
  * [`chabok plugins update`](#chabok-plugins-update)
49
+ * [`chabok service list`](#chabok-service-list)
50
+ * [`chabok service logs`](#chabok-service-logs)
51
+ * [`chabok service resize`](#chabok-service-resize)
52
+ * [`chabok service restart`](#chabok-service-restart)
53
+ * [`chabok service start`](#chabok-service-start)
54
+ * [`chabok service stop`](#chabok-service-stop)
44
55
  * [`chabok version`](#chabok-version)
45
56
 
57
+ ## `chabok account list`
58
+
59
+ show accounts list
60
+
61
+ ```
62
+ USAGE
63
+ $ chabok account list [-h]
64
+
65
+ FLAGS
66
+ -h, --help Show CLI help.
67
+
68
+ DESCRIPTION
69
+ show accounts list
70
+ ```
71
+
72
+ _See code: [src/commands/account/list.ts](https://github.com/chabokan/cli/blob/v0.8.10/src/commands/account/list.ts)_
73
+
74
+ ## `chabok account remove`
75
+
76
+ remove account from list
77
+
78
+ ```
79
+ USAGE
80
+ $ chabok account remove [-h]
81
+
82
+ FLAGS
83
+ -h, --help Show CLI help.
84
+
85
+ DESCRIPTION
86
+ remove account from list
87
+ ```
88
+
89
+ _See code: [src/commands/account/remove.ts](https://github.com/chabokan/cli/blob/v0.8.10/src/commands/account/remove.ts)_
90
+
91
+ ## `chabok account use`
92
+
93
+ switch your default user between logged in users
94
+
95
+ ```
96
+ USAGE
97
+ $ chabok account use [-h] [-u <value>]
98
+
99
+ FLAGS
100
+ -h, --help Show CLI help.
101
+ -u, --user=<value> default user
102
+
103
+ DESCRIPTION
104
+ switch your default user between logged in users
105
+ ```
106
+
107
+ _See code: [src/commands/account/use.ts](https://github.com/chabokan/cli/blob/v0.8.10/src/commands/account/use.ts)_
108
+
46
109
  ## `chabok autocomplete [SHELL]`
47
110
 
48
111
  Display autocomplete installation instructions.
@@ -72,7 +135,26 @@ EXAMPLES
72
135
  $ chabok autocomplete --refresh-cache
73
136
  ```
74
137
 
75
- _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.0.18/src/commands/autocomplete/index.ts)_
138
+ _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.31/src/commands/autocomplete/index.ts)_
139
+
140
+ ## `chabok deploy`
141
+
142
+ this command help you build and deploy your service to chabokan in easy way.
143
+
144
+ ```
145
+ USAGE
146
+ $ chabok deploy [-h] [-p <value>] [-s <value>]
147
+
148
+ FLAGS
149
+ -h, --help Show CLI help.
150
+ -p, --path=<value> service path in your computer
151
+ -s, --service=<value> service name
152
+
153
+ DESCRIPTION
154
+ this command help you build and deploy your service to chabokan in easy way.
155
+ ```
156
+
157
+ _See code: [src/commands/deploy.ts](https://github.com/chabokan/cli/blob/v0.8.10/src/commands/deploy.ts)_
76
158
 
77
159
  ## `chabok help [COMMAND]`
78
160
 
@@ -92,7 +174,27 @@ DESCRIPTION
92
174
  Display help for chabok.
93
175
  ```
94
176
 
95
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.22/src/commands/help.ts)_
177
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.29/src/commands/help.ts)_
178
+
179
+ ## `chabok login`
180
+
181
+ login to hub.chabokan.net account
182
+
183
+ ```
184
+ USAGE
185
+ $ chabok login [-h] [-u <value>] [-p <value>] [-t <value>]
186
+
187
+ FLAGS
188
+ -h, --help Show CLI help.
189
+ -p, --password=<value> your password
190
+ -t, --token=<value> login with api token
191
+ -u, --username=<value> your username
192
+
193
+ DESCRIPTION
194
+ login to hub.chabokan.net account
195
+ ```
196
+
197
+ _See code: [src/commands/login.ts](https://github.com/chabokan/cli/blob/v0.8.10/src/commands/login.ts)_
96
198
 
97
199
  ## `chabok plugins`
98
200
 
@@ -115,7 +217,7 @@ EXAMPLES
115
217
  $ chabok plugins
116
218
  ```
117
219
 
118
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.1.3/src/commands/plugins/index.ts)_
220
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.43/src/commands/plugins/index.ts)_
119
221
 
120
222
  ## `chabok plugins add PLUGIN`
121
223
 
@@ -140,7 +242,7 @@ GLOBAL FLAGS
140
242
  DESCRIPTION
141
243
  Installs a plugin into chabok.
142
244
 
143
- Uses bundled npm executable to install plugins into /Users/mohammad/.local/share/@chabokan.net/cli
245
+ Uses npm to install plugins.
144
246
 
145
247
  Installation of a user-installed plugin will override a core plugin.
146
248
 
@@ -189,7 +291,7 @@ EXAMPLES
189
291
  $ chabok plugins inspect myplugin
190
292
  ```
191
293
 
192
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.1.3/src/commands/plugins/inspect.ts)_
294
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.43/src/commands/plugins/inspect.ts)_
193
295
 
194
296
  ## `chabok plugins install PLUGIN`
195
297
 
@@ -214,7 +316,7 @@ GLOBAL FLAGS
214
316
  DESCRIPTION
215
317
  Installs a plugin into chabok.
216
318
 
217
- Uses bundled npm executable to install plugins into /Users/mohammad/.local/share/@chabokan.net/cli
319
+ Uses npm to install plugins.
218
320
 
219
321
  Installation of a user-installed plugin will override a core plugin.
220
322
 
@@ -238,7 +340,7 @@ EXAMPLES
238
340
  $ chabok plugins install someuser/someplugin
239
341
  ```
240
342
 
241
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.1.3/src/commands/plugins/install.ts)_
343
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.43/src/commands/plugins/install.ts)_
242
344
 
243
345
  ## `chabok plugins link PATH`
244
346
 
@@ -258,6 +360,7 @@ FLAGS
258
360
 
259
361
  DESCRIPTION
260
362
  Links a plugin into the CLI for development.
363
+
261
364
  Installation of a linked plugin will override a user-installed or core plugin.
262
365
 
263
366
  e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
@@ -268,7 +371,7 @@ EXAMPLES
268
371
  $ chabok plugins link myplugin
269
372
  ```
270
373
 
271
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.1.3/src/commands/plugins/link.ts)_
374
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.43/src/commands/plugins/link.ts)_
272
375
 
273
376
  ## `chabok plugins remove [PLUGIN]`
274
377
 
@@ -309,7 +412,7 @@ FLAGS
309
412
  --reinstall Reinstall all plugins after uninstalling.
310
413
  ```
311
414
 
312
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.1.3/src/commands/plugins/reset.ts)_
415
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.43/src/commands/plugins/reset.ts)_
313
416
 
314
417
  ## `chabok plugins uninstall [PLUGIN]`
315
418
 
@@ -337,7 +440,7 @@ EXAMPLES
337
440
  $ chabok plugins uninstall myplugin
338
441
  ```
339
442
 
340
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.1.3/src/commands/plugins/uninstall.ts)_
443
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.43/src/commands/plugins/uninstall.ts)_
341
444
 
342
445
  ## `chabok plugins unlink [PLUGIN]`
343
446
 
@@ -381,7 +484,117 @@ DESCRIPTION
381
484
  Update installed plugins.
382
485
  ```
383
486
 
384
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.1.3/src/commands/plugins/update.ts)_
487
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.43/src/commands/plugins/update.ts)_
488
+
489
+ ## `chabok service list`
490
+
491
+ show account services list
492
+
493
+ ```
494
+ USAGE
495
+ $ chabok service list [-h]
496
+
497
+ FLAGS
498
+ -h, --help Show CLI help.
499
+
500
+ DESCRIPTION
501
+ show account services list
502
+ ```
503
+
504
+ _See code: [src/commands/service/list.ts](https://github.com/chabokan/cli/blob/v0.8.10/src/commands/service/list.ts)_
505
+
506
+ ## `chabok service logs`
507
+
508
+ read latest logs from service
509
+
510
+ ```
511
+ USAGE
512
+ $ chabok service logs [-h] [-s <value>]
513
+
514
+ FLAGS
515
+ -h, --help Show CLI help.
516
+ -s, --service=<value> service name
517
+
518
+ DESCRIPTION
519
+ read latest logs from service
520
+ ```
521
+
522
+ _See code: [src/commands/service/logs.ts](https://github.com/chabokan/cli/blob/v0.8.10/src/commands/service/logs.ts)_
523
+
524
+ ## `chabok service resize`
525
+
526
+ resize a service
527
+
528
+ ```
529
+ USAGE
530
+ $ chabok service resize [-h] [-s <value>] [-r <value>] [-c <value>] [-d <value>]
531
+
532
+ FLAGS
533
+ -c, --cpu=<value> CPU
534
+ -d, --disk=<value> DISK
535
+ -h, --help Show CLI help.
536
+ -r, --ram=<value> RAM
537
+ -s, --service=<value> service name
538
+
539
+ DESCRIPTION
540
+ resize a service
541
+ ```
542
+
543
+ _See code: [src/commands/service/resize.ts](https://github.com/chabokan/cli/blob/v0.8.10/src/commands/service/resize.ts)_
544
+
545
+ ## `chabok service restart`
546
+
547
+ restart a service
548
+
549
+ ```
550
+ USAGE
551
+ $ chabok service restart [-h] [-s <value>]
552
+
553
+ FLAGS
554
+ -h, --help Show CLI help.
555
+ -s, --service=<value> service name
556
+
557
+ DESCRIPTION
558
+ restart a service
559
+ ```
560
+
561
+ _See code: [src/commands/service/restart.ts](https://github.com/chabokan/cli/blob/v0.8.10/src/commands/service/restart.ts)_
562
+
563
+ ## `chabok service start`
564
+
565
+ start a service
566
+
567
+ ```
568
+ USAGE
569
+ $ chabok service start [-h] [-s <value>]
570
+
571
+ FLAGS
572
+ -h, --help Show CLI help.
573
+ -s, --service=<value> service name
574
+
575
+ DESCRIPTION
576
+ start a service
577
+ ```
578
+
579
+ _See code: [src/commands/service/start.ts](https://github.com/chabokan/cli/blob/v0.8.10/src/commands/service/start.ts)_
580
+
581
+ ## `chabok service stop`
582
+
583
+ stop a service
584
+
585
+ ```
586
+ USAGE
587
+ $ chabok service stop [-h] [-s <value>]
588
+
589
+ FLAGS
590
+ -h, --help Show CLI help.
591
+ -s, --service=<value> service name
592
+
593
+ DESCRIPTION
594
+ stop a service
595
+ ```
596
+
597
+ _See code: [src/commands/service/stop.ts](https://github.com/chabokan/cli/blob/v0.8.10/src/commands/service/stop.ts)_
385
598
 
386
599
  ## `chabok version`
387
600
 
@@ -401,5 +614,5 @@ FLAG DESCRIPTIONS
401
614
  Additionally shows the architecture, node version, operating system, and versions of plugins that the CLI is using.
402
615
  ```
403
616
 
404
- _See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.1.2/src/commands/version.ts)_
617
+ _See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.2.30/src/commands/version.ts)_
405
618
  <!-- commandsstop -->
package/dist/base.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { Command } from '@oclif/core';
2
+ export default abstract class extends Command {
3
+ static flags: {
4
+ help: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<void>;
5
+ };
6
+ axiosConfig: any;
7
+ got: import("got").Got<never>;
8
+ read_config(): Promise<{
9
+ users: {};
10
+ default_user: string;
11
+ }>;
12
+ write_config(object: any): Promise<void>;
13
+ get_services(filter?: {}): Promise<any>;
14
+ init_run(): Promise<void>;
15
+ }
package/dist/base.js ADDED
@@ -0,0 +1,60 @@
1
+ import { Command, Flags } from '@oclif/core';
2
+ import axios from 'axios';
3
+ import { BASE_API_URL, GLOBAL_CONF_PATH } from './constants.js';
4
+ import { checkUpdate, get_all_services, isEmptyObject, read_config_file } from './helper.js';
5
+ import HttpsProxyAgent from 'https-proxy-agent';
6
+ import * as fs from 'fs';
7
+ import got from 'got';
8
+ import * as https from 'https';
9
+ export default class default_1 extends Command {
10
+ static flags = {
11
+ help: Flags.help({ char: 'h' }),
12
+ };
13
+ axiosConfig = {
14
+ ...axios.defaults
15
+ };
16
+ got = got.extend();
17
+ async read_config() {
18
+ return read_config_file();
19
+ }
20
+ async write_config(object) {
21
+ fs.writeFileSync(GLOBAL_CONF_PATH, JSON.stringify(object));
22
+ }
23
+ async get_services(filter = {}) {
24
+ return await get_all_services(filter, this.axiosConfig);
25
+ }
26
+ async init_run() {
27
+ await checkUpdate(this.config.version);
28
+ const main_agent = new https.Agent({
29
+ rejectUnauthorized: false
30
+ });
31
+ // @ts-ignore
32
+ const gotConfig = {};
33
+ this.axiosConfig.httpsAgent = main_agent;
34
+ this.axiosConfig.baseURL = BASE_API_URL;
35
+ gotConfig.prefixUrl = this.axiosConfig.baseURL;
36
+ gotConfig.agent = { https: main_agent };
37
+ const proxy = process.env.http_proxy || process.env.https_proxy;
38
+ if (proxy) {
39
+ this.log(`Using proxy server ${proxy}`);
40
+ // @ts-ignore
41
+ const agent = new HttpsProxyAgent(proxy);
42
+ this.axiosConfig.httpsAgent = agent;
43
+ this.axiosConfig.proxy = false;
44
+ // @ts-ignore
45
+ gotConfig.agent = { https: agent };
46
+ }
47
+ const config_json = read_config_file();
48
+ this.got = got.extend(gotConfig);
49
+ if (isEmptyObject(config_json) || isEmptyObject(config_json.users)) {
50
+ return;
51
+ }
52
+ // @ts-ignore
53
+ const token = config_json.users[config_json.default_user]["token"] || null;
54
+ if (token) {
55
+ this.axiosConfig.headers.Authorization = `Token ${token}`;
56
+ gotConfig.headers = { Authorization: `Token ${token}` };
57
+ }
58
+ this.got = got.extend(gotConfig);
59
+ }
60
+ }
@@ -0,0 +1,8 @@
1
+ import Command from "../../base.js";
2
+ export default class AccountList 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,28 @@
1
+ import Command from "../../base.js";
2
+ import { ux } from "@oclif/core";
3
+ export default class AccountList extends Command {
4
+ static description = "show accounts list";
5
+ static flags = {
6
+ ...Command.flags,
7
+ };
8
+ async run() {
9
+ const { args, flags } = await this.parse(AccountList);
10
+ const cli = this;
11
+ await this.init_run();
12
+ const config_json = await this.read_config();
13
+ if (Object.keys(config_json.users).length > 0) {
14
+ const accounts_data = Object.keys(config_json.users).map((account) => {
15
+ return {
16
+ Name: account,
17
+ };
18
+ });
19
+ ux.table(accounts_data, {
20
+ Name: {},
21
+ }, flags);
22
+ }
23
+ else {
24
+ cli.log("first you should login");
25
+ return;
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,8 @@
1
+ import Command from "../../base.js";
2
+ export default class AccountRemove 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,34 @@
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
+ export default class AccountRemove extends Command {
8
+ static description = "remove account from list";
9
+ static flags = {
10
+ ...Command.flags,
11
+ };
12
+ async run() {
13
+ const cli = this;
14
+ const { args, flags } = await this.parse(AccountRemove);
15
+ const config_json = read_config_file();
16
+ if (isEmptyObject(config_json.users)) {
17
+ cli.log(`${chalk.red("[Error]")} first you should login!`);
18
+ return;
19
+ }
20
+ let { user } = await inquirer.prompt({
21
+ type: "list",
22
+ message: "Please select a user:",
23
+ name: "user",
24
+ choices: Object.keys(config_json.users),
25
+ });
26
+ // @ts-ignore
27
+ delete config_json.users[user];
28
+ if (config_json["default_user"] == user) {
29
+ config_json["default_user"] = "";
30
+ }
31
+ fs.writeFileSync(GLOBAL_CONF_PATH, JSON.stringify(config_json));
32
+ cli.log(`${chalk.green("[Success]")} user deleted successfully.`);
33
+ }
34
+ }
@@ -0,0 +1,9 @@
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
+ }
@@ -0,0 +1,41 @@
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
+ export default class AccountUse extends Command {
9
+ static description = "switch your default user between logged in users";
10
+ static flags = {
11
+ ...Command.flags,
12
+ user: Flags.string({ char: "u", description: "default user" }),
13
+ };
14
+ async run() {
15
+ const cli = this;
16
+ const { args, flags } = await this.parse(AccountUse);
17
+ const config_json = read_config_file();
18
+ let default_user = flags.user;
19
+ if (isEmptyObject(config_json.users)) {
20
+ cli.log(`${chalk.red("[Error]")} first you should login!`);
21
+ return;
22
+ }
23
+ if (!flags.user) {
24
+ let { user } = await inquirer.prompt({
25
+ type: "list",
26
+ message: "Please select a user:",
27
+ name: "user",
28
+ choices: Object.keys(config_json.users),
29
+ });
30
+ default_user = user;
31
+ }
32
+ if (default_user in config_json.users) {
33
+ config_json["default_user"] = default_user;
34
+ fs.writeFileSync(GLOBAL_CONF_PATH, JSON.stringify(config_json));
35
+ cli.log(`${chalk.green("[Success]")} user changed successfully.`);
36
+ }
37
+ else {
38
+ cli.log(`${chalk.red("[Error]")} selected user not exist!`);
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,15 @@
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
+ }