deepspace 0.5.0 → 0.5.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.
package/dist/cli.js CHANGED
@@ -4,9 +4,50 @@
4
4
  import { defineCommand as defineCommand20, runMain } from "citty";
5
5
  import { execSync as execSync4 } from "child_process";
6
6
  import { readFileSync as readFileSync14, existsSync as existsSync15 } from "fs";
7
- import { dirname as dirname4, join as join16 } from "path";
7
+ import { dirname as dirname4, join as join17 } from "path";
8
8
  import { fileURLToPath as fileURLToPath2 } from "url";
9
9
 
10
+ // src/cli/lib/cli-errors.ts
11
+ var API_ERROR_HINTS = {
12
+ not_app_owner: "Only the app owner can do this.",
13
+ app_not_found: "App not found. Check the app name (wrangler.toml `name`) and that it has been deployed.",
14
+ not_app_owner_or_collaborator: "You must be the app owner or a collaborator to do this.",
15
+ test_account_cannot_be_collaborator: "Test accounts cannot be added as collaborators. Use a real DeepSpace account.",
16
+ user_not_found: "No DeepSpace user with that email. New users must sign in and use DeepSpace once (e.g. run `deepspace whoami`) before they can be referenced by email."
17
+ };
18
+ function formatCliError(err) {
19
+ const message = err instanceof Error ? err.message : String(err);
20
+ const slug = /^API \S+ \(\d+\): ([a-z0-9_]+)$/.exec(message)?.[1];
21
+ const hint = slug ? API_ERROR_HINTS[slug] : void 0;
22
+ return hint ? `${message}
23
+ ${hint}` : message;
24
+ }
25
+ function renderCliError(err) {
26
+ console.error(formatCliError(err));
27
+ if (process.env.DEBUG && err instanceof Error && err.stack) {
28
+ console.error("\n" + err.stack);
29
+ }
30
+ process.exit(1);
31
+ }
32
+ function wrapCommandErrors(cmd) {
33
+ const run2 = cmd.run;
34
+ if (run2) {
35
+ cmd.run = (async (ctx) => {
36
+ try {
37
+ await run2(ctx);
38
+ } catch (err) {
39
+ renderCliError(err);
40
+ }
41
+ });
42
+ }
43
+ if (cmd.subCommands && typeof cmd.subCommands === "object") {
44
+ for (const sub of Object.values(cmd.subCommands)) {
45
+ if (sub && typeof sub === "object") wrapCommandErrors(sub);
46
+ }
47
+ }
48
+ return cmd;
49
+ }
50
+
10
51
  // src/cli/commands/login.ts
11
52
  import { defineCommand } from "citty";
12
53
  import { writeFileSync as writeFileSync4, mkdirSync } from "fs";
@@ -727,7 +768,7 @@ var logout_default = defineCommand2({
727
768
 
728
769
  // src/cli/commands/dev.ts
729
770
  import { defineCommand as defineCommand3 } from "citty";
730
- import { resolve as resolve4, basename, join as join8 } from "path";
771
+ import { resolve as resolve4, basename, join as join9 } from "path";
731
772
  import spawn from "cross-spawn";
732
773
 
733
774
  // src/cli/auth.ts
@@ -966,7 +1007,16 @@ Full log: ${logPath}`);
966
1007
  // src/cli/lib/preflight.ts
967
1008
  import { execFileSync } from "child_process";
968
1009
  import { existsSync as existsSync7 } from "fs";
1010
+ import * as nodeModule from "module";
969
1011
  import { resolve as resolve2 } from "path";
1012
+ function preflightNodeVersion(command, hasRegisterHooks = typeof nodeModule.registerHooks === "function") {
1013
+ if (hasRegisterHooks) return;
1014
+ console.error(
1015
+ `deepspace ${command} requires Node 22.15 or newer (found v${process.versions.node}).`
1016
+ );
1017
+ console.error("Install the current LTS from https://nodejs.org and re-run.");
1018
+ process.exit(1);
1019
+ }
970
1020
  var DLL_NOT_FOUND = -1073741515;
971
1021
  function preflightWindowsWorkerd(appDir2) {
972
1022
  if (process.platform !== "win32") return;
@@ -1000,9 +1050,38 @@ function preflightWindowsWorkerd(appDir2) {
1000
1050
  }
1001
1051
  }
1002
1052
 
1053
+ // src/cli/lib/macos-junk.ts
1054
+ import { readdirSync as readdirSync2, rmSync as rmSync3 } from "fs";
1055
+ import { join as join7 } from "path";
1056
+ var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", ".wrangler", ".vite"]);
1057
+ function removeMacosJunk(dir) {
1058
+ let removed = 0;
1059
+ let entries;
1060
+ try {
1061
+ entries = readdirSync2(dir, { withFileTypes: true });
1062
+ } catch {
1063
+ return removed;
1064
+ }
1065
+ for (const entry of entries) {
1066
+ const path = join7(dir, entry.name);
1067
+ if (entry.isDirectory()) {
1068
+ if (!SKIP_DIRS.has(entry.name)) removed += removeMacosJunk(path);
1069
+ continue;
1070
+ }
1071
+ if (entry.name === ".DS_Store" || entry.name.startsWith("._")) {
1072
+ try {
1073
+ rmSync3(path, { force: true });
1074
+ removed++;
1075
+ } catch {
1076
+ }
1077
+ }
1078
+ }
1079
+ return removed;
1080
+ }
1081
+
1003
1082
  // src/cli/lib/secrets.ts
1004
1083
  import { existsSync as existsSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "fs";
1005
- import { join as join7, resolve as resolve3 } from "path";
1084
+ import { join as join8, resolve as resolve3 } from "path";
1006
1085
 
1007
1086
  // src/server/rooms/binding-manifest.ts
1008
1087
  var AUTO_PROVISION_SENTINEL = "auto";
@@ -1367,7 +1446,7 @@ function appScopedSecretsApiOptions(appDir2, target) {
1367
1446
  return { appName: resolveSecretsAppName(appDir2, target.wranglerEnv) };
1368
1447
  }
1369
1448
  function secretsCacheFilePath(appDir2) {
1370
- return join7(appDir2, ".dev.vars");
1449
+ return join8(appDir2, ".dev.vars");
1371
1450
  }
1372
1451
  async function pullLinkedSecretsCache(deployUrl, token, appDir2, wranglerEnv2) {
1373
1452
  const link = resolveSecretsLink(appDir2, wranglerEnv2);
@@ -1507,7 +1586,7 @@ function parseSecretsUpload(content) {
1507
1586
  return out;
1508
1587
  }
1509
1588
  function writeWranglerSecretsLink(appDir2, target, opts = {}) {
1510
- const path = join7(resolve3(appDir2), "wrangler.toml");
1589
+ const path = join8(resolve3(appDir2), "wrangler.toml");
1511
1590
  const raw = readFileSync7(path, "utf-8");
1512
1591
  const table = target.wranglerEnv ? `env.${target.wranglerEnv}.vars` : "vars";
1513
1592
  const vars = {
@@ -1527,7 +1606,7 @@ function removeWranglerSecretsLink(appDir2, wranglerEnv2) {
1527
1606
  removeWranglerSecretsLinkKeys(appDir2, wranglerEnv2, ["project", "config"]);
1528
1607
  }
1529
1608
  function removeWranglerSecretsLinkKeys(appDir2, wranglerEnv2, keys) {
1530
- const path = join7(resolve3(appDir2), "wrangler.toml");
1609
+ const path = join8(resolve3(appDir2), "wrangler.toml");
1531
1610
  const raw = readFileSync7(path, "utf-8");
1532
1611
  const table = wranglerEnv2 ? `env.${wranglerEnv2}.vars` : "vars";
1533
1612
  const vars = {};
@@ -1537,7 +1616,7 @@ function removeWranglerSecretsLinkKeys(appDir2, wranglerEnv2, keys) {
1537
1616
  writeFileSync7(path, setTomlVars(raw, table, vars));
1538
1617
  }
1539
1618
  function updateWranglerRequiredSecrets(appDir2, secretNames, opts = {}) {
1540
- const path = join7(resolve3(appDir2), "wrangler.toml");
1619
+ const path = join8(resolve3(appDir2), "wrangler.toml");
1541
1620
  const raw = readFileSync7(path, "utf-8");
1542
1621
  const existing = readRequiredSecretNamesFromToml(raw);
1543
1622
  const incoming = normalizeRequiredSecretNames(secretNames);
@@ -1549,7 +1628,7 @@ function updateWranglerRequiredSecrets(appDir2, secretNames, opts = {}) {
1549
1628
  return next;
1550
1629
  }
1551
1630
  function removeWranglerRequiredSecrets(appDir2, secretNames) {
1552
- const path = join7(resolve3(appDir2), "wrangler.toml");
1631
+ const path = join8(resolve3(appDir2), "wrangler.toml");
1553
1632
  const raw = readFileSync7(path, "utf-8");
1554
1633
  const remove2 = new Set(normalizeRequiredSecretNames(secretNames));
1555
1634
  const next = readRequiredSecretNamesFromToml(raw).filter((key) => !remove2.has(key));
@@ -1762,6 +1841,7 @@ var dev_default = defineCommand3({
1762
1841
  }
1763
1842
  },
1764
1843
  async run({ args }) {
1844
+ preflightNodeVersion("dev");
1765
1845
  const wranglerEnv2 = typeof args.env === "string" && args.env.trim() ? args.env.trim() : void 0;
1766
1846
  const start = resolve4(args.dir ?? ".");
1767
1847
  const appDir2 = findAppDir(start);
@@ -1776,6 +1856,8 @@ var dev_default = defineCommand3({
1776
1856
  }
1777
1857
  process.exit(1);
1778
1858
  }
1859
+ const junk = removeMacosJunk(appDir2);
1860
+ if (junk > 0) console.log(`Removed ${junk} macOS metadata file(s) (._*, .DS_Store)`);
1779
1861
  const worktree = detectClaudeWorktree(appDir2);
1780
1862
  const explicitPort = Boolean(args.port);
1781
1863
  let port = worktree && !explicitPort ? deriveWorktreePort(worktree.worktreeName) : resolvePort(args.port);
@@ -1797,7 +1879,7 @@ var dev_default = defineCommand3({
1797
1879
  );
1798
1880
  } else {
1799
1881
  console.warn(
1800
- `Warning: could not update ${join8(worktree.mainRepoRoot, ".claude", "launch.json")} (malformed or unwritable) \u2014 the Claude preview tool may serve the main repo's code instead of this worktree.`
1882
+ `Warning: could not update ${join9(worktree.mainRepoRoot, ".claude", "launch.json")} (malformed or unwritable) \u2014 the Claude preview tool may serve the main repo's code instead of this worktree.`
1801
1883
  );
1802
1884
  }
1803
1885
  if (!explicitPort && process.env.DEEPSPACE_PORT) {
@@ -2074,6 +2156,7 @@ var test_default = defineCommand5({
2074
2156
  }
2075
2157
  },
2076
2158
  async run({ args }) {
2159
+ preflightNodeVersion("test");
2077
2160
  const suite = args.suite ?? "default";
2078
2161
  const wranglerEnv2 = typeof args.env === "string" && args.env.trim() ? args.env.trim() : void 0;
2079
2162
  const start = resolve5(".");
@@ -2265,12 +2348,12 @@ var screenshot_default = defineCommand6({
2265
2348
  import { defineCommand as defineCommand7 } from "citty";
2266
2349
  import * as p3 from "@clack/prompts";
2267
2350
  import { readFileSync as readFileSync8, writeFileSync as writeFileSync8, existsSync as existsSync9, mkdirSync as mkdirSync4 } from "fs";
2268
- import { join as join9 } from "path";
2351
+ import { join as join10 } from "path";
2269
2352
  import { homedir as homedir4 } from "os";
2270
2353
  var SESSION_COOKIE2 = "__Secure-better-auth.session_token";
2271
2354
  var AUTH_URL4 = process.env.DEEPSPACE_AUTH_URL ?? PLATFORM_URLS.auth;
2272
- var DIR3 = join9(homedir4(), ".deepspace");
2273
- var ACCOUNTS_PATH = join9(DIR3, "test-accounts.json");
2355
+ var DIR3 = join10(homedir4(), ".deepspace");
2356
+ var ACCOUNTS_PATH = join10(DIR3, "test-accounts.json");
2274
2357
  function loadAccounts() {
2275
2358
  if (!existsSync9(ACCOUNTS_PATH)) return [];
2276
2359
  try {
@@ -2554,8 +2637,8 @@ var test_accounts_default = defineCommand7({
2554
2637
  import { defineCommand as defineCommand8 } from "citty";
2555
2638
  import { execSync as execSync2 } from "child_process";
2556
2639
  import { randomUUID } from "crypto";
2557
- import { readFileSync as readFileSync9, readdirSync as readdirSync2, existsSync as existsSync10 } from "fs";
2558
- import { join as join10, resolve as resolve7, dirname as dirname2 } from "path";
2640
+ import { readFileSync as readFileSync9, readdirSync as readdirSync3, existsSync as existsSync10 } from "fs";
2641
+ import { join as join11, resolve as resolve7, dirname as dirname2 } from "path";
2559
2642
  import { pathToFileURL } from "url";
2560
2643
  import * as p4 from "@clack/prompts";
2561
2644
  var DEPLOY_URL3 = process.env.DEEPSPACE_DEPLOY_URL ?? PLATFORM_URLS.deploy;
@@ -2679,6 +2762,7 @@ var deploy_default = defineCommand8({
2679
2762
  }
2680
2763
  },
2681
2764
  async run({ args }) {
2765
+ preflightNodeVersion("deploy");
2682
2766
  const appDir2 = resolve7(args.dir ?? ".");
2683
2767
  const envName = typeof args.env === "string" && args.env.trim() ? args.env.trim() : void 0;
2684
2768
  if (!hasWranglerConfig(appDir2)) {
@@ -2736,6 +2820,8 @@ var deploy_default = defineCommand8({
2736
2820
  p4.cancel(`Failed to refresh linked secrets before deploy: ${errMessage(err)}`);
2737
2821
  process.exit(1);
2738
2822
  }
2823
+ const junk = removeMacosJunk(appDir2);
2824
+ if (junk > 0) p4.log.info(`Removed ${junk} macOS metadata file(s) (._*, .DS_Store)`);
2739
2825
  const s = createSpinner();
2740
2826
  s.start("Building...");
2741
2827
  let preparedWranglerConfig;
@@ -2758,7 +2844,7 @@ var deploy_default = defineCommand8({
2758
2844
  preparedWranglerConfig?.cleanup();
2759
2845
  }
2760
2846
  s.stop("Built");
2761
- const deployConfigPath = join10(appDir2, ".wrangler", "deploy", "config.json");
2847
+ const deployConfigPath = join11(appDir2, ".wrangler", "deploy", "config.json");
2762
2848
  if (!existsSync10(deployConfigPath)) {
2763
2849
  p4.cancel("Build output config not found at .wrangler/deploy/config.json");
2764
2850
  process.exit(1);
@@ -2778,7 +2864,7 @@ var deploy_default = defineCommand8({
2778
2864
  process.exit(1);
2779
2865
  }
2780
2866
  const workerDir = dirname2(outputWranglerPath);
2781
- const workerBundlePath = join10(workerDir, outputConfig.main);
2867
+ const workerBundlePath = join11(workerDir, outputConfig.main);
2782
2868
  const clientDir = outputConfig.assets?.directory ? resolve7(workerDir, outputConfig.assets.directory) : null;
2783
2869
  if (!existsSync10(workerBundlePath)) {
2784
2870
  p4.cancel(`Worker bundle not found at ${workerBundlePath}`);
@@ -2992,13 +3078,13 @@ var deploy_default = defineCommand8({
2992
3078
  }
2993
3079
  });
2994
3080
  async function syncSubscriptionPlans(appDir2, appName, token) {
2995
- const subsPath = join10(appDir2, "src", "subscriptions.ts");
3081
+ const subsPath = join11(appDir2, "src", "subscriptions.ts");
2996
3082
  if (!existsSync10(subsPath)) return;
2997
3083
  let plans;
2998
3084
  try {
2999
3085
  const esbuild = await import("esbuild");
3000
- const outDir = join10(appDir2, ".wrangler", "deploy");
3001
- const outFile = join10(outDir, "subscriptions.bundle.mjs");
3086
+ const outDir = join11(appDir2, ".wrangler", "deploy");
3087
+ const outFile = join11(outDir, "subscriptions.bundle.mjs");
3002
3088
  await esbuild.build({
3003
3089
  entryPoints: [subsPath],
3004
3090
  bundle: true,
@@ -3140,13 +3226,13 @@ current billing period? (Skip to leave them grandfathered.)`
3140
3226
  }
3141
3227
  }
3142
3228
  async function syncOneTimeProducts(appDir2, appName, token) {
3143
- const productsPath = join10(appDir2, "src", "products.ts");
3229
+ const productsPath = join11(appDir2, "src", "products.ts");
3144
3230
  if (!existsSync10(productsPath)) return;
3145
3231
  let products;
3146
3232
  try {
3147
3233
  const esbuild = await import("esbuild");
3148
- const outDir = join10(appDir2, ".wrangler", "deploy");
3149
- const outFile = join10(outDir, "products.bundle.mjs");
3234
+ const outDir = join11(appDir2, ".wrangler", "deploy");
3235
+ const outFile = join11(outDir, "products.bundle.mjs");
3150
3236
  await esbuild.build({
3151
3237
  entryPoints: [productsPath],
3152
3238
  bundle: true,
@@ -3219,9 +3305,9 @@ async function waitForAssetsReady(url, timeoutMs) {
3219
3305
  function collectAssets(dir) {
3220
3306
  const assets = [];
3221
3307
  function walk(d, prefix) {
3222
- for (const entry of readdirSync2(d, { withFileTypes: true })) {
3308
+ for (const entry of readdirSync3(d, { withFileTypes: true })) {
3223
3309
  if (entry.name === ".assetsignore") continue;
3224
- const full = join10(d, entry.name);
3310
+ const full = join11(d, entry.name);
3225
3311
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
3226
3312
  if (entry.isDirectory()) {
3227
3313
  walk(full, rel);
@@ -3360,12 +3446,12 @@ var whoami_default = defineCommand10({
3360
3446
  // src/cli/commands/add.ts
3361
3447
  import { defineCommand as defineCommand11 } from "citty";
3362
3448
  import { existsSync as existsSync11 } from "fs";
3363
- import { resolve as resolve8, join as join11 } from "path";
3449
+ import { resolve as resolve8, join as join12 } from "path";
3364
3450
  import { execSync as execSync3 } from "child_process";
3365
3451
  function findScript(from) {
3366
- const inNodeModules = join11(from, "node_modules", "deepspace", "scripts", "add-feature.cjs");
3452
+ const inNodeModules = join12(from, "node_modules", "deepspace", "scripts", "add-feature.cjs");
3367
3453
  if (existsSync11(inNodeModules)) return inNodeModules;
3368
- const inDotDeepspace = join11(from, ".deepspace", "scripts", "add-feature.cjs");
3454
+ const inDotDeepspace = join12(from, ".deepspace", "scripts", "add-feature.cjs");
3369
3455
  if (existsSync11(inDotDeepspace)) return inDotDeepspace;
3370
3456
  return null;
3371
3457
  }
@@ -3404,8 +3490,8 @@ var add_default = defineCommand11({
3404
3490
  if (!script) {
3405
3491
  console.error("Could not find the deepspace feature installer.");
3406
3492
  console.error("Looked in:");
3407
- console.error(` ${join11(appDir2, "node_modules", "deepspace", "scripts", "add-feature.cjs")}`);
3408
- console.error(` ${join11(appDir2, ".deepspace", "scripts", "add-feature.cjs")}`);
3493
+ console.error(` ${join12(appDir2, "node_modules", "deepspace", "scripts", "add-feature.cjs")}`);
3494
+ console.error(` ${join12(appDir2, ".deepspace", "scripts", "add-feature.cjs")}`);
3409
3495
  console.error("Are you in a DeepSpace app directory? Try `npm install` first.");
3410
3496
  process.exit(1);
3411
3497
  }
@@ -3430,7 +3516,7 @@ var add_default = defineCommand11({
3430
3516
  import { defineCommand as defineCommand12 } from "citty";
3431
3517
  import spawn2 from "cross-spawn";
3432
3518
  import { mkdirSync as mkdirSync5 } from "fs";
3433
- import { join as join12 } from "path";
3519
+ import { join as join13 } from "path";
3434
3520
  import { homedir as homedir5 } from "os";
3435
3521
  var SKILL_REPO = "deepdotspace/deepspace-skill";
3436
3522
  function runSkillsAdd(extraArgs) {
@@ -3449,7 +3535,7 @@ function runSkillsAdd(extraArgs) {
3449
3535
  });
3450
3536
  }
3451
3537
  function precreateClaudeDir(baseDir) {
3452
- mkdirSync5(join12(baseDir, ".claude"), { recursive: true });
3538
+ mkdirSync5(join13(baseDir, ".claude"), { recursive: true });
3453
3539
  }
3454
3540
  var add = defineCommand12({
3455
3541
  meta: {
@@ -3856,6 +3942,14 @@ var domain_default = defineCommand13({
3856
3942
 
3857
3943
  // src/cli/commands/collaborators.ts
3858
3944
  import { defineCommand as defineCommand14 } from "citty";
3945
+
3946
+ // src/server/auth/testAccounts.ts
3947
+ var TEST_ACCOUNT_EMAIL_SUFFIX = "@deepspace.test";
3948
+ function isTestAccountEmail(email) {
3949
+ return !!email && email.trim().toLowerCase().endsWith(TEST_ACCOUNT_EMAIL_SUFFIX);
3950
+ }
3951
+
3952
+ // src/cli/commands/collaborators.ts
3859
3953
  var API_URL3 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
3860
3954
  async function api2(token, path, init) {
3861
3955
  const res = await fetch(`${API_URL3}${path}`, {
@@ -3917,6 +4011,12 @@ var add2 = defineCommand14({
3917
4011
  async run({ args }) {
3918
4012
  const token = await ensureToken();
3919
4013
  const app = requireAppName(args.app);
4014
+ if (isTestAccountEmail(args.email)) {
4015
+ console.error(
4016
+ "Test accounts (@deepspace.test) cannot be added as collaborators. Use a real DeepSpace account."
4017
+ );
4018
+ process.exit(1);
4019
+ }
3920
4020
  const { collaborator } = await api2(
3921
4021
  token,
3922
4022
  `/api/app-collaborators/${encodeURIComponent(app)}`,
@@ -4341,7 +4441,7 @@ var invoke_default = defineCommand16({
4341
4441
  // src/cli/commands/library.ts
4342
4442
  import { defineCommand as defineCommand17 } from "citty";
4343
4443
  import { existsSync as existsSync12, readFileSync as readFileSync11 } from "fs";
4344
- import { join as join13, resolve as resolve9 } from "path";
4444
+ import { join as join14, resolve as resolve9 } from "path";
4345
4445
  import { parse as parseToml3 } from "smol-toml";
4346
4446
  import * as p6 from "@clack/prompts";
4347
4447
  var DEFAULT_LIBRARY_APP = "deepdotspace-site";
@@ -4419,7 +4519,7 @@ var publish = defineCommand17({
4419
4519
  let appName = typeof args.app === "string" && args.app.trim() ? args.app.trim() : void 0;
4420
4520
  if (!appName) {
4421
4521
  const appDir2 = resolve9(typeof args.dir === "string" && args.dir ? args.dir : ".");
4422
- const wranglerPath = join13(appDir2, "wrangler.toml");
4522
+ const wranglerPath = join14(appDir2, "wrangler.toml");
4423
4523
  if (!existsSync12(wranglerPath)) {
4424
4524
  return die("No --app provided and no wrangler.toml found. Either pass --app <name> or run from your app's directory.");
4425
4525
  }
@@ -4558,7 +4658,7 @@ var library_default = defineCommand17({
4558
4658
  import { defineCommand as defineCommand18 } from "citty";
4559
4659
  import * as p7 from "@clack/prompts";
4560
4660
  import { existsSync as existsSync13, readFileSync as readFileSync12 } from "fs";
4561
- import { dirname as dirname3, join as join14 } from "path";
4661
+ import { dirname as dirname3, join as join15 } from "path";
4562
4662
  import { fileURLToPath } from "url";
4563
4663
  import { release } from "os";
4564
4664
  var API_URL5 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
@@ -4581,8 +4681,8 @@ function readCliVersion() {
4581
4681
  try {
4582
4682
  const here = dirname3(fileURLToPath(import.meta.url));
4583
4683
  const candidates = [
4584
- join14(here, "..", "package.json"),
4585
- join14(here, "..", "..", "..", "package.json")
4684
+ join15(here, "..", "package.json"),
4685
+ join15(here, "..", "..", "..", "package.json")
4586
4686
  ];
4587
4687
  for (const path of candidates) {
4588
4688
  if (!existsSync13(path)) continue;
@@ -4796,8 +4896,8 @@ Context: deepspace ${payload.cliVersion} \xB7 ${payload.nodeVersion} \xB7 ${payl
4796
4896
 
4797
4897
  // src/cli/commands/secrets.ts
4798
4898
  import { defineCommand as defineCommand19 } from "citty";
4799
- import { existsSync as existsSync14, readFileSync as readFileSync13, rmSync as rmSync3 } from "fs";
4800
- import { join as join15, resolve as resolve10 } from "path";
4899
+ import { existsSync as existsSync14, readFileSync as readFileSync13, rmSync as rmSync4 } from "fs";
4900
+ import { join as join16, resolve as resolve10 } from "path";
4801
4901
  var DEPLOY_URL5 = process.env.DEEPSPACE_DEPLOY_URL ?? PLATFORM_URLS.deploy;
4802
4902
  function appDir(args) {
4803
4903
  const dir = typeof args.dir === "string" && args.dir ? args.dir : typeof args.scope === "string" && args.scope ? args.scope : ".";
@@ -4951,7 +5051,7 @@ async function bestEffortClearServerSecretsLink(dir, targetEnv) {
4951
5051
  }
4952
5052
  async function importLegacyDevVarsSecrets(dir, target, remoteCheck) {
4953
5053
  if (remoteCheck.status === "unchecked") return null;
4954
- const legacyPath = target.wranglerEnv ? join15(dir, `.dev.vars.${target.wranglerEnv}`) : join15(dir, ".dev.vars");
5054
+ const legacyPath = target.wranglerEnv ? join16(dir, `.dev.vars.${target.wranglerEnv}`) : join16(dir, ".dev.vars");
4955
5055
  if (!existsSync14(legacyPath)) return null;
4956
5056
  try {
4957
5057
  const custom = extractCustomDevVars(
@@ -5001,7 +5101,7 @@ async function importLegacyDevVarsSecrets(dir, target, remoteCheck) {
5001
5101
  new Set(keys)
5002
5102
  );
5003
5103
  if (target.wranglerEnv && !extractCustomDevVars(cleaned).trim()) {
5004
- rmSync3(legacyPath, { force: true });
5104
+ rmSync4(legacyPath, { force: true });
5005
5105
  } else {
5006
5106
  writeSecretFileSync(legacyPath, cleaned ? `${cleaned}
5007
5107
  ` : "");
@@ -5761,7 +5861,7 @@ function readExistingFile(path) {
5761
5861
 
5762
5862
  // src/cli/cli.ts
5763
5863
  var __dirname = dirname4(fileURLToPath2(import.meta.url));
5764
- var pkg = JSON.parse(readFileSync14(join16(__dirname, "..", "package.json"), "utf-8"));
5864
+ var pkg = JSON.parse(readFileSync14(join17(__dirname, "..", "package.json"), "utf-8"));
5765
5865
  if (process.platform === "linux" && !process.env.SSL_CERT_FILE && existsSync15("/etc/ssl/certs/ca-certificates.crt")) {
5766
5866
  process.env.SSL_CERT_FILE = "/etc/ssl/certs/ca-certificates.crt";
5767
5867
  }
@@ -5817,5 +5917,5 @@ var main = defineCommand20({
5817
5917
  // command. Citty's default behavior when no subcommand matches is to print
5818
5918
  // help, which is what we want for `deepspace` with no args.
5819
5919
  });
5820
- runMain(main);
5920
+ runMain(wrapCommandErrors(main));
5821
5921
  //# sourceMappingURL=cli.js.map