@jango-blockchained/hoox-cli 0.5.2 → 0.5.7
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/bin/hoox.js +3 -4
- package/dist/index.js +32989 -0
- package/package.json +10 -15
- package/src/commands/check/check-command.test.ts +0 -476
- package/src/commands/check/check-command.ts +0 -1087
- package/src/commands/check/index.ts +0 -10
- package/src/commands/check/prerequisites-command.test.ts +0 -19
- package/src/commands/check/prerequisites-command.ts +0 -97
- package/src/commands/check/types.ts +0 -103
- package/src/commands/clone/clone-command.test.ts +0 -440
- package/src/commands/clone/clone-command.ts +0 -431
- package/src/commands/clone/index.ts +0 -1
- package/src/commands/config/config-command.test.ts +0 -583
- package/src/commands/config/config-command.ts +0 -896
- package/src/commands/config/env-command.test.ts +0 -43
- package/src/commands/config/env-command.ts +0 -292
- package/src/commands/config/index.ts +0 -3
- package/src/commands/config/kv-command.test.ts +0 -14
- package/src/commands/config/kv-command.ts +0 -290
- package/src/commands/dashboard/dashboard-command.test.ts +0 -47
- package/src/commands/dashboard/dashboard-command.ts +0 -130
- package/src/commands/dashboard/index.ts +0 -1
- package/src/commands/db/db-command.test.ts +0 -21
- package/src/commands/db/db-command.ts +0 -311
- package/src/commands/db/index.ts +0 -1
- package/src/commands/deploy/deploy-command.test.ts +0 -324
- package/src/commands/deploy/deploy-command.ts +0 -1054
- package/src/commands/deploy/index.ts +0 -2
- package/src/commands/deploy/telegram-service.ts +0 -76
- package/src/commands/deploy/types.ts +0 -34
- package/src/commands/dev/dev-command.test.ts +0 -405
- package/src/commands/dev/dev-command.ts +0 -398
- package/src/commands/dev/index.ts +0 -1
- package/src/commands/disclaimer/disclaimer-command.ts +0 -21
- package/src/commands/disclaimer/index.ts +0 -1
- package/src/commands/infra/index.ts +0 -5
- package/src/commands/infra/infra-command.test.ts +0 -719
- package/src/commands/infra/infra-command.ts +0 -974
- package/src/commands/infra/types.ts +0 -23
- package/src/commands/init/__tests__/cli-provisioner.test.ts +0 -17
- package/src/commands/init/cli-provisioner.ts +0 -71
- package/src/commands/init/index.ts +0 -1
- package/src/commands/init/init-command.test.ts +0 -854
- package/src/commands/init/init-command.ts +0 -597
- package/src/commands/init/types.ts +0 -23
- package/src/commands/logs/index.ts +0 -1
- package/src/commands/logs/logs-command.test.ts +0 -293
- package/src/commands/logs/logs-command.ts +0 -452
- package/src/commands/monitor/index.ts +0 -2
- package/src/commands/monitor/monitor-command.test.ts +0 -271
- package/src/commands/monitor/monitor-command.ts +0 -269
- package/src/commands/monitor/monitor-service.ts +0 -65
- package/src/commands/monitor/types.ts +0 -13
- package/src/commands/repair/index.ts +0 -2
- package/src/commands/repair/repair-command.test.ts +0 -243
- package/src/commands/repair/repair-command.ts +0 -220
- package/src/commands/repair/repair-service.ts +0 -164
- package/src/commands/repair/types.ts +0 -13
- package/src/commands/schema/index.ts +0 -1
- package/src/commands/schema/schema-command.ts +0 -137
- package/src/commands/test/index.ts +0 -2
- package/src/commands/test/test-command.test.ts +0 -318
- package/src/commands/test/test-command.ts +0 -406
- package/src/commands/tui/index.ts +0 -1
- package/src/commands/tui/tui-command.ts +0 -87
- package/src/commands/update/index.ts +0 -1
- package/src/commands/update/update-command.ts +0 -109
- package/src/commands/waf/index.ts +0 -2
- package/src/commands/waf/types.ts +0 -48
- package/src/commands/waf/waf-command.test.ts +0 -506
- package/src/commands/waf/waf-command.ts +0 -545
- package/src/index.ts +0 -261
- package/src/services/cloudflare/cloudflare-service.test.ts +0 -658
- package/src/services/cloudflare/cloudflare-service.ts +0 -433
- package/src/services/cloudflare/index.ts +0 -2
- package/src/services/cloudflare/types.ts +0 -30
- package/src/services/config/config-service.test.ts +0 -395
- package/src/services/config/config-service.ts +0 -202
- package/src/services/config/index.ts +0 -9
- package/src/services/config/types.ts +0 -66
- package/src/services/db/db-service.test.ts +0 -63
- package/src/services/db/db-service.ts +0 -131
- package/src/services/db/index.ts +0 -1
- package/src/services/docker/docker-service.ts +0 -155
- package/src/services/docker/index.ts +0 -1
- package/src/services/env/env-service.test.ts +0 -259
- package/src/services/env/env-service.ts +0 -372
- package/src/services/env/index.ts +0 -1
- package/src/services/kv/index.ts +0 -1
- package/src/services/kv/kv-sync-service.test.ts +0 -38
- package/src/services/kv/kv-sync-service.ts +0 -243
- package/src/services/prerequisites/index.ts +0 -1
- package/src/services/prerequisites/prerequisites-service.test.ts +0 -89
- package/src/services/prerequisites/prerequisites-service.ts +0 -377
- package/src/services/prerequisites/types.ts +0 -48
- package/src/services/schema/index.ts +0 -1
- package/src/services/schema/schema-service.ts +0 -99
- package/src/services/secrets/index.ts +0 -11
- package/src/services/secrets/secrets-service.test.ts +0 -502
- package/src/services/secrets/secrets-service.ts +0 -287
- package/src/services/secrets/types.ts +0 -50
- package/src/services/update/index.ts +0 -2
- package/src/services/update/update-service.test.ts +0 -76
- package/src/services/update/update-service.ts +0 -193
- package/src/ui/banner.ts +0 -141
- package/src/ui/index.ts +0 -8
- package/src/ui/menu.ts +0 -490
- package/src/utils/error-handler.ts +0 -62
- package/src/utils/errors.test.ts +0 -69
- package/src/utils/errors.ts +0 -24
- package/src/utils/formatters.test.ts +0 -180
- package/src/utils/formatters.ts +0 -269
- package/src/utils/git.ts +0 -134
- package/src/utils/theme.ts +0 -92
package/src/index.ts
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
/**
|
|
3
|
-
* Hoox CLI — main entry point.
|
|
4
|
-
* Built with commander.js. Commands are registered via dedicated register* functions.
|
|
5
|
-
* Global options --json and --quiet are available to all commands via program.opts().
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { Command } from "commander";
|
|
9
|
-
import { toError } from "@jango-blockchained/hoox-shared";
|
|
10
|
-
import { COPYRIGHT } from "@jango-blockchained/hoox-shared/legal";
|
|
11
|
-
import { CLIError, ExitCode } from "./utils/errors.js";
|
|
12
|
-
import { formatError } from "./utils/formatters.js";
|
|
13
|
-
import { theme } from "./utils/theme.js";
|
|
14
|
-
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// Program setup
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
|
|
19
|
-
const program = new Command();
|
|
20
|
-
|
|
21
|
-
program
|
|
22
|
-
.name("hoox")
|
|
23
|
-
.description(
|
|
24
|
-
"Hoox CLI — manage Cloudflare Workers, infrastructure, secrets, and deployments"
|
|
25
|
-
)
|
|
26
|
-
.version(`0.2.0\n\n${COPYRIGHT}`)
|
|
27
|
-
.addHelpText(
|
|
28
|
-
"beforeAll",
|
|
29
|
-
theme.heading("\nHoox CLI — Cloudflare Workers Platform\n")
|
|
30
|
-
)
|
|
31
|
-
.configureHelp({
|
|
32
|
-
styleTitle: (str: string) => theme.heading(str),
|
|
33
|
-
styleCommandText: (str: string) => theme.bold(str),
|
|
34
|
-
styleOptionText: (str: string) => str,
|
|
35
|
-
styleDescriptionText: (str: string) => theme.dim(str),
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Global options — accessible by all commands via program.opts()
|
|
39
|
-
program.option("--json", "Output in JSON format");
|
|
40
|
-
program.option("--quiet", "Minimal output");
|
|
41
|
-
program.option("-y, --yes", "Skip confirmation prompts");
|
|
42
|
-
|
|
43
|
-
// ---------------------------------------------------------------------------
|
|
44
|
-
// Error handling — map CommanderError and CLIError to proper exit codes
|
|
45
|
-
// ---------------------------------------------------------------------------
|
|
46
|
-
|
|
47
|
-
program.exitOverride((err) => {
|
|
48
|
-
// Commander's own informational exits — let them through
|
|
49
|
-
if (
|
|
50
|
-
err.code === "commander.helpDisplayed" ||
|
|
51
|
-
err.code === "commander.version"
|
|
52
|
-
) {
|
|
53
|
-
process.exit(ExitCode.SUCCESS);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Parent command without subcommand — already displayed help, clean exit
|
|
57
|
-
if (
|
|
58
|
-
err.code === "commander.missingArgument" ||
|
|
59
|
-
err.message === "(outputHelp)" ||
|
|
60
|
-
err.message?.includes("outputHelp")
|
|
61
|
-
) {
|
|
62
|
-
process.exit(ExitCode.SUCCESS);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Unknown command / option: exit code 2 (invalid usage)
|
|
66
|
-
if (
|
|
67
|
-
err.code === "commander.unknownCommand" ||
|
|
68
|
-
err.code === "commander.unknownOption"
|
|
69
|
-
) {
|
|
70
|
-
formatError(
|
|
71
|
-
new CLIError(err.message, ExitCode.INVALID_USAGE, undefined, false)
|
|
72
|
-
);
|
|
73
|
-
process.exit(ExitCode.INVALID_USAGE);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Missing mandatory option / argument: exit code 2 (invalid usage)
|
|
77
|
-
if (
|
|
78
|
-
err.code === "commander.missingMandatoryOptionValue" ||
|
|
79
|
-
err.code === "commander.missingArgument"
|
|
80
|
-
) {
|
|
81
|
-
formatError(
|
|
82
|
-
new CLIError(err.message, ExitCode.INVALID_USAGE, undefined, false)
|
|
83
|
-
);
|
|
84
|
-
process.exit(ExitCode.INVALID_USAGE);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// If the error is already a CLIError, use its exit code
|
|
88
|
-
if (err instanceof CLIError) {
|
|
89
|
-
formatError(err);
|
|
90
|
-
process.exit((err as CLIError).code);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Generic fallback
|
|
94
|
-
formatError(new CLIError(err.message, ExitCode.ERROR, undefined, false));
|
|
95
|
-
process.exit(ExitCode.ERROR);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// ---------------------------------------------------------------------------
|
|
99
|
-
// Global process error handlers
|
|
100
|
-
// ---------------------------------------------------------------------------
|
|
101
|
-
|
|
102
|
-
process.on("uncaughtException", (err) => {
|
|
103
|
-
formatError(
|
|
104
|
-
err instanceof CLIError
|
|
105
|
-
? err
|
|
106
|
-
: new CLIError(
|
|
107
|
-
`Uncaught exception: ${err.message}`,
|
|
108
|
-
ExitCode.ERROR,
|
|
109
|
-
err.stack,
|
|
110
|
-
false
|
|
111
|
-
)
|
|
112
|
-
);
|
|
113
|
-
process.exit(ExitCode.ERROR);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
process.on("unhandledRejection", (reason) => {
|
|
117
|
-
const err =
|
|
118
|
-
reason instanceof Error
|
|
119
|
-
? reason
|
|
120
|
-
: new Error(`Unhandled rejection: ${toError(reason)}`);
|
|
121
|
-
|
|
122
|
-
formatError(new CLIError(err.message, ExitCode.ERROR, err.stack, false));
|
|
123
|
-
process.exit(ExitCode.ERROR);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
// ---------------------------------------------------------------------------
|
|
127
|
-
// Command registration (added in subtasks 06–16)
|
|
128
|
-
// ---------------------------------------------------------------------------
|
|
129
|
-
|
|
130
|
-
import { registerInitCommand } from "./commands/init/index.js";
|
|
131
|
-
import { WIZARD_STATE_PATH } from "@jango-blockchained/hoox-shared";
|
|
132
|
-
import { registerDevCommand } from "./commands/dev/index.js";
|
|
133
|
-
import { registerDeployCommand } from "./commands/deploy/index.js";
|
|
134
|
-
import { registerInfraCommand } from "./commands/infra/index.js";
|
|
135
|
-
import { registerConfigCommand } from "./commands/config/index.js";
|
|
136
|
-
import { registerCheckCommand } from "./commands/check/index.js";
|
|
137
|
-
import { registerLogsCommand } from "./commands/logs/index.js";
|
|
138
|
-
import { registerTestCommand } from "./commands/test/index.js";
|
|
139
|
-
import { registerWafCommand } from "./commands/waf/index.js";
|
|
140
|
-
import { registerCloneCommand } from "./commands/clone/index.js";
|
|
141
|
-
import { registerDashboardCommand } from "./commands/dashboard/index.js";
|
|
142
|
-
import { registerDbCommand } from "./commands/db/index.js";
|
|
143
|
-
import { registerMonitorCommand } from "./commands/monitor/index.js";
|
|
144
|
-
import { registerRepairCommand } from "./commands/repair/index.js";
|
|
145
|
-
import { registerUpdateCommand } from "./commands/update/index.js";
|
|
146
|
-
import { registerSchemaCommand } from "./commands/schema/index.js";
|
|
147
|
-
import { registerTUICommand } from "./commands/tui/index.js";
|
|
148
|
-
import { registerDisclaimerCommand } from "./commands/disclaimer/index.js";
|
|
149
|
-
import { runInteractiveTUI } from "./ui/index.js";
|
|
150
|
-
|
|
151
|
-
// ── Command registration ────────────────────────────────────────────────
|
|
152
|
-
|
|
153
|
-
registerInitCommand(program);
|
|
154
|
-
registerDevCommand(program);
|
|
155
|
-
registerDeployCommand(program);
|
|
156
|
-
registerInfraCommand(program);
|
|
157
|
-
registerConfigCommand(program);
|
|
158
|
-
registerCheckCommand(program);
|
|
159
|
-
registerLogsCommand(program);
|
|
160
|
-
registerTestCommand(program);
|
|
161
|
-
registerWafCommand(program);
|
|
162
|
-
registerCloneCommand(program);
|
|
163
|
-
registerDashboardCommand(program);
|
|
164
|
-
registerDbCommand(program);
|
|
165
|
-
registerMonitorCommand(program);
|
|
166
|
-
registerRepairCommand(program);
|
|
167
|
-
registerSchemaCommand(program);
|
|
168
|
-
registerUpdateCommand(program);
|
|
169
|
-
registerTUICommand(program);
|
|
170
|
-
registerDisclaimerCommand(program);
|
|
171
|
-
|
|
172
|
-
// ---------------------------------------------------------------------------
|
|
173
|
-
// preAction hooks — auto-check wrangler version before dev/deploy
|
|
174
|
-
// ---------------------------------------------------------------------------
|
|
175
|
-
|
|
176
|
-
import { UpdateService } from "./services/update/index.js";
|
|
177
|
-
|
|
178
|
-
const devCmd = program.commands.find((c) => c.name() === "dev");
|
|
179
|
-
if (devCmd) {
|
|
180
|
-
const devStartCmd = devCmd.commands.find((c) => c.name() === "start");
|
|
181
|
-
if (devStartCmd) {
|
|
182
|
-
devStartCmd.hook("preAction", async () => {
|
|
183
|
-
const service = new UpdateService();
|
|
184
|
-
await service.checkAndPromptUpdate({ yes: program.opts().yes });
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const deployCmd = program.commands.find((c) => c.name() === "deploy");
|
|
190
|
-
if (deployCmd) {
|
|
191
|
-
const deploySubs = ["all", "workers", "worker", "dashboard"];
|
|
192
|
-
for (const sub of deploySubs) {
|
|
193
|
-
const cmd = deployCmd.commands.find((c) => c.name() === sub);
|
|
194
|
-
if (cmd) {
|
|
195
|
-
cmd.hook("preAction", async () => {
|
|
196
|
-
const service = new UpdateService();
|
|
197
|
-
await service.checkAndPromptUpdate({ yes: program.opts().yes });
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// ---------------------------------------------------------------------------
|
|
204
|
-
// Main entry — exported so bin/hoox.js can invoke it explicitly
|
|
205
|
-
// (import.meta.main is false when loaded as a dependency)
|
|
206
|
-
// ---------------------------------------------------------------------------
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Main CLI entry point.
|
|
210
|
-
* Parses args or launches the interactive TUI if no args are given.
|
|
211
|
-
*/
|
|
212
|
-
export async function main(): Promise<void> {
|
|
213
|
-
const hasArgs = process.argv.slice(2).length > 0;
|
|
214
|
-
|
|
215
|
-
if (hasArgs) {
|
|
216
|
-
program.parse();
|
|
217
|
-
} else {
|
|
218
|
-
// Auto-launch the setup wizard if not yet initialized
|
|
219
|
-
const configFile = Bun.file("wrangler.jsonc");
|
|
220
|
-
const hasConfig = await configFile.exists();
|
|
221
|
-
const wizardStateFile = Bun.file(WIZARD_STATE_PATH);
|
|
222
|
-
const hasWizardState = await wizardStateFile.exists();
|
|
223
|
-
|
|
224
|
-
if (!hasConfig) {
|
|
225
|
-
// No wrangler.jsonc → project is uninitialized → run the wizard
|
|
226
|
-
// If there's a partial wizard state file, auto-resume
|
|
227
|
-
const args = hasWizardState ? ["init", "--resume"] : ["init"];
|
|
228
|
-
await program.parseAsync(args, { from: "user" });
|
|
229
|
-
process.exit(ExitCode.SUCCESS);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// Clean up stale wizard state if project is already initialized
|
|
233
|
-
if (hasWizardState) {
|
|
234
|
-
await Bun.write(WIZARD_STATE_PATH, "");
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// Interactive TUI mode — launches when hoox is called with no arguments
|
|
238
|
-
await runInteractiveTUI(program);
|
|
239
|
-
process.exit(ExitCode.SUCCESS);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (import.meta.main) {
|
|
244
|
-
await main();
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// ---------------------------------------------------------------------------
|
|
248
|
-
// Exports
|
|
249
|
-
// ---------------------------------------------------------------------------
|
|
250
|
-
|
|
251
|
-
export { program };
|
|
252
|
-
export { CLIError, ExitCode } from "./utils/errors.js";
|
|
253
|
-
export {
|
|
254
|
-
formatSuccess,
|
|
255
|
-
formatError,
|
|
256
|
-
formatTable,
|
|
257
|
-
formatJson,
|
|
258
|
-
formatKeyValue,
|
|
259
|
-
} from "./utils/formatters.js";
|
|
260
|
-
export type { FormatOptions } from "./utils/formatters.js";
|
|
261
|
-
export { theme, icons } from "./utils/theme.js";
|