@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,131 +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 ServiceResize extends Command {
|
|
8
|
-
async run() {
|
|
9
|
-
const { args, flags } = await this.parse(ServiceResize);
|
|
10
|
-
const cli = this;
|
|
11
|
-
await this.init_run();
|
|
12
|
-
const config_json = await this.read_config();
|
|
13
|
-
let selected_service = flags.service;
|
|
14
|
-
let selected_ram = flags.ram;
|
|
15
|
-
let selected_cpu = flags.cpu;
|
|
16
|
-
let selected_disk = flags.disk;
|
|
17
|
-
if (isEmptyObject(config_json.users)) {
|
|
18
|
-
cli.log(`${chalk.red('[Error]')} first you should login!`);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (!selected_service) {
|
|
22
|
-
let all_services = await this.get_services({ 'not_status': 'pending', 'has_custom_plan': 'true' });
|
|
23
|
-
if (all_services) {
|
|
24
|
-
let { service } = await inquirer.prompt({
|
|
25
|
-
type: 'list',
|
|
26
|
-
message: 'Please select a service:',
|
|
27
|
-
name: 'service',
|
|
28
|
-
choices: all_services
|
|
29
|
-
});
|
|
30
|
-
selected_service = service;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (!selected_ram) {
|
|
34
|
-
let { ram } = await inquirer.prompt({
|
|
35
|
-
type: 'list',
|
|
36
|
-
message: 'Please select service ram:',
|
|
37
|
-
name: 'ram',
|
|
38
|
-
choices: [
|
|
39
|
-
{ value: "0.5", name: "0.5G" },
|
|
40
|
-
{ value: "1", name: "1G" },
|
|
41
|
-
{ value: "2", name: "2G" },
|
|
42
|
-
{ value: "4", name: "4G" },
|
|
43
|
-
{ value: "6", name: "6G" },
|
|
44
|
-
{ value: "8", name: "8G" },
|
|
45
|
-
]
|
|
46
|
-
});
|
|
47
|
-
selected_ram = ram;
|
|
48
|
-
}
|
|
49
|
-
if (!selected_cpu) {
|
|
50
|
-
let { cpu } = await inquirer.prompt({
|
|
51
|
-
type: 'list',
|
|
52
|
-
message: 'Please select service cpu:',
|
|
53
|
-
name: 'cpu',
|
|
54
|
-
choices: [
|
|
55
|
-
{ value: "0.5", name: "0.5 Core" },
|
|
56
|
-
{ value: "1", name: "1 Core" },
|
|
57
|
-
{ value: "2", name: "2 Core" },
|
|
58
|
-
{ value: "3", name: "3 Core" },
|
|
59
|
-
{ value: "4", name: "4 Core" },
|
|
60
|
-
]
|
|
61
|
-
});
|
|
62
|
-
selected_cpu = cpu;
|
|
63
|
-
}
|
|
64
|
-
if (!selected_disk) {
|
|
65
|
-
let { disk } = await inquirer.prompt({
|
|
66
|
-
type: 'list',
|
|
67
|
-
message: 'Please select service disk:',
|
|
68
|
-
name: 'disk',
|
|
69
|
-
choices: [
|
|
70
|
-
{ value: "5", name: "5G" },
|
|
71
|
-
{ value: "10", name: "10G" },
|
|
72
|
-
{ value: "15", name: "15G" },
|
|
73
|
-
{ value: "30", name: "30G" },
|
|
74
|
-
{ value: "40", name: "40G" },
|
|
75
|
-
{ value: "50", name: "50G" },
|
|
76
|
-
]
|
|
77
|
-
});
|
|
78
|
-
selected_disk = disk;
|
|
79
|
-
}
|
|
80
|
-
let wrong_value = false;
|
|
81
|
-
if (selected_ram % 0.5 != 0) {
|
|
82
|
-
cli.log(`${chalk.red('[Error]')} ram amount should coefficient of 0.5`);
|
|
83
|
-
wrong_value = true;
|
|
84
|
-
}
|
|
85
|
-
if (selected_cpu % 0.5 != 0) {
|
|
86
|
-
cli.log(`${chalk.red('[Error]')} cpu amount should coefficient of 0.5`);
|
|
87
|
-
wrong_value = true;
|
|
88
|
-
}
|
|
89
|
-
if (selected_disk % 5 != 0) {
|
|
90
|
-
cli.log(`${chalk.red('[Error]')} disk amount should coefficient of 5`);
|
|
91
|
-
wrong_value = true;
|
|
92
|
-
}
|
|
93
|
-
if (selected_service && selected_ram && selected_cpu && selected_disk && !wrong_value) {
|
|
94
|
-
await this.send_request(cli, selected_service, selected_ram, selected_cpu, selected_disk);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
async send_request(cli, selected_service, ram, cpu, disk) {
|
|
98
|
-
try {
|
|
99
|
-
if (selected_service) {
|
|
100
|
-
const { data } = await axios.post("services/" + selected_service + "/resize/", {
|
|
101
|
-
"ram": ram,
|
|
102
|
-
"cpu": cpu,
|
|
103
|
-
"disk": disk,
|
|
104
|
-
}, this.axiosConfig);
|
|
105
|
-
if (data.success) {
|
|
106
|
-
cli.log(`${chalk.green('[Success]')} service resized successfully.`);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
cli.log(`${chalk.red('[Error]')} some problem in resize.`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
catch (e) {
|
|
114
|
-
if (e.response.status == 404) {
|
|
115
|
-
cli.log(chalk.blue("Selected Service Not Founded."));
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
console.log(e.data);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
ServiceResize.description = 'resize a service';
|
|
124
|
-
ServiceResize.flags = {
|
|
125
|
-
...Command.flags,
|
|
126
|
-
service: Flags.string({ char: 's', description: 'service name' }),
|
|
127
|
-
ram: Flags.string({ char: 'r', description: 'RAM' }),
|
|
128
|
-
cpu: Flags.string({ char: 'c', description: 'CPU' }),
|
|
129
|
-
disk: Flags.string({ char: 'd', description: 'DISK' }),
|
|
130
|
-
};
|
|
131
|
-
export default ServiceResize;
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,58 +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 ServiceRestart extends Command {
|
|
8
|
-
async run() {
|
|
9
|
-
const { args, flags } = await this.parse(ServiceRestart);
|
|
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
|
-
not_status: "pending",
|
|
21
|
-
});
|
|
22
|
-
if (all_services) {
|
|
23
|
-
let { service } = await inquirer.prompt({
|
|
24
|
-
type: "list",
|
|
25
|
-
message: "Please select a service:",
|
|
26
|
-
name: "service",
|
|
27
|
-
choices: all_services,
|
|
28
|
-
});
|
|
29
|
-
selected_service = service;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
await this.send_request(cli, selected_service);
|
|
33
|
-
}
|
|
34
|
-
async send_request(cli, selected_service) {
|
|
35
|
-
try {
|
|
36
|
-
if (selected_service) {
|
|
37
|
-
const { data } = await axios.get("services/" + selected_service + "/restart/", this.axiosConfig);
|
|
38
|
-
if (data.success) {
|
|
39
|
-
cli.log(`${chalk.green("[Success]")} service restarted successfully.`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
if (e.response.status == 404) {
|
|
45
|
-
cli.log(chalk.blue("Selected Service Not Founded."));
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
console.log(e.data);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
ServiceRestart.description = "restart a service";
|
|
54
|
-
ServiceRestart.flags = {
|
|
55
|
-
...Command.flags,
|
|
56
|
-
service: Flags.string({ char: "s", description: "service name" }),
|
|
57
|
-
};
|
|
58
|
-
export default ServiceRestart;
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,56 +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 ServiceStart extends Command {
|
|
8
|
-
async run() {
|
|
9
|
-
const { args, flags } = await this.parse(ServiceStart);
|
|
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({ 'not_status': 'pending' });
|
|
20
|
-
if (all_services) {
|
|
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
|
-
}
|
|
30
|
-
await this.send_request(cli, selected_service);
|
|
31
|
-
}
|
|
32
|
-
async send_request(cli, selected_service) {
|
|
33
|
-
try {
|
|
34
|
-
if (selected_service) {
|
|
35
|
-
const { data } = await axios.get("services/" + selected_service + "/start/", this.axiosConfig);
|
|
36
|
-
if (data.success) {
|
|
37
|
-
cli.log(`${chalk.green('[Success]')} service start successfully.`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
if (e.response.status == 404) {
|
|
43
|
-
cli.log(chalk.blue("Selected Service Not Founded."));
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
console.log(e.data);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
ServiceStart.description = 'start a service';
|
|
52
|
-
ServiceStart.flags = {
|
|
53
|
-
...Command.flags,
|
|
54
|
-
service: Flags.string({ char: 's', description: 'service name' }),
|
|
55
|
-
};
|
|
56
|
-
export default ServiceStart;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import Command from "../../base.js";
|
|
2
|
-
export default class ServiceStop 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,56 +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 ServiceStop extends Command {
|
|
8
|
-
async run() {
|
|
9
|
-
const { args, flags } = await this.parse(ServiceStop);
|
|
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({ 'not_status': 'pending' });
|
|
20
|
-
if (all_services) {
|
|
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
|
-
}
|
|
30
|
-
await this.send_request(cli, selected_service);
|
|
31
|
-
}
|
|
32
|
-
async send_request(cli, selected_service) {
|
|
33
|
-
try {
|
|
34
|
-
if (selected_service) {
|
|
35
|
-
const { data } = await axios.get("services/" + selected_service + "/stop/", this.axiosConfig);
|
|
36
|
-
if (data.success) {
|
|
37
|
-
cli.log(`${chalk.green('[Success]')} service stop successfully.`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
if (e.response.status == 404) {
|
|
43
|
-
cli.log(chalk.blue("Selected Service Not Founded."));
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
console.log(e.data);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
ServiceStop.description = 'stop a service';
|
|
52
|
-
ServiceStop.flags = {
|
|
53
|
-
...Command.flags,
|
|
54
|
-
service: Flags.string({ char: 's', description: 'service name' }),
|
|
55
|
-
};
|
|
56
|
-
export default ServiceStop;
|
package/lib/constants.d.ts
DELETED
package/lib/constants.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
|
-
import * as os from 'os';
|
|
3
|
-
export const GLOBAL_CONF_PATH = path.join(os.homedir(), '.chabok.json');
|
|
4
|
-
export let BASE_API_URL = 'https://apihub.chabokan.net/fa/api/v1/';
|
|
5
|
-
if (process.env.CHABOK_API_URL) {
|
|
6
|
-
BASE_API_URL = process.env.CHABOK_API_URL;
|
|
7
|
-
}
|
package/lib/helper.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Ignore } from 'ignore';
|
|
2
|
-
export declare function isObject(obj: any): boolean;
|
|
3
|
-
export declare function isEmptyObject(obj: any): any;
|
|
4
|
-
export declare function read_config_file(): {
|
|
5
|
-
users: {};
|
|
6
|
-
default_user: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function get_all_services(filter: {} | undefined, axiosConfig: any): Promise<any>;
|
|
9
|
-
export declare function trimLines(lines: string[]): string[];
|
|
10
|
-
export declare const loadIgnoreFile: (ignoreInstance: Ignore, ignoreFilePath: string, projectPath: string) => void;
|
|
11
|
-
export declare function addIgnorePatterns(ignoreInstance: Ignore, projectPath: string, dir: string): void;
|
|
12
|
-
export declare const checkUpdate: (version: any) => Promise<void>;
|
package/lib/helper.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import { GLOBAL_CONF_PATH } from "./constants.js";
|
|
3
|
-
import axios from "axios";
|
|
4
|
-
import { dirname, join, relative } from "path";
|
|
5
|
-
import boxen from 'boxen';
|
|
6
|
-
import chalk from 'chalk';
|
|
7
|
-
import semver from 'semver';
|
|
8
|
-
import pkgJson from 'package-json';
|
|
9
|
-
import semverDiff from 'semver-diff';
|
|
10
|
-
export function isObject(obj) {
|
|
11
|
-
return obj != null && obj.constructor.name === "Object";
|
|
12
|
-
}
|
|
13
|
-
export function isEmptyObject(obj) {
|
|
14
|
-
return obj && obj.constructor === Object && Object.keys(obj).length === 0;
|
|
15
|
-
}
|
|
16
|
-
export function read_config_file() {
|
|
17
|
-
let config_json = {
|
|
18
|
-
users: {},
|
|
19
|
-
default_user: ""
|
|
20
|
-
};
|
|
21
|
-
try {
|
|
22
|
-
config_json = JSON.parse(fs.readFileSync(GLOBAL_CONF_PATH).toString('utf-8')) || {};
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
}
|
|
26
|
-
return config_json;
|
|
27
|
-
}
|
|
28
|
-
export async function get_all_services(filter = {}, axiosConfig) {
|
|
29
|
-
let all_services = [];
|
|
30
|
-
try {
|
|
31
|
-
let url_filter = "";
|
|
32
|
-
Object.keys(filter).forEach((item, index) => {
|
|
33
|
-
let key = item;
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
let value = filter[item];
|
|
36
|
-
if (index == 0) {
|
|
37
|
-
url_filter += `?${key}=${value}`;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
url_filter += `&${key}=${value}`;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
const { data } = await axios.get("services/" + url_filter, axiosConfig);
|
|
44
|
-
data.services.forEach(function (item) {
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
all_services.push({ "value": item.main_name, "name": `${item.main_name} (${item.platform.name})` });
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
console.log(e.response.data);
|
|
51
|
-
}
|
|
52
|
-
return all_services;
|
|
53
|
-
}
|
|
54
|
-
export function trimLines(lines) {
|
|
55
|
-
return lines.reduce((prev, line) => {
|
|
56
|
-
if (!line.trim() || line.startsWith('#')) {
|
|
57
|
-
return prev;
|
|
58
|
-
}
|
|
59
|
-
return [...prev, line];
|
|
60
|
-
}, []);
|
|
61
|
-
}
|
|
62
|
-
export const loadIgnoreFile = (ignoreInstance, ignoreFilePath, projectPath) => {
|
|
63
|
-
const patterns = trimLines(fs.readFileSync(ignoreFilePath).toString().split('\n'));
|
|
64
|
-
const relativeToProjectPath = patterns.map((pattern) => {
|
|
65
|
-
const dir = dirname(ignoreFilePath);
|
|
66
|
-
if (pattern.startsWith('!')) {
|
|
67
|
-
const absolutePrefix = pattern.substr(1).startsWith('/') ? '/' : '';
|
|
68
|
-
return '!' + absolutePrefix + relative(projectPath, join(dir, pattern.substr(1)));
|
|
69
|
-
}
|
|
70
|
-
const absolutePrefix = pattern.startsWith('/') ? '/' : '';
|
|
71
|
-
return absolutePrefix + relative(projectPath, join(dir, pattern));
|
|
72
|
-
});
|
|
73
|
-
const linuxify = relativeToProjectPath.map(p => p.replace(/\\/g, '/'));
|
|
74
|
-
ignoreInstance.add(linuxify);
|
|
75
|
-
};
|
|
76
|
-
export function addIgnorePatterns(ignoreInstance, projectPath, dir) {
|
|
77
|
-
const chabokignorePath = join(projectPath, dir, '.chabokignore');
|
|
78
|
-
const dockerignorePath = join(projectPath, dir, '.dockerignore');
|
|
79
|
-
const gitignorePath = join(projectPath, dir, '.gitignore');
|
|
80
|
-
if (fs.existsSync(chabokignorePath)) {
|
|
81
|
-
loadIgnoreFile(ignoreInstance, chabokignorePath, projectPath);
|
|
82
|
-
}
|
|
83
|
-
else if (fs.existsSync(dockerignorePath)) {
|
|
84
|
-
loadIgnoreFile(ignoreInstance, dockerignorePath, projectPath);
|
|
85
|
-
}
|
|
86
|
-
else if (fs.existsSync(gitignorePath)) {
|
|
87
|
-
loadIgnoreFile(ignoreInstance, gitignorePath, projectPath);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
export const checkUpdate = async (version) => {
|
|
91
|
-
const name = "@chabokan.net/cli";
|
|
92
|
-
const { version: latestVersion } = await pkgJson(name);
|
|
93
|
-
// check if local package version is less than the remote version
|
|
94
|
-
const updateAvailable = semver.lt(version, latestVersion);
|
|
95
|
-
if (updateAvailable) {
|
|
96
|
-
let updateType = '';
|
|
97
|
-
// check the type of version difference which is usually patch, minor, major etc.
|
|
98
|
-
let verDiff = semverDiff(version, latestVersion);
|
|
99
|
-
if (verDiff) {
|
|
100
|
-
updateType = verDiff;
|
|
101
|
-
}
|
|
102
|
-
const msg = {
|
|
103
|
-
updateAvailable: `${updateType} update available ${chalk.dim(version)} → ${chalk.green(latestVersion)}`,
|
|
104
|
-
runUpdate: `Run ${chalk.cyan(`npm i -g ${name}`)} to update`,
|
|
105
|
-
};
|
|
106
|
-
// notify the user about the available udpate
|
|
107
|
-
console.log(boxen(`${msg.updateAvailable}\n${msg.runUpdate}`, {
|
|
108
|
-
margin: 1,
|
|
109
|
-
padding: 1,
|
|
110
|
-
align: 'center',
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
};
|
package/lib/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { run } from '@oclif/core';
|
package/lib/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { run } from '@oclif/core';
|