godmode 0.0.2 → 0.0.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.
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ showExtHelp
4
+ } from "./chunk-ZTPILA7B.js";
5
+ import {
6
+ EXIT_CODES
7
+ } from "./chunk-XFFBFBN6.js";
8
+ import {
9
+ warnSettingsErrors
10
+ } from "./chunk-SMQBMG24.js";
11
+ import {
12
+ findInstalledManifestSync,
13
+ listApis,
14
+ removeApi,
15
+ updateApi
16
+ } from "./chunk-KHFZI7IA.js";
17
+ import "./chunk-3AQ2CZKC.js";
18
+ import "./chunk-YDXTIN53.js";
19
+
20
+ // src/commands/ext.ts
21
+ function extractScope(args) {
22
+ const rest = [];
23
+ let global = false;
24
+ for (const a of args) {
25
+ if (a === "-g" || a === "--global") {
26
+ global = true;
27
+ continue;
28
+ }
29
+ rest.push(a);
30
+ }
31
+ return { rest, scope: global ? "global" : void 0 };
32
+ }
33
+ async function runExt(rest) {
34
+ const cmd = rest[0];
35
+ if (!cmd || cmd === "--help" || cmd === "-h") {
36
+ showExtHelp();
37
+ return;
38
+ }
39
+ const { rest: cmdArgs, scope } = extractScope(rest.slice(1));
40
+ if (cmd === "install") {
41
+ if (!cmdArgs[0]) {
42
+ console.error("Usage: godmode ext install [-g] <name|folder>");
43
+ process.exit(1);
44
+ }
45
+ const { runAdd } = await import("./add-D74TIN3J.js");
46
+ await runAdd(cmdArgs, scope ?? "project");
47
+ return;
48
+ }
49
+ if (cmd === "uninstall") {
50
+ if (!cmdArgs[0]) {
51
+ console.error("Usage: godmode ext uninstall [-g] <name>");
52
+ process.exit(1);
53
+ }
54
+ await removeApi(cmdArgs[0], scope);
55
+ return;
56
+ }
57
+ if (cmd === "update") {
58
+ if (!cmdArgs[0]) {
59
+ console.error("Usage: godmode ext update [-g] <name>");
60
+ process.exit(1);
61
+ }
62
+ await updateApi(cmdArgs[0], scope);
63
+ return;
64
+ }
65
+ if (cmd === "list") {
66
+ warnSettingsErrors();
67
+ await listApis();
68
+ return;
69
+ }
70
+ if (cmd === "create") {
71
+ const { configWizard } = await import("./prompt-YPAZ5433.js");
72
+ await configWizard();
73
+ return;
74
+ }
75
+ const multi = findInstalledManifestSync(cmd);
76
+ if (multi) {
77
+ const ifaces = Object.keys(multi.interfaces);
78
+ process.stderr.write(`'${cmd}' is an installed extension, not an ext command.
79
+
80
+ `);
81
+ process.stderr.write(`Did you mean:
82
+ `);
83
+ process.stderr.write(` godmode ${cmd} --help
84
+ `);
85
+ for (const i of ifaces) {
86
+ process.stderr.write(` godmode ${cmd} ${i} --help
87
+ `);
88
+ }
89
+ process.stderr.write(`
90
+ Try 'godmode ext --help' for more information.
91
+ `);
92
+ process.exit(EXIT_CODES.usage);
93
+ }
94
+ process.stderr.write(`Unknown ext command '${cmd}'.
95
+ `);
96
+ process.stderr.write(`Try 'godmode ext --help' for more information.
97
+ `);
98
+ process.exit(EXIT_CODES.usage);
99
+ }
100
+ export {
101
+ runExt
102
+ };