sv 1.0.0-next.3 → 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.
- package/dist/bin.mjs +2 -2
- package/dist/{engine-CJqhBXva.mjs → engine-DrWuL_6T.mjs} +484 -430
- package/dist/{engine-0wnzAQ2W.d.mts → engine-_lPWeyCH.d.mts} +1 -0
- package/dist/shared.json +1 -1
- package/dist/src/index.d.mts +1 -1
- package/dist/src/index.mjs +1 -1
- package/dist/src/testing.d.mts +1 -1
- package/dist/src/testing.mjs +4 -4
- package/dist/templates/addon/assets/src/index.js +5 -5
- package/dist/templates/addon/assets/tests/addon.test.js +4 -4
- package/dist/templates/addon/package.json +5 -5
- package/dist/templates/demo/files.types=checkjs.json +2 -2
- package/dist/templates/demo/files.types=none.json +2 -2
- package/dist/templates/demo/files.types=typescript.json +4 -4
- package/dist/templates/demo/package.json +1 -1
- package/dist/templates/library/package.json +1 -1
- package/dist/templates/minimal/package.json +1 -1
- package/package.json +16 -18
|
@@ -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 {
|
|
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
|
|
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$
|
|
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$
|
|
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
|
|
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
|
|
433
|
-
if (typeof r == "string") return h
|
|
434
|
-
for (const s of r) if (s !== void 0 && C
|
|
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
|
|
451
|
-
function R$
|
|
452
|
-
return r === k
|
|
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$
|
|
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
|
|
459
|
+
const i = b.createInterface({
|
|
460
460
|
input: r,
|
|
461
461
|
output: t,
|
|
462
462
|
prompt: "",
|
|
463
463
|
tabSize: 1
|
|
464
464
|
});
|
|
465
|
-
b
|
|
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
|
|
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
|
|
478
|
-
b
|
|
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
|
|
488
|
-
function B
|
|
489
|
-
return wrapAnsi(t, A
|
|
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$
|
|
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
|
|
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$
|
|
562
|
-
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), w$
|
|
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$
|
|
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
|
|
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$
|
|
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
|
|
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$
|
|
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
|
|
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
|
|
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
|
|
799
|
-
const c = A
|
|
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
|
|
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
|
|
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
|
|
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$
|
|
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
|
|
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
|
|
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
|
|
884
|
+
R.message(t, {
|
|
885
885
|
...i,
|
|
886
886
|
symbol: styleText("blue", pt)
|
|
887
887
|
});
|
|
888
888
|
},
|
|
889
889
|
success: (t, i) => {
|
|
890
|
-
R
|
|
890
|
+
R.message(t, {
|
|
891
891
|
...i,
|
|
892
892
|
symbol: styleText("green", mt)
|
|
893
893
|
});
|
|
894
894
|
},
|
|
895
895
|
step: (t, i) => {
|
|
896
|
-
R
|
|
896
|
+
R.message(t, {
|
|
897
897
|
...i,
|
|
898
898
|
symbol: styleText("green", H)
|
|
899
899
|
});
|
|
900
900
|
},
|
|
901
901
|
warn: (t, i) => {
|
|
902
|
-
R
|
|
902
|
+
R.message(t, {
|
|
903
903
|
...i,
|
|
904
904
|
symbol: styleText("yellow", gt)
|
|
905
905
|
});
|
|
906
906
|
},
|
|
907
907
|
warning: (t, i) => {
|
|
908
|
-
R
|
|
908
|
+
R.warn(t, i);
|
|
909
909
|
},
|
|
910
910
|
error: (t, i) => {
|
|
911
|
-
R
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
1019
|
+
const r = s?.output ?? V.stdout, u = s?.withGuide ?? h.withGuide, n = s?.format ?? be, a = [
|
|
1020
1020
|
"",
|
|
1021
|
-
...Se(t, A
|
|
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
|
|
1048
|
-
const A = _ > 1 ? u ?? h
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
1314
|
-
` : ""}${P
|
|
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.
|
|
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 {
|
|
@@ -1445,18 +1445,18 @@ async function runCommand(action) {
|
|
|
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
1447
|
const minimumVersion = "22.17.0";
|
|
1448
|
-
if (isVersionUnsupportedBelow(V.versions.node, minimumVersion)) R
|
|
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
|
|
1456
|
-
R
|
|
1455
|
+
R.error(`${e.name}\n\n${message}`);
|
|
1456
|
+
R.message();
|
|
1457
1457
|
} else if (e instanceof Error) {
|
|
1458
|
-
R
|
|
1459
|
-
R
|
|
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
|
|
1492
|
-
R
|
|
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
|
|
1514
|
-
R
|
|
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$
|
|
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
|
-
"
|
|
1601
|
-
"
|
|
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.
|
|
1735
|
-
const
|
|
1736
|
-
const
|
|
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
|
|
1741
|
-
for (const
|
|
1742
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
1743
|
-
const
|
|
1744
|
-
if (!
|
|
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
|
|
1747
|
-
value
|
|
1746
|
+
key,
|
|
1747
|
+
value
|
|
1748
1748
|
};
|
|
1749
1749
|
}
|
|
1750
|
-
return
|
|
1750
|
+
return defaultEnvPathInfo;
|
|
1751
1751
|
}
|
|
1752
|
-
function
|
|
1753
|
-
const
|
|
1754
|
-
const
|
|
1755
|
-
let
|
|
1756
|
-
let
|
|
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
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
} while (
|
|
1762
|
-
|
|
1763
|
-
const
|
|
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:
|
|
1766
|
-
value:
|
|
1765
|
+
key: path.key,
|
|
1766
|
+
value: newPath
|
|
1767
1767
|
};
|
|
1768
1768
|
}
|
|
1769
|
-
function
|
|
1770
|
-
const
|
|
1769
|
+
function computeEnv(cwd, env, nodePath = true) {
|
|
1770
|
+
const envWithDefault = {
|
|
1771
1771
|
...process.env,
|
|
1772
|
-
...
|
|
1772
|
+
...env
|
|
1773
1773
|
};
|
|
1774
|
-
if (!
|
|
1775
|
-
const
|
|
1776
|
-
|
|
1777
|
-
return
|
|
1778
|
-
}
|
|
1779
|
-
const
|
|
1780
|
-
let
|
|
1781
|
-
const
|
|
1782
|
-
const
|
|
1783
|
-
if (--
|
|
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
|
|
1786
|
-
return
|
|
1785
|
+
for (const stream of streams) pipeline(stream, combined, { end: false }).then(maybeEmitEnd).catch(maybeEmitEnd);
|
|
1786
|
+
return combined;
|
|
1787
1787
|
};
|
|
1788
|
-
const
|
|
1789
|
-
const
|
|
1790
|
-
const
|
|
1791
|
-
const
|
|
1792
|
-
const
|
|
1793
|
-
const
|
|
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
|
|
1806
|
-
if (
|
|
1807
|
-
command
|
|
1808
|
-
args
|
|
1809
|
-
options
|
|
1806
|
+
function normalizeSpawnCommand(command, args = [], options = {}) {
|
|
1807
|
+
if (options.shell === true || !isWindows) return {
|
|
1808
|
+
command,
|
|
1809
|
+
args,
|
|
1810
|
+
options
|
|
1810
1811
|
};
|
|
1811
|
-
let
|
|
1812
|
-
let
|
|
1813
|
-
if (
|
|
1814
|
-
const
|
|
1815
|
-
const
|
|
1816
|
-
let
|
|
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
|
-
|
|
1819
|
-
readSync(
|
|
1819
|
+
fd = openSync(file, "r");
|
|
1820
|
+
readSync(fd, buffer, 0, size, 0);
|
|
1820
1821
|
} catch {} finally {
|
|
1821
|
-
if (
|
|
1822
|
-
}
|
|
1823
|
-
const
|
|
1824
|
-
if (
|
|
1825
|
-
const
|
|
1826
|
-
const
|
|
1827
|
-
const
|
|
1828
|
-
const
|
|
1829
|
-
const
|
|
1830
|
-
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
if (
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
}
|
|
1838
|
-
if (
|
|
1839
|
-
const
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
if (
|
|
1848
|
-
return
|
|
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
|
-
|
|
1851
|
+
args = [
|
|
1851
1852
|
"/d",
|
|
1852
1853
|
"/s",
|
|
1853
1854
|
"/c",
|
|
1854
|
-
`"${[
|
|
1855
|
+
`"${[command, ...args].join(" ")}"`
|
|
1855
1856
|
];
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
...
|
|
1857
|
+
command = options.env?.comspec ?? "cmd.exe";
|
|
1858
|
+
options = {
|
|
1859
|
+
...options,
|
|
1859
1860
|
windowsVerbatimArguments: true
|
|
1860
1861
|
};
|
|
1861
1862
|
}
|
|
1862
1863
|
return {
|
|
1863
|
-
command
|
|
1864
|
-
args
|
|
1865
|
-
options
|
|
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
|
|
1873
|
-
const
|
|
1874
|
-
const
|
|
1875
|
-
const
|
|
1876
|
-
const
|
|
1877
|
-
|
|
1878
|
-
if (
|
|
1879
|
-
for (const
|
|
1880
|
-
const
|
|
1881
|
-
for (const
|
|
1882
|
-
const
|
|
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(
|
|
1885
|
+
if (statSync(destWithExt).isFile()) return destWithExt;
|
|
1885
1886
|
} catch {}
|
|
1886
1887
|
}
|
|
1887
1888
|
}
|
|
1888
1889
|
return null;
|
|
1889
1890
|
}
|
|
1890
|
-
var
|
|
1891
|
+
var NonZeroExitError = class extends Error {
|
|
1891
1892
|
result;
|
|
1892
1893
|
output;
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
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
|
|
1903
|
-
const
|
|
1913
|
+
const LINE_SEPARATOR_REGEX = /\r?\n/;
|
|
1914
|
+
const defaultOptions = {
|
|
1904
1915
|
timeout: void 0,
|
|
1905
1916
|
persist: false
|
|
1906
1917
|
};
|
|
1907
|
-
const
|
|
1908
|
-
const
|
|
1909
|
-
function
|
|
1910
|
-
const
|
|
1911
|
-
for (const
|
|
1912
|
-
if (
|
|
1913
|
-
|
|
1914
|
-
return
|
|
1915
|
-
}
|
|
1916
|
-
const
|
|
1917
|
-
|
|
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
|
-
|
|
1930
|
+
signal.addEventListener("abort", onAbort, { signal: controller.signal });
|
|
1920
1931
|
}
|
|
1921
|
-
return
|
|
1932
|
+
return controller.signal;
|
|
1922
1933
|
}
|
|
1923
|
-
async function
|
|
1924
|
-
let
|
|
1934
|
+
async function readStream(stream) {
|
|
1935
|
+
let output = "";
|
|
1925
1936
|
try {
|
|
1926
|
-
for await (const
|
|
1937
|
+
for await (const chunk of stream) output += chunk.toString();
|
|
1927
1938
|
} catch {}
|
|
1928
|
-
return
|
|
1939
|
+
return output;
|
|
1929
1940
|
}
|
|
1930
|
-
var
|
|
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
|
-
|
|
1959
|
+
get signalCode() {
|
|
1960
|
+
return this._process?.signalCode ?? null;
|
|
1961
|
+
}
|
|
1962
|
+
constructor(command, args, options) {
|
|
1949
1963
|
this._options = {
|
|
1950
|
-
...
|
|
1951
|
-
...
|
|
1964
|
+
...defaultOptions,
|
|
1965
|
+
...options
|
|
1952
1966
|
};
|
|
1953
|
-
this._command =
|
|
1954
|
-
this._args =
|
|
1955
|
-
this._processClosed = new Promise((
|
|
1956
|
-
this._resolveClose =
|
|
1967
|
+
this._command = command;
|
|
1968
|
+
this._args = args ?? [];
|
|
1969
|
+
this._processClosed = new Promise((resolve) => {
|
|
1970
|
+
this._resolveClose = resolve;
|
|
1957
1971
|
});
|
|
1958
1972
|
}
|
|
1959
|
-
kill(
|
|
1960
|
-
return this._process?.kill(
|
|
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(
|
|
1969
|
-
return
|
|
1970
|
-
...
|
|
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
|
|
1976
|
-
if (!
|
|
1977
|
-
const
|
|
1978
|
-
if (this._streamErr)
|
|
1979
|
-
if (this._streamOut)
|
|
1980
|
-
const
|
|
1981
|
-
const
|
|
1982
|
-
for await (const
|
|
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
|
-
|
|
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
|
|
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
|
|
1990
|
-
if (!
|
|
1991
|
-
const [
|
|
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
|
|
1994
|
-
if (
|
|
1995
|
-
|
|
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
|
|
1998
|
-
stderr
|
|
1999
|
-
stdout
|
|
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
|
|
2003
|
-
return
|
|
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(
|
|
2006
|
-
return this._waitForOutput().then(
|
|
2019
|
+
then(onfulfilled, onrejected) {
|
|
2020
|
+
return this._waitForOutput().then(onfulfilled, onrejected);
|
|
2007
2021
|
}
|
|
2008
2022
|
_streamOut;
|
|
2009
2023
|
_streamErr;
|
|
2010
2024
|
spawn() {
|
|
2011
|
-
const
|
|
2012
|
-
const
|
|
2013
|
-
const
|
|
2014
|
-
...
|
|
2015
|
-
...
|
|
2025
|
+
const cwd$1 = cwd();
|
|
2026
|
+
const options = this._options;
|
|
2027
|
+
const nodeOptions = {
|
|
2028
|
+
...defaultNodeOptions,
|
|
2029
|
+
...options.nodeOptions
|
|
2016
2030
|
};
|
|
2017
|
-
const
|
|
2031
|
+
const signals = [];
|
|
2018
2032
|
this._resetState();
|
|
2019
|
-
if (
|
|
2020
|
-
if (
|
|
2021
|
-
if (
|
|
2022
|
-
if (
|
|
2023
|
-
|
|
2024
|
-
const
|
|
2025
|
-
const
|
|
2026
|
-
if (
|
|
2027
|
-
if (
|
|
2028
|
-
this._process =
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
if (
|
|
2032
|
-
const { stdin
|
|
2033
|
-
if (typeof
|
|
2034
|
-
else
|
|
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((
|
|
2040
|
-
this._resolveClose =
|
|
2053
|
+
this._processClosed = new Promise((resolve) => {
|
|
2054
|
+
this._resolveClose = resolve;
|
|
2041
2055
|
});
|
|
2042
2056
|
this._thrownError = void 0;
|
|
2043
2057
|
}
|
|
2044
|
-
_onError = (
|
|
2045
|
-
if (
|
|
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 =
|
|
2063
|
+
this._thrownError = err;
|
|
2050
2064
|
};
|
|
2051
2065
|
_onClose = () => {
|
|
2052
2066
|
if (this._resolveClose) this._resolveClose();
|
|
2053
2067
|
};
|
|
2054
2068
|
};
|
|
2055
|
-
function
|
|
2056
|
-
const
|
|
2057
|
-
...
|
|
2058
|
-
...
|
|
2069
|
+
function xSync(command, args, options) {
|
|
2070
|
+
const opts = {
|
|
2071
|
+
...defaultSyncOptions,
|
|
2072
|
+
...options
|
|
2059
2073
|
};
|
|
2060
|
-
const
|
|
2061
|
-
const
|
|
2074
|
+
const cwd$2 = cwd();
|
|
2075
|
+
const nodeOptions = {
|
|
2062
2076
|
windowsHide: true,
|
|
2063
|
-
...
|
|
2077
|
+
...opts.nodeOptions
|
|
2064
2078
|
};
|
|
2065
|
-
if (
|
|
2066
|
-
|
|
2067
|
-
const
|
|
2068
|
-
const
|
|
2069
|
-
if (
|
|
2070
|
-
const
|
|
2071
|
-
const
|
|
2072
|
-
const
|
|
2073
|
-
const
|
|
2074
|
-
const
|
|
2075
|
-
|
|
2076
|
-
|
|
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
|
|
2093
|
+
return exitCode;
|
|
2094
|
+
},
|
|
2095
|
+
get signalCode() {
|
|
2096
|
+
return signalCode;
|
|
2079
2097
|
},
|
|
2080
2098
|
get pid() {
|
|
2081
|
-
return
|
|
2099
|
+
return spawnResult.pid;
|
|
2082
2100
|
},
|
|
2083
2101
|
get killed() {
|
|
2084
|
-
return
|
|
2102
|
+
return killed;
|
|
2085
2103
|
},
|
|
2086
2104
|
*[Symbol.iterator]() {
|
|
2087
|
-
for (const
|
|
2088
|
-
if (!
|
|
2089
|
-
const
|
|
2090
|
-
if (
|
|
2091
|
-
yield*
|
|
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 (
|
|
2096
|
-
|
|
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
|
|
2099
|
-
const
|
|
2100
|
-
|
|
2101
|
-
return
|
|
2120
|
+
const x = (command, args, userOptions) => {
|
|
2121
|
+
const proc = new ExecProcess(command, args, userOptions);
|
|
2122
|
+
proc.spawn();
|
|
2123
|
+
return proc;
|
|
2102
2124
|
};
|
|
2103
|
-
const
|
|
2104
|
-
const
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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;
|
|
@@ -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 ${
|
|
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
|
-
])
|
|
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
|
-
|
|
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
|
-
])
|
|
7074
|
+
])} to generate a D1 database ID for your ${color.path(`wrangler.${ext}`)}`);
|
|
7037
7075
|
}
|
|
7038
|
-
if (options.docker) steps.push(`Run ${
|
|
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 ${
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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(`
|
|
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) {
|
|
@@ -9219,7 +9258,7 @@ async function packageManagerPrompt(cwd) {
|
|
|
9219
9258
|
}, ...AGENT_NAMES.filter(isInstalled).map((agent) => ({ value: agent }))],
|
|
9220
9259
|
initialValue: agent
|
|
9221
9260
|
});
|
|
9222
|
-
if (R$
|
|
9261
|
+
if (R$1(pm)) {
|
|
9223
9262
|
ge("Operation cancelled.");
|
|
9224
9263
|
V.exit(1);
|
|
9225
9264
|
}
|
|
@@ -9228,7 +9267,7 @@ async function packageManagerPrompt(cwd) {
|
|
|
9228
9267
|
/** Returns `false` when the package manager isn't installed and the install was skipped. */
|
|
9229
9268
|
async function installDependencies(agent, cwd) {
|
|
9230
9269
|
if (!isInstalled(agent)) {
|
|
9231
|
-
R
|
|
9270
|
+
R.warn(`${color.command(agent)} is not installed, skipping dependency installation.`);
|
|
9232
9271
|
return false;
|
|
9233
9272
|
}
|
|
9234
9273
|
const task = Pe({
|
|
@@ -9238,7 +9277,7 @@ async function installDependencies(agent, cwd) {
|
|
|
9238
9277
|
retainLog: true
|
|
9239
9278
|
});
|
|
9240
9279
|
const { command, args } = constructCommand(COMMANDS[agent].install, []);
|
|
9241
|
-
const proc =
|
|
9280
|
+
const proc = exec$1(command, args, {
|
|
9242
9281
|
nodeOptions: {
|
|
9243
9282
|
cwd,
|
|
9244
9283
|
stdio: "pipe"
|
|
@@ -9258,7 +9297,7 @@ async function installDependencies(agent, cwd) {
|
|
|
9258
9297
|
}
|
|
9259
9298
|
if (agent === "pnpm" && output.join("\n").includes("ERR_PNPM_IGNORED_BUILDS")) {
|
|
9260
9299
|
task.success(`Installed dependencies with ${color.command(agent)}`);
|
|
9261
|
-
R
|
|
9300
|
+
R.warn(`Some build scripts were skipped. Run ${color.command(`${agent} approve-builds`)} to approve them.`);
|
|
9262
9301
|
return true;
|
|
9263
9302
|
}
|
|
9264
9303
|
task.error("Failed to install dependencies");
|
|
@@ -9281,7 +9320,7 @@ function isInstalled(agent) {
|
|
|
9281
9320
|
let installed = installedCache.get(agent);
|
|
9282
9321
|
if (installed === void 0) {
|
|
9283
9322
|
try {
|
|
9284
|
-
|
|
9323
|
+
execSync$1(agent, ["--version"], { nodeOptions: { stdio: "ignore" } });
|
|
9285
9324
|
installed = true;
|
|
9286
9325
|
} catch {
|
|
9287
9326
|
installed = false;
|
|
@@ -9436,13 +9475,25 @@ async function formatFiles(options) {
|
|
|
9436
9475
|
];
|
|
9437
9476
|
await withSpinner("Formatting modified files", async () => {
|
|
9438
9477
|
let result = await run("prettier", args, options.cwd);
|
|
9439
|
-
if (result.
|
|
9478
|
+
if (result.error) {
|
|
9440
9479
|
const cmd = resolveCommand(options.packageManager, "execute-local", ["prettier", ...args]);
|
|
9441
9480
|
result = await run(cmd.command, cmd.args, options.cwd);
|
|
9442
9481
|
}
|
|
9443
9482
|
return result;
|
|
9444
9483
|
});
|
|
9445
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
|
+
}
|
|
9446
9497
|
/** Nearest dir from `cwd` up to the workspace root with a `format` or `fmt` package.json script. */
|
|
9447
9498
|
function findFormatScript(cwd) {
|
|
9448
9499
|
const workspaceRoot = findWorkspaceRoot(cwd);
|
|
@@ -9470,14 +9521,14 @@ async function withSpinner(startMsg, task) {
|
|
|
9470
9521
|
const { error } = await task();
|
|
9471
9522
|
if (error !== void 0) {
|
|
9472
9523
|
stop("Failed to format files");
|
|
9473
|
-
R
|
|
9524
|
+
R.error(error);
|
|
9474
9525
|
return;
|
|
9475
9526
|
}
|
|
9476
9527
|
stop("Successfully formatted files");
|
|
9477
9528
|
}
|
|
9478
9529
|
async function run(command, args, cwd) {
|
|
9479
9530
|
try {
|
|
9480
|
-
await
|
|
9531
|
+
await exec$1(command, args, {
|
|
9481
9532
|
nodeOptions: {
|
|
9482
9533
|
cwd,
|
|
9483
9534
|
stdio: "pipe"
|
|
@@ -9486,12 +9537,11 @@ async function run(command, args, cwd) {
|
|
|
9486
9537
|
});
|
|
9487
9538
|
return {};
|
|
9488
9539
|
} catch (e) {
|
|
9489
|
-
if (e
|
|
9490
|
-
|
|
9491
|
-
error:
|
|
9492
|
-
}
|
|
9493
|
-
|
|
9494
|
-
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" };
|
|
9495
9545
|
}
|
|
9496
9546
|
}
|
|
9497
9547
|
//#endregion
|
|
@@ -9727,6 +9777,7 @@ const langOption = new Option("--types <lang>", "add type checking").choices(lan
|
|
|
9727
9777
|
const templateOption = new Option("--template <type>", "template to scaffold").choices(templateChoices);
|
|
9728
9778
|
const noAddonsOption = new Option("--no-add-ons", "do not prompt to add add-ons").conflicts("add");
|
|
9729
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>)");
|
|
9730
9781
|
const noDownloadCheckOption = new Option("--no-download-check", "skip all download confirmation prompts");
|
|
9731
9782
|
const noInstallOption = new Option("--no-install", "skip installing dependencies");
|
|
9732
9783
|
const ProjectPathSchema = /* @__PURE__ */ optional(/* @__PURE__ */ string());
|
|
@@ -9738,9 +9789,10 @@ const OptionsSchema$1 = /* @__PURE__ */ strictObject({
|
|
|
9738
9789
|
template: /* @__PURE__ */ optional(/* @__PURE__ */ picklist(templateChoices)),
|
|
9739
9790
|
fromPlayground: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
|
|
9740
9791
|
dirCheck: /* @__PURE__ */ boolean(),
|
|
9741
|
-
downloadCheck: /* @__PURE__ */ boolean()
|
|
9792
|
+
downloadCheck: /* @__PURE__ */ boolean(),
|
|
9793
|
+
addonName: /* @__PURE__ */ optional(/* @__PURE__ */ string())
|
|
9742
9794
|
});
|
|
9743
|
-
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({
|
|
9744
9796
|
...helpConfig,
|
|
9745
9797
|
formatHelp(cmd, helper) {
|
|
9746
9798
|
const s = getHelpSections(cmd, helper);
|
|
@@ -9775,21 +9827,17 @@ const create = new Command("create").description("Scaffold a new project (--add
|
|
|
9775
9827
|
runCommand(async () => {
|
|
9776
9828
|
const { directory, addOnNextSteps, packageManager, depsInstalled } = await createProject(cwd, options);
|
|
9777
9829
|
let i = 1;
|
|
9778
|
-
const
|
|
9830
|
+
const steps = ["📁 Project steps", ""];
|
|
9779
9831
|
const relative = path.relative(V.cwd(), directory);
|
|
9780
9832
|
const pm = packageManager ?? await detectPackageManager(directory);
|
|
9781
9833
|
if (relative !== "") {
|
|
9782
9834
|
const pathHasSpaces = relative.includes(" ");
|
|
9783
|
-
|
|
9835
|
+
steps.push(` ${i++}: ${color.command(`cd ${pathHasSpaces ? `"${relative}"` : relative}`)}`);
|
|
9784
9836
|
}
|
|
9785
|
-
if (packageManager && !depsInstalled)
|
|
9786
|
-
if (!packageManager || !depsInstalled)
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
` ${i++}: ${color.command(resolveCommandArray(pm, "run", ["dev", "--open"]))}`,
|
|
9790
|
-
"",
|
|
9791
|
-
`To close the dev server, hit ${color.command("Ctrl-C")}`
|
|
9792
|
-
];
|
|
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")}`);
|
|
9793
9841
|
if (addOnNextSteps.length > 0) {
|
|
9794
9842
|
steps.push("", "🧩 Add-on steps", "");
|
|
9795
9843
|
for (const step of addOnNextSteps) {
|
|
@@ -9802,8 +9850,8 @@ const create = new Command("create").description("Scaffold a new project (--add
|
|
|
9802
9850
|
});
|
|
9803
9851
|
}).showHelpAfterError(true);
|
|
9804
9852
|
async function createProject(cwd, options) {
|
|
9805
|
-
if (options.fromPlayground) R
|
|
9806
|
-
if (options.template === "addon" && options.types === "typescript") R
|
|
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.`);
|
|
9807
9855
|
const promptGroupResult = await pe({
|
|
9808
9856
|
directory: () => {
|
|
9809
9857
|
const defaultPath = "./";
|
|
@@ -9822,7 +9870,7 @@ async function createProject(cwd, options) {
|
|
|
9822
9870
|
message: "Directory not empty. Continue?",
|
|
9823
9871
|
initialValue: false
|
|
9824
9872
|
});
|
|
9825
|
-
if (R$
|
|
9873
|
+
if (R$1(force) || !force) {
|
|
9826
9874
|
ge("Exiting.");
|
|
9827
9875
|
V.exit(0);
|
|
9828
9876
|
}
|
|
@@ -9872,23 +9920,19 @@ async function createProject(cwd, options) {
|
|
|
9872
9920
|
const basename = path.basename(projectPath);
|
|
9873
9921
|
const parentDirName = path.basename(path.dirname(projectPath));
|
|
9874
9922
|
let projectName = parentDirName.startsWith("@") ? `${parentDirName}/${basename}` : basename;
|
|
9875
|
-
if (template === "addon"
|
|
9876
|
-
|
|
9877
|
-
|
|
9878
|
-
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
if (!value.startsWith("@")) return "Must start with @";
|
|
9882
|
-
if (value.includes("/")) return "Just the org, not the full package name";
|
|
9883
|
-
}
|
|
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())
|
|
9884
9929
|
});
|
|
9885
|
-
if (R$
|
|
9930
|
+
if (R$1(namePrompt)) {
|
|
9886
9931
|
ge("Operation cancelled.");
|
|
9887
9932
|
V.exit(0);
|
|
9888
9933
|
}
|
|
9889
|
-
projectName =
|
|
9934
|
+
projectName = namePrompt;
|
|
9890
9935
|
}
|
|
9891
|
-
if (template === "addon" && options.add.length > 0) errorAndExit(`The ${color.command("--add")} flag cannot be used with the ${color.command("addon")} template.`);
|
|
9892
9936
|
let loadedAddons = [];
|
|
9893
9937
|
let answers = {};
|
|
9894
9938
|
let addonsOptionsMap = {};
|
|
@@ -9922,7 +9966,7 @@ async function createProject(cwd, options) {
|
|
|
9922
9966
|
types: language
|
|
9923
9967
|
});
|
|
9924
9968
|
if (options.fromPlayground) await createProjectFromPlayground(options.fromPlayground, projectPath);
|
|
9925
|
-
R
|
|
9969
|
+
R.success("Project created");
|
|
9926
9970
|
const packageManager = options.install === false ? null : options.install === true ? await packageManagerPrompt(projectPath) : options.install;
|
|
9927
9971
|
if (packageManager) workspace.packageManager = packageManager;
|
|
9928
9972
|
let argsFormattedAddons = [];
|
|
@@ -9984,12 +10028,12 @@ async function createProjectFromPlayground(url, cwd) {
|
|
|
9984
10028
|
async function confirmExternalDependencies(dependencies) {
|
|
9985
10029
|
if (dependencies.length === 0) return false;
|
|
9986
10030
|
const dependencyList = dependencies.map(color.warning).join(", ");
|
|
9987
|
-
R
|
|
10031
|
+
R.warn(`The following external dependencies were found in the playground:\n\n${dependencyList}`);
|
|
9988
10032
|
const installDeps = await le({
|
|
9989
10033
|
message: "Do you want to install these external dependencies?",
|
|
9990
10034
|
initialValue: false
|
|
9991
10035
|
});
|
|
9992
|
-
if (R$
|
|
10036
|
+
if (R$1(installDeps)) {
|
|
9993
10037
|
ge("Operation cancelled.");
|
|
9994
10038
|
V.exit(0);
|
|
9995
10039
|
}
|
|
@@ -10277,7 +10321,7 @@ async function promptAddonQuestions({ options, loadedAddons, workspace }) {
|
|
|
10277
10321
|
options: addonOptions,
|
|
10278
10322
|
required: false
|
|
10279
10323
|
});
|
|
10280
|
-
if (R$
|
|
10324
|
+
if (R$1(selected)) {
|
|
10281
10325
|
ge("Operation cancelled.");
|
|
10282
10326
|
V.exit(1);
|
|
10283
10327
|
}
|
|
@@ -10370,7 +10414,7 @@ async function promptAddonQuestions({ options, loadedAddons, workspace }) {
|
|
|
10370
10414
|
});
|
|
10371
10415
|
if (question.type === "number") answer = Number(answer);
|
|
10372
10416
|
}
|
|
10373
|
-
if (R$
|
|
10417
|
+
if (R$1(answer)) {
|
|
10374
10418
|
ge("Operation cancelled.");
|
|
10375
10419
|
V.exit(1);
|
|
10376
10420
|
}
|
|
@@ -10391,7 +10435,7 @@ async function runAddonsApply({ answers, options, loadedAddons, setupResults, wo
|
|
|
10391
10435
|
successfulAddons: [],
|
|
10392
10436
|
setupResults: {}
|
|
10393
10437
|
};
|
|
10394
|
-
const { filesToFormat, status } = await applyAddons({
|
|
10438
|
+
const { filesToFormat, status, installNeeded } = await applyAddons({
|
|
10395
10439
|
loadedAddons,
|
|
10396
10440
|
workspace,
|
|
10397
10441
|
setupResults,
|
|
@@ -10401,17 +10445,20 @@ async function runAddonsApply({ answers, options, loadedAddons, setupResults, wo
|
|
|
10401
10445
|
const canceledAddonIds = [];
|
|
10402
10446
|
for (const [addonId, info] of Object.entries(status)) if (info === "success") addonSuccess.push(addonId);
|
|
10403
10447
|
else {
|
|
10404
|
-
R
|
|
10448
|
+
R.warn(`Canceled ${addonId}: ${info.join(", ")}`);
|
|
10405
10449
|
canceledAddonIds.push(addonId);
|
|
10406
10450
|
}
|
|
10407
10451
|
const successfulAddons = loadedAddons.filter((a) => !canceledAddonIds.includes(a.addon.id));
|
|
10408
|
-
if (addonSuccess.length === 0) if (fromCommand === "create") R
|
|
10452
|
+
if (addonSuccess.length === 0) if (fromCommand === "create") R.warn("All selected add-ons were canceled.");
|
|
10409
10453
|
else {
|
|
10410
10454
|
ge("All selected add-ons were canceled.");
|
|
10411
10455
|
V.exit(1);
|
|
10412
10456
|
}
|
|
10413
|
-
else R
|
|
10414
|
-
|
|
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;
|
|
10415
10462
|
addPnpmAllowBuilds(workspace.cwd, packageManager, "esbuild");
|
|
10416
10463
|
const argsFormattedAddons = [];
|
|
10417
10464
|
for (const loaded of successfulAddons) {
|
|
@@ -10442,17 +10489,17 @@ async function runAddonsApply({ answers, options, loadedAddons, setupResults, wo
|
|
|
10442
10489
|
if (!options.gitCheck) argsFormattedAddons.push("--no-git-check");
|
|
10443
10490
|
buildAndLogArgs(packageManager, "add", argsFormattedAddons);
|
|
10444
10491
|
}
|
|
10445
|
-
let depsInstalled =
|
|
10492
|
+
let depsInstalled = false;
|
|
10446
10493
|
if (packageManager) {
|
|
10447
10494
|
workspace.packageManager = packageManager;
|
|
10448
10495
|
depsInstalled = await installDependencies(packageManager, options.cwd);
|
|
10449
|
-
if (depsInstalled) await formatFiles({
|
|
10450
|
-
packageManager,
|
|
10451
|
-
cwd: options.cwd,
|
|
10452
|
-
filesToFormat,
|
|
10453
|
-
strategy: "files-only"
|
|
10454
|
-
});
|
|
10455
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
|
+
});
|
|
10456
10503
|
const nextSteps = getNextSteps(successfulAddons, workspace, answers, setupResults);
|
|
10457
10504
|
if (packageManager && !depsInstalled) nextSteps.unshift(`Install ${color.command(packageManager)}, then run ${color.command(resolveCommandArray(packageManager, "install", []))}`);
|
|
10458
10505
|
return {
|
|
@@ -10474,7 +10521,7 @@ function getNextSteps(loadedAddons, workspace, answers, setupResults) {
|
|
|
10474
10521
|
});
|
|
10475
10522
|
if (addonNextSteps.length === 0) return;
|
|
10476
10523
|
let addonMessage = `${color.addon(addon.id)}:\n`;
|
|
10477
|
-
addonMessage += ` - ${
|
|
10524
|
+
addonMessage += addonNextSteps.map((line) => ` - ${line}`).join("\n");
|
|
10478
10525
|
return addonMessage;
|
|
10479
10526
|
}).filter((msg) => msg !== void 0);
|
|
10480
10527
|
}
|
|
@@ -10596,14 +10643,14 @@ async function resolveNonOfficialAddons(refs, downloadCheck) {
|
|
|
10596
10643
|
return await getPackageJSON(ref);
|
|
10597
10644
|
}));
|
|
10598
10645
|
stop("Resolved community add-on packages");
|
|
10599
|
-
for (const { warning } of pkgs) if (warning) R
|
|
10600
|
-
R
|
|
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.");
|
|
10601
10648
|
const paddingName = getPadding(pkgs.map(({ pkg }) => pkg.name));
|
|
10602
10649
|
const paddingVersion = getPadding(pkgs.map(({ pkg }) => `(v${pkg.version})`));
|
|
10603
10650
|
const packageInfos = pkgs.map(({ pkg, repo: _repo }) => {
|
|
10604
10651
|
return `${color.warning(pkg.name.padEnd(paddingName))} ${color.dim(`(v${pkg.version})`.padEnd(paddingVersion))} ${color.dim(`(${_repo})`)}`;
|
|
10605
10652
|
});
|
|
10606
|
-
R
|
|
10653
|
+
R.message(packageInfos.join("\n"));
|
|
10607
10654
|
if (downloadCheck) {
|
|
10608
10655
|
if (await le({ message: "Would you like to continue?" }) !== true) {
|
|
10609
10656
|
ge("Operation cancelled.");
|
|
@@ -10645,23 +10692,24 @@ function alphabetizeRecord(obj) {
|
|
|
10645
10692
|
return ordered;
|
|
10646
10693
|
}
|
|
10647
10694
|
function updatePackages(dependencies, sv) {
|
|
10648
|
-
|
|
10695
|
+
let installNeeded = false;
|
|
10696
|
+
if (dependencies.length === 0) return { installNeeded };
|
|
10649
10697
|
const pkgPath = filePaths.packageJson;
|
|
10650
10698
|
sv.file(pkgPath, transforms.json(({ content, data }) => {
|
|
10651
10699
|
if (!content) throw new Error(`Invalid workspace: missing '${pkgPath}'`);
|
|
10652
|
-
let modified = false;
|
|
10653
10700
|
for (const { dev, pkg, version } of dependencies) {
|
|
10654
10701
|
const dependency = dev ? "devDependencies" : "dependencies";
|
|
10655
10702
|
data[dependency] ??= {};
|
|
10656
|
-
|
|
10657
|
-
|
|
10658
|
-
|
|
10659
|
-
|
|
10703
|
+
const declared = data[dependency][pkg];
|
|
10704
|
+
if (declared && isRangeWithin(declared, version)) continue;
|
|
10705
|
+
installNeeded = true;
|
|
10706
|
+
data[dependency][pkg] = version;
|
|
10660
10707
|
}
|
|
10661
|
-
if (!
|
|
10708
|
+
if (!installNeeded) return false;
|
|
10662
10709
|
if (data.dependencies) data.dependencies = alphabetizeRecord(data.dependencies);
|
|
10663
10710
|
if (data.devDependencies) data.devDependencies = alphabetizeRecord(data.devDependencies);
|
|
10664
10711
|
}));
|
|
10712
|
+
return { installNeeded };
|
|
10665
10713
|
}
|
|
10666
10714
|
async function add({ addons, cwd, options, packageManager = "npm" }) {
|
|
10667
10715
|
const workspace = await createWorkspace({
|
|
@@ -10680,6 +10728,7 @@ async function applyAddons({ loadedAddons, workspace, setupResults, options }) {
|
|
|
10680
10728
|
const filesToFormat = /* @__PURE__ */ new Set();
|
|
10681
10729
|
const status = {};
|
|
10682
10730
|
const canceledAddons = /* @__PURE__ */ new Set();
|
|
10731
|
+
let installNeeded = false;
|
|
10683
10732
|
const ordered = orderAddons(loadedAddons.map((l) => l.addon), setupResults);
|
|
10684
10733
|
let hasFormatter = false;
|
|
10685
10734
|
for (const addon of ordered) {
|
|
@@ -10696,7 +10745,7 @@ async function applyAddons({ loadedAddons, workspace, setupResults, options }) {
|
|
|
10696
10745
|
packageManager: workspace.packageManager
|
|
10697
10746
|
});
|
|
10698
10747
|
if (!hasFormatter) hasFormatter = !!addonWorkspace.dependencyVersion("prettier");
|
|
10699
|
-
const { files, cancels } = await runAddon({
|
|
10748
|
+
const { files, cancels, installNeeded: addonInstallNeeded } = await runAddon({
|
|
10700
10749
|
workspace: addonWorkspace,
|
|
10701
10750
|
workspaceOptions,
|
|
10702
10751
|
addon,
|
|
@@ -10704,6 +10753,7 @@ async function applyAddons({ loadedAddons, workspace, setupResults, options }) {
|
|
|
10704
10753
|
multiple: ordered.length > 1
|
|
10705
10754
|
});
|
|
10706
10755
|
files.forEach((f) => filesToFormat.add(f));
|
|
10756
|
+
if (addonInstallNeeded) installNeeded = true;
|
|
10707
10757
|
if (cancels.length === 0) status[addon.id] = "success";
|
|
10708
10758
|
else {
|
|
10709
10759
|
canceledAddons.add(addon.id);
|
|
@@ -10712,7 +10762,8 @@ async function applyAddons({ loadedAddons, workspace, setupResults, options }) {
|
|
|
10712
10762
|
}
|
|
10713
10763
|
return {
|
|
10714
10764
|
filesToFormat: hasFormatter ? Array.from(filesToFormat) : [],
|
|
10715
|
-
status
|
|
10765
|
+
status,
|
|
10766
|
+
installNeeded
|
|
10716
10767
|
};
|
|
10717
10768
|
}
|
|
10718
10769
|
/** Setup addons - takes LoadedAddon[] and returns setup results */
|
|
@@ -10768,10 +10819,12 @@ async function runAddon({ addon, loaded, multiple, workspace, workspaceOptions }
|
|
|
10768
10819
|
const msg = err instanceof Error ? err.message : String(err);
|
|
10769
10820
|
throw new Error(`Add-on '${addon.id}' failed during run: ${msg}\n\n${getErrorHint(loaded.reference.source)}`, { cause: err });
|
|
10770
10821
|
}
|
|
10771
|
-
|
|
10822
|
+
let installNeeded = false;
|
|
10823
|
+
if (cancels.length === 0) ({modifiedFiles, installNeeded} = finalize());
|
|
10772
10824
|
return {
|
|
10773
10825
|
files: Array.from(modifiedFiles),
|
|
10774
|
-
cancels
|
|
10826
|
+
cancels,
|
|
10827
|
+
installNeeded
|
|
10775
10828
|
};
|
|
10776
10829
|
}
|
|
10777
10830
|
function editFile(file, edit, workspace, modifiedFiles, unmodifiedFiles, options, include) {
|
|
@@ -10841,10 +10894,10 @@ function prepareSvApi(workspace, options = {
|
|
|
10841
10894
|
execute: async (commandArgs, stdio) => {
|
|
10842
10895
|
const { command, args } = resolveCommand(workspace.packageManager, "execute", commandArgs);
|
|
10843
10896
|
const executedCommand = [command, ...args].join(" ");
|
|
10844
|
-
if (!TESTING) R
|
|
10897
|
+
if (!TESTING) R.step(`${options?.executeOutputPrefix}Running external command ${color.optional(`(${executedCommand})`)}`);
|
|
10845
10898
|
if (workspace.packageManager === "npm") args.unshift("--yes");
|
|
10846
10899
|
try {
|
|
10847
|
-
await
|
|
10900
|
+
await exec$1(command, args, {
|
|
10848
10901
|
nodeOptions: {
|
|
10849
10902
|
cwd: workspace.cwd,
|
|
10850
10903
|
stdio: TESTING ? "pipe" : stdio
|
|
@@ -10873,10 +10926,11 @@ function prepareSvApi(workspace, options = {
|
|
|
10873
10926
|
return {
|
|
10874
10927
|
sv,
|
|
10875
10928
|
finalize: () => {
|
|
10876
|
-
updatePackages(dependencies, sv);
|
|
10929
|
+
const { installNeeded } = updatePackages(dependencies, sv);
|
|
10877
10930
|
return {
|
|
10878
10931
|
modifiedFiles,
|
|
10879
|
-
unmodifiedFiles
|
|
10932
|
+
unmodifiedFiles,
|
|
10933
|
+
installNeeded
|
|
10880
10934
|
};
|
|
10881
10935
|
}
|
|
10882
10936
|
};
|
|
@@ -10907,4 +10961,4 @@ function orderAddons(addons, setupResults) {
|
|
|
10907
10961
|
return ordered;
|
|
10908
10962
|
}
|
|
10909
10963
|
//#endregion
|
|
10910
|
-
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,
|
|
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 };
|