@chabokan.net/cli 0.8.10 → 0.9.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 (55) hide show
  1. package/README.md +520 -66
  2. package/dist/base.d.ts +34 -9
  3. package/dist/base.js +172 -20
  4. package/dist/commands/account/info.d.ts +12 -0
  5. package/dist/commands/account/info.js +40 -0
  6. package/dist/commands/account/list.d.ts +5 -1
  7. package/dist/commands/account/list.js +35 -16
  8. package/dist/commands/account/remove.d.ts +5 -1
  9. package/dist/commands/account/remove.js +30 -15
  10. package/dist/commands/account/use.d.ts +6 -2
  11. package/dist/commands/account/use.js +26 -15
  12. package/dist/commands/cloudserver/create.d.ts +40 -0
  13. package/dist/commands/cloudserver/create.js +242 -0
  14. package/dist/commands/cloudserver/delete.d.ts +14 -0
  15. package/dist/commands/cloudserver/delete.js +65 -0
  16. package/dist/commands/cloudserver/list.d.ts +12 -0
  17. package/dist/commands/cloudserver/list.js +46 -0
  18. package/dist/commands/cloudserver/restart.d.ts +13 -0
  19. package/dist/commands/cloudserver/restart.js +51 -0
  20. package/dist/commands/cloudserver/start.d.ts +13 -0
  21. package/dist/commands/cloudserver/start.js +51 -0
  22. package/dist/commands/cloudserver/stop.d.ts +13 -0
  23. package/dist/commands/cloudserver/stop.js +52 -0
  24. package/dist/commands/deploy.d.ts +16 -5
  25. package/dist/commands/deploy.js +182 -101
  26. package/dist/commands/login.d.ts +8 -4
  27. package/dist/commands/login.js +97 -49
  28. package/dist/commands/service/domain/add.d.ts +15 -0
  29. package/dist/commands/service/domain/add.js +74 -0
  30. package/dist/commands/service/domain/remove.d.ts +15 -0
  31. package/dist/commands/service/domain/remove.js +72 -0
  32. package/dist/commands/service/list.d.ts +5 -1
  33. package/dist/commands/service/list.js +41 -20
  34. package/dist/commands/service/logs.d.ts +7 -3
  35. package/dist/commands/service/logs.js +46 -34
  36. package/dist/commands/service/resize.d.ts +10 -6
  37. package/dist/commands/service/resize.js +94 -72
  38. package/dist/commands/service/restart.d.ts +7 -3
  39. package/dist/commands/service/restart.js +40 -31
  40. package/dist/commands/service/start.d.ts +7 -3
  41. package/dist/commands/service/start.js +41 -30
  42. package/dist/commands/service/stop.d.ts +7 -3
  43. package/dist/commands/service/stop.js +41 -30
  44. package/dist/commands/wallet/list.d.ts +12 -0
  45. package/dist/commands/wallet/list.js +41 -0
  46. package/dist/constants.d.ts +2 -0
  47. package/dist/constants.js +7 -2
  48. package/dist/helper.d.ts +32 -9
  49. package/dist/helper.js +426 -49
  50. package/dist/types.d.ts +77 -0
  51. package/dist/types.js +2 -0
  52. package/dist/ui.d.ts +23 -0
  53. package/dist/ui.js +70 -0
  54. package/oclif.manifest.json +635 -25
  55. 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
+ }