@boxes-dev/dvb 1.0.35 → 1.0.37

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/bin/dvb.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c5ff8eeb-e556-5c16-a965-f352e4d938da")}catch(e){}}();
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="40d741de-8ab0-5af9-b40e-d750caa3ceab")}catch(e){}}();
4
4
 
5
5
  var __create = Object.create;
6
6
  var __defProp = Object.defineProperty;
@@ -88634,8 +88634,8 @@ var init_otel = __esm({
88634
88634
  return trimmed && trimmed.length > 0 ? trimmed : void 0;
88635
88635
  };
88636
88636
  readBuildMetadata = () => {
88637
- const rawPackageVersion = "1.0.35";
88638
- const rawGitSha = "f3556e7e62d92e3775dcf9005933b49b6f735161";
88637
+ const rawPackageVersion = "1.0.37";
88638
+ const rawGitSha = "c3f5a2ab47817d9cb07bb8bc3ef137c6aeccdfcf";
88639
88639
  const packageVersion = typeof rawPackageVersion === "string" ? rawPackageVersion : void 0;
88640
88640
  const gitSha = typeof rawGitSha === "string" ? rawGitSha : void 0;
88641
88641
  return { packageVersion, gitSha };
@@ -120623,9 +120623,9 @@ var init_sentry = __esm({
120623
120623
  sentryEnabled = false;
120624
120624
  uncaughtExceptionMonitorInstalled = false;
120625
120625
  readBuildMetadata2 = () => {
120626
- const rawPackageVersion = "1.0.35";
120627
- const rawGitSha = "f3556e7e62d92e3775dcf9005933b49b6f735161";
120628
- const rawSentryRelease = "boxes-dev-dvb@1.0.35+f3556e7e62d92e3775dcf9005933b49b6f735161";
120626
+ const rawPackageVersion = "1.0.37";
120627
+ const rawGitSha = "c3f5a2ab47817d9cb07bb8bc3ef137c6aeccdfcf";
120628
+ const rawSentryRelease = "boxes-dev-dvb@1.0.37+c3f5a2ab47817d9cb07bb8bc3ef137c6aeccdfcf";
120629
120629
  const packageVersion = typeof rawPackageVersion === "string" ? rawPackageVersion : void 0;
120630
120630
  const gitSha = typeof rawGitSha === "string" ? rawGitSha : void 0;
120631
120631
  const sentryRelease = typeof rawSentryRelease === "string" ? rawSentryRelease : void 0;
@@ -139928,6 +139928,7 @@ var init_completions = __esm({
139928
139928
  addValueOption(init3, "alias", "Alias for the devbox");
139929
139929
  addValueOption(init3, "name", "Canonical devbox name");
139930
139930
  addStaticOption(init3, "force", "Force provisioning");
139931
+ addStaticOption(init3, "yes", "Skip force destroy confirmation");
139931
139932
  addStaticOption(init3, "resume", "Resume a previous init");
139932
139933
  addStaticOption(init3, "status", "Show init status and checkpoint info");
139933
139934
  addStaticOption(init3, "json", "Output JSON");
@@ -142375,6 +142376,64 @@ var init_daemon = __esm({
142375
142376
  }
142376
142377
  });
142377
142378
 
142379
+ // src/devbox/commands/destroyShared.ts
142380
+ var isHttpSuccess, checkSpriteExists, destroySpriteAndClearState;
142381
+ var init_destroyShared = __esm({
142382
+ "src/devbox/commands/destroyShared.ts"() {
142383
+ "use strict";
142384
+ init_src();
142385
+ init_daemonClient();
142386
+ isHttpSuccess = (status) => status >= 200 && status < 300;
142387
+ checkSpriteExists = async (client, canonical) => {
142388
+ try {
142389
+ await client.getSprite(canonical);
142390
+ return true;
142391
+ } catch (error2) {
142392
+ if (error2 instanceof SpritesApiError && error2.status === 404) {
142393
+ return false;
142394
+ }
142395
+ throw error2;
142396
+ }
142397
+ };
142398
+ destroySpriteAndClearState = async ({
142399
+ client,
142400
+ canonical,
142401
+ socketPath
142402
+ }) => {
142403
+ const spriteExisted = await checkSpriteExists(client, canonical);
142404
+ if (spriteExisted) {
142405
+ try {
142406
+ await client.deleteSprite(canonical);
142407
+ } catch (error2) {
142408
+ if (!(error2 instanceof SpritesApiError && error2.status === 404)) {
142409
+ throw error2;
142410
+ }
142411
+ }
142412
+ }
142413
+ const portsClear = await requestJson3(
142414
+ socketPath,
142415
+ "POST",
142416
+ "/ports/clear",
142417
+ DAEMON_TIMEOUT_MS.quick,
142418
+ { box: canonical }
142419
+ );
142420
+ const registryRemove2 = await requestJson3(
142421
+ socketPath,
142422
+ "POST",
142423
+ "/registry/remove",
142424
+ DAEMON_TIMEOUT_MS.registry,
142425
+ { canonical }
142426
+ );
142427
+ if (!isHttpSuccess(portsClear.status) || !isHttpSuccess(registryRemove2.status)) {
142428
+ throw new Error(
142429
+ "dvbd failed to clear local state. Restart dvbd and retry."
142430
+ );
142431
+ }
142432
+ return { spriteExisted };
142433
+ };
142434
+ }
142435
+ });
142436
+
142378
142437
  // src/devbox/commands/destroy.ts
142379
142438
  var import_promises12, import_promises13, import_node_os7, import_node_path13, isObject, readCanonicalFromJson, cleanupLocalProjectDirsForBox, parseDestroyArgs, confirmDestroy, runDestroy;
142380
142439
  var init_destroy = __esm({
@@ -142389,6 +142448,7 @@ var init_destroy = __esm({
142389
142448
  init_auth();
142390
142449
  init_statusLine();
142391
142450
  init_boxSelect();
142451
+ init_destroyShared();
142392
142452
  isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
142393
142453
  readCanonicalFromJson = async (filePath) => {
142394
142454
  try {
@@ -142522,51 +142582,13 @@ var init_destroy = __esm({
142522
142582
  );
142523
142583
  const client = createSpritesClient({ apiBaseUrl, token });
142524
142584
  status.stage("Deleting devbox");
142525
- try {
142526
- await client.deleteSprite(canonical);
142527
- } catch (error2) {
142528
- if (error2 instanceof SpritesApiError && error2.status === 404) {
142529
- status.stage("Devbox already deleted", "warn");
142530
- } else if (error2 instanceof SpritesApiError) {
142531
- const deleteError = error2;
142532
- let spriteStillExists = true;
142533
- try {
142534
- const sprite = await client.getSprite(canonical);
142535
- spriteStillExists = Boolean(sprite);
142536
- } catch {
142537
- spriteStillExists = true;
142538
- }
142539
- if (spriteStillExists) {
142540
- throw deleteError;
142541
- }
142542
- status.stop();
142543
- console.error(
142544
- `Sprites delete failed but "${canonical}" is gone; cleaning local state.`
142545
- );
142546
- } else {
142547
- throw error2;
142548
- }
142549
- }
142550
- status.stage("Clearing local state");
142551
- const isOk = (statusCode) => statusCode >= 200 && statusCode < 300;
142552
- const portsClear = await requestJson3(
142553
- socketInfo.socketPath,
142554
- "POST",
142555
- "/ports/clear",
142556
- DAEMON_TIMEOUT_MS.quick,
142557
- { box: canonical }
142558
- );
142559
- const registryRemove2 = await requestJson3(
142560
- socketInfo.socketPath,
142561
- "POST",
142562
- "/registry/remove",
142563
- DAEMON_TIMEOUT_MS.registry,
142564
- { canonical }
142565
- );
142566
- if (!isOk(portsClear.status) || !isOk(registryRemove2.status)) {
142567
- throw new Error(
142568
- "dvbd failed to clear local state. Restart dvbd and retry."
142569
- );
142585
+ const { spriteExisted } = await destroySpriteAndClearState({
142586
+ client,
142587
+ canonical,
142588
+ socketPath: socketInfo.socketPath
142589
+ });
142590
+ if (!spriteExisted) {
142591
+ status.stage("Devbox already deleted", "warn");
142570
142592
  }
142571
142593
  status.stage("Cleaning local project state");
142572
142594
  try {
@@ -142993,7 +143015,7 @@ var init_args = __esm({
142993
143015
  "src/devbox/commands/init/args.ts"() {
142994
143016
  "use strict";
142995
143017
  parseInitArgs = (args) => {
142996
- const parsed = { force: false };
143018
+ const parsed = { force: false, yes: false };
142997
143019
  for (let i2 = 0; i2 < args.length; i2 += 1) {
142998
143020
  const arg = args[i2];
142999
143021
  if (arg === "--alias" && args[i2 + 1]) {
@@ -143014,6 +143036,10 @@ var init_args = __esm({
143014
143036
  parsed.force = true;
143015
143037
  continue;
143016
143038
  }
143039
+ if (arg === "--yes") {
143040
+ parsed.yes = true;
143041
+ continue;
143042
+ }
143017
143043
  if (arg === "--json") {
143018
143044
  parsed.json = true;
143019
143045
  continue;
@@ -147931,6 +147957,7 @@ var init_init = __esm({
147931
147957
  init_mountSsh();
147932
147958
  init_codex();
147933
147959
  init_servicesToml();
147960
+ init_destroyShared();
147934
147961
  init_progress();
147935
147962
  requireDaemonJsonOk = (response, label) => {
147936
147963
  if (response.status >= 200 && response.status < 300) {
@@ -148386,7 +148413,7 @@ var init_init = __esm({
148386
148413
  let initState = detected.initState;
148387
148414
  const initFingerprintMismatch = detected.initFingerprintMismatch;
148388
148415
  if (parsed.status) {
148389
- if (parsed.resume || parsed.force || parsed.codexSetupOnly || parsed.alias || parsed.name) {
148416
+ if (parsed.resume || parsed.force || parsed.yes || parsed.codexSetupOnly || parsed.alias || parsed.name) {
148390
148417
  throw new Error(
148391
148418
  "`dvb init --status` cannot be combined with other init flags (except --json)."
148392
148419
  );
@@ -148509,7 +148536,7 @@ var init_init = __esm({
148509
148536
  " If init was started elsewhere, re-run `dvb init --resume` from that repo."
148510
148537
  );
148511
148538
  lines.push(
148512
- " Otherwise, restart init with `dvb init --force` (re-provisions the remote workdir)."
148539
+ " Otherwise, restart init with `dvb init --force` (destroys and recreates the existing devbox)."
148513
148540
  );
148514
148541
  } else {
148515
148542
  lines.push(" (none)");
@@ -148571,17 +148598,29 @@ var init_init = __esm({
148571
148598
  initState = null;
148572
148599
  }
148573
148600
  const wantsResume = Boolean(parsed.resume);
148574
- if (parsed.force && initState && !initState.complete && !wantsResume) {
148575
- initState = null;
148576
- }
148577
- const shouldResume = Boolean(
148578
- wantsResume && initState && !initState.complete
148579
- );
148580
148601
  if (!parsed.codexSetupOnly && !wantsResume && initState && !initState.complete && !parsed.force) {
148581
148602
  throw new Error(
148582
148603
  "Previous init is incomplete. Run `dvb init --resume` to finish the previous init or `dvb init --force` to restart."
148583
148604
  );
148584
148605
  }
148606
+ if (parsed.force && !wantsResume) {
148607
+ const previousState = initState;
148608
+ const freshState = {
148609
+ version: 1,
148610
+ fingerprint,
148611
+ ...previousState?.canonical !== void 0 ? { canonical: previousState.canonical } : {},
148612
+ ...previousState?.alias !== void 0 ? { alias: previousState.alias } : {},
148613
+ ...previousState?.workdir !== void 0 ? { workdir: previousState.workdir } : {},
148614
+ steps: {},
148615
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
148616
+ complete: false
148617
+ };
148618
+ initState = freshState;
148619
+ await writeInitState(projectDir, freshState);
148620
+ }
148621
+ const shouldResume = Boolean(
148622
+ wantsResume && initState && !initState.complete
148623
+ );
148585
148624
  const ensureInitState = () => {
148586
148625
  if (!initState || initState.fingerprint !== fingerprint) {
148587
148626
  initState = {
@@ -148926,7 +148965,7 @@ var init_init = __esm({
148926
148965
  await requireDaemonFeatures(socketInfo.socketPath, ["registry"]);
148927
148966
  }
148928
148967
  });
148929
- const existingEntry = await runInitStep({
148968
+ let existingEntry = await runInitStep({
148930
148969
  enabled: progressEnabled,
148931
148970
  title: "Checking sprites",
148932
148971
  fn: async () => {
@@ -149004,6 +149043,59 @@ var init_init = __esm({
149004
149043
  return { config: config4, client: client2, controlPlaneToken: controlPlaneToken2 };
149005
149044
  }
149006
149045
  });
149046
+ if (parsed.force && existingEntry && !shouldResume) {
149047
+ const forceCanonical = existingEntry.canonical;
149048
+ await runInitStep({
149049
+ enabled: progressEnabled,
149050
+ title: "Destroying existing devbox (--force)",
149051
+ fn: async ({ status }) => {
149052
+ logger7.info("init_force_destroy_start", {
149053
+ box: forceCanonical,
149054
+ fingerprint
149055
+ });
149056
+ const spriteExists = await checkSpriteExists(client, forceCanonical);
149057
+ if (spriteExists && !parsed.yes) {
149058
+ if (!process.stdin.isTTY || parsed.json) {
149059
+ throw new Error(
149060
+ `--force would destroy existing devbox "${forceCanonical}". Re-run with --yes to confirm.`
149061
+ );
149062
+ }
149063
+ status.stop();
149064
+ const confirmedDestroy = await Mt2({
149065
+ message: `Destroy existing devbox "${forceCanonical}" before re-running init with --force?`,
149066
+ active: "Destroy and continue",
149067
+ inactive: "Abort init",
149068
+ initialValue: false
149069
+ });
149070
+ if (Ct(confirmedDestroy)) {
149071
+ throwInitCanceled();
149072
+ }
149073
+ if (!confirmedDestroy) {
149074
+ throw new Error("Force init canceled.");
149075
+ }
149076
+ status.stage("Destroying existing devbox (--force)");
149077
+ }
149078
+ if (spriteExists) {
149079
+ logger7.info("init_force_destroy_confirmed", {
149080
+ box: forceCanonical,
149081
+ fingerprint
149082
+ });
149083
+ }
149084
+ await requireDaemonFeatures(socketInfo.socketPath, ["ports"]);
149085
+ const result = await destroySpriteAndClearState({
149086
+ client,
149087
+ canonical: forceCanonical,
149088
+ socketPath: socketInfo.socketPath
149089
+ });
149090
+ logger7.info("init_force_destroy_complete", {
149091
+ box: forceCanonical,
149092
+ fingerprint,
149093
+ spriteExisted: result.spriteExisted
149094
+ });
149095
+ }
149096
+ });
149097
+ existingEntry = null;
149098
+ }
149007
149099
  const username = import_node_os11.default.userInfo().username;
149008
149100
  let canonical = (shouldResume && initState?.canonical ? initState.canonical : null) ?? canonicalHint ?? `${username}-${slug}`;
149009
149101
  const knownAssociatedCanonicals = new Set(
@@ -155396,7 +155488,7 @@ var init_cli = __esm({
155396
155488
  console.log(" dvb uninstall [--dry-run] [--yes] [--json]");
155397
155489
  console.log(" dvb init [--alias <alias>] [--name <canonical>]");
155398
155490
  console.log(
155399
- " [--force] [--resume] [--status] [--json] [--codex-setup-only]"
155491
+ " [--force] [--yes] [--resume] [--status] [--json] [--codex-setup-only]"
155400
155492
  );
155401
155493
  console.log(
155402
155494
  " dvb connect [<box>[/<session>]] [-n <name>] [--command <cmd>] [--detach] [--no-log]"
@@ -155771,4 +155863,4 @@ smol-toml/dist/index.js:
155771
155863
  */
155772
155864
  //# sourceMappingURL=dvb.cjs.map
155773
155865
 
155774
- //# debugId=c5ff8eeb-e556-5c16-a965-f352e4d938da
155866
+ //# debugId=40d741de-8ab0-5af9-b40e-d750caa3ceab