@hoox-sh/hoox-cli 0.11.0 → 0.11.1

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 (2) hide show
  1. package/dist/index.js +68 -22
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -33256,6 +33256,35 @@ init_dist4();
33256
33256
  // src/services/secrets/secrets-service.ts
33257
33257
  init_main();
33258
33258
  init_wrangler_output();
33259
+ import { join as join8, resolve as resolvePath } from "path";
33260
+ async function resolveWorkerWranglerConfig(workerPath) {
33261
+ const abs = resolvePath(workerPath);
33262
+ const candidates = [
33263
+ join8(abs, "wrangler.jsonc"),
33264
+ join8(abs, "wrangler.toml"),
33265
+ join8(abs, "wrangler.jsonc.example")
33266
+ ];
33267
+ for (const configPath of candidates) {
33268
+ if (!await Bun.file(configPath).exists())
33269
+ continue;
33270
+ let deployName = null;
33271
+ try {
33272
+ const text2 = await Bun.file(configPath).text();
33273
+ if (configPath.endsWith(".toml")) {
33274
+ const m3 = text2.match(/^\s*name\s*=\s*["']([^"']+)["']/m);
33275
+ if (m3?.[1])
33276
+ deployName = m3[1];
33277
+ } else {
33278
+ const parsed = parse6(text2);
33279
+ if (typeof parsed?.name === "string" && parsed.name.trim()) {
33280
+ deployName = parsed.name.trim();
33281
+ }
33282
+ }
33283
+ } catch {}
33284
+ return { configPath, deployName };
33285
+ }
33286
+ throw new Error(`No wrangler.jsonc (or wrangler.jsonc.example) in ${workerPath}. ` + `Copy the example config into wrangler.jsonc and fill account resources, ` + `then re-run secrets sync.`);
33287
+ }
33259
33288
  var SYSTEM_SECRET_NAMES = [
33260
33289
  "INTERNAL_KEY_BINDING",
33261
33290
  "AGENT_INTERNAL_KEY",
@@ -33400,7 +33429,7 @@ class SecretsService {
33400
33429
  try {
33401
33430
  const value = existingValues.get(secret);
33402
33431
  if (value !== undefined && !this.isPlaceholder(value)) {
33403
- await this.execWranglerSecretPut(worker.path, secret, value);
33432
+ await this.execWranglerSecretPut(worker.path, secret, value, workerName);
33404
33433
  synced.push(secret);
33405
33434
  items.push({ name: secret, status: "synced" });
33406
33435
  } else {
@@ -33456,9 +33485,15 @@ class SecretsService {
33456
33485
  const v = value.trim();
33457
33486
  return v === "" || v.startsWith("placeholder_") || v.startsWith("your_") || v.startsWith("generate_") || v.startsWith("<") || v.includes("generate-with");
33458
33487
  }
33459
- async execWranglerSecretPut(workerPath, name, value) {
33460
- const proc = Bun.spawn(["wrangler", "secret", "put", name], {
33461
- cwd: workerPath,
33488
+ async execWranglerSecretPut(workerPath, name, value, logicalWorkerName) {
33489
+ const { configPath, deployName } = await resolveWorkerWranglerConfig(workerPath);
33490
+ const workerName = deployName ?? logicalWorkerName ?? null;
33491
+ const args = ["wrangler", "secret", "put", name, "-c", configPath];
33492
+ if (workerName) {
33493
+ args.push("--name", workerName);
33494
+ }
33495
+ const proc = Bun.spawn(args, {
33496
+ cwd: resolvePath(workerPath),
33462
33497
  stdin: "pipe",
33463
33498
  stdout: "pipe",
33464
33499
  stderr: "pipe"
@@ -33725,7 +33760,18 @@ EXAMPLES:
33725
33760
  throw new CLIError(`Secret "${secretName}" is not declared for worker "${workerName}".`, 2 /* INVALID_USAGE */);
33726
33761
  }
33727
33762
  const workerPath = svc.getWorkerPath(workerName) ?? `workers/${workerName}`;
33728
- const proc = Bun.spawn(["wrangler", "secret", "delete", secretName], {
33763
+ const { configPath, deployName } = await resolveWorkerWranglerConfig(workerPath);
33764
+ const deploy = deployName ?? workerName;
33765
+ const proc = Bun.spawn([
33766
+ "wrangler",
33767
+ "secret",
33768
+ "delete",
33769
+ secretName,
33770
+ "-c",
33771
+ configPath,
33772
+ "--name",
33773
+ deploy
33774
+ ], {
33729
33775
  cwd: workerPath,
33730
33776
  stdout: "pipe",
33731
33777
  stderr: "pipe"
@@ -36175,7 +36221,7 @@ init_dist4();
36175
36221
  init_config2();
36176
36222
  init_cloudflare_service();
36177
36223
  import { existsSync as existsSync9 } from "fs";
36178
- import { join as join8 } from "path";
36224
+ import { join as join9 } from "path";
36179
36225
  var D1_WRANGLER_CONFIG_CANDIDATES = [
36180
36226
  "workers/d1-worker/wrangler.jsonc",
36181
36227
  "workers/trade-worker/wrangler.jsonc"
@@ -36192,13 +36238,13 @@ class DbService {
36192
36238
  }
36193
36239
  resolveDefaultSchemaPath() {
36194
36240
  if (this.homeDir) {
36195
- return join8(this.homeDir, ".hoox", "workers", "trade-worker", "schema.sql");
36241
+ return join9(this.homeDir, ".hoox", "workers", "trade-worker", "schema.sql");
36196
36242
  }
36197
36243
  return "workers/trade-worker/schema.sql";
36198
36244
  }
36199
36245
  resolveMigrationScriptPath() {
36200
36246
  if (this.homeDir) {
36201
- return join8(this.homeDir, ".hoox", "scripts", "migrate-tracking.sh");
36247
+ return join9(this.homeDir, ".hoox", "scripts", "migrate-tracking.sh");
36202
36248
  }
36203
36249
  return "scripts/migrate-tracking.sh";
36204
36250
  }
@@ -37405,7 +37451,7 @@ init_theme();
37405
37451
  init_errors4();
37406
37452
  import { spawn } from "child_process";
37407
37453
  import { createRequire } from "module";
37408
- import { resolve as resolve6, dirname as dirname3, join as join9 } from "path";
37454
+ import { resolve as resolve6, dirname as dirname3, join as join10 } from "path";
37409
37455
  import { fileURLToPath } from "url";
37410
37456
  import { existsSync as existsSync11, realpathSync } from "fs";
37411
37457
  import { homedir as homedir5 } from "os";
@@ -37458,14 +37504,14 @@ function collectTuiCandidates() {
37458
37504
  candidates.push(resolve6(__dirname2, "../../../../tui/src/main.tsx"), resolve6(__dirname2, "../../../../tui/dist/main.js"), resolve6(__dirname2, "../../../tui/src/main.tsx"), resolve6(__dirname2, "../../../tui/dist/main.js"), resolve6(process.cwd(), "packages/tui/src/main.tsx"), resolve6(process.cwd(), "packages/tui/dist/main.js"), resolve6(process.cwd(), "../tui/src/main.tsx"), resolve6(process.cwd(), "../tui/dist/main.js"));
37459
37505
  pushPackageEntries(candidates, require2);
37460
37506
  try {
37461
- const cwdRequire = createRequire(join9(process.cwd(), "package.json"));
37507
+ const cwdRequire = createRequire(join10(process.cwd(), "package.json"));
37462
37508
  pushPackageEntries(candidates, cwdRequire);
37463
37509
  } catch {}
37464
- const bunGlobal = join9(homedir5(), ".bun", "install", "global", "node_modules", TUI_PKG);
37510
+ const bunGlobal = join10(homedir5(), ".bun", "install", "global", "node_modules", TUI_PKG);
37465
37511
  pushPackageRootEntries(candidates, bunGlobal);
37466
37512
  const npmGlobal = process.env.npm_config_prefix?.trim();
37467
37513
  if (npmGlobal) {
37468
- pushPackageRootEntries(candidates, join9(npmGlobal, "lib", "node_modules", TUI_PKG));
37514
+ pushPackageRootEntries(candidates, join10(npmGlobal, "lib", "node_modules", TUI_PKG));
37469
37515
  }
37470
37516
  pushFromWhich(candidates, "hoox-tui");
37471
37517
  return [...new Set(candidates)];
@@ -37473,7 +37519,7 @@ function collectTuiCandidates() {
37473
37519
  function pushPackageRootEntries(candidates, root) {
37474
37520
  if (!root || !existsSync11(root))
37475
37521
  return;
37476
- candidates.push(join9(root, "dist", "main.js"), join9(root, "src", "main.tsx"), join9(root, "bin", "hoox-tui.js"), join9(root, "src", "main.ts"));
37522
+ candidates.push(join10(root, "dist", "main.js"), join10(root, "src", "main.tsx"), join10(root, "bin", "hoox-tui.js"), join10(root, "src", "main.ts"));
37477
37523
  }
37478
37524
  function pushPackageEntries(candidates, req) {
37479
37525
  try {
@@ -37713,14 +37759,14 @@ TUI exited with code ${code}
37713
37759
  // src/commands/doctor/doctor-command.ts
37714
37760
  init_dist4();
37715
37761
  init_src();
37716
- import { join as join11 } from "path";
37762
+ import { join as join12 } from "path";
37717
37763
  import { homedir as homedir6 } from "os";
37718
37764
 
37719
37765
  // src/services/runtime/runtime-service.ts
37720
37766
  init_src();
37721
37767
  import { existsSync as existsSync12, lstatSync as lstatSync2, readlinkSync, rmSync } from "fs";
37722
37768
  import { mkdir } from "fs/promises";
37723
- import { join as join10 } from "path";
37769
+ import { join as join11 } from "path";
37724
37770
  var DEFAULT_HOOX_RUNTIME_REPO = "https://github.com/hoox-sh/hoox.git";
37725
37771
  function firstExisting(paths) {
37726
37772
  for (const p3 of paths) {
@@ -37803,9 +37849,9 @@ ${clone2.stderr || clone2.stdout}`.trim());
37803
37849
  }
37804
37850
  let installed = false;
37805
37851
  if (!options.skipInstall) {
37806
- const nodeModules = join10(repoPath, "node_modules");
37807
- const tuiPkg = join10(repoPath, "packages", "tui", "package.json");
37808
- const needsInstall = !existsSync12(nodeModules) || existsSync12(tuiPkg) && !existsSync12(join10(repoPath, "packages", "tui", "node_modules")) && !existsSync12(join10(nodeModules, "@opentui"));
37852
+ const nodeModules = join11(repoPath, "node_modules");
37853
+ const tuiPkg = join11(repoPath, "packages", "tui", "package.json");
37854
+ const needsInstall = !existsSync12(nodeModules) || existsSync12(tuiPkg) && !existsSync12(join11(repoPath, "packages", "tui", "node_modules")) && !existsSync12(join11(nodeModules, "@opentui"));
37809
37855
  if (cloned || needsInstall || !existsSync12(nodeModules)) {
37810
37856
  log2(`Running bun install in ${repoPath}`);
37811
37857
  const install = await runCommand(["bun", "install"], repoPath);
@@ -38134,7 +38180,7 @@ Hoox doctor
38134
38180
  return failed === 0 ? 0 /* SUCCESS */ : 1 /* ERROR */;
38135
38181
  }
38136
38182
  function printSecurityHygieneSection(env = process.env) {
38137
- const configPath = join11(homedir6(), ".hoox", "config.json");
38183
+ const configPath = join12(homedir6(), ".hoox", "config.json");
38138
38184
  const lines = collectSecurityHygiene(env, { configPath });
38139
38185
  process.stdout.write(theme.heading(`Security hygiene
38140
38186
  `));
@@ -38152,7 +38198,7 @@ async function runSecurityDoctor(options) {
38152
38198
  env.HOOX_API_URL = options.apiUrl;
38153
38199
  }
38154
38200
  const profile = resolveOperatorTransportProfile(env);
38155
- const configPath = join11(homedir6(), ".hoox", "config.json");
38201
+ const configPath = join12(homedir6(), ".hoox", "config.json");
38156
38202
  const hygiene = collectSecurityHygiene(env, { configPath });
38157
38203
  const isLocal = profile.apiBase.includes("localhost") || profile.apiBase.includes("127.0.0.1");
38158
38204
  const shouldProbe = options.probe === true || options.probe !== false && !isLocal;
@@ -40880,7 +40926,7 @@ init_ansis();
40880
40926
  init_theme();
40881
40927
  import { existsSync as existsSync14, readFileSync as readFileSync9 } from "fs";
40882
40928
  import { fileURLToPath as fileURLToPath2 } from "url";
40883
- import { dirname as dirname4, join as join12 } from "path";
40929
+ import { dirname as dirname4, join as join13 } from "path";
40884
40930
  var ORANGE = ansis_default.hex("#ff7f2a");
40885
40931
  var AMBER = ansis_default.hex("#ffb722");
40886
40932
  var INDIGO = ansis_default.hex("#818cf8");
@@ -40893,7 +40939,7 @@ function findCliVersion() {
40893
40939
  const PKG_NAME = "@hoox-sh/hoox-cli";
40894
40940
  let dir = dirname4(fileURLToPath2(import.meta.url));
40895
40941
  for (let i2 = 0;i2 < 5; i2++) {
40896
- const pkgPath = join12(dir, "package.json");
40942
+ const pkgPath = join13(dir, "package.json");
40897
40943
  if (existsSync14(pkgPath)) {
40898
40944
  try {
40899
40945
  const pkg = JSON.parse(readFileSync9(pkgPath, "utf-8"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hoox-sh/hoox-cli",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Hoox CLI — manage Cloudflare Workers, infrastructure, secrets, and deployments (@hoox-sh/hoox-cli)",
5
5
  "type": "module",
6
6
  "bin": {