@chabokan.net/cli 0.8.15 → 0.9.1
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 +520 -66
- package/dist/base.d.ts +30 -7
- package/dist/base.js +163 -14
- package/dist/commands/account/info.d.ts +12 -0
- package/dist/commands/account/info.js +40 -0
- package/dist/commands/account/list.d.ts +5 -1
- package/dist/commands/account/list.js +29 -19
- package/dist/commands/account/remove.d.ts +5 -1
- package/dist/commands/account/remove.js +23 -12
- package/dist/commands/account/use.d.ts +6 -2
- package/dist/commands/account/use.js +22 -11
- package/dist/commands/cloudserver/create.d.ts +40 -0
- package/dist/commands/cloudserver/create.js +242 -0
- package/dist/commands/cloudserver/delete.d.ts +14 -0
- package/dist/commands/cloudserver/delete.js +65 -0
- package/dist/commands/cloudserver/list.d.ts +12 -0
- package/dist/commands/cloudserver/list.js +46 -0
- package/dist/commands/cloudserver/restart.d.ts +13 -0
- package/dist/commands/cloudserver/restart.js +51 -0
- package/dist/commands/cloudserver/start.d.ts +13 -0
- package/dist/commands/cloudserver/start.js +51 -0
- package/dist/commands/cloudserver/stop.d.ts +13 -0
- package/dist/commands/cloudserver/stop.js +52 -0
- package/dist/commands/deploy.d.ts +13 -3
- package/dist/commands/deploy.js +96 -60
- package/dist/commands/login.d.ts +8 -4
- package/dist/commands/login.js +69 -41
- package/dist/commands/service/domain/add.d.ts +15 -0
- package/dist/commands/service/domain/add.js +74 -0
- package/dist/commands/service/domain/remove.d.ts +15 -0
- package/dist/commands/service/domain/remove.js +72 -0
- package/dist/commands/service/list.d.ts +5 -1
- package/dist/commands/service/list.js +29 -21
- package/dist/commands/service/logs.d.ts +6 -2
- package/dist/commands/service/logs.js +33 -30
- package/dist/commands/service/resize.d.ts +9 -5
- package/dist/commands/service/resize.js +73 -69
- package/dist/commands/service/restart.d.ts +6 -2
- package/dist/commands/service/restart.js +28 -32
- package/dist/commands/service/start.d.ts +6 -2
- package/dist/commands/service/start.js +29 -31
- package/dist/commands/service/stop.d.ts +6 -2
- package/dist/commands/service/stop.js +29 -31
- package/dist/commands/wallet/list.d.ts +12 -0
- package/dist/commands/wallet/list.js +41 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +7 -2
- package/dist/helper.d.ts +23 -7
- package/dist/helper.js +294 -113
- package/dist/types.d.ts +28 -8
- package/dist/ui.d.ts +23 -0
- package/dist/ui.js +70 -0
- package/oclif.manifest.json +635 -25
- package/package.json +39 -35
package/dist/ui.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { printTable } from '@oclif/table';
|
|
3
|
+
// Windows terminals outside Windows Terminal often cannot render these glyphs.
|
|
4
|
+
const richGlyphs = process.platform !== 'win32' || Boolean(process.env.WT_SESSION);
|
|
5
|
+
const symbols = {
|
|
6
|
+
success: richGlyphs ? '✔' : 'v',
|
|
7
|
+
error: richGlyphs ? '✖' : 'x',
|
|
8
|
+
warning: richGlyphs ? '⚠' : '!',
|
|
9
|
+
info: richGlyphs ? 'ℹ' : 'i',
|
|
10
|
+
arrow: richGlyphs ? '→' : '->',
|
|
11
|
+
};
|
|
12
|
+
export function success(message) {
|
|
13
|
+
return `${chalk.green(symbols.success)} ${message}`;
|
|
14
|
+
}
|
|
15
|
+
export function error(message) {
|
|
16
|
+
return `${chalk.red(symbols.error)} ${message}`;
|
|
17
|
+
}
|
|
18
|
+
export function warning(message) {
|
|
19
|
+
return `${chalk.yellow(symbols.warning)} ${message}`;
|
|
20
|
+
}
|
|
21
|
+
export function info(message) {
|
|
22
|
+
return `${chalk.cyan(symbols.info)} ${message}`;
|
|
23
|
+
}
|
|
24
|
+
/** A dimmed follow-up line telling the user what to do next. */
|
|
25
|
+
export function hint(message) {
|
|
26
|
+
return chalk.dim(` ${symbols.arrow} ${message}`);
|
|
27
|
+
}
|
|
28
|
+
/** Highlights a command the user is meant to run. */
|
|
29
|
+
export function cmd(command) {
|
|
30
|
+
return chalk.cyan(command);
|
|
31
|
+
}
|
|
32
|
+
/** Highlights a value the user supplied or chose, such as a service name. */
|
|
33
|
+
export function value(text) {
|
|
34
|
+
return chalk.bold(text);
|
|
35
|
+
}
|
|
36
|
+
function formatCell(cellValue) {
|
|
37
|
+
if (cellValue === null || cellValue === undefined) {
|
|
38
|
+
return '';
|
|
39
|
+
}
|
|
40
|
+
if (typeof cellValue === 'object') {
|
|
41
|
+
return JSON.stringify(cellValue);
|
|
42
|
+
}
|
|
43
|
+
return String(cellValue);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Renders an array of API records as a table without assuming which fields
|
|
47
|
+
* it contains — the columns are whichever keys are present on the first row.
|
|
48
|
+
* Used for endpoints whose response shape isn't fixed enough to hard-code a
|
|
49
|
+
* column list against.
|
|
50
|
+
*/
|
|
51
|
+
export function printRecords(records) {
|
|
52
|
+
const columns = [...new Set(records.flatMap((record) => Object.keys(record)))];
|
|
53
|
+
const data = records.map((record) => {
|
|
54
|
+
const row = {};
|
|
55
|
+
for (const column of columns) {
|
|
56
|
+
row[column] = formatCell(record[column]);
|
|
57
|
+
}
|
|
58
|
+
return row;
|
|
59
|
+
});
|
|
60
|
+
printTable({ data, columns });
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Renders a single API record as Field/Value rows. Preferred over
|
|
64
|
+
* `printRecords` for one object with many fields, which would otherwise
|
|
65
|
+
* produce one very wide, mostly-empty table.
|
|
66
|
+
*/
|
|
67
|
+
export function printRecord(record) {
|
|
68
|
+
const data = Object.entries(record).map(([Field, val]) => ({ Field, Value: formatCell(val) }));
|
|
69
|
+
printTable({ data, columns: ['Field', 'Value'] });
|
|
70
|
+
}
|