sv 1.0.0-next.2 → 1.0.0-next.4

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.
@@ -1,12 +1,12 @@
1
1
  import { createRequire } from "node:module";
2
- import { AGENTS, COMMANDS, Walker, coerceVersion, color, constructCommand, createPrinter, dedent, defineEnv, detect, downloadJson, fileExists, isKit3, isVersionUnsupportedBelow, js, loadFile, loadPackageJson, minVersion, minimizeDiff, parse, pnpm, resolveCommand, resolveCommandArray, resolveLibPrefix, sanitizeName, saveFile, svelte, svelteConfig, transforms } from "@sveltejs/sv-utils";
3
2
  import * as fs$1 from "node:fs";
4
3
  import fs, { closeSync, existsSync, openSync, readSync, statSync } from "node:fs";
5
4
  import * as path$1 from "node:path";
6
5
  import path, { basename, delimiter, dirname, isAbsolute, join, normalize, resolve } from "node:path";
7
- import { promisify, stripVTControlCharacters, styleText } from "node:util";
6
+ import { AGENTS, COMMANDS, Walker, coerceVersion, color, constructCommand, createPrinter, dedent, defineEnv, detect, downloadJson, fileExists, isKit3, isRangeWithin, isVersionUnsupportedBelow, js, loadFile, loadPackageJson, minVersion, minimizeDiff, parse, pnpm, resolveCommand, resolveCommandArray, resolveLibPrefix, sanitizeName, saveFile, svelte, svelteConfig, transforms } from "@sveltejs/sv-utils";
8
7
  import V, { cwd, stdin, stdout } from "node:process";
9
- import * as b$1 from "node:readline";
8
+ import { promisify, stripVTControlCharacters, styleText } from "node:util";
9
+ import * as b from "node:readline";
10
10
  import G from "node:readline";
11
11
  import { ReadStream } from "node:tty";
12
12
  import { fileURLToPath } from "node:url";
@@ -15,9 +15,9 @@ import { pipeline } from "node:stream/promises";
15
15
  import { PassThrough, Writable } from "node:stream";
16
16
  import { EventEmitter } from "node:events";
17
17
  import crypto from "node:crypto";
18
- import * as fsp from "node:fs/promises";
19
18
  import { cpus, platform } from "node:os";
20
19
  import { createGunzip } from "node:zlib";
20
+ import * as fsp from "node:fs/promises";
21
21
  //#region \0rolldown/runtime.js
22
22
  var __create = Object.create;
23
23
  var __defProp = Object.defineProperty;
@@ -236,7 +236,7 @@ const stringVisibleTrimSpacesRight = (string) => {
236
236
  if (last === words.length) return string;
237
237
  return words.slice(0, last).join(" ") + words.slice(last).join("");
238
238
  };
239
- const exec$1 = (string, columns, options = {}) => {
239
+ const exec$2 = (string, columns, options = {}) => {
240
240
  if (options.trim !== false && string.trim() === "") return "";
241
241
  let returnValue = "";
242
242
  let escapeCode;
@@ -321,7 +321,7 @@ const exec$1 = (string, columns, options = {}) => {
321
321
  };
322
322
  const CRLF_OR_LF = /\r?\n/;
323
323
  function wrapAnsi(string, columns, options) {
324
- return String(string).normalize().split(CRLF_OR_LF).map((line) => exec$1(line, columns, options)).join("\n");
324
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec$2(line, columns, options)).join("\n");
325
325
  }
326
326
  //#endregion
327
327
  //#region ../../node_modules/.pnpm/@clack+core@1.4.0/node_modules/@clack/core/dist/index.mjs
@@ -382,7 +382,7 @@ function f(r, t, s) {
382
382
  const e = r + t, i = Math.max(s.length - 1, 0), n = e < 0 ? i : e > i ? 0 : e;
383
383
  return s[n].disabled ? f(n, t < 0 ? -1 : 1, s) : n;
384
384
  }
385
- const h$1 = {
385
+ const h = {
386
386
  actions: /* @__PURE__ */ new Set([
387
387
  "up",
388
388
  "down",
@@ -429,9 +429,9 @@ const h$1 = {
429
429
  }
430
430
  }
431
431
  };
432
- function C$1(r, t) {
433
- if (typeof r == "string") return h$1.aliases.get(r) === t;
434
- for (const s of r) if (s !== void 0 && C$1(s, t)) return !0;
432
+ function C(r, t) {
433
+ if (typeof r == "string") return h.aliases.get(r) === t;
434
+ for (const s of r) if (s !== void 0 && C(s, t)) return !0;
435
435
  return !1;
436
436
  }
437
437
  function Y$1(r, t) {
@@ -447,24 +447,24 @@ function Y$1(r, t) {
447
447
  numLines: i
448
448
  };
449
449
  }
450
- const q$1 = globalThis.process.platform.startsWith("win"), k$1 = Symbol("clack:cancel");
451
- function R$2(r) {
452
- return r === k$1;
450
+ const q$1 = globalThis.process.platform.startsWith("win"), k = Symbol("clack:cancel");
451
+ function R$1(r) {
452
+ return r === k;
453
453
  }
454
- function w$2(r, t) {
454
+ function w$1(r, t) {
455
455
  const s = r;
456
456
  s.isTTY && s.setRawMode(t);
457
457
  }
458
458
  function W({ input: r = stdin, output: t = stdout, overwrite: s = !0, hideCursor: e = !0 } = {}) {
459
- const i = b$1.createInterface({
459
+ const i = b.createInterface({
460
460
  input: r,
461
461
  output: t,
462
462
  prompt: "",
463
463
  tabSize: 1
464
464
  });
465
- b$1.emitKeypressEvents(r, i), r instanceof ReadStream && r.isTTY && r.setRawMode(!0);
465
+ b.emitKeypressEvents(r, i), r instanceof ReadStream && r.isTTY && r.setRawMode(!0);
466
466
  const n = (o, { name: u, sequence: a }) => {
467
- if (C$1([
467
+ if (C([
468
468
  String(o),
469
469
  u,
470
470
  a
@@ -474,8 +474,8 @@ function W({ input: r = stdin, output: t = stdout, overwrite: s = !0, hideCursor
474
474
  }
475
475
  if (!s) return;
476
476
  const c = u === "return" ? 0 : -1, y = u === "return" ? -1 : 0;
477
- b$1.moveCursor(t, c, y, () => {
478
- b$1.clearLine(t, 1, () => {
477
+ b.moveCursor(t, c, y, () => {
478
+ b.clearLine(t, 1, () => {
479
479
  r.once("keypress", n);
480
480
  });
481
481
  });
@@ -484,9 +484,9 @@ function W({ input: r = stdin, output: t = stdout, overwrite: s = !0, hideCursor
484
484
  r.off("keypress", n), e && t.write(import_src.cursor.show), r instanceof ReadStream && r.isTTY && !q$1 && r.setRawMode(!1), i.terminal = !1, i.close();
485
485
  };
486
486
  }
487
- const A$1 = (r) => "columns" in r && typeof r.columns == "number" ? r.columns : 80, L$1 = (r) => "rows" in r && typeof r.rows == "number" ? r.rows : 20;
488
- function B$1(r, t, s, e = s, i = s, n) {
489
- return wrapAnsi(t, A$1(r ?? stdout) - s.length, {
487
+ const A = (r) => "columns" in r && typeof r.columns == "number" ? r.columns : 80, L = (r) => "rows" in r && typeof r.rows == "number" ? r.rows : 20;
488
+ function B(r, t, s, e = s, i = s, n) {
489
+ return wrapAnsi(t, A(r ?? stdout) - s.length, {
490
490
  hard: !0,
491
491
  trim: !1
492
492
  }).split(`
@@ -496,7 +496,7 @@ function B$1(r, t, s, e = s, i = s, n) {
496
496
  }).join(`
497
497
  `);
498
498
  }
499
- function P$2(r, t) {
499
+ function P$1(r, t) {
500
500
  if ("~standard" in r) {
501
501
  const s = r["~standard"].validate(t);
502
502
  if (s instanceof Promise) throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
@@ -547,7 +547,7 @@ var m = class {
547
547
  prompt() {
548
548
  return new Promise((t) => {
549
549
  if (this._abortSignal) {
550
- if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(k$1);
550
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(k);
551
551
  this._abortSignal.addEventListener("abort", () => {
552
552
  this.state = "cancel", this.close();
553
553
  }, { once: !0 });
@@ -558,10 +558,10 @@ var m = class {
558
558
  prompt: "",
559
559
  escapeCodeTimeout: 50,
560
560
  terminal: !0
561
- }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), w$2(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
562
- this.output.write(import_src.cursor.show), this.output.off("resize", this.render), w$2(this.input, !1), t(this.value);
561
+ }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), w$1(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
562
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), w$1(this.input, !1), t(this.value);
563
563
  }), this.once("cancel", () => {
564
- this.output.write(import_src.cursor.show), this.output.off("resize", this.render), w$2(this.input, !1), t(k$1);
564
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), w$1(this.input, !1), t(k);
565
565
  });
566
566
  });
567
567
  }
@@ -587,14 +587,14 @@ var m = class {
587
587
  if (this._track && s.name !== "return" && (s.name && this._isActionKey(t, s) && this.rl?.write(null, {
588
588
  ctrl: !0,
589
589
  name: "h"
590
- }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && h$1.aliases.has(s.name) && this.emit("cursor", h$1.aliases.get(s.name)), h$1.actions.has(s.name) && this.emit("cursor", s.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, s), s?.name === "return" && this._shouldSubmit(t, s)) {
590
+ }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && h.aliases.has(s.name) && this.emit("cursor", h.aliases.get(s.name)), h.actions.has(s.name) && this.emit("cursor", s.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, s), s?.name === "return" && this._shouldSubmit(t, s)) {
591
591
  if (this.opts.validate) {
592
- const e = P$2(this.opts.validate, this.value);
592
+ const e = P$1(this.opts.validate, this.value);
593
593
  e && (this.error = e instanceof Error ? e.message : e, this.state = "error", this.rl?.write(this.userInput));
594
594
  }
595
595
  this.state !== "error" && (this.state = "submit");
596
596
  }
597
- C$1([
597
+ C([
598
598
  t,
599
599
  s?.name,
600
600
  s?.sequence
@@ -602,7 +602,7 @@ var m = class {
602
602
  }
603
603
  close() {
604
604
  this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
605
- `), w$2(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
605
+ `), w$1(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
606
606
  }
607
607
  restoreCursor() {
608
608
  const t = wrapAnsi(this._prevFrame, process.stdout.columns, {
@@ -620,7 +620,7 @@ var m = class {
620
620
  if (t !== this._prevFrame) {
621
621
  if (this.state === "initial") this.output.write(import_src.cursor.hide);
622
622
  else {
623
- const s = Y$1(this._prevFrame, t), e = L$1(this.output);
623
+ const s = Y$1(this._prevFrame, t), e = L(this.output);
624
624
  if (this.restoreCursor(), s) {
625
625
  const i = Math.max(0, s.numLinesAfter - e), n = Math.max(0, s.numLinesBefore - e);
626
626
  let o = s.lines.find((u) => u >= i);
@@ -771,7 +771,7 @@ var ct$1 = class extends m {
771
771
  function se() {
772
772
  return V.platform !== "win32" ? V.env.TERM !== "linux" : !!V.env.CI || !!V.env.WT_SESSION || !!V.env.TERMINUS_SUBLIME || V.env.ConEmuTask === "{cmd::Cmder}" || V.env.TERM_PROGRAM === "Terminus-Sublime" || V.env.TERM_PROGRAM === "vscode" || V.env.TERM === "xterm-256color" || V.env.TERM === "alacritty" || V.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
773
773
  }
774
- const tt = se(), at = () => process.env.CI === "true", Tt = (t) => t.isTTY === !0, w$1 = (t, i) => tt ? t : i, _t = w$1("◆", "*"), ut = w$1("■", "x"), lt = w$1("▲", "x"), H = w$1("◇", "o"), ct = w$1("┌", "T"), $ = w$1("│", "|"), x$1 = w$1("└", "—"), z$1 = w$1("●", ">"), U = w$1("○", " "), et = w$1("◻", "[•]"), K = w$1("◼", "[+]"), Y = w$1("◻", "[ ]"), st = w$1("─", "-"), $t = w$1("╮", "+"), Mt = w$1("├", "+"), dt = w$1("╯", "+"), ht = w$1("╰", "+"), pt = w$1("●", "•"), mt = w$1("◆", "*"), gt = w$1("▲", "!"), yt = w$1("■", "x"), P$1 = (t) => {
774
+ const tt = se(), at = () => process.env.CI === "true", Tt = (t) => t.isTTY === !0, w = (t, i) => tt ? t : i, _t = w("◆", "*"), ut = w("■", "x"), lt = w("▲", "x"), H = w("◇", "o"), ct = w("┌", "T"), $ = w("│", "|"), x$1 = w("└", "—"), z = w("●", ">"), U = w("○", " "), et = w("◻", "[•]"), K = w("◼", "[+]"), Y = w("◻", "[ ]"), st = w("─", "-"), $t = w("╮", "+"), Mt = w("├", "+"), dt = w("╯", "+"), ht = w("╰", "+"), pt = w("●", "•"), mt = w("◆", "*"), gt = w("▲", "!"), yt = w("■", "x"), P = (t) => {
775
775
  switch (t) {
776
776
  case "initial":
777
777
  case "active": return styleText("cyan", _t);
@@ -795,8 +795,8 @@ const tt = se(), at = () => process.env.CI === "true", Tt = (t) => t.isTTY === !
795
795
  lineCount: a,
796
796
  removals: c
797
797
  };
798
- }, F$1 = ({ cursor: t, options: i, style: s, output: r = process.stdout, maxItems: u = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: a = 4 }) => {
799
- const c = A$1(r) - n, o = L$1(r), l = styleText("dim", "..."), d = Math.max(o - a, 0), g = Math.max(Math.min(u, d), 5);
798
+ }, F = ({ cursor: t, options: i, style: s, output: r = process.stdout, maxItems: u = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: a = 4 }) => {
799
+ const c = A(r) - n, o = L(r), l = styleText("dim", "..."), d = Math.max(o - a, 0), g = Math.max(Math.min(u, d), 5);
800
800
  let p = 0;
801
801
  t >= g - 3 && (p = Math.max(Math.min(t - g + 3, i.length - g), 0));
802
802
  let f = g < i.length && p > 0, h = g < i.length && p + g < i.length;
@@ -834,7 +834,7 @@ const le = (t) => {
834
834
  output: t.output,
835
835
  initialValue: t.initialValue ?? !0,
836
836
  render() {
837
- const r = t.withGuide ?? h$1.withGuide, u = `${P$1(this.state)} `, n = r ? `${styleText("gray", $)} ` : "", a = B$1(t.output, t.message, n, u), c = `${r ? `${styleText("gray", $)}
837
+ const r = t.withGuide ?? h.withGuide, u = `${P(this.state)} `, n = r ? `${styleText("gray", $)} ` : "", a = B(t.output, t.message, n, u), c = `${r ? `${styleText("gray", $)}
838
838
  ` : ""}${a}
839
839
  `, o = this.value ? i : s;
840
840
  switch (this.state) {
@@ -843,9 +843,9 @@ const le = (t) => {
843
843
  ${styleText("gray", $)}` : ""}`;
844
844
  default: {
845
845
  const l = r ? `${styleText("cyan", $)} ` : "", d = r ? styleText("cyan", x$1) : "";
846
- return `${c}${l}${this.value ? `${styleText("green", z$1)} ${i}` : `${styleText("dim", U)} ${styleText("dim", i)}`}${t.vertical ? r ? `
846
+ return `${c}${l}${this.value ? `${styleText("green", z)} ${i}` : `${styleText("dim", U)} ${styleText("dim", i)}`}${t.vertical ? r ? `
847
847
  ${styleText("cyan", $)} ` : `
848
- ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", U)} ${styleText("dim", s)}` : `${styleText("green", z$1)} ${s}`}
848
+ ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", U)} ${styleText("dim", s)}` : `${styleText("green", z)} ${s}`}
849
849
  ${d}
850
850
  `;
851
851
  }
@@ -858,16 +858,16 @@ ${d}
858
858
  const n = t[u], a = await n({ results: s })?.catch((c) => {
859
859
  throw c;
860
860
  });
861
- if (typeof i?.onCancel == "function" && R$2(a)) {
861
+ if (typeof i?.onCancel == "function" && R$1(a)) {
862
862
  s[u] = "canceled", i.onCancel({ results: s });
863
863
  continue;
864
864
  }
865
865
  s[u] = a;
866
866
  }
867
867
  return s;
868
- }, R$1 = {
868
+ }, R = {
869
869
  message: (t = [], { symbol: i = styleText("gray", $), secondarySymbol: s = styleText("gray", $), output: r = process.stdout, spacing: u = 1, withGuide: n } = {}) => {
870
- const a = [], c = n ?? h$1.withGuide, o = c ? s : "", l = c ? `${i} ` : "", d = c ? `${s} ` : "";
870
+ const a = [], c = n ?? h.withGuide, o = c ? s : "", l = c ? `${i} ` : "", d = c ? `${s} ` : "";
871
871
  for (let p = 0; p < u; p++) a.push(o);
872
872
  const g = Array.isArray(t) ? t : t.split(`
873
873
  `);
@@ -881,49 +881,49 @@ ${d}
881
881
  `);
882
882
  },
883
883
  info: (t, i) => {
884
- R$1.message(t, {
884
+ R.message(t, {
885
885
  ...i,
886
886
  symbol: styleText("blue", pt)
887
887
  });
888
888
  },
889
889
  success: (t, i) => {
890
- R$1.message(t, {
890
+ R.message(t, {
891
891
  ...i,
892
892
  symbol: styleText("green", mt)
893
893
  });
894
894
  },
895
895
  step: (t, i) => {
896
- R$1.message(t, {
896
+ R.message(t, {
897
897
  ...i,
898
898
  symbol: styleText("green", H)
899
899
  });
900
900
  },
901
901
  warn: (t, i) => {
902
- R$1.message(t, {
902
+ R.message(t, {
903
903
  ...i,
904
904
  symbol: styleText("yellow", gt)
905
905
  });
906
906
  },
907
907
  warning: (t, i) => {
908
- R$1.warn(t, i);
908
+ R.warn(t, i);
909
909
  },
910
910
  error: (t, i) => {
911
- R$1.message(t, {
911
+ R.message(t, {
912
912
  ...i,
913
913
  symbol: styleText("red", yt)
914
914
  });
915
915
  }
916
916
  }, ge = (t = "", i) => {
917
- const s = i?.output ?? process.stdout, r = i?.withGuide ?? h$1.withGuide ? `${styleText("gray", x$1)} ` : "";
917
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${styleText("gray", x$1)} ` : "";
918
918
  s.write(`${r}${styleText("red", t)}
919
919
 
920
920
  `);
921
921
  }, ye = (t = "", i) => {
922
- const s = i?.output ?? process.stdout, r = i?.withGuide ?? h$1.withGuide ? `${styleText("gray", ct)} ` : "";
922
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${styleText("gray", ct)} ` : "";
923
923
  s.write(`${r}${t}
924
924
  `);
925
925
  }, fe = (t = "", i) => {
926
- const s = i?.output ?? process.stdout, r = i?.withGuide ?? h$1.withGuide ? `${styleText("gray", $)}
926
+ const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${styleText("gray", $)}
927
927
  ${styleText("gray", x$1)} ` : "";
928
928
  s.write(`${r}${t}
929
929
 
@@ -952,7 +952,7 @@ ${styleText("reset", styleText("dim", `Press ${styleText([
952
952
  ], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
953
953
  },
954
954
  render() {
955
- const r = t.withGuide ?? h$1.withGuide, u = B$1(t.output, t.message, r ? `${ft(this.state)} ` : "", `${P$1(this.state)} `), n = `${r ? `${styleText("gray", $)}
955
+ const r = t.withGuide ?? h.withGuide, u = B(t.output, t.message, r ? `${ft(this.state)} ` : "", `${P(this.state)} `), n = `${r ? `${styleText("gray", $)}
956
956
  ` : ""}${u}
957
957
  `, a = this.value ?? [], c = (o, l) => {
958
958
  if (o.disabled) return i(o, "disabled");
@@ -962,12 +962,12 @@ ${styleText("reset", styleText("dim", `Press ${styleText([
962
962
  switch (this.state) {
963
963
  case "submit": {
964
964
  const o = this.options.filter(({ value: d }) => a.includes(d)).map((d) => i(d, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none");
965
- return `${n}${B$1(t.output, o, r ? `${styleText("gray", $)} ` : "")}`;
965
+ return `${n}${B(t.output, o, r ? `${styleText("gray", $)} ` : "")}`;
966
966
  }
967
967
  case "cancel": {
968
968
  const o = this.options.filter(({ value: d }) => a.includes(d)).map((d) => i(d, "cancelled")).join(styleText("dim", ", "));
969
969
  if (o.trim() === "") return `${n}${styleText("gray", $)}`;
970
- return `${n}${B$1(t.output, o, r ? `${styleText("gray", $)} ` : "")}${r ? `
970
+ return `${n}${B(t.output, o, r ? `${styleText("gray", $)} ` : "")}${r ? `
971
971
  ${styleText("gray", $)}` : ""}`;
972
972
  }
973
973
  case "error": {
@@ -976,7 +976,7 @@ ${styleText("gray", $)}` : ""}`;
976
976
  `), d = n.split(`
977
977
  `).length, g = l.split(`
978
978
  `).length + 1;
979
- return `${n}${o}${F$1({
979
+ return `${n}${o}${F({
980
980
  output: t.output,
981
981
  options: this.options,
982
982
  cursor: this.cursor,
@@ -992,7 +992,7 @@ ${l}
992
992
  default: {
993
993
  const o = r ? `${styleText("cyan", $)} ` : "", l = n.split(`
994
994
  `).length, d = r ? 2 : 1;
995
- return `${n}${o}${F$1({
995
+ return `${n}${o}${F({
996
996
  output: t.output,
997
997
  options: this.options,
998
998
  cursor: this.cursor,
@@ -1016,9 +1016,9 @@ ${r ? styleText("cyan", x$1) : ""}
1016
1016
  `), n = u.reduce((o, l) => Math.max(fastStringWidth(l), o), 0);
1017
1017
  return wrapAnsi(t, i - (u.map(s).reduce((o, l) => Math.max(fastStringWidth(l), o), 0) - n), r);
1018
1018
  }, Ce = (t = "", i = "", s) => {
1019
- const r = s?.output ?? V.stdout, u = s?.withGuide ?? h$1.withGuide, n = s?.format ?? be, a = [
1019
+ const r = s?.output ?? V.stdout, u = s?.withGuide ?? h.withGuide, n = s?.format ?? be, a = [
1020
1020
  "",
1021
- ...Se(t, A$1(r) - 6, n).split(`
1021
+ ...Se(t, A(r) - 6, n).split(`
1022
1022
  `).map(n),
1023
1023
  ""
1024
1024
  ], c = fastStringWidth(i), o = Math.max(a.reduce((p, f) => {
@@ -1043,9 +1043,9 @@ ${styleText("gray", g + st.repeat(o + 2) + dt)}
1043
1043
  "0"
1044
1044
  ], delay: a = tt ? 80 : 120, signal: c, ...o } = {}) => {
1045
1045
  const l = at();
1046
- let d, g, p = !1, f = !1, h = "", I, m = performance.now();
1047
- const y = A$1(s), v = o?.styleFrame ?? _e, C = (_) => {
1048
- const A = _ > 1 ? u ?? h$1.messages.error : r ?? h$1.messages.cancel;
1046
+ let d, g, p = !1, f = !1, h$2 = "", I, m = performance.now();
1047
+ const y = A(s), v = o?.styleFrame ?? _e, C = (_) => {
1048
+ const A = _ > 1 ? u ?? h.messages.error : r ?? h.messages.cancel;
1049
1049
  f = _ === 1, p && (W$1(A, _), f && typeof i == "function" && i());
1050
1050
  }, S = () => C(2), b = () => C(1), G = () => {
1051
1051
  process.on("uncaughtExceptionMonitor", S), process.on("unhandledRejection", S), process.on("SIGINT", b), process.on("SIGTERM", b), process.on("exit", C), c && c.addEventListener("abort", b);
@@ -1064,20 +1064,20 @@ ${styleText("gray", g + st.repeat(o + 2) + dt)}
1064
1064
  }, O = (_) => _.replace(/\.+$/, ""), j = (_) => {
1065
1065
  const A = (performance.now() - _) / 1e3, L = Math.floor(A / 60), D = Math.floor(A % 60);
1066
1066
  return L > 0 ? `[${L}m ${D}s]` : `[${D}s]`;
1067
- }, k = o.withGuide ?? h$1.withGuide, rt = (_ = "") => {
1068
- p = !0, d = W({ output: s }), h = O(_), m = performance.now(), k && s.write(`${styleText("gray", $)}
1067
+ }, k = o.withGuide ?? h.withGuide, rt = (_ = "") => {
1068
+ p = !0, d = W({ output: s }), h$2 = O(_), m = performance.now(), k && s.write(`${styleText("gray", $)}
1069
1069
  `);
1070
1070
  let A = 0, L = 0;
1071
1071
  G(), g = setInterval(() => {
1072
- if (l && h === I) return;
1073
- N(), I = h;
1072
+ if (l && h$2 === I) return;
1073
+ N(), I = h$2;
1074
1074
  const D = v(n[A]);
1075
1075
  let Z;
1076
- if (l) Z = `${D} ${h}...`;
1077
- else if (t === "timer") Z = `${D} ${h} ${j(m)}`;
1076
+ if (l) Z = `${D} ${h$2}...`;
1077
+ else if (t === "timer") Z = `${D} ${h$2} ${j(m)}`;
1078
1078
  else {
1079
1079
  const Lt = ".".repeat(Math.floor(L)).slice(0, 3);
1080
- Z = `${D} ${h}${Lt}`;
1080
+ Z = `${D} ${h$2}${Lt}`;
1081
1081
  }
1082
1082
  const kt = wrapAnsi(Z, y, {
1083
1083
  hard: !0,
@@ -1089,15 +1089,15 @@ ${styleText("gray", g + st.repeat(o + 2) + dt)}
1089
1089
  if (!p) return;
1090
1090
  p = !1, clearInterval(g), N();
1091
1091
  const D = A === 0 ? styleText("green", H) : A === 1 ? styleText("red", ut) : styleText("red", lt);
1092
- h = _ ?? h, L || (t === "timer" ? s.write(`${D} ${h} ${j(m)}
1093
- `) : s.write(`${D} ${h}
1092
+ h$2 = _ ?? h$2, L || (t === "timer" ? s.write(`${D} ${h$2} ${j(m)}
1093
+ `) : s.write(`${D} ${h$2}
1094
1094
  `)), M(), d();
1095
1095
  };
1096
1096
  return {
1097
1097
  start: rt,
1098
1098
  stop: (_ = "") => W$1(_, 0),
1099
1099
  message: (_ = "") => {
1100
- h = O(_ ?? h);
1100
+ h$2 = O(_ ?? h$2);
1101
1101
  },
1102
1102
  cancel: (_ = "") => W$1(_, 1),
1103
1103
  error: (_ = "") => W$1(_, 2),
@@ -1115,7 +1115,7 @@ ${styleText("gray", g + st.repeat(o + 2) + dt)}
1115
1115
  switch (r) {
1116
1116
  case "disabled": return `${styleText("gray", U)} ${it(u, (n) => styleText("gray", n))}${s.hint ? ` ${styleText("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
1117
1117
  case "selected": return `${it(u, (n) => styleText("dim", n))}`;
1118
- case "active": return `${styleText("green", z$1)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
1118
+ case "active": return `${styleText("green", z)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
1119
1119
  case "cancelled": return `${it(u, (n) => styleText(["strikethrough", "dim"], n))}`;
1120
1120
  default: return `${styleText("dim", U)} ${it(u, (n) => styleText("dim", n))}`;
1121
1121
  }
@@ -1127,23 +1127,23 @@ ${styleText("gray", g + st.repeat(o + 2) + dt)}
1127
1127
  output: t.output,
1128
1128
  initialValue: t.initialValue,
1129
1129
  render() {
1130
- const s = t.withGuide ?? h$1.withGuide, r = `${P$1(this.state)} `, u = `${ft(this.state)} `, n = B$1(t.output, t.message, u, r), a = `${s ? `${styleText("gray", $)}
1130
+ const s = t.withGuide ?? h.withGuide, r = `${P(this.state)} `, u = `${ft(this.state)} `, n = B(t.output, t.message, u, r), a = `${s ? `${styleText("gray", $)}
1131
1131
  ` : ""}${n}
1132
1132
  `;
1133
1133
  switch (this.state) {
1134
1134
  case "submit": {
1135
1135
  const c = s ? `${styleText("gray", $)} ` : "";
1136
- return `${a}${B$1(t.output, i(this.options[this.cursor], "selected"), c)}`;
1136
+ return `${a}${B(t.output, i(this.options[this.cursor], "selected"), c)}`;
1137
1137
  }
1138
1138
  case "cancel": {
1139
1139
  const c = s ? `${styleText("gray", $)} ` : "";
1140
- return `${a}${B$1(t.output, i(this.options[this.cursor], "cancelled"), c)}${s ? `
1140
+ return `${a}${B(t.output, i(this.options[this.cursor], "cancelled"), c)}${s ? `
1141
1141
  ${styleText("gray", $)}` : ""}`;
1142
1142
  }
1143
1143
  default: {
1144
1144
  const c = s ? `${styleText("cyan", $)} ` : "", o = s ? styleText("cyan", x$1) : "", l = a.split(`
1145
1145
  `).length, d = s ? 2 : 1;
1146
- return `${a}${c}${F$1({
1146
+ return `${a}${c}${F({
1147
1147
  output: t.output,
1148
1148
  cursor: this.cursor,
1149
1149
  options: this.options,
@@ -1183,7 +1183,7 @@ ${Bt}${r.trimStart()}`), s = 3 + stripVTControlCharacters(r.trimStart()).length)
1183
1183
  warning: (t) => q.warn(t),
1184
1184
  error: (t) => q.message(t, { symbol: styleText("red", yt) })
1185
1185
  }, Oe = (t) => t.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, ""), Pe = (t) => {
1186
- const i = t.output ?? process.stdout, s = A$1(i), r = styleText("gray", $), u = t.spacing ?? 1, n = 3, a = t.retainLog === !0, c = !at() && Tt(i);
1186
+ const i = t.output ?? process.stdout, s = A(i), r = styleText("gray", $), u = t.spacing ?? 1, n = 3, a = t.retainLog === !0, c = !at() && Tt(i);
1187
1187
  i.write(`${r}
1188
1188
  `), i.write(`${styleText("green", H)} ${t.title}
1189
1189
  `);
@@ -1212,13 +1212,13 @@ ${v.header}`);
1212
1212
  }, g = (m, y, v) => {
1213
1213
  const C = v ? `${m.full}
1214
1214
  ${m.value}` : m.value;
1215
- m.header !== void 0 && m.header !== "" && R$1.message(m.header.split(`
1215
+ m.header !== void 0 && m.header !== "" && R.message(m.header.split(`
1216
1216
  `).map((S) => styleText("bold", S)), {
1217
1217
  output: i,
1218
1218
  secondarySymbol: r,
1219
1219
  symbol: r,
1220
1220
  spacing: 0
1221
- }), R$1.message(C.split(`
1221
+ }), R.message(C.split(`
1222
1222
  `).map((S) => styleText("dim", S)), {
1223
1223
  output: i,
1224
1224
  secondarySymbol: r,
@@ -1246,11 +1246,11 @@ ${m.value}` : m.value;
1246
1246
  }
1247
1247
  c && h();
1248
1248
  }, h = () => {
1249
- for (const m of o) m.result ? m.result.status === "error" ? R$1.error(m.result.message, {
1249
+ for (const m of o) m.result ? m.result.status === "error" ? R.error(m.result.message, {
1250
1250
  output: i,
1251
1251
  secondarySymbol: r,
1252
1252
  spacing: 0
1253
- }) : R$1.success(m.result.message, {
1253
+ }) : R.success(m.result.message, {
1254
1254
  output: i,
1255
1255
  secondarySymbol: r,
1256
1256
  spacing: 0
@@ -1287,14 +1287,14 @@ ${m.value}` : m.value;
1287
1287
  };
1288
1288
  },
1289
1289
  error(m, y) {
1290
- d(!0), R$1.error(m, {
1290
+ d(!0), R.error(m, {
1291
1291
  output: i,
1292
1292
  secondarySymbol: r,
1293
1293
  spacing: 1
1294
1294
  }), y?.showLog !== !1 && p(), o.splice(1, o.length - 1), o[0].value = "", o[0].full = "";
1295
1295
  },
1296
1296
  success(m, y) {
1297
- d(!0), R$1.success(m, {
1297
+ d(!0), R.success(m, {
1298
1298
  output: i,
1299
1299
  secondarySymbol: r,
1300
1300
  spacing: 1
@@ -1310,8 +1310,8 @@ ${m.value}` : m.value;
1310
1310
  signal: t.signal,
1311
1311
  input: t.input,
1312
1312
  render() {
1313
- const i = t?.withGuide ?? h$1.withGuide, s = `${`${i ? `${styleText("gray", $)}
1314
- ` : ""}${P$1(this.state)} `}${t.message}
1313
+ const i = t?.withGuide ?? h.withGuide, s = `${`${i ? `${styleText("gray", $)}
1314
+ ` : ""}${P(this.state)} `}${t.message}
1315
1315
  `, r = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
1316
1316
  switch (this.state) {
1317
1317
  case "error": {
@@ -1339,7 +1339,7 @@ ${i ? styleText("cyan", x$1) : ""}
1339
1339
  //#endregion
1340
1340
  //#region package.json
1341
1341
  var name = "sv";
1342
- var version = "1.0.0-next.2";
1342
+ var version = "1.0.0-next.4";
1343
1343
  //#endregion
1344
1344
  //#region src/core/errors.ts
1345
1345
  var UnsupportedError = class extends Error {
@@ -1444,19 +1444,19 @@ async function runCommand(action) {
1444
1444
  try {
1445
1445
  console.log(color.hidden("HINT: Run \"sv --help\" to get the full list of commands, add-ons, and examples to one-shot and skip interactive prompts."));
1446
1446
  ye(`Welcome to the Svelte CLI! ${color.optional(`(v${version})`)}`);
1447
- const minimumVersion = "18.3.0";
1448
- if (isVersionUnsupportedBelow(V.versions.node, minimumVersion)) R$1.warn(`You are using Node.js ${color.error(V.versions.node)}, please upgrade to Node.js ${color.success(minimumVersion)} or higher.`);
1447
+ const minimumVersion = "22.17.0";
1448
+ if (isVersionUnsupportedBelow(V.versions.node, minimumVersion)) R.warn(`You are using Node.js ${color.error(V.versions.node)}, please upgrade to Node.js ${color.success(minimumVersion)} or higher.`);
1449
1449
  await action();
1450
1450
  fe("You're all set!");
1451
1451
  } catch (e) {
1452
1452
  if (e instanceof UnsupportedError) {
1453
1453
  const padding = getPadding(e.reasons.map((r) => r.id));
1454
1454
  const message = e.reasons.map((r) => ` ${r.id.padEnd(padding)} ${color.error(r.reason)}`).join("\n");
1455
- R$1.error(`${e.name}\n\n${message}`);
1456
- R$1.message();
1455
+ R.error(`${e.name}\n\n${message}`);
1456
+ R.message();
1457
1457
  } else if (e instanceof Error) {
1458
- R$1.error(e.stack ?? String(e));
1459
- R$1.message();
1458
+ R.error(e.stack ?? String(e));
1459
+ R.message();
1460
1460
  }
1461
1461
  ge("Operation failed.");
1462
1462
  }
@@ -1488,8 +1488,8 @@ function buildAndLogArgs(agent, command, args, lastArgs = []) {
1488
1488
  if (agent === null || agent === void 0) allArgs.push("--no-install");
1489
1489
  else allArgs.push("--install", agent);
1490
1490
  const message = resolveCommandArray(agent ?? "npm", "execute", [...allArgs, ...lastArgs]).join(" ");
1491
- R$1.message(color.optional(color.dim(`To skip prompts next time, run:`)));
1492
- R$1.info(color.optional(message), { spacing: -1 });
1491
+ R.message(color.optional(color.dim(`To skip prompts next time, run:`)));
1492
+ R.info(color.optional(message), { spacing: -1 });
1493
1493
  return message;
1494
1494
  }
1495
1495
  function updateReadme(projectPath, command) {
@@ -1510,8 +1510,8 @@ ${command}\n\`\`\`
1510
1510
  fs.writeFileSync(readmePath, content);
1511
1511
  }
1512
1512
  function errorAndExit(message) {
1513
- R$1.error(message);
1514
- R$1.message();
1513
+ R.error(message);
1514
+ R.message();
1515
1515
  ge("Operation failed.");
1516
1516
  V.exit(1);
1517
1517
  }
@@ -1571,7 +1571,7 @@ async function runAndValidateVerifications(verifications) {
1571
1571
  message: "Verifications failed. Do you wish to continue?",
1572
1572
  initialValue: false
1573
1573
  });
1574
- if (R$2(force) || !force) {
1574
+ if (R$1(force) || !force) {
1575
1575
  ge("Operation cancelled.");
1576
1576
  V.exit(1);
1577
1577
  }
@@ -1597,8 +1597,8 @@ function replace(contents, kv) {
1597
1597
  }
1598
1598
  function kv(name) {
1599
1599
  return {
1600
- "~SV-PROTOCOL-NAME-TODO~": name.startsWith("@") ? name.split("/")[0] : name,
1601
- "~SV-NAME-TODO~": name
1600
+ "$SV-PROTOCOL-NAME-TODO$": name.startsWith("@") ? name.split("/")[0] : name,
1601
+ "$SV-NAME-TODO$": name
1602
1602
  };
1603
1603
  }
1604
1604
  const withReplaceExtensions = [
@@ -1731,203 +1731,214 @@ function sort_files(files) {
1731
1731
  });
1732
1732
  }
1733
1733
  //#endregion
1734
- //#region ../../node_modules/.pnpm/tinyexec@1.2.4/node_modules/tinyexec/dist/main.mjs
1735
- const h = /^path$/i;
1736
- const g = {
1734
+ //#region ../../node_modules/.pnpm/tinyexec@1.3.0/node_modules/tinyexec/dist/main.mjs
1735
+ const isPathLikePattern = /^path$/i;
1736
+ const defaultEnvPathInfo = {
1737
1737
  key: "PATH",
1738
1738
  value: ""
1739
1739
  };
1740
- function _(e) {
1741
- for (const t in e) {
1742
- if (!Object.prototype.hasOwnProperty.call(e, t) || !h.test(t)) continue;
1743
- const n = e[t];
1744
- if (!n) return g;
1740
+ function getPathFromEnv(env) {
1741
+ for (const key in env) {
1742
+ if (!Object.prototype.hasOwnProperty.call(env, key) || !isPathLikePattern.test(key)) continue;
1743
+ const value = env[key];
1744
+ if (!value) return defaultEnvPathInfo;
1745
1745
  return {
1746
- key: t,
1747
- value: n
1746
+ key,
1747
+ value
1748
1748
  };
1749
1749
  }
1750
- return g;
1750
+ return defaultEnvPathInfo;
1751
1751
  }
1752
- function v(e, t) {
1753
- const n = t.value.split(delimiter);
1754
- const r = [];
1755
- let o = e;
1756
- let c;
1752
+ function addNodeBinToPath(cwd, path) {
1753
+ const parts = path.value.split(delimiter);
1754
+ const nodeBinPaths = [];
1755
+ let currentPath = cwd;
1756
+ let lastPath;
1757
1757
  do {
1758
- r.push(resolve(o, "node_modules", ".bin"));
1759
- c = o;
1760
- o = dirname(o);
1761
- } while (o !== c);
1762
- r.push(dirname(process.execPath));
1763
- const l = r.concat(n).join(delimiter);
1758
+ nodeBinPaths.push(resolve(currentPath, "node_modules", ".bin"));
1759
+ lastPath = currentPath;
1760
+ currentPath = dirname(currentPath);
1761
+ } while (currentPath !== lastPath);
1762
+ nodeBinPaths.push(dirname(process.execPath));
1763
+ const newPath = nodeBinPaths.concat(parts).join(delimiter);
1764
1764
  return {
1765
- key: t.key,
1766
- value: l
1765
+ key: path.key,
1766
+ value: newPath
1767
1767
  };
1768
1768
  }
1769
- function y(e, t, n = true) {
1770
- const r = {
1769
+ function computeEnv(cwd, env, nodePath = true) {
1770
+ const envWithDefault = {
1771
1771
  ...process.env,
1772
- ...t
1772
+ ...env
1773
1773
  };
1774
- if (!n) return r;
1775
- const i = v(e, _(r));
1776
- r[i.key] = i.value;
1777
- return r;
1778
- }
1779
- const b = (e) => {
1780
- let t = e.length;
1781
- const n = new PassThrough();
1782
- const r = () => {
1783
- if (--t === 0) n.end();
1774
+ if (!nodePath) return envWithDefault;
1775
+ const envPathInfo = addNodeBinToPath(cwd, getPathFromEnv(envWithDefault));
1776
+ envWithDefault[envPathInfo.key] = envPathInfo.value;
1777
+ return envWithDefault;
1778
+ }
1779
+ const combineStreams = (streams) => {
1780
+ let streamCount = streams.length;
1781
+ const combined = new PassThrough();
1782
+ const maybeEmitEnd = () => {
1783
+ if (--streamCount === 0) combined.end();
1784
1784
  };
1785
- for (const t of e) pipeline(t, n, { end: false }).then(r).catch(r);
1786
- return n;
1785
+ for (const stream of streams) pipeline(stream, combined, { end: false }).then(maybeEmitEnd).catch(maybeEmitEnd);
1786
+ return combined;
1787
1787
  };
1788
- const x = /([()\][%!^"`<>&|;, *?])/g;
1789
- const S = /^#!\s*(.+)/;
1790
- const C = /\.(?:com|exe)$/i;
1791
- const w = /node_modules[\\/]\.bin[\\/][^\\/]+\.cmd$/i;
1792
- const T = process.platform === "win32";
1793
- const E = [
1788
+ const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
1789
+ const shebangRegExp = /^#!\s*(.+)/;
1790
+ const isWindowsExecutableRegExp = /\.(?:com|exe)$/i;
1791
+ const isNodeModulesCmdRegExp = /node_modules[\\/]\.bin[\\/][^\\/]+\.cmd$/i;
1792
+ const isWindows = process.platform === "win32";
1793
+ const defaultPathExt = [
1794
1794
  ".EXE",
1795
1795
  ".CMD",
1796
1796
  ".BAT",
1797
1797
  ".COM"
1798
1798
  ];
1799
+ const noPathExt = [""];
1799
1800
  /**
1800
1801
  * Normalizes the command and arguments to work cross-platform.
1801
1802
  * On Windows, this basically handles things like shebangs, calling
1802
1803
  * `node_modules/.bin` commands, and escaping meta characters.
1803
1804
  * On other platforms, it just returns the command and arguments as-is.
1804
1805
  */
1805
- function D(e, t = [], n = {}) {
1806
- if (n.shell === true || !T) return {
1807
- command: e,
1808
- args: t,
1809
- options: n
1806
+ function normalizeSpawnCommand(command, args = [], options = {}) {
1807
+ if (options.shell === true || !isWindows) return {
1808
+ command,
1809
+ args,
1810
+ options
1810
1811
  };
1811
- let i = O(e, n);
1812
- let a = null;
1813
- if (i !== null) {
1814
- const e = 150;
1815
- const t = Buffer.alloc(e);
1816
- let n = null;
1812
+ let file = resolveCommand$1(command, options);
1813
+ let shebang = null;
1814
+ if (file !== null) {
1815
+ const size = 150;
1816
+ const buffer = Buffer.alloc(size);
1817
+ let fd = null;
1817
1818
  try {
1818
- n = openSync(i, "r");
1819
- readSync(n, t, 0, e, 0);
1819
+ fd = openSync(file, "r");
1820
+ readSync(fd, buffer, 0, size, 0);
1820
1821
  } catch {} finally {
1821
- if (n !== null) closeSync(n);
1822
- }
1823
- const o = t.toString().match(S);
1824
- if (o !== null) {
1825
- const e = o[1].trim();
1826
- const t = e.indexOf(" ");
1827
- const n = t !== -1 ? e.slice(0, t) : e;
1828
- const i = t !== -1 ? e.slice(t + 1) : "";
1829
- const s = basename(n);
1830
- a = s === "env" ? i || null : s;
1831
- }
1832
- }
1833
- if (a !== null && i !== null) {
1834
- t = [i, ...t];
1835
- e = a;
1836
- i = O(e, n);
1837
- }
1838
- if (i === null || !C.test(i)) {
1839
- const r = i !== null && w.test(i);
1840
- e = normalize(e);
1841
- e = e.replace(x, "^$1");
1842
- t = t.map((e) => {
1843
- e = e.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
1844
- e = e.replace(/(?=(\\+?)?)\1$/, "$1$1");
1845
- e = `"${e}"`;
1846
- e = e.replace(x, "^$1");
1847
- if (r) e = e.replace(x, "^$1");
1848
- return e;
1822
+ if (fd !== null) closeSync(fd);
1823
+ }
1824
+ const match = buffer.toString().match(shebangRegExp);
1825
+ if (match !== null) {
1826
+ const line = match[1].trim();
1827
+ const separatorIndex = line.indexOf(" ");
1828
+ const path = separatorIndex !== -1 ? line.slice(0, separatorIndex) : line;
1829
+ const argument = separatorIndex !== -1 ? line.slice(separatorIndex + 1) : "";
1830
+ const binary = basename(path);
1831
+ shebang = binary === "env" ? argument || null : binary;
1832
+ }
1833
+ }
1834
+ if (shebang !== null && file !== null) {
1835
+ args = [file, ...args];
1836
+ command = shebang;
1837
+ file = resolveCommand$1(command, options);
1838
+ }
1839
+ if (file === null || !isWindowsExecutableRegExp.test(file)) {
1840
+ const needsDoubleEscapeMetaChars = file !== null && isNodeModulesCmdRegExp.test(file);
1841
+ command = normalize(command);
1842
+ command = command.replace(metaCharsRegExp, "^$1");
1843
+ args = args.map((arg) => {
1844
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
1845
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
1846
+ arg = `"${arg}"`;
1847
+ arg = arg.replace(metaCharsRegExp, "^$1");
1848
+ if (needsDoubleEscapeMetaChars) arg = arg.replace(metaCharsRegExp, "^$1");
1849
+ return arg;
1849
1850
  });
1850
- t = [
1851
+ args = [
1851
1852
  "/d",
1852
1853
  "/s",
1853
1854
  "/c",
1854
- `"${[e, ...t].join(" ")}"`
1855
+ `"${[command, ...args].join(" ")}"`
1855
1856
  ];
1856
- e = n.env?.comspec ?? "cmd.exe";
1857
- n = {
1858
- ...n,
1857
+ command = options.env?.comspec ?? "cmd.exe";
1858
+ options = {
1859
+ ...options,
1859
1860
  windowsVerbatimArguments: true
1860
1861
  };
1861
1862
  }
1862
1863
  return {
1863
- command: e,
1864
- args: t,
1865
- options: n
1864
+ command,
1865
+ args,
1866
+ options
1866
1867
  };
1867
1868
  }
1868
1869
  /**
1869
1870
  * Resolves the command to an absolute path if possible.
1870
1871
  * Handles things like traversing PATH and adding extensions from PATHEXT
1871
1872
  */
1872
- function O(e, t) {
1873
- const r = (t.cwd ?? cwd()).toString();
1874
- const a = t.env ?? process.env;
1875
- const o = _(a).value;
1876
- const c = e.includes("/") || e.includes("\\") ? [""] : [r, ...o.split(delimiter)];
1877
- const l = a.PATHEXT ? a.PATHEXT.split(delimiter) : E;
1878
- if (e.includes(".") && l[0] !== "") l.unshift("");
1879
- for (const t of c) {
1880
- const n = resolve(r, t.startsWith("\"") && t.endsWith("\"") && t.length > 1 ? t.slice(1, -1) : t, e);
1881
- for (const e of l) {
1882
- const t = n + e;
1873
+ function resolveCommand$1(command, options) {
1874
+ const cwd$3 = (options.cwd ?? cwd()).toString();
1875
+ const env = options.env ?? process.env;
1876
+ const PATH = getPathFromEnv(env).value;
1877
+ const pathEnv = command.includes("/") || command.includes("\\") ? [""] : [cwd$3, ...PATH.split(delimiter)];
1878
+ let pathExt = env.PATHEXT ? env.PATHEXT.split(delimiter) : defaultPathExt;
1879
+ if (command.includes(".") && pathExt[0] !== "") pathExt = ["", ...pathExt];
1880
+ for (const extensions of [pathExt, noPathExt]) for (const path of pathEnv) {
1881
+ const dest = resolve(cwd$3, path.startsWith("\"") && path.endsWith("\"") && path.length > 1 ? path.slice(1, -1) : path, command);
1882
+ for (const ext of extensions) {
1883
+ const destWithExt = dest + ext;
1883
1884
  try {
1884
- if (statSync(t).isFile()) return t;
1885
+ if (statSync(destWithExt).isFile()) return destWithExt;
1885
1886
  } catch {}
1886
1887
  }
1887
1888
  }
1888
1889
  return null;
1889
1890
  }
1890
- var k = class extends Error {
1891
+ var NonZeroExitError = class extends Error {
1891
1892
  result;
1892
1893
  output;
1893
- get exitCode() {
1894
- if (this.result.exitCode !== null) return this.result.exitCode;
1895
- }
1896
- constructor(e, t) {
1897
- super(`Process exited with non-zero status (${e.exitCode})`);
1898
- this.result = e;
1899
- this.output = t;
1894
+ exitCode;
1895
+ get signalCode() {
1896
+ return this.result.signalCode;
1897
+ }
1898
+ constructor(result, output, command, args) {
1899
+ let target = "The process";
1900
+ if (command) target = `The command \`${args?.length ? `${command} ${args.map((a) => /[ "'`()]/.test(a) ? JSON.stringify(a) : a).join(" ")}` : command}\``;
1901
+ const exitCode = result.exitCode ?? 1;
1902
+ super(result.signalCode !== null ? `${target} was killed by the signal ${result.signalCode}` : `${target} exited with a non-zero status (${exitCode})`);
1903
+ this.result = result;
1904
+ this.output = output;
1905
+ this.exitCode = exitCode;
1906
+ Object.defineProperty(this, "result", {
1907
+ enumerable: false,
1908
+ writable: false,
1909
+ configurable: false
1910
+ });
1900
1911
  }
1901
1912
  };
1902
- const A = /\r?\n/;
1903
- const j = {
1913
+ const LINE_SEPARATOR_REGEX = /\r?\n/;
1914
+ const defaultOptions = {
1904
1915
  timeout: void 0,
1905
1916
  persist: false
1906
1917
  };
1907
- const M = { timeout: void 0 };
1908
- const N = { windowsHide: true };
1909
- function P(e) {
1910
- const t = new AbortController();
1911
- for (const n of e) {
1912
- if (n.aborted) {
1913
- t.abort();
1914
- return n;
1915
- }
1916
- const e = () => {
1917
- t.abort(n.reason);
1918
+ const defaultSyncOptions = { timeout: void 0 };
1919
+ const defaultNodeOptions = { windowsHide: true };
1920
+ function combineSignals(signals) {
1921
+ const controller = new AbortController();
1922
+ for (const signal of signals) {
1923
+ if (signal.aborted) {
1924
+ controller.abort();
1925
+ return signal;
1926
+ }
1927
+ const onAbort = () => {
1928
+ controller.abort(signal.reason);
1918
1929
  };
1919
- n.addEventListener("abort", e, { signal: t.signal });
1930
+ signal.addEventListener("abort", onAbort, { signal: controller.signal });
1920
1931
  }
1921
- return t.signal;
1932
+ return controller.signal;
1922
1933
  }
1923
- async function F(e) {
1924
- let t = "";
1934
+ async function readStream(stream) {
1935
+ let output = "";
1925
1936
  try {
1926
- for await (const n of e) t += n.toString();
1937
+ for await (const chunk of stream) output += chunk.toString();
1927
1938
  } catch {}
1928
- return t;
1939
+ return output;
1929
1940
  }
1930
- var I = class {
1941
+ var ExecProcess = class {
1931
1942
  _process;
1932
1943
  _aborted = false;
1933
1944
  _options;
@@ -1945,19 +1956,22 @@ var I = class {
1945
1956
  get exitCode() {
1946
1957
  if (this._process && this._process.exitCode !== null) return this._process.exitCode;
1947
1958
  }
1948
- constructor(e, t, n) {
1959
+ get signalCode() {
1960
+ return this._process?.signalCode ?? null;
1961
+ }
1962
+ constructor(command, args, options) {
1949
1963
  this._options = {
1950
- ...j,
1951
- ...n
1964
+ ...defaultOptions,
1965
+ ...options
1952
1966
  };
1953
- this._command = e;
1954
- this._args = t ?? [];
1955
- this._processClosed = new Promise((e) => {
1956
- this._resolveClose = e;
1967
+ this._command = command;
1968
+ this._args = args ?? [];
1969
+ this._processClosed = new Promise((resolve) => {
1970
+ this._resolveClose = resolve;
1957
1971
  });
1958
1972
  }
1959
- kill(e) {
1960
- return this._process?.kill(e) === true;
1973
+ kill(signal) {
1974
+ return this._process?.kill(signal) === true;
1961
1975
  }
1962
1976
  get aborted() {
1963
1977
  return this._aborted;
@@ -1965,143 +1979,151 @@ var I = class {
1965
1979
  get killed() {
1966
1980
  return this._process?.killed === true;
1967
1981
  }
1968
- pipe(e, t, n) {
1969
- return z(e, t, {
1970
- ...n,
1982
+ pipe(command, args, options) {
1983
+ return exec$1(command, args, {
1984
+ ...options,
1971
1985
  stdin: this
1972
1986
  });
1973
1987
  }
1974
1988
  async *[Symbol.asyncIterator]() {
1975
- const e = this._process;
1976
- if (!e) return;
1977
- const t = [];
1978
- if (this._streamErr) t.push(this._streamErr);
1979
- if (this._streamOut) t.push(this._streamOut);
1980
- const n = b(t);
1981
- const r = G.createInterface({ input: n });
1982
- for await (const e of r) yield e.toString();
1989
+ const proc = this._process;
1990
+ if (!proc) return;
1991
+ const streams = [];
1992
+ if (this._streamErr) streams.push(this._streamErr);
1993
+ if (this._streamOut) streams.push(this._streamOut);
1994
+ const streamCombined = combineStreams(streams);
1995
+ const rl = G.createInterface({ input: streamCombined });
1996
+ for await (const chunk of rl) yield chunk.toString();
1983
1997
  await this._processClosed;
1984
- e.removeAllListeners();
1998
+ proc.removeAllListeners();
1985
1999
  if (this._thrownError) throw this._thrownError;
1986
- if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new k(this);
2000
+ if (this._options?.throwOnError && (this.exitCode !== 0 && this.exitCode !== void 0 || this.signalCode !== null)) throw new NonZeroExitError(this, void 0, this._command, this._args);
1987
2001
  }
1988
2002
  async _waitForOutput() {
1989
- const e = this._process;
1990
- if (!e) throw new Error("No process was started");
1991
- const [t, n] = await Promise.all([this._streamOut ? F(this._streamOut) : "", this._streamErr ? F(this._streamErr) : ""]);
2003
+ const proc = this._process;
2004
+ if (!proc) throw new Error("No process was started");
2005
+ const [stdout, stderr] = await Promise.all([this._streamOut ? readStream(this._streamOut) : "", this._streamErr ? readStream(this._streamErr) : ""]);
1992
2006
  await this._processClosed;
1993
- const { stdin: r } = this._options;
1994
- if (r && typeof r !== "string") await r;
1995
- e.removeAllListeners();
2007
+ const { stdin } = this._options;
2008
+ if (stdin && typeof stdin !== "string") await stdin;
2009
+ proc.removeAllListeners();
1996
2010
  if (this._thrownError) throw this._thrownError;
1997
- const i = {
1998
- stderr: n,
1999
- stdout: t,
2011
+ const result = {
2012
+ stderr,
2013
+ stdout,
2000
2014
  exitCode: this.exitCode
2001
2015
  };
2002
- if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new k(this, i);
2003
- return i;
2016
+ if (this._options.throwOnError && (this.exitCode !== 0 && this.exitCode !== void 0 || this.signalCode !== null)) throw new NonZeroExitError(this, result, this._command, this._args);
2017
+ return result;
2004
2018
  }
2005
- then(e, t) {
2006
- return this._waitForOutput().then(e, t);
2019
+ then(onfulfilled, onrejected) {
2020
+ return this._waitForOutput().then(onfulfilled, onrejected);
2007
2021
  }
2008
2022
  _streamOut;
2009
2023
  _streamErr;
2010
2024
  spawn() {
2011
- const t = cwd();
2012
- const r = this._options;
2013
- const i = {
2014
- ...N,
2015
- ...r.nodeOptions
2025
+ const cwd$1 = cwd();
2026
+ const options = this._options;
2027
+ const nodeOptions = {
2028
+ ...defaultNodeOptions,
2029
+ ...options.nodeOptions
2016
2030
  };
2017
- const a = [];
2031
+ const signals = [];
2018
2032
  this._resetState();
2019
- if (r.timeout !== void 0) a.push(AbortSignal.timeout(r.timeout));
2020
- if (r.signal !== void 0) a.push(r.signal);
2021
- if (r.persist === true) i.detached = true;
2022
- if (a.length > 0) i.signal = P(a);
2023
- i.env = y(t, i.env, r.nodePath);
2024
- const o = D(this._command, this._args, i);
2025
- const s = spawn(o.command, o.args, o.options);
2026
- if (s.stderr) this._streamErr = s.stderr;
2027
- if (s.stdout) this._streamOut = s.stdout;
2028
- this._process = s;
2029
- s.once("error", this._onError);
2030
- s.once("close", this._onClose);
2031
- if (s.stdin) {
2032
- const { stdin: e } = r;
2033
- if (typeof e === "string") s.stdin.end(e);
2034
- else e?.process?.stdout?.pipe(s.stdin);
2033
+ if (options.timeout !== void 0) signals.push(AbortSignal.timeout(options.timeout));
2034
+ if (options.signal !== void 0) signals.push(options.signal);
2035
+ if (options.persist === true) nodeOptions.detached = true;
2036
+ if (signals.length > 0) nodeOptions.signal = combineSignals(signals);
2037
+ nodeOptions.env = computeEnv(cwd$1, nodeOptions.env, options.nodePath);
2038
+ const crossResult = normalizeSpawnCommand(this._command, this._args, nodeOptions);
2039
+ const handle = spawn(crossResult.command, crossResult.args, crossResult.options);
2040
+ if (handle.stderr) this._streamErr = handle.stderr;
2041
+ if (handle.stdout) this._streamOut = handle.stdout;
2042
+ this._process = handle;
2043
+ handle.once("error", this._onError);
2044
+ handle.once("close", this._onClose);
2045
+ if (handle.stdin) {
2046
+ const { stdin } = options;
2047
+ if (typeof stdin === "string") handle.stdin.end(stdin);
2048
+ else stdin?.process?.stdout?.pipe(handle.stdin);
2035
2049
  }
2036
2050
  }
2037
2051
  _resetState() {
2038
2052
  this._aborted = false;
2039
- this._processClosed = new Promise((e) => {
2040
- this._resolveClose = e;
2053
+ this._processClosed = new Promise((resolve) => {
2054
+ this._resolveClose = resolve;
2041
2055
  });
2042
2056
  this._thrownError = void 0;
2043
2057
  }
2044
- _onError = (e) => {
2045
- if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
2058
+ _onError = (err) => {
2059
+ if (err.name === "AbortError" && (!(err.cause instanceof Error) || err.cause.name !== "TimeoutError")) {
2046
2060
  this._aborted = true;
2047
2061
  return;
2048
2062
  }
2049
- this._thrownError = e;
2063
+ this._thrownError = err;
2050
2064
  };
2051
2065
  _onClose = () => {
2052
2066
  if (this._resolveClose) this._resolveClose();
2053
2067
  };
2054
2068
  };
2055
- function L(e, r, i) {
2056
- const a = {
2057
- ...M,
2058
- ...i
2069
+ function xSync(command, args, options) {
2070
+ const opts = {
2071
+ ...defaultSyncOptions,
2072
+ ...options
2059
2073
  };
2060
- const o = cwd();
2061
- const s = {
2074
+ const cwd$2 = cwd();
2075
+ const nodeOptions = {
2062
2076
  windowsHide: true,
2063
- ...a.nodeOptions
2077
+ ...opts.nodeOptions
2064
2078
  };
2065
- if (a.timeout !== void 0) s.timeout = a.timeout;
2066
- s.env = y(o, s.env, a.nodePath);
2067
- const c = D(e, r ?? [], s);
2068
- const l = spawnSync(c.command, c.args, c.options);
2069
- if (l.error) throw l.error;
2070
- const u = l.stdout?.toString() ?? "";
2071
- const d = l.stderr?.toString() ?? "";
2072
- const f = l.status ?? void 0;
2073
- const p = l.signal != null;
2074
- const m = {
2075
- stdout: u,
2076
- stderr: d,
2079
+ if (opts.timeout !== void 0) nodeOptions.timeout = opts.timeout;
2080
+ nodeOptions.env = computeEnv(cwd$2, nodeOptions.env, opts.nodePath);
2081
+ const crossResult = normalizeSpawnCommand(command, args ?? [], nodeOptions);
2082
+ const spawnResult = spawnSync(crossResult.command, crossResult.args, crossResult.options);
2083
+ if (spawnResult.error) throw spawnResult.error;
2084
+ const stdout = spawnResult.stdout?.toString() ?? "";
2085
+ const stderr = spawnResult.stderr?.toString() ?? "";
2086
+ const exitCode = spawnResult.status ?? void 0;
2087
+ const signalCode = spawnResult.signal ?? null;
2088
+ const killed = signalCode !== null;
2089
+ const result = {
2090
+ stdout,
2091
+ stderr,
2077
2092
  get exitCode() {
2078
- return f;
2093
+ return exitCode;
2094
+ },
2095
+ get signalCode() {
2096
+ return signalCode;
2079
2097
  },
2080
2098
  get pid() {
2081
- return l.pid;
2099
+ return spawnResult.pid;
2082
2100
  },
2083
2101
  get killed() {
2084
- return p;
2102
+ return killed;
2085
2103
  },
2086
2104
  *[Symbol.iterator]() {
2087
- for (const e of [u, d]) {
2088
- if (!e) continue;
2089
- const t = e.split(A);
2090
- if (t[t.length - 1] === "") t.pop();
2091
- yield* t;
2105
+ for (const text of [stdout, stderr]) {
2106
+ if (!text) continue;
2107
+ const lines = text.split(LINE_SEPARATOR_REGEX);
2108
+ if (lines[lines.length - 1] === "") lines.pop();
2109
+ yield* lines;
2092
2110
  }
2093
2111
  }
2094
2112
  };
2095
- if (a.throwOnError && f !== 0 && f !== void 0) throw new k(m, m);
2096
- return m;
2113
+ if (opts.throwOnError && (exitCode !== 0 && exitCode !== void 0 || signalCode !== null)) throw new NonZeroExitError(result, {
2114
+ stdout: result.stdout,
2115
+ stderr: result.stderr,
2116
+ exitCode: result.exitCode
2117
+ }, command, args);
2118
+ return result;
2097
2119
  }
2098
- const R = (e, t, n) => {
2099
- const r = new I(e, t, n);
2100
- r.spawn();
2101
- return r;
2120
+ const x = (command, args, userOptions) => {
2121
+ const proc = new ExecProcess(command, args, userOptions);
2122
+ proc.spawn();
2123
+ return proc;
2102
2124
  };
2103
- const z = R;
2104
- const B = L;
2125
+ const exec$1 = x;
2126
+ const execSync$1 = xSync;
2105
2127
  //#endregion
2106
2128
  //#region ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
2107
2129
  /**
@@ -5279,6 +5301,21 @@ var ValiError = class extends Error {
5279
5301
  this.issues = issues;
5280
5302
  }
5281
5303
  };
5304
+ /* @__NO_SIDE_EFFECTS__ */
5305
+ function nonEmpty(message$1) {
5306
+ return {
5307
+ kind: "validation",
5308
+ type: "non_empty",
5309
+ reference: nonEmpty,
5310
+ async: false,
5311
+ expects: "!0",
5312
+ message: message$1,
5313
+ "~run"(dataset, config$1) {
5314
+ if (dataset.typed && dataset.value.length === 0) _addIssue(this, "length", dataset, config$1, { received: "0" });
5315
+ return dataset;
5316
+ }
5317
+ };
5318
+ }
5282
5319
  /**
5283
5320
  * Creates a custom transformation action.
5284
5321
  *
@@ -6000,7 +6037,7 @@ var ai_tools_default = defineAddon({
6000
6037
  addFile(`${agentsPath}/${file.name.replace(REGEX_MD, ext)}`, file.contents);
6001
6038
  }
6002
6039
  }
6003
- if (filesExistingAlready.length > 0) R$1.warn(`${filesExistingAlready.map((path) => color.path(path)).join(", ")} already exists, we didn't touch ${filesExistingAlready.length > 1 ? "them" : "it"}. See ${color.website("https://svelte.dev/docs/ai")} for manual setup.`);
6040
+ if (filesExistingAlready.length > 0) R.warn(`${filesExistingAlready.map((path) => color.path(path)).join(", ")} already exists, we didn't touch ${filesExistingAlready.length > 1 ? "them" : "it"}. See ${color.website("https://svelte.dev/docs/ai")} for manual setup.`);
6004
6041
  },
6005
6042
  nextSteps({ options, cwd }) {
6006
6043
  const steps = [];
@@ -6074,7 +6111,7 @@ function prettierConfigPath() {
6074
6111
  */
6075
6112
  const createPrettierConfig = (opts) => transforms.script(({ ast, comments, js }) => {
6076
6113
  if (ast.body.some((node) => node.type === "ExportDefaultDeclaration")) {
6077
- R$1.warn(`A ${color.warning("prettier")} config already exists. Skipping initialization.`);
6114
+ R.warn(`A ${color.warning("prettier")} config already exists. Skipping initialization.`);
6078
6115
  return false;
6079
6116
  }
6080
6117
  const plugins = ["prettier-plugin-svelte"];
@@ -6378,7 +6415,7 @@ var better_auth_default = defineAddon({
6378
6415
  sv.file(`${directory.kitRoutes}/demo/better-auth/login/+page.server.${language}`, (content) => {
6379
6416
  if (content) {
6380
6417
  const filePath = `${directory.kitRoutes}/demo/better-auth/login/+page.server.${language}`;
6381
- R$1.warn(`Existing ${color.warning(filePath)} file. Could not update.`);
6418
+ R.warn(`Existing ${color.warning(filePath)} file. Could not update.`);
6382
6419
  return false;
6383
6420
  }
6384
6421
  const d1AuthLine = d1 ? "\n const { auth } = event.locals;\n" : "";
@@ -6469,7 +6506,7 @@ var better_auth_default = defineAddon({
6469
6506
  sv.file(`${directory.kitRoutes}/demo/better-auth/login/+page.svelte`, (content) => {
6470
6507
  if (content) {
6471
6508
  const filePath = `${directory.kitRoutes}/demo/better-auth/login/+page.svelte`;
6472
- R$1.warn(`Existing ${color.warning(filePath)} file. Could not update.`);
6509
+ R.warn(`Existing ${color.warning(filePath)} file. Could not update.`);
6473
6510
  return false;
6474
6511
  }
6475
6512
  const tailwind = dependencyVersion("@tailwindcss/vite") !== void 0;
@@ -6513,7 +6550,7 @@ var better_auth_default = defineAddon({
6513
6550
  sv.file(`${directory.kitRoutes}/demo/better-auth/+page.server.${language}`, (content) => {
6514
6551
  if (content) {
6515
6552
  const filePath = `${directory.kitRoutes}/demo/better-auth/+page.server.${language}`;
6516
- R$1.warn(`Existing ${color.warning(filePath)} file. Could not update.`);
6553
+ R.warn(`Existing ${color.warning(filePath)} file. Could not update.`);
6517
6554
  return false;
6518
6555
  }
6519
6556
  const d1AuthLine = d1 ? "\n const { auth } = event.locals;\n" : "";
@@ -6543,7 +6580,7 @@ var better_auth_default = defineAddon({
6543
6580
  sv.file(`${directory.kitRoutes}/demo/better-auth/+page.svelte`, (content) => {
6544
6581
  if (content) {
6545
6582
  const filePath = `${directory.kitRoutes}/demo/better-auth/+page.svelte`;
6546
- R$1.warn(`Existing ${color.warning(filePath)} file. Could not update.`);
6583
+ R.warn(`Existing ${color.warning(filePath)} file. Could not update.`);
6547
6584
  return false;
6548
6585
  }
6549
6586
  const tailwind = dependencyVersion("@tailwindcss/vite") !== void 0;
@@ -6711,7 +6748,7 @@ var drizzle_default = defineAddon({
6711
6748
  if (options.postgresql === "postgres.js") sv.devDependency("postgres", "^3.4.9");
6712
6749
  if (options.sqlite === "better-sqlite3") {
6713
6750
  sv.dependency("better-sqlite3", "^13.0.2");
6714
- sv.devDependency("@types/better-sqlite3", "^7.6.13");
6751
+ sv.devDependency("@types/better-sqlite3", "^9.6.0");
6715
6752
  }
6716
6753
  if (options.sqlite === "libsql" || options.sqlite === "turso") sv.devDependency("@libsql/client", "^0.17.3");
6717
6754
  sv.file(".env", generateEnv(options, false));
@@ -7019,25 +7056,26 @@ var drizzle_default = defineAddon({
7019
7056
  }));
7020
7057
  },
7021
7058
  nextSteps: ({ options, packageManager, cwd, dependencyVersion }) => {
7059
+ const pm = (command, args) => color.command(resolveCommandArray(packageManager, command, args));
7022
7060
  const steps = [];
7023
7061
  if (options.database === "d1") {
7024
- if (!dependencyVersion("@sveltejs/adapter-cloudflare")) steps.push(`Cloudflare D1 requires ${color.addon("@sveltejs/adapter-cloudflare")}. Run ${color.command(resolveCommandArray(packageManager, "execute", [
7062
+ if (!dependencyVersion("@sveltejs/adapter-cloudflare")) steps.push(`Cloudflare D1 requires ${color.addon("@sveltejs/adapter-cloudflare")}. Run ${pm("execute", [
7025
7063
  "sv",
7026
7064
  "add",
7027
7065
  "sveltekit-adapter=adapter:cloudflare"
7028
- ]))} to add it`);
7029
- const ext = fileExists(cwd, "wrangler.toml") ? "toml" : "jsonc";
7066
+ ])} to add it`);
7030
7067
  steps.push(`Add your ${color.env("CLOUDFLARE_ACCOUNT_ID")}, ${color.env("CLOUDFLARE_DATABASE_ID")}, and ${color.env("CLOUDFLARE_D1_TOKEN")} to ${color.path(".env")}`);
7031
- steps.push(`Run ${color.command(resolveCommandArray(packageManager, "execute-local", [
7068
+ const ext = fileExists(cwd, "wrangler.toml") ? "toml" : "jsonc";
7069
+ steps.push(`Run ${pm("execute-local", [
7032
7070
  "wrangler",
7033
7071
  "d1",
7034
7072
  "create",
7035
7073
  "<DATABASE_NAME>"
7036
- ]))} to generate a D1 database ID for your ${color.path(`wrangler.${ext}`)}`);
7074
+ ])} to generate a D1 database ID for your ${color.path(`wrangler.${ext}`)}`);
7037
7075
  }
7038
- if (options.docker) steps.push(`Run ${color.command(resolveCommandArray(packageManager, "run", ["db:start"]))} to start the docker container`);
7076
+ if (options.docker) steps.push(`Run ${pm("run", ["db:start"])} to start the docker container`);
7039
7077
  else if (options.database !== "d1") steps.push(`Check ${color.env("DATABASE_URL")} in ${color.path(".env")} and adjust it to your needs`);
7040
- steps.push(`Run ${color.command(resolveCommandArray(packageManager, "run", ["db:push"]))} to update your database schema`);
7078
+ steps.push(`Run ${pm("run", ["db:push"])} to update your database schema`);
7041
7079
  return steps;
7042
7080
  }
7043
7081
  });
@@ -7194,7 +7232,7 @@ var eslint_default = defineAddon({
7194
7232
  }
7195
7233
  const { value: defaultExport } = js.exports.createDefault(ast, { fallback: exportExpression });
7196
7234
  if (defaultExport !== exportExpression) {
7197
- R$1.warn("An eslint config is already defined. Skipping initialization.");
7235
+ R.warn("An eslint config is already defined. Skipping initialization.");
7198
7236
  return false;
7199
7237
  }
7200
7238
  if (typescript) js.imports.addDefault(ast, {
@@ -7382,7 +7420,7 @@ var paraglide_default = defineAddon({
7382
7420
  name: "reroute",
7383
7421
  fallback: rerouteIdentifier
7384
7422
  });
7385
- if (existingExport.declaration !== rerouteIdentifier) R$1.warn("Adding the reroute hook automatically failed. Add it manually");
7423
+ if (existingExport.declaration !== rerouteIdentifier) R.warn("Adding the reroute hook automatically failed. Add it manually");
7386
7424
  if (language === "ts") js.imports.addNamed(ast, {
7387
7425
  from: "@sveltejs/kit/hooks",
7388
7426
  imports: ["Reroute"],
@@ -7413,7 +7451,7 @@ var paraglide_default = defineAddon({
7413
7451
  sv.file("src/app.html", transforms.html(({ ast, html }) => {
7414
7452
  const htmlNode = ast.nodes.find((child) => child.type === "RegularElement" && child.name === "html");
7415
7453
  if (!htmlNode) {
7416
- R$1.warn("Could not find <html> node in app.html. You'll need to add the language placeholder manually");
7454
+ R.warn("Could not find <html> node in app.html. You'll need to add the language placeholder manually");
7417
7455
  return false;
7418
7456
  }
7419
7457
  html.addAttribute(htmlNode, "lang", "%paraglide.lang%");
@@ -7482,11 +7520,7 @@ var paraglide_default = defineAddon({
7482
7520
  data.hello_world = `Hello, {name} from ${languageTag}!`;
7483
7521
  }));
7484
7522
  },
7485
- nextSteps: () => {
7486
- const steps = [`Edit your messages in ${color.path("messages/en.json")}`];
7487
- if (options$3.demo) steps.push(`Visit ${color.route("/demo/paraglide")} route to view the demo`);
7488
- return steps;
7489
- }
7523
+ nextSteps: () => [`Edit your messages in ${color.path("messages/en.json")}`, options$3.demo && `Visit ${color.route("/demo/paraglide")} route to view the demo`].filter((line) => Boolean(line))
7490
7524
  });
7491
7525
  const isValidLanguageTag = (languageTag) => RegExp("^((?<grandfathered>(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?))(-(?<script>[A-Za-z]{4}))?(-(?<region>[A-Za-z]{2}|[0-9]{3}))?(-(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*))$").test(languageTag);
7492
7526
  function parseLanguageTagInput(input) {
@@ -7557,7 +7591,7 @@ var playwright_default = defineAddon({
7557
7591
  });
7558
7592
  js.object.overrideProperties(defaultExport.arguments[0], config);
7559
7593
  } else if (defaultExport.type === "ObjectExpression") js.object.overrideProperties(defaultExport, config);
7560
- else R$1.warn("Unexpected playwright config for playwright add-on. Could not update.");
7594
+ else R.warn("Unexpected playwright config for playwright add-on. Could not update.");
7561
7595
  }));
7562
7596
  },
7563
7597
  nextSteps: ({ isKit, packageManager }) => {
@@ -7606,7 +7640,7 @@ var prettier_default = defineAddon({
7606
7640
  sv.file(".vscode/extensions.json", transforms.json(({ data, json }) => {
7607
7641
  json.arrayUpsert(data, "recommendations", "esbenp.prettier-vscode");
7608
7642
  }));
7609
- if (eslintInfo.installed && !eslintInfo.supported) R$1.warn(`An unsupported major version of ${color.warning("eslint")} was detected. Skipping ${color.warning("eslint-config-prettier")} installation.`);
7643
+ if (eslintInfo.installed && !eslintInfo.supported) R.warn(`An unsupported major version of ${color.warning("eslint")} was detected. Skipping ${color.warning("eslint-config-prettier")} installation.`);
7610
7644
  if (eslintInfo.supported) {
7611
7645
  sv.devDependency("eslint-config-prettier", "^10.1.8");
7612
7646
  sv.file("eslint.config.js", addEslintConfigPrettier);
@@ -9177,7 +9211,12 @@ async function importAddonCode(pkgName, pkgVersion) {
9177
9211
  } catch {
9178
9212
  issues.push(`default export not found`);
9179
9213
  }
9180
- if (!details && issues.length > 0) throw new Error(`Failed to load add-on '${pkgName}@${pkgVersion}':\n- ${issues.join("\n- ")}\n\nPlease report this to the add-on author.`);
9214
+ if (!details && issues.length > 0) throw new Error(dedent`
9215
+ Failed to load add-on '${pkgName}@${pkgVersion}':
9216
+ ${issues.map((i) => `- ${i}`).join("\n")}
9217
+
9218
+ Please report this to the add-on author.
9219
+ `);
9181
9220
  return details;
9182
9221
  }
9183
9222
  async function getPackageJSON(ref) {
@@ -9216,17 +9255,10 @@ async function packageManagerPrompt(cwd) {
9216
9255
  options: [{
9217
9256
  label: "None",
9218
9257
  value: void 0
9219
- }, ...AGENT_NAMES.map((agent) => {
9220
- const installed = isInstalled(agent);
9221
- return {
9222
- value: agent,
9223
- label: installed ? agent : color.dim(`${agent} (not installed)`),
9224
- installed
9225
- };
9226
- }).sort((a, b) => Number(b.installed) - Number(a.installed))],
9258
+ }, ...AGENT_NAMES.filter(isInstalled).map((agent) => ({ value: agent }))],
9227
9259
  initialValue: agent
9228
9260
  });
9229
- if (R$2(pm)) {
9261
+ if (R$1(pm)) {
9230
9262
  ge("Operation cancelled.");
9231
9263
  V.exit(1);
9232
9264
  }
@@ -9235,7 +9267,7 @@ async function packageManagerPrompt(cwd) {
9235
9267
  /** Returns `false` when the package manager isn't installed and the install was skipped. */
9236
9268
  async function installDependencies(agent, cwd) {
9237
9269
  if (!isInstalled(agent)) {
9238
- R$1.warn(`${color.command(agent)} is not installed, skipping dependency installation.`);
9270
+ R.warn(`${color.command(agent)} is not installed, skipping dependency installation.`);
9239
9271
  return false;
9240
9272
  }
9241
9273
  const task = Pe({
@@ -9245,7 +9277,7 @@ async function installDependencies(agent, cwd) {
9245
9277
  retainLog: true
9246
9278
  });
9247
9279
  const { command, args } = constructCommand(COMMANDS[agent].install, []);
9248
- const proc = z(command, args, {
9280
+ const proc = exec$1(command, args, {
9249
9281
  nodeOptions: {
9250
9282
  cwd,
9251
9283
  stdio: "pipe"
@@ -9265,7 +9297,7 @@ async function installDependencies(agent, cwd) {
9265
9297
  }
9266
9298
  if (agent === "pnpm" && output.join("\n").includes("ERR_PNPM_IGNORED_BUILDS")) {
9267
9299
  task.success(`Installed dependencies with ${color.command(agent)}`);
9268
- R$1.warn(`Some build scripts were skipped. Run ${color.command(`${agent} approve-builds`)} to approve them.`);
9300
+ R.warn(`Some build scripts were skipped. Run ${color.command(`${agent} approve-builds`)} to approve them.`);
9269
9301
  return true;
9270
9302
  }
9271
9303
  task.error("Failed to install dependencies");
@@ -9288,7 +9320,7 @@ function isInstalled(agent) {
9288
9320
  let installed = installedCache.get(agent);
9289
9321
  if (installed === void 0) {
9290
9322
  try {
9291
- B(agent, ["--version"], { nodeOptions: { stdio: "ignore" } });
9323
+ execSync$1(agent, ["--version"], { nodeOptions: { stdio: "ignore" } });
9292
9324
  installed = true;
9293
9325
  } catch {
9294
9326
  installed = false;
@@ -9443,13 +9475,25 @@ async function formatFiles(options) {
9443
9475
  ];
9444
9476
  await withSpinner("Formatting modified files", async () => {
9445
9477
  let result = await run("prettier", args, options.cwd);
9446
- if (result.notFound) {
9478
+ if (result.error) {
9447
9479
  const cmd = resolveCommand(options.packageManager, "execute-local", ["prettier", ...args]);
9448
9480
  result = await run(cmd.command, cmd.args, options.cwd);
9449
9481
  }
9450
9482
  return result;
9451
9483
  });
9452
9484
  }
9485
+ /**
9486
+ * Whether `prettier` resolves from `cwd`, walking up `node_modules` the same way the spawned
9487
+ * binary does - so formatting can be skipped instead of failing when deps were never installed.
9488
+ */
9489
+ function isFormatterInstalled(cwd) {
9490
+ try {
9491
+ createRequire(path.join(cwd, "index.js")).resolve("prettier/package.json");
9492
+ return true;
9493
+ } catch {
9494
+ return false;
9495
+ }
9496
+ }
9453
9497
  /** Nearest dir from `cwd` up to the workspace root with a `format` or `fmt` package.json script. */
9454
9498
  function findFormatScript(cwd) {
9455
9499
  const workspaceRoot = findWorkspaceRoot(cwd);
@@ -9477,14 +9521,14 @@ async function withSpinner(startMsg, task) {
9477
9521
  const { error } = await task();
9478
9522
  if (error !== void 0) {
9479
9523
  stop("Failed to format files");
9480
- R$1.error(error);
9524
+ R.error(error);
9481
9525
  return;
9482
9526
  }
9483
9527
  stop("Successfully formatted files");
9484
9528
  }
9485
9529
  async function run(command, args, cwd) {
9486
9530
  try {
9487
- await z(command, args, {
9531
+ await exec$1(command, args, {
9488
9532
  nodeOptions: {
9489
9533
  cwd,
9490
9534
  stdio: "pipe"
@@ -9493,12 +9537,11 @@ async function run(command, args, cwd) {
9493
9537
  });
9494
9538
  return {};
9495
9539
  } catch (e) {
9496
- if (e?.code === "ENOENT") return {
9497
- notFound: true,
9498
- error: `${command} not found`
9499
- };
9500
- const output = e?.output;
9501
- return { error: [output?.stderr, output?.stdout].filter(Boolean).join("\n").trim() || (e instanceof Error ? e.message : "unknown error") };
9540
+ if (e instanceof Error && "code" in e && e.code === "ENOENT") {
9541
+ if ("code" in e && e.code === "ENOENT") return { error: `${command} not found` };
9542
+ return { error: e.message };
9543
+ }
9544
+ return { error: "unknown error" };
9502
9545
  }
9503
9546
  }
9504
9547
  //#endregion
@@ -9734,6 +9777,7 @@ const langOption = new Option("--types <lang>", "add type checking").choices(lan
9734
9777
  const templateOption = new Option("--template <type>", "template to scaffold").choices(templateChoices);
9735
9778
  const noAddonsOption = new Option("--no-add-ons", "do not prompt to add add-ons").conflicts("add");
9736
9779
  const addOption = new Option("--add <addon...>", "add-ons to include (see Add-Ons section below)").default([]);
9780
+ const addonNameOption = new Option("--addon-name <name>", "name for the addon package (e.g. @<org>/<pkg> or <pkg>)");
9737
9781
  const noDownloadCheckOption = new Option("--no-download-check", "skip all download confirmation prompts");
9738
9782
  const noInstallOption = new Option("--no-install", "skip installing dependencies");
9739
9783
  const ProjectPathSchema = /* @__PURE__ */ optional(/* @__PURE__ */ string());
@@ -9745,9 +9789,10 @@ const OptionsSchema$1 = /* @__PURE__ */ strictObject({
9745
9789
  template: /* @__PURE__ */ optional(/* @__PURE__ */ picklist(templateChoices)),
9746
9790
  fromPlayground: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
9747
9791
  dirCheck: /* @__PURE__ */ boolean(),
9748
- downloadCheck: /* @__PURE__ */ boolean()
9792
+ downloadCheck: /* @__PURE__ */ boolean(),
9793
+ addonName: /* @__PURE__ */ optional(/* @__PURE__ */ string())
9749
9794
  });
9750
- const create = new Command("create").description("Scaffold a new project (--add to include add-ons)").argument("[path]", "where the project will be created").addOption(templateOption).addOption(langOption).option("--no-types").addOption(noAddonsOption).addOption(addOption).addOption(noInstallOption).option("--from-playground <url>", "create a project from the svelte playground").option("--no-dir-check", "even if the folder is not empty, no prompt will be shown").addOption(noDownloadCheckOption).addOption(installOption).configureHelp({
9795
+ const create = new Command("create").description("Scaffold a new project (--add to include add-ons)").argument("[path]", "where the project will be created").addOption(templateOption).addOption(langOption).option("--no-types").addOption(noAddonsOption).addOption(addOption).addOption(addonNameOption).addOption(noInstallOption).option("--from-playground <url>", "create a project from the svelte playground").option("--no-dir-check", "even if the folder is not empty, no prompt will be shown").addOption(noDownloadCheckOption).addOption(installOption).configureHelp({
9751
9796
  ...helpConfig,
9752
9797
  formatHelp(cmd, helper) {
9753
9798
  const s = getHelpSections(cmd, helper);
@@ -9782,21 +9827,17 @@ const create = new Command("create").description("Scaffold a new project (--add
9782
9827
  runCommand(async () => {
9783
9828
  const { directory, addOnNextSteps, packageManager, depsInstalled } = await createProject(cwd, options);
9784
9829
  let i = 1;
9785
- const initialSteps = ["📁 Project steps", ""];
9830
+ const steps = ["📁 Project steps", ""];
9786
9831
  const relative = path.relative(V.cwd(), directory);
9787
9832
  const pm = packageManager ?? await detectPackageManager(directory);
9788
9833
  if (relative !== "") {
9789
9834
  const pathHasSpaces = relative.includes(" ");
9790
- initialSteps.push(` ${i++}: ${color.command(`cd ${pathHasSpaces ? `"${relative}"` : relative}`)}`);
9835
+ steps.push(` ${i++}: ${color.command(`cd ${pathHasSpaces ? `"${relative}"` : relative}`)}`);
9791
9836
  }
9792
- if (packageManager && !depsInstalled) initialSteps.push(` ${i++}: Install ${color.command(pm)}`);
9793
- if (!packageManager || !depsInstalled) initialSteps.push(` ${i++}: ${color.command(resolveCommandArray(pm, "install", []))}`);
9794
- const steps = [
9795
- ...initialSteps,
9796
- ` ${i++}: ${color.command(resolveCommandArray(pm, "run", ["dev", "--open"]))}`,
9797
- "",
9798
- `To close the dev server, hit ${color.command("Ctrl-C")}`
9799
- ];
9837
+ if (packageManager && !depsInstalled) steps.push(` ${i++}: Install ${color.command(pm)}`);
9838
+ if (!packageManager || !depsInstalled) steps.push(` ${i++}: ${color.command(resolveCommandArray(pm, "install", []))}`);
9839
+ steps.push(` ${i++}: ${color.command(resolveCommandArray(pm, "run", ["dev", "--open"]))}\n`);
9840
+ steps.push(`To close the dev server, hit ${color.command("Ctrl-C")}`);
9800
9841
  if (addOnNextSteps.length > 0) {
9801
9842
  steps.push("", "🧩 Add-on steps", "");
9802
9843
  for (const step of addOnNextSteps) {
@@ -9809,8 +9850,8 @@ const create = new Command("create").description("Scaffold a new project (--add
9809
9850
  });
9810
9851
  }).showHelpAfterError(true);
9811
9852
  async function createProject(cwd, options) {
9812
- if (options.fromPlayground) R$1.warn("Svelte maintainers have not reviewed playgrounds for malicious code! Use at your discretion.");
9813
- if (options.template === "addon" && options.types === "typescript") R$1.warn(`The addon template does not support TypeScript. The ${color.command("--types")} flag will be ignored.`);
9853
+ if (options.fromPlayground) R.warn("Svelte maintainers have not reviewed playgrounds for malicious code! Use at your discretion.");
9854
+ if (options.template === "addon" && options.types === "typescript") R.warn(`The addon template does not support TypeScript. The ${color.command("--types")} flag will be ignored.`);
9814
9855
  const promptGroupResult = await pe({
9815
9856
  directory: () => {
9816
9857
  const defaultPath = "./";
@@ -9829,7 +9870,7 @@ async function createProject(cwd, options) {
9829
9870
  message: "Directory not empty. Continue?",
9830
9871
  initialValue: false
9831
9872
  });
9832
- if (R$2(force) || !force) {
9873
+ if (R$1(force) || !force) {
9833
9874
  ge("Exiting.");
9834
9875
  V.exit(0);
9835
9876
  }
@@ -9879,23 +9920,19 @@ async function createProject(cwd, options) {
9879
9920
  const basename = path.basename(projectPath);
9880
9921
  const parentDirName = path.basename(path.dirname(projectPath));
9881
9922
  let projectName = parentDirName.startsWith("@") ? `${parentDirName}/${basename}` : basename;
9882
- if (template === "addon" && !projectName.startsWith("@")) {
9883
- const org = await Re({
9884
- message: `Community add-ons must be published under an npm org. Enter the name of your npm org:`,
9885
- placeholder: " @my-org",
9886
- validate: (value) => {
9887
- if (!value) return "Organization name is required";
9888
- if (!value.startsWith("@")) return "Must start with @";
9889
- if (value.includes("/")) return "Just the org, not the full package name";
9890
- }
9923
+ if (template === "addon") {
9924
+ if (options.add.length > 0) errorAndExit(`The ${color.command("--add")} flag cannot be used with the ${color.command("addon")} template.`);
9925
+ const namePrompt = options.addonName ?? await Re({
9926
+ message: `Enter the package name for your add-on: (e.g. ${color.path("@<org>/<pkg>")} or ${color.path("<pkg>")})`,
9927
+ initialValue: projectName,
9928
+ validate: /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ nonEmpty())
9891
9929
  });
9892
- if (R$2(org)) {
9930
+ if (R$1(namePrompt)) {
9893
9931
  ge("Operation cancelled.");
9894
9932
  V.exit(0);
9895
9933
  }
9896
- projectName = `${org}/${basename}`;
9934
+ projectName = namePrompt;
9897
9935
  }
9898
- if (template === "addon" && options.add.length > 0) errorAndExit(`The ${color.command("--add")} flag cannot be used with the ${color.command("addon")} template.`);
9899
9936
  let loadedAddons = [];
9900
9937
  let answers = {};
9901
9938
  let addonsOptionsMap = {};
@@ -9929,7 +9966,7 @@ async function createProject(cwd, options) {
9929
9966
  types: language
9930
9967
  });
9931
9968
  if (options.fromPlayground) await createProjectFromPlayground(options.fromPlayground, projectPath);
9932
- R$1.success("Project created");
9969
+ R.success("Project created");
9933
9970
  const packageManager = options.install === false ? null : options.install === true ? await packageManagerPrompt(projectPath) : options.install;
9934
9971
  if (packageManager) workspace.packageManager = packageManager;
9935
9972
  let argsFormattedAddons = [];
@@ -9991,12 +10028,12 @@ async function createProjectFromPlayground(url, cwd) {
9991
10028
  async function confirmExternalDependencies(dependencies) {
9992
10029
  if (dependencies.length === 0) return false;
9993
10030
  const dependencyList = dependencies.map(color.warning).join(", ");
9994
- R$1.warn(`The following external dependencies were found in the playground:\n\n${dependencyList}`);
10031
+ R.warn(`The following external dependencies were found in the playground:\n\n${dependencyList}`);
9995
10032
  const installDeps = await le({
9996
10033
  message: "Do you want to install these external dependencies?",
9997
10034
  initialValue: false
9998
10035
  });
9999
- if (R$2(installDeps)) {
10036
+ if (R$1(installDeps)) {
10000
10037
  ge("Operation cancelled.");
10001
10038
  V.exit(0);
10002
10039
  }
@@ -10284,7 +10321,7 @@ async function promptAddonQuestions({ options, loadedAddons, workspace }) {
10284
10321
  options: addonOptions,
10285
10322
  required: false
10286
10323
  });
10287
- if (R$2(selected)) {
10324
+ if (R$1(selected)) {
10288
10325
  ge("Operation cancelled.");
10289
10326
  V.exit(1);
10290
10327
  }
@@ -10377,7 +10414,7 @@ async function promptAddonQuestions({ options, loadedAddons, workspace }) {
10377
10414
  });
10378
10415
  if (question.type === "number") answer = Number(answer);
10379
10416
  }
10380
- if (R$2(answer)) {
10417
+ if (R$1(answer)) {
10381
10418
  ge("Operation cancelled.");
10382
10419
  V.exit(1);
10383
10420
  }
@@ -10398,7 +10435,7 @@ async function runAddonsApply({ answers, options, loadedAddons, setupResults, wo
10398
10435
  successfulAddons: [],
10399
10436
  setupResults: {}
10400
10437
  };
10401
- const { filesToFormat, status } = await applyAddons({
10438
+ const { filesToFormat, status, installNeeded } = await applyAddons({
10402
10439
  loadedAddons,
10403
10440
  workspace,
10404
10441
  setupResults,
@@ -10408,17 +10445,20 @@ async function runAddonsApply({ answers, options, loadedAddons, setupResults, wo
10408
10445
  const canceledAddonIds = [];
10409
10446
  for (const [addonId, info] of Object.entries(status)) if (info === "success") addonSuccess.push(addonId);
10410
10447
  else {
10411
- R$1.warn(`Canceled ${addonId}: ${info.join(", ")}`);
10448
+ R.warn(`Canceled ${addonId}: ${info.join(", ")}`);
10412
10449
  canceledAddonIds.push(addonId);
10413
10450
  }
10414
10451
  const successfulAddons = loadedAddons.filter((a) => !canceledAddonIds.includes(a.addon.id));
10415
- if (addonSuccess.length === 0) if (fromCommand === "create") R$1.warn("All selected add-ons were canceled.");
10452
+ if (addonSuccess.length === 0) if (fromCommand === "create") R.warn("All selected add-ons were canceled.");
10416
10453
  else {
10417
10454
  ge("All selected add-ons were canceled.");
10418
10455
  V.exit(1);
10419
10456
  }
10420
- else R$1.success(`Successfully setup add-ons: ${addonSuccess.map((c) => color.addon(c)).join(", ")}`);
10421
- const packageManager = options.install === false ? null : options.install === true ? await packageManagerPrompt(options.cwd) : options.install;
10457
+ else R.success(`Successfully setup add-ons: ${addonSuccess.map((c) => color.addon(c)).join(", ")}`);
10458
+ let packageManager = null;
10459
+ if (options.install === true) {
10460
+ if (installNeeded) packageManager = await packageManagerPrompt(options.cwd);
10461
+ } else if (options.install === false) {} else packageManager = options.install;
10422
10462
  addPnpmAllowBuilds(workspace.cwd, packageManager, "esbuild");
10423
10463
  const argsFormattedAddons = [];
10424
10464
  for (const loaded of successfulAddons) {
@@ -10449,17 +10489,17 @@ async function runAddonsApply({ answers, options, loadedAddons, setupResults, wo
10449
10489
  if (!options.gitCheck) argsFormattedAddons.push("--no-git-check");
10450
10490
  buildAndLogArgs(packageManager, "add", argsFormattedAddons);
10451
10491
  }
10452
- let depsInstalled = true;
10492
+ let depsInstalled = false;
10453
10493
  if (packageManager) {
10454
10494
  workspace.packageManager = packageManager;
10455
10495
  depsInstalled = await installDependencies(packageManager, options.cwd);
10456
- if (depsInstalled) await formatFiles({
10457
- packageManager,
10458
- cwd: options.cwd,
10459
- filesToFormat,
10460
- strategy: "files-only"
10461
- });
10462
10496
  }
10497
+ if (depsInstalled || isFormatterInstalled(options.cwd)) await formatFiles({
10498
+ packageManager: packageManager ?? workspace.packageManager,
10499
+ cwd: options.cwd,
10500
+ filesToFormat,
10501
+ strategy: "files-only"
10502
+ });
10463
10503
  const nextSteps = getNextSteps(successfulAddons, workspace, answers, setupResults);
10464
10504
  if (packageManager && !depsInstalled) nextSteps.unshift(`Install ${color.command(packageManager)}, then run ${color.command(resolveCommandArray(packageManager, "install", []))}`);
10465
10505
  return {
@@ -10481,7 +10521,7 @@ function getNextSteps(loadedAddons, workspace, answers, setupResults) {
10481
10521
  });
10482
10522
  if (addonNextSteps.length === 0) return;
10483
10523
  let addonMessage = `${color.addon(addon.id)}:\n`;
10484
- addonMessage += ` - ${addonNextSteps.join("\n - ")}`;
10524
+ addonMessage += addonNextSteps.map((line) => ` - ${line}`).join("\n");
10485
10525
  return addonMessage;
10486
10526
  }).filter((msg) => msg !== void 0);
10487
10527
  }
@@ -10603,14 +10643,14 @@ async function resolveNonOfficialAddons(refs, downloadCheck) {
10603
10643
  return await getPackageJSON(ref);
10604
10644
  }));
10605
10645
  stop("Resolved community add-on packages");
10606
- for (const { warning } of pkgs) if (warning) R$1.warn(warning);
10607
- R$1.warn("Svelte maintainers have not reviewed community add-ons for malicious code! Use at your discretion.");
10646
+ for (const { warning } of pkgs) if (warning) R.warn(warning);
10647
+ R.warn("Svelte maintainers have not reviewed community add-ons for malicious code! Use at your discretion.");
10608
10648
  const paddingName = getPadding(pkgs.map(({ pkg }) => pkg.name));
10609
10649
  const paddingVersion = getPadding(pkgs.map(({ pkg }) => `(v${pkg.version})`));
10610
10650
  const packageInfos = pkgs.map(({ pkg, repo: _repo }) => {
10611
10651
  return `${color.warning(pkg.name.padEnd(paddingName))} ${color.dim(`(v${pkg.version})`.padEnd(paddingVersion))} ${color.dim(`(${_repo})`)}`;
10612
10652
  });
10613
- R$1.message(packageInfos.join("\n"));
10653
+ R.message(packageInfos.join("\n"));
10614
10654
  if (downloadCheck) {
10615
10655
  if (await le({ message: "Would you like to continue?" }) !== true) {
10616
10656
  ge("Operation cancelled.");
@@ -10652,23 +10692,24 @@ function alphabetizeRecord(obj) {
10652
10692
  return ordered;
10653
10693
  }
10654
10694
  function updatePackages(dependencies, sv) {
10655
- if (dependencies.length === 0) return;
10695
+ let installNeeded = false;
10696
+ if (dependencies.length === 0) return { installNeeded };
10656
10697
  const pkgPath = filePaths.packageJson;
10657
10698
  sv.file(pkgPath, transforms.json(({ content, data }) => {
10658
10699
  if (!content) throw new Error(`Invalid workspace: missing '${pkgPath}'`);
10659
- let modified = false;
10660
10700
  for (const { dev, pkg, version } of dependencies) {
10661
10701
  const dependency = dev ? "devDependencies" : "dependencies";
10662
10702
  data[dependency] ??= {};
10663
- if (data[dependency][pkg] !== version) {
10664
- modified = true;
10665
- data[dependency][pkg] = version;
10666
- }
10703
+ const declared = data[dependency][pkg];
10704
+ if (declared && isRangeWithin(declared, version)) continue;
10705
+ installNeeded = true;
10706
+ data[dependency][pkg] = version;
10667
10707
  }
10668
- if (!modified) return false;
10708
+ if (!installNeeded) return false;
10669
10709
  if (data.dependencies) data.dependencies = alphabetizeRecord(data.dependencies);
10670
10710
  if (data.devDependencies) data.devDependencies = alphabetizeRecord(data.devDependencies);
10671
10711
  }));
10712
+ return { installNeeded };
10672
10713
  }
10673
10714
  async function add({ addons, cwd, options, packageManager = "npm" }) {
10674
10715
  const workspace = await createWorkspace({
@@ -10687,6 +10728,7 @@ async function applyAddons({ loadedAddons, workspace, setupResults, options }) {
10687
10728
  const filesToFormat = /* @__PURE__ */ new Set();
10688
10729
  const status = {};
10689
10730
  const canceledAddons = /* @__PURE__ */ new Set();
10731
+ let installNeeded = false;
10690
10732
  const ordered = orderAddons(loadedAddons.map((l) => l.addon), setupResults);
10691
10733
  let hasFormatter = false;
10692
10734
  for (const addon of ordered) {
@@ -10703,7 +10745,7 @@ async function applyAddons({ loadedAddons, workspace, setupResults, options }) {
10703
10745
  packageManager: workspace.packageManager
10704
10746
  });
10705
10747
  if (!hasFormatter) hasFormatter = !!addonWorkspace.dependencyVersion("prettier");
10706
- const { files, cancels } = await runAddon({
10748
+ const { files, cancels, installNeeded: addonInstallNeeded } = await runAddon({
10707
10749
  workspace: addonWorkspace,
10708
10750
  workspaceOptions,
10709
10751
  addon,
@@ -10711,6 +10753,7 @@ async function applyAddons({ loadedAddons, workspace, setupResults, options }) {
10711
10753
  multiple: ordered.length > 1
10712
10754
  });
10713
10755
  files.forEach((f) => filesToFormat.add(f));
10756
+ if (addonInstallNeeded) installNeeded = true;
10714
10757
  if (cancels.length === 0) status[addon.id] = "success";
10715
10758
  else {
10716
10759
  canceledAddons.add(addon.id);
@@ -10719,7 +10762,8 @@ async function applyAddons({ loadedAddons, workspace, setupResults, options }) {
10719
10762
  }
10720
10763
  return {
10721
10764
  filesToFormat: hasFormatter ? Array.from(filesToFormat) : [],
10722
- status
10765
+ status,
10766
+ installNeeded
10723
10767
  };
10724
10768
  }
10725
10769
  /** Setup addons - takes LoadedAddon[] and returns setup results */
@@ -10775,10 +10819,12 @@ async function runAddon({ addon, loaded, multiple, workspace, workspaceOptions }
10775
10819
  const msg = err instanceof Error ? err.message : String(err);
10776
10820
  throw new Error(`Add-on '${addon.id}' failed during run: ${msg}\n\n${getErrorHint(loaded.reference.source)}`, { cause: err });
10777
10821
  }
10778
- if (cancels.length === 0) ({modifiedFiles} = finalize());
10822
+ let installNeeded = false;
10823
+ if (cancels.length === 0) ({modifiedFiles, installNeeded} = finalize());
10779
10824
  return {
10780
10825
  files: Array.from(modifiedFiles),
10781
- cancels
10826
+ cancels,
10827
+ installNeeded
10782
10828
  };
10783
10829
  }
10784
10830
  function editFile(file, edit, workspace, modifiedFiles, unmodifiedFiles, options, include) {
@@ -10848,10 +10894,10 @@ function prepareSvApi(workspace, options = {
10848
10894
  execute: async (commandArgs, stdio) => {
10849
10895
  const { command, args } = resolveCommand(workspace.packageManager, "execute", commandArgs);
10850
10896
  const executedCommand = [command, ...args].join(" ");
10851
- if (!TESTING) R$1.step(`${options?.executeOutputPrefix}Running external command ${color.optional(`(${executedCommand})`)}`);
10897
+ if (!TESTING) R.step(`${options?.executeOutputPrefix}Running external command ${color.optional(`(${executedCommand})`)}`);
10852
10898
  if (workspace.packageManager === "npm") args.unshift("--yes");
10853
10899
  try {
10854
- await z(command, args, {
10900
+ await exec$1(command, args, {
10855
10901
  nodeOptions: {
10856
10902
  cwd: workspace.cwd,
10857
10903
  stdio: TESTING ? "pipe" : stdio
@@ -10880,10 +10926,11 @@ function prepareSvApi(workspace, options = {
10880
10926
  return {
10881
10927
  sv,
10882
10928
  finalize: () => {
10883
- updatePackages(dependencies, sv);
10929
+ const { installNeeded } = updatePackages(dependencies, sv);
10884
10930
  return {
10885
10931
  modifiedFiles,
10886
- unmodifiedFiles
10932
+ unmodifiedFiles,
10933
+ installNeeded
10887
10934
  };
10888
10935
  }
10889
10936
  };
@@ -10914,4 +10961,4 @@ function orderAddons(addons, setupResults) {
10914
10961
  return ordered;
10915
10962
  }
10916
10963
  //#endregion
10917
- export { Command as A, name as B, pipe as C, union as D, transform as E, forwardExitCode as F, ge as G, Ce as H, helpConfig as I, we as J, le as K, normalizePosix as L, z as M, create$1 as N, from as O, errorAndExit as P, __toESM as Q, runAndValidateVerifications as R, picklist as S, string as T, Ee as U, version as V, R$1 as W, __commonJSMin as X, R$2 as Y, __require as Z, array as _, verifyCleanWorkingDirectory as a, optional as b, AGENT_NAMES as c, installDependencies as d, installOption as f, defineAddonOptions as g, defineAddon as h, create as i, R as j, program as k, addPnpmAllowBuilds as l, officialAddons$1 as m, prepareSvApi as n, formatFiles as o, packageManagerPrompt as p, vt as q, add$1 as r, createWorkspace as s, add as t, detectPackageManager as u, boolean as v, strictObject as w, parse$1 as x, literal as y, runCommand as z };
10964
+ export { Command as A, name as B, pipe as C, union as D, transform as E, forwardExitCode as F, ge as G, Ce as H, helpConfig as I, we as J, le as K, normalizePosix as L, x as M, create$1 as N, from as O, errorAndExit as P, __toESM as Q, runAndValidateVerifications as R, picklist as S, string as T, Ee as U, version as V, R as W, __commonJSMin as X, R$1 as Y, __require as Z, array as _, verifyCleanWorkingDirectory as a, optional as b, AGENT_NAMES as c, installDependencies as d, installOption as f, defineAddonOptions as g, defineAddon as h, create as i, exec$1 as j, program as k, addPnpmAllowBuilds as l, officialAddons$1 as m, prepareSvApi as n, formatFiles as o, packageManagerPrompt as p, vt as q, add$1 as r, createWorkspace as s, add as t, detectPackageManager as u, boolean as v, strictObject as w, parse$1 as x, literal as y, runCommand as z };