@project-ajax/sdk 0.0.54 → 0.0.56

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 (51) hide show
  1. package/dist/cli/api/client.d.ts +2 -2
  2. package/dist/cli/api/client.d.ts.map +1 -1
  3. package/dist/cli/commands/auth.impl.d.ts.map +1 -1
  4. package/dist/cli/commands/auth.impl.js +14 -10
  5. package/dist/cli/commands/bundle.impl.js +2 -2
  6. package/dist/cli/commands/capabilities.impl.js +4 -4
  7. package/dist/cli/commands/connect.impl.js +13 -13
  8. package/dist/cli/commands/deploy.impl.d.ts.map +1 -1
  9. package/dist/cli/commands/deploy.impl.js +11 -17
  10. package/dist/cli/commands/env.impl.d.ts.map +1 -1
  11. package/dist/cli/commands/env.impl.js +7 -10
  12. package/dist/cli/commands/exec.impl.d.ts.map +1 -1
  13. package/dist/cli/commands/exec.impl.js +14 -16
  14. package/dist/cli/commands/runs.impl.js +7 -7
  15. package/dist/cli/commands/secrets.impl.js +12 -12
  16. package/dist/cli/commands/utils/testing.d.ts +8 -20
  17. package/dist/cli/commands/utils/testing.d.ts.map +1 -1
  18. package/dist/cli/commands/utils/testing.js +25 -18
  19. package/dist/cli/config.d.ts +13 -6
  20. package/dist/cli/config.d.ts.map +1 -1
  21. package/dist/cli/config.js +60 -35
  22. package/dist/cli/context.d.ts +2 -2
  23. package/dist/cli/context.d.ts.map +1 -1
  24. package/dist/cli/context.js +3 -3
  25. package/dist/cli/deploy.js +11 -11
  26. package/dist/cli/handler.js +2 -2
  27. package/dist/cli/{writer.d.ts → io.d.ts} +10 -3
  28. package/dist/cli/io.d.ts.map +1 -0
  29. package/dist/cli/{writer.js → io.js} +24 -2
  30. package/package.json +3 -3
  31. package/src/cli/api/client.ts +3 -3
  32. package/src/cli/commands/auth.impl.test.ts +66 -46
  33. package/src/cli/commands/auth.impl.ts +14 -10
  34. package/src/cli/commands/bundle.impl.test.ts +25 -19
  35. package/src/cli/commands/bundle.impl.ts +2 -2
  36. package/src/cli/commands/capabilities.impl.ts +4 -4
  37. package/src/cli/commands/connect.impl.ts +13 -13
  38. package/src/cli/commands/deploy.impl.test.ts +78 -63
  39. package/src/cli/commands/deploy.impl.ts +12 -17
  40. package/src/cli/commands/env.impl.ts +7 -11
  41. package/src/cli/commands/exec.impl.ts +14 -16
  42. package/src/cli/commands/runs.impl.ts +7 -7
  43. package/src/cli/commands/secrets.impl.ts +12 -12
  44. package/src/cli/commands/utils/testing.ts +33 -27
  45. package/src/cli/config.test.ts +45 -95
  46. package/src/cli/config.ts +69 -42
  47. package/src/cli/context.ts +3 -3
  48. package/src/cli/deploy.ts +11 -11
  49. package/src/cli/handler.ts +2 -2
  50. package/src/cli/{writer.ts → io.ts} +34 -2
  51. package/dist/cli/writer.d.ts.map +0 -1
@@ -35,7 +35,7 @@ export function buildHandler<const FLAGS, const ARGS extends BaseArgs = []>(
35
35
  flags,
36
36
  });
37
37
 
38
- this.writer.debugEnabled = flags.debug;
38
+ this.io.debugEnabled = flags.debug;
39
39
 
40
40
  await handler.call({ ...this, config }, flags, ...args);
41
41
  };
@@ -61,7 +61,7 @@ export function buildAuthedHandler<
61
61
  environment,
62
62
  baseUrl: this.config.baseUrl,
63
63
  cellId,
64
- writer: this.writer,
64
+ writer: this.io,
65
65
  });
66
66
  return handler.call({ ...this, apiClient: client }, flags, ...args);
67
67
  });
@@ -1,3 +1,4 @@
1
+ import * as prompts from "@inquirer/prompts";
1
2
  import { createTable, type TableCell, type TableItem } from "@visulima/tabular";
2
3
 
3
4
  export interface WriterOptions {
@@ -10,10 +11,14 @@ export interface TableOptions {
10
11
  plain: boolean;
11
12
  }
12
13
 
14
+ type WithSafety<T> = T & {
15
+ noTTY: string;
16
+ };
17
+
13
18
  /**
14
- * A writer writes messages to standard out and standard error.
19
+ * IO manages safe, consistent, input and output patterns for the CLI.
15
20
  */
16
- export class Writer {
21
+ export class IO {
17
22
  debugEnabled: boolean;
18
23
 
19
24
  constructor(options: WriterOptions) {
@@ -74,6 +79,33 @@ export class Writer {
74
79
  this.writeErr(content);
75
80
  }
76
81
 
82
+ confirm(config: WithSafety<Parameters<typeof prompts.confirm>[0]>) {
83
+ if (!process.stdin.isTTY) {
84
+ this.writeErr(config.noTTY);
85
+ process.exit(1);
86
+ }
87
+
88
+ return prompts.confirm(config).catch(this.#handlePromptExit.bind(this));
89
+ }
90
+
91
+ input(config: WithSafety<Parameters<typeof prompts.input>[0]>) {
92
+ if (!process.stdin.isTTY) {
93
+ this.writeErr(config.noTTY);
94
+ process.exit(1);
95
+ }
96
+
97
+ return prompts.input(config).catch(this.#handlePromptExit.bind(this));
98
+ }
99
+
100
+ #handlePromptExit(err: unknown) {
101
+ if (err instanceof Error && err.name === "ExitPromptError") {
102
+ this.writeErr("👋 Prompt cancelled. Goodbye!");
103
+ process.exit(1);
104
+ }
105
+
106
+ throw err;
107
+ }
108
+
77
109
  #buildTable(tableConfig: TableOptions) {
78
110
  if (tableConfig.plain) {
79
111
  return tableConfig.rows
@@ -1 +0,0 @@
1
- {"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/cli/writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,SAAS,EAAkB,MAAM,mBAAmB,CAAC;AAEhF,MAAM,WAAW,aAAa;IAC7B,YAAY,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC5B,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,EAAE,CAAC;IACrC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;CACf;AAED;;GAEG;AACH,qBAAa,MAAM;;IAClB,YAAY,EAAE,OAAO,CAAC;gBAEV,OAAO,EAAE,aAAa;IAIlC;;;;OAIG;IACH,KAAK,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,GAAG,CAAC;IAW7C;;;;OAIG;IACH,QAAQ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IAIzD;;;;OAIG;IACH,QAAQ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IAIzD;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,YAAY;IAKvC;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,YAAY;CAqBvC"}