@fire-spark/cli 0.0.0-stage → 0.13.3

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 (39) hide show
  1. package/bin/firespark.mjs +14 -0
  2. package/package.json +39 -3
  3. package/src/commands/doctor/client/admin.flow.ts +553 -0
  4. package/src/commands/doctor/client/catalog.json +1586 -0
  5. package/src/commands/doctor/client/catalog.ts +179 -0
  6. package/src/commands/doctor/client/checkout.flow.ts +400 -0
  7. package/src/commands/doctor/client/command.ts +246 -0
  8. package/src/commands/doctor/client/config.ts +346 -0
  9. package/src/commands/doctor/client/content.flow.ts +450 -0
  10. package/src/commands/doctor/client/copy.ts +248 -0
  11. package/src/commands/doctor/client/flow.ts +182 -0
  12. package/src/commands/doctor/client/log.flow.ts +410 -0
  13. package/src/commands/doctor/client/manifests.ts +161 -0
  14. package/src/commands/doctor/client/men.flow.ts +412 -0
  15. package/src/commands/doctor/client/ops.flow.ts +312 -0
  16. package/src/commands/doctor/client/options.ts +201 -0
  17. package/src/commands/doctor/client/ord.flow.ts +445 -0
  18. package/src/commands/doctor/client/order.ts +261 -0
  19. package/src/commands/doctor/client/pay.flow.ts +772 -0
  20. package/src/commands/doctor/client/repo.scan.ts +142 -0
  21. package/src/commands/doctor/client/runner.ts +182 -0
  22. package/src/commands/doctor/client/sdk.flow.ts +630 -0
  23. package/src/commands/doctor/client/store.flow.ts +577 -0
  24. package/src/commands/doctor/client/yaml.ts +179 -0
  25. package/src/commands/doctor/live/http.ts +81 -0
  26. package/src/commands/doctor/live/live.session.ts +250 -0
  27. package/src/commands/doctor/live/order.ts +95 -0
  28. package/src/commands/doctor/live/realtime.ts +161 -0
  29. package/src/commands/doctor/live/result.ts +76 -0
  30. package/src/commands/index.ts +8 -0
  31. package/src/core/command.types.ts +25 -0
  32. package/src/core/help.ts +85 -0
  33. package/src/core/i18n.ts +49 -0
  34. package/src/core/options.ts +131 -0
  35. package/src/core/output.ts +47 -0
  36. package/src/core/redact.ts +71 -0
  37. package/src/index.ts +4 -0
  38. package/src/main.ts +113 -0
  39. package/README.md +0 -3
package/src/main.ts ADDED
@@ -0,0 +1,113 @@
1
+ import { COMMANDS, findCommand } from "./commands";
2
+ import type { Command } from "./core/command.types";
3
+ import { renderCommandHelp, renderRootHelp } from "./core/help";
4
+ import { resolveLocale, translate } from "./core/i18n";
5
+ import type { Locale } from "./core/i18n";
6
+ import { GLOBAL_OPTIONS, UsageError, parseOptions } from "./core/options";
7
+ import { resolveOptions, secretValues } from "./core/options";
8
+ import { createOutput } from "./core/output";
9
+ import type { Writer } from "./core/output";
10
+ import { createRedactor, redactError, secretsFromEnv } from "./core/redact";
11
+ import type { Redactor } from "./core/redact";
12
+
13
+ export interface RunIo {
14
+ env: NodeJS.ProcessEnv;
15
+ cwd: string;
16
+ stdout: Writer;
17
+ stderr: Writer;
18
+ isTty: boolean;
19
+ ask?: (question: string) => Promise<string>;
20
+ }
21
+
22
+ const UNKNOWN_COMMAND = {
23
+ "es-EC": "Comando desconocido: {name}",
24
+ "en-US": "Unknown command: {name}",
25
+ "pt-BR": "Comando desconhecido: {name}"
26
+ };
27
+
28
+ const USAGE_ERROR = {
29
+ "es-EC": "Error de uso: {message}",
30
+ "en-US": "Usage error: {message}",
31
+ "pt-BR": "Erro de uso: {message}"
32
+ };
33
+
34
+ const UNEXPECTED = {
35
+ "es-EC": "Error inesperado: {message}",
36
+ "en-US": "Unexpected error: {message}",
37
+ "pt-BR": "Erro inesperado: {message}"
38
+ };
39
+
40
+ const defaultIo = (): RunIo => {
41
+ return {
42
+ env: process.env,
43
+ cwd: process.cwd(),
44
+ stdout: process.stdout,
45
+ stderr: process.stderr,
46
+ isTty: Boolean(process.stdout.isTTY)
47
+ };
48
+ };
49
+
50
+ const peekLocale = (argv: string[], env: NodeJS.ProcessEnv) => {
51
+ const index = argv.findIndex(arg => arg === "--locale");
52
+ const inline = argv.find(arg => arg.startsWith("--locale="));
53
+ const flag = inline ? inline.slice("--locale=".length) : argv[index + 1];
54
+ return resolveLocale(index >= 0 || inline ? flag : undefined, env);
55
+ };
56
+
57
+ interface CommandRun {
58
+ command: Command;
59
+ argv: string[];
60
+ io: RunIo;
61
+ locale: Locale;
62
+ redactor: Redactor;
63
+ }
64
+
65
+ const runCommand = async (input: CommandRun) => {
66
+ const { command, argv, io, locale, redactor } = input;
67
+ const specs = [...command.options, ...GLOBAL_OPTIONS];
68
+ const { values, positionals } = parseOptions(argv, specs);
69
+ const options = resolveOptions(specs, values, io.env);
70
+ for (const secret of secretValues(specs, options)) redactor.add(secret);
71
+ const colors = io.isTty && !options["no-color"];
72
+ const output = createOutput(io.stdout, io.stderr, redactor, colors);
73
+ if (options.help) {
74
+ output.line(renderCommandHelp(command, locale));
75
+ return 0;
76
+ }
77
+ const { env, cwd, ask, isTty } = io;
78
+ const context = { locale, options, positionals, env, cwd, output, redactor };
79
+ return command.run({ ...context, isTty, ask });
80
+ };
81
+
82
+ // `pnpm run doctor -- --live` forwards the separator itself.
83
+ const dropSeparators = (argv: string[]) => argv.filter(arg => arg !== "--");
84
+
85
+ export const run = async (input: string[], io: RunIo = defaultIo()) => {
86
+ const argv = dropSeparators(input);
87
+ const locale = peekLocale(argv, io.env);
88
+ const redactor = createRedactor(secretsFromEnv(io.env));
89
+ const output = createOutput(io.stdout, io.stderr, redactor, false);
90
+ const [name, ...rest] = argv;
91
+ if (!name || name === "--help" || name === "-h" || name === "help") {
92
+ output.line(renderRootHelp(COMMANDS, locale));
93
+ return 0;
94
+ }
95
+ const command = findCommand(name);
96
+ if (!command) {
97
+ output.error(translate(locale, UNKNOWN_COMMAND, { name }));
98
+ output.error(renderRootHelp(COMMANDS, locale));
99
+ return 2;
100
+ }
101
+ try {
102
+ const input = { command, argv: rest, io, locale, redactor };
103
+ return await runCommand(input);
104
+ } catch (error) {
105
+ const message = redactError(error, redactor);
106
+ if (error instanceof UsageError) {
107
+ output.error(translate(locale, USAGE_ERROR, { message }));
108
+ return 2;
109
+ }
110
+ output.error(translate(locale, UNEXPECTED, { message }));
111
+ return 1;
112
+ }
113
+ };
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.