vite-plus 0.2.1 → 0.2.3
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/bin/oxfmt +6 -3
- package/bin/oxlint +6 -3
- package/bin/vpr +9 -0
- package/binding/index.cjs +53 -53
- package/binding/index.d.cts +86 -144
- package/dist/agent-D3nZAMGI.js +9456 -0
- package/dist/bin.js +10 -7
- package/dist/{cli-truncate-CWsmbK3p.js → cli-truncate-BVOlIIPy.js} +1 -1
- package/dist/config/bin.js +2 -2
- package/dist/{constants-CrfJQIUX.js → constants-CZ7Mnq-C.js} +7 -3
- package/dist/create/bin.js +800 -806
- package/dist/{define-config-2tfJoXr1.d.ts → define-config-BuMs_LKa.d.ts} +64 -9
- package/dist/{define-config-DJUehepE.js → define-config-D2jo1xVA.js} +43 -18
- package/dist/{define-config-BGSjF6Xp.cjs → define-config-Dut6XD42.cjs} +61 -22
- package/dist/define-config.cjs +2 -1
- package/dist/define-config.d.ts +2 -2
- package/dist/define-config.js +2 -2
- package/dist/{dist-Oxo16Y0q.js → dist-CKz3vcoG.js} +4 -4
- package/dist/dist-CtM2JRbM.js +3 -0
- package/dist/editor-D1BZiU1h.js +584 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{json-Dn87fvjk.js → json-DiRs8ceZ.js} +13 -1
- package/dist/{log-update-lyIiuflf.js → log-update-DHZRyJ2m.js} +2 -2
- package/dist/migration/bin.d.ts +1 -10
- package/dist/migration/bin.js +531 -170
- package/dist/migration/compat/worker.d.ts +1 -0
- package/dist/migration/compat/worker.js +35 -0
- package/dist/{oxlint-plugin-config-q8a5PFch.js → oxlint-plugin-config-BSbv66Qn.js} +1 -1
- package/dist/oxlint-plugin.js +78 -9
- package/dist/pack-bin.js +1 -1
- package/dist/{package-BHirM1_v.js → package-Cpo2ei_V.js} +52 -3
- package/dist/protocol-D99W10Qi.js +4 -0
- package/dist/{report-BHSkWqRR.js → report-BS7ULx7A.js} +2 -0
- package/dist/{resolve-vite-config-CmdsfQzS.js → resolve-vite-config-DX2o0SWM.js} +14 -10
- package/dist/{rolldown-runtime-DnnnRqeS.js → rolldown-runtime-C7HZzL1F.js} +1 -1
- package/dist/staged/bin.js +23 -19
- package/dist/{tsconfig-BWQPmGKz.js → tsconfig-D6sTl0dN.js} +439 -208
- package/dist/version.js +2 -5
- package/dist/versions.js +5 -5
- package/dist/{wrap-ansi-k7Dn4VtV.js → wrap-ansi-DNjkuBEp.js} +1 -1
- package/dist/wrap-ansi-DUi52C6W.js +2 -0
- package/docs/_data/team.ts +9 -0
- package/docs/config/check.md +35 -0
- package/docs/config/index.md +2 -0
- package/docs/config/run.md +61 -12
- package/docs/guide/automatic-data-tracking.md +145 -0
- package/docs/guide/cache.md +14 -35
- package/docs/guide/check.md +16 -0
- package/docs/guide/ci.md +4 -0
- package/docs/guide/docker.md +175 -0
- package/docs/guide/env.md +13 -1
- package/docs/guide/github-actions-cache.md +165 -0
- package/docs/guide/install.md +12 -2
- package/docs/guide/migrate-rules.md +347 -0
- package/docs/guide/migrate.md +14 -0
- package/docs/guide/pack.md +8 -0
- package/docs/guide/run.md +33 -3
- package/docs/guide/troubleshooting.md +3 -3
- package/docs/guide/upgrade.md +43 -21
- package/docs/package.json +3 -2
- package/docs/vite.config.ts +17 -0
- package/package.json +19 -18
- package/dist/agent--cKmgD_n.js +0 -3341
- package/dist/compat-Cql3K40m.js +0 -14
- package/dist/dist-DRJUd9bL.js +0 -3
- package/dist/workspace-D0AVy4fu.js +0 -5830
- package/dist/wrap-ansi-CeQuiQ31.js +0 -2
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { n as __require, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-
|
|
2
|
-
import { l as
|
|
1
|
+
import { n as __require, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-C7HZzL1F.js";
|
|
2
|
+
import { l as VITE_PLUS_VERSION, t as BASEURL_TSCONFIG_FIX_PACKAGE, u as createBaseUrlTsconfigFixArgs } from "./constants-CZ7Mnq-C.js";
|
|
3
3
|
import { t as accent } from "./terminal-uTv0ZaMr.js";
|
|
4
|
-
import { a as
|
|
4
|
+
import { a as writeJsonFile, c as parse, i as readJsonFile, o as applyEdits, s as modify } from "./json-DiRs8ceZ.js";
|
|
5
|
+
import { t as require_dist } from "./dist-CKz3vcoG.js";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import { downloadPackageManager } from "../binding/index.js";
|
|
7
8
|
import fs from "node:fs";
|
|
8
9
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
9
10
|
import process$1, { stdin, stdout } from "node:process";
|
|
10
|
-
import * as
|
|
11
|
-
import
|
|
11
|
+
import * as l from "node:readline";
|
|
12
|
+
import l__default from "node:readline";
|
|
12
13
|
import { ReadStream } from "node:tty";
|
|
13
14
|
//#region ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
|
|
14
15
|
var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -146,7 +147,8 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
146
147
|
const ppRaw = pathEnv[i];
|
|
147
148
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
148
149
|
const pCmd = path$3.join(pathPart, cmd);
|
|
149
|
-
|
|
150
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
151
|
+
resolve(subStep(p, i, 0));
|
|
150
152
|
});
|
|
151
153
|
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
152
154
|
if (ii === pathExt.length) return resolve(step(i + 1));
|
|
@@ -421,6 +423,12 @@ async function runCommandSilently(options) {
|
|
|
421
423
|
return await new Promise((resolve, reject) => {
|
|
422
424
|
const stdout = [];
|
|
423
425
|
const stderr = [];
|
|
426
|
+
let timedOut = false;
|
|
427
|
+
const timer = options.timeoutMs === void 0 ? void 0 : setTimeout(() => {
|
|
428
|
+
timedOut = true;
|
|
429
|
+
child.kill("SIGKILL");
|
|
430
|
+
}, options.timeoutMs);
|
|
431
|
+
timer?.unref();
|
|
424
432
|
child.stdout?.on("data", (data) => {
|
|
425
433
|
stdout.push(data);
|
|
426
434
|
});
|
|
@@ -428,6 +436,11 @@ async function runCommandSilently(options) {
|
|
|
428
436
|
stderr.push(data);
|
|
429
437
|
});
|
|
430
438
|
child.on("close", (code) => {
|
|
439
|
+
clearTimeout(timer);
|
|
440
|
+
if (timedOut) {
|
|
441
|
+
reject(/* @__PURE__ */ new Error(`Command timed out after ${options.timeoutMs}ms: ${options.command}`));
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
431
444
|
resolve({
|
|
432
445
|
exitCode: code ?? 0,
|
|
433
446
|
stdout: Buffer.concat(stdout),
|
|
@@ -435,6 +448,7 @@ async function runCommandSilently(options) {
|
|
|
435
448
|
});
|
|
436
449
|
});
|
|
437
450
|
child.on("error", (err) => {
|
|
451
|
+
clearTimeout(timer);
|
|
438
452
|
reject(err);
|
|
439
453
|
});
|
|
440
454
|
});
|
|
@@ -737,7 +751,7 @@ function wrapAnsi$1(string, columns, options) {
|
|
|
737
751
|
return String(string).normalize().split(CRLF_OR_LF$1).map((line) => exec$1(line, columns, options)).join("\n");
|
|
738
752
|
}
|
|
739
753
|
//#endregion
|
|
740
|
-
//#region ../../node_modules/.pnpm/@clack+core@1.4.
|
|
754
|
+
//#region ../../node_modules/.pnpm/@clack+core@1.4.2/node_modules/@clack/core/dist/index.mjs
|
|
741
755
|
var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
742
756
|
const ESC = "\x1B";
|
|
743
757
|
const CSI = `${ESC}[`;
|
|
@@ -790,13 +804,13 @@ var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
790
804
|
beep
|
|
791
805
|
};
|
|
792
806
|
})))();
|
|
793
|
-
function
|
|
794
|
-
if (!
|
|
795
|
-
const
|
|
796
|
-
return
|
|
807
|
+
function findCursor(s, o, l) {
|
|
808
|
+
if (!l.some((r) => !r.disabled)) return s;
|
|
809
|
+
const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
810
|
+
return l[e].disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
|
|
797
811
|
}
|
|
798
|
-
const
|
|
799
|
-
actions: new Set([
|
|
812
|
+
const settings = {
|
|
813
|
+
actions: /* @__PURE__ */ new Set([
|
|
800
814
|
"up",
|
|
801
815
|
"down",
|
|
802
816
|
"left",
|
|
@@ -805,7 +819,7 @@ const h = {
|
|
|
805
819
|
"enter",
|
|
806
820
|
"cancel"
|
|
807
821
|
]),
|
|
808
|
-
aliases: new Map([
|
|
822
|
+
aliases: /* @__PURE__ */ new Map([
|
|
809
823
|
["k", "up"],
|
|
810
824
|
["j", "down"],
|
|
811
825
|
["h", "left"],
|
|
@@ -817,7 +831,7 @@ const h = {
|
|
|
817
831
|
cancel: "Canceled",
|
|
818
832
|
error: "Something went wrong"
|
|
819
833
|
},
|
|
820
|
-
withGuide:
|
|
834
|
+
withGuide: true,
|
|
821
835
|
date: {
|
|
822
836
|
monthNames: [...[
|
|
823
837
|
"January",
|
|
@@ -836,95 +850,96 @@ const h = {
|
|
|
836
850
|
messages: {
|
|
837
851
|
required: "Please enter a valid date",
|
|
838
852
|
invalidMonth: "There are only 12 months in a year",
|
|
839
|
-
invalidDay: (
|
|
840
|
-
afterMin: (
|
|
841
|
-
beforeMax: (
|
|
853
|
+
invalidDay: (n, e) => `There are only ${n} days in ${e}`,
|
|
854
|
+
afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
|
|
855
|
+
beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
|
|
842
856
|
}
|
|
843
857
|
}
|
|
844
858
|
};
|
|
845
|
-
function
|
|
846
|
-
if (typeof
|
|
847
|
-
for (const s of
|
|
848
|
-
return
|
|
859
|
+
function isActionKey(n, e) {
|
|
860
|
+
if (typeof n == "string") return settings.aliases.get(n) === e;
|
|
861
|
+
for (const s of n) if (s !== void 0 && isActionKey(s, e)) return true;
|
|
862
|
+
return false;
|
|
849
863
|
}
|
|
850
|
-
function
|
|
851
|
-
if (
|
|
852
|
-
const
|
|
853
|
-
`),
|
|
854
|
-
`),
|
|
855
|
-
for (let
|
|
864
|
+
function diffLines(i, s) {
|
|
865
|
+
if (i === s) return;
|
|
866
|
+
const e = i.split(`
|
|
867
|
+
`), t = s.split(`
|
|
868
|
+
`), r = Math.max(e.length, t.length), f = [];
|
|
869
|
+
for (let n = 0; n < r; n++) e[n] !== t[n] && f.push(n);
|
|
856
870
|
return {
|
|
857
|
-
lines:
|
|
858
|
-
numLinesBefore:
|
|
859
|
-
numLinesAfter:
|
|
860
|
-
numLines:
|
|
871
|
+
lines: f,
|
|
872
|
+
numLinesBefore: e.length,
|
|
873
|
+
numLinesAfter: t.length,
|
|
874
|
+
numLines: r
|
|
861
875
|
};
|
|
862
876
|
}
|
|
863
|
-
const
|
|
864
|
-
|
|
865
|
-
|
|
877
|
+
const R = globalThis.process.platform.startsWith("win");
|
|
878
|
+
const CANCEL_SYMBOL = Symbol("clack:cancel");
|
|
879
|
+
function isCancel(e) {
|
|
880
|
+
return e === CANCEL_SYMBOL;
|
|
866
881
|
}
|
|
867
|
-
function
|
|
868
|
-
const
|
|
869
|
-
|
|
882
|
+
function setRawMode(e, r) {
|
|
883
|
+
const o = e;
|
|
884
|
+
o.isTTY && o.setRawMode(r);
|
|
870
885
|
}
|
|
871
|
-
function
|
|
872
|
-
const
|
|
873
|
-
input:
|
|
874
|
-
output:
|
|
886
|
+
function block({ input: e = stdin, output: r = stdout, overwrite: o = true, hideCursor: t = true } = {}) {
|
|
887
|
+
const s = l.createInterface({
|
|
888
|
+
input: e,
|
|
889
|
+
output: r,
|
|
875
890
|
prompt: "",
|
|
876
891
|
tabSize: 1
|
|
877
892
|
});
|
|
878
|
-
|
|
879
|
-
const n = (
|
|
880
|
-
if (
|
|
881
|
-
String(
|
|
882
|
-
|
|
883
|
-
|
|
893
|
+
l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
|
|
894
|
+
const n = (f, { name: a, sequence: p }) => {
|
|
895
|
+
if (isActionKey([
|
|
896
|
+
String(f),
|
|
897
|
+
a,
|
|
898
|
+
p
|
|
884
899
|
], "cancel")) {
|
|
885
|
-
|
|
900
|
+
t && r.write(import_src.cursor.show), process.exit(0);
|
|
886
901
|
return;
|
|
887
902
|
}
|
|
888
|
-
if (!
|
|
889
|
-
const
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
903
|
+
if (!o) return;
|
|
904
|
+
const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
|
|
905
|
+
l.moveCursor(r, i, m, () => {
|
|
906
|
+
l.clearLine(r, 1, () => {
|
|
907
|
+
e.once("keypress", n);
|
|
893
908
|
});
|
|
894
909
|
});
|
|
895
910
|
};
|
|
896
|
-
return
|
|
897
|
-
|
|
911
|
+
return t && r.write(import_src.cursor.hide), e.once("keypress", n), () => {
|
|
912
|
+
e.off("keypress", n), t && r.write(import_src.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
|
|
898
913
|
};
|
|
899
914
|
}
|
|
900
|
-
const
|
|
901
|
-
function
|
|
902
|
-
return wrapAnsi$1(
|
|
903
|
-
hard:
|
|
904
|
-
trim:
|
|
915
|
+
const getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80, getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
916
|
+
function wrapTextWithPrefix(e, r, o, t = o, s = o, n) {
|
|
917
|
+
return wrapAnsi$1(r, getColumns(e ?? stdout) - o.length, {
|
|
918
|
+
hard: true,
|
|
919
|
+
trim: false
|
|
905
920
|
}).split(`
|
|
906
|
-
`).map((
|
|
907
|
-
const
|
|
908
|
-
return
|
|
921
|
+
`).map((c, i, m) => {
|
|
922
|
+
const d = n ? n(c, i) : c;
|
|
923
|
+
return i === 0 ? `${t}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
909
924
|
}).join(`
|
|
910
925
|
`);
|
|
911
926
|
}
|
|
912
|
-
function
|
|
913
|
-
if ("~standard" in
|
|
914
|
-
const
|
|
915
|
-
if (
|
|
916
|
-
return
|
|
927
|
+
function runValidation(e, n) {
|
|
928
|
+
if ("~standard" in e) {
|
|
929
|
+
const a = e["~standard"].validate(n);
|
|
930
|
+
if (a instanceof Promise) throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
931
|
+
return a.issues?.at(0)?.message;
|
|
917
932
|
}
|
|
918
|
-
return
|
|
933
|
+
return e(n);
|
|
919
934
|
}
|
|
920
|
-
var
|
|
935
|
+
var V = class {
|
|
921
936
|
input;
|
|
922
937
|
output;
|
|
923
938
|
_abortSignal;
|
|
924
939
|
rl;
|
|
925
940
|
opts;
|
|
926
941
|
_render;
|
|
927
|
-
_track =
|
|
942
|
+
_track = false;
|
|
928
943
|
_prevFrame = "";
|
|
929
944
|
_subscribers = /* @__PURE__ */ new Map();
|
|
930
945
|
_cursor = 0;
|
|
@@ -932,131 +947,153 @@ var m = class {
|
|
|
932
947
|
error = "";
|
|
933
948
|
value;
|
|
934
949
|
userInput = "";
|
|
935
|
-
constructor(t,
|
|
936
|
-
const { input:
|
|
937
|
-
this.opts =
|
|
950
|
+
constructor(t, e = true) {
|
|
951
|
+
const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t;
|
|
952
|
+
this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i, this.output = n;
|
|
938
953
|
}
|
|
954
|
+
/**
|
|
955
|
+
* Unsubscribe all listeners
|
|
956
|
+
*/
|
|
939
957
|
unsubscribe() {
|
|
940
958
|
this._subscribers.clear();
|
|
941
959
|
}
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
960
|
+
/**
|
|
961
|
+
* Set a subscriber with opts
|
|
962
|
+
* @param event - The event name
|
|
963
|
+
*/
|
|
964
|
+
setSubscriber(t, e) {
|
|
965
|
+
const i = this._subscribers.get(t) ?? [];
|
|
966
|
+
i.push(e), this._subscribers.set(t, i);
|
|
945
967
|
}
|
|
946
|
-
|
|
947
|
-
|
|
968
|
+
/**
|
|
969
|
+
* Subscribe to an event
|
|
970
|
+
* @param event - The event name
|
|
971
|
+
* @param cb - The callback
|
|
972
|
+
*/
|
|
973
|
+
on(t, e) {
|
|
974
|
+
this.setSubscriber(t, { cb: e });
|
|
948
975
|
}
|
|
949
|
-
|
|
976
|
+
/**
|
|
977
|
+
* Subscribe to an event once
|
|
978
|
+
* @param event - The event name
|
|
979
|
+
* @param cb - The callback
|
|
980
|
+
*/
|
|
981
|
+
once(t, e) {
|
|
950
982
|
this.setSubscriber(t, {
|
|
951
|
-
cb:
|
|
952
|
-
once:
|
|
983
|
+
cb: e,
|
|
984
|
+
once: true
|
|
953
985
|
});
|
|
954
986
|
}
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
987
|
+
/**
|
|
988
|
+
* Emit an event with data
|
|
989
|
+
* @param event - The event name
|
|
990
|
+
* @param data - The data to pass to the callback
|
|
991
|
+
*/
|
|
992
|
+
emit(t, ...e) {
|
|
993
|
+
const i = this._subscribers.get(t) ?? [], n = [];
|
|
994
|
+
for (const s of i) s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
|
|
995
|
+
for (const s of n) s();
|
|
959
996
|
}
|
|
960
997
|
prompt() {
|
|
961
998
|
return new Promise((t) => {
|
|
962
999
|
if (this._abortSignal) {
|
|
963
|
-
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(
|
|
1000
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
|
|
964
1001
|
this._abortSignal.addEventListener("abort", () => {
|
|
965
1002
|
this.state = "cancel", this.close();
|
|
966
|
-
}, { once:
|
|
1003
|
+
}, { once: true });
|
|
967
1004
|
}
|
|
968
|
-
this.rl =
|
|
1005
|
+
this.rl = l__default.createInterface({
|
|
969
1006
|
input: this.input,
|
|
970
1007
|
tabSize: 2,
|
|
971
1008
|
prompt: "",
|
|
972
1009
|
escapeCodeTimeout: 50,
|
|
973
|
-
terminal:
|
|
974
|
-
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput,
|
|
975
|
-
this.output.write(import_src.cursor.show), this.output.off("resize", this.render),
|
|
1010
|
+
terminal: true
|
|
1011
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
1012
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
|
|
976
1013
|
}), this.once("cancel", () => {
|
|
977
|
-
this.output.write(import_src.cursor.show), this.output.off("resize", this.render),
|
|
1014
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
|
|
978
1015
|
});
|
|
979
1016
|
});
|
|
980
1017
|
}
|
|
981
|
-
_isActionKey(t,
|
|
1018
|
+
_isActionKey(t, e) {
|
|
982
1019
|
return t === " ";
|
|
983
1020
|
}
|
|
984
|
-
_shouldSubmit(t,
|
|
985
|
-
return
|
|
1021
|
+
_shouldSubmit(t, e) {
|
|
1022
|
+
return true;
|
|
986
1023
|
}
|
|
987
1024
|
_setValue(t) {
|
|
988
1025
|
this.value = t, this.emit("value", this.value);
|
|
989
1026
|
}
|
|
990
|
-
_setUserInput(t,
|
|
991
|
-
this.userInput = t ?? "", this.emit("userInput", this.userInput),
|
|
1027
|
+
_setUserInput(t, e) {
|
|
1028
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
992
1029
|
}
|
|
993
1030
|
_clearUserInput() {
|
|
994
1031
|
this.rl?.write(null, {
|
|
995
|
-
ctrl:
|
|
1032
|
+
ctrl: true,
|
|
996
1033
|
name: "u"
|
|
997
1034
|
}), this._setUserInput("");
|
|
998
1035
|
}
|
|
999
|
-
onKeypress(t,
|
|
1000
|
-
if (this._track &&
|
|
1001
|
-
ctrl:
|
|
1036
|
+
onKeypress(t, e) {
|
|
1037
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, {
|
|
1038
|
+
ctrl: true,
|
|
1002
1039
|
name: "h"
|
|
1003
|
-
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"),
|
|
1040
|
+
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
|
|
1004
1041
|
if (this.opts.validate) {
|
|
1005
|
-
const
|
|
1006
|
-
|
|
1042
|
+
const i = runValidation(this.opts.validate, this.value);
|
|
1043
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
1007
1044
|
}
|
|
1008
1045
|
this.state !== "error" && (this.state = "submit");
|
|
1009
1046
|
}
|
|
1010
|
-
|
|
1047
|
+
isActionKey([
|
|
1011
1048
|
t,
|
|
1012
|
-
|
|
1013
|
-
|
|
1049
|
+
e?.name,
|
|
1050
|
+
e?.sequence
|
|
1014
1051
|
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
1015
1052
|
}
|
|
1016
1053
|
close() {
|
|
1017
1054
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
1018
|
-
`),
|
|
1055
|
+
`), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
1019
1056
|
}
|
|
1020
1057
|
restoreCursor() {
|
|
1021
1058
|
const t = wrapAnsi$1(this._prevFrame, process.stdout.columns, {
|
|
1022
|
-
hard:
|
|
1023
|
-
trim:
|
|
1059
|
+
hard: true,
|
|
1060
|
+
trim: false
|
|
1024
1061
|
}).split(`
|
|
1025
1062
|
`).length - 1;
|
|
1026
1063
|
this.output.write(import_src.cursor.move(-999, t * -1));
|
|
1027
1064
|
}
|
|
1028
1065
|
render() {
|
|
1029
1066
|
const t = wrapAnsi$1(this._render(this) ?? "", process.stdout.columns, {
|
|
1030
|
-
hard:
|
|
1031
|
-
trim:
|
|
1067
|
+
hard: true,
|
|
1068
|
+
trim: false
|
|
1032
1069
|
});
|
|
1033
1070
|
if (t !== this._prevFrame) {
|
|
1034
1071
|
if (this.state === "initial") this.output.write(import_src.cursor.hide);
|
|
1035
1072
|
else {
|
|
1036
|
-
const
|
|
1037
|
-
if (this.restoreCursor(),
|
|
1038
|
-
const
|
|
1039
|
-
let
|
|
1040
|
-
if (
|
|
1073
|
+
const e = diffLines(this._prevFrame, t), i = getRows(this.output);
|
|
1074
|
+
if (this.restoreCursor(), e) {
|
|
1075
|
+
const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
|
|
1076
|
+
let r = e.lines.find((o) => o >= n);
|
|
1077
|
+
if (r === void 0) {
|
|
1041
1078
|
this._prevFrame = t;
|
|
1042
1079
|
return;
|
|
1043
1080
|
}
|
|
1044
|
-
if (
|
|
1045
|
-
this.output.write(import_src.cursor.move(0,
|
|
1046
|
-
const
|
|
1081
|
+
if (e.lines.length === 1) {
|
|
1082
|
+
this.output.write(import_src.cursor.move(0, r - s)), this.output.write(import_src.erase.lines(1));
|
|
1083
|
+
const o = t.split(`
|
|
1047
1084
|
`);
|
|
1048
|
-
this.output.write(
|
|
1085
|
+
this.output.write(o[r]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, o.length - r - 1));
|
|
1049
1086
|
return;
|
|
1050
|
-
} else if (
|
|
1051
|
-
if (
|
|
1087
|
+
} else if (e.lines.length > 1) {
|
|
1088
|
+
if (n < s) r = n;
|
|
1052
1089
|
else {
|
|
1053
|
-
const
|
|
1054
|
-
|
|
1090
|
+
const h = r - s;
|
|
1091
|
+
h > 0 && this.output.write(import_src.cursor.move(0, h));
|
|
1055
1092
|
}
|
|
1056
1093
|
this.output.write(import_src.erase.down());
|
|
1057
|
-
const
|
|
1058
|
-
`).slice(
|
|
1059
|
-
this.output.write(
|
|
1094
|
+
const f = t.split(`
|
|
1095
|
+
`).slice(r);
|
|
1096
|
+
this.output.write(f.join(`
|
|
1060
1097
|
`)), this._prevFrame = t;
|
|
1061
1098
|
return;
|
|
1062
1099
|
}
|
|
@@ -1067,7 +1104,7 @@ var m = class {
|
|
|
1067
1104
|
}
|
|
1068
1105
|
}
|
|
1069
1106
|
};
|
|
1070
|
-
var
|
|
1107
|
+
var r = class extends V {
|
|
1071
1108
|
get cursor() {
|
|
1072
1109
|
return this.value ? 0 : 1;
|
|
1073
1110
|
}
|
|
@@ -1075,53 +1112,53 @@ var Z = class extends m {
|
|
|
1075
1112
|
return this.cursor === 0;
|
|
1076
1113
|
}
|
|
1077
1114
|
constructor(t) {
|
|
1078
|
-
super(t,
|
|
1115
|
+
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
1079
1116
|
this.value = this._value;
|
|
1080
|
-
}), this.on("confirm", (
|
|
1081
|
-
this.output.write(import_src.cursor.move(0, -1)), this.value =
|
|
1117
|
+
}), this.on("confirm", (i) => {
|
|
1118
|
+
this.output.write(import_src.cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
|
|
1082
1119
|
}), this.on("cursor", () => {
|
|
1083
1120
|
this.value = !this.value;
|
|
1084
1121
|
});
|
|
1085
1122
|
}
|
|
1086
1123
|
};
|
|
1087
|
-
let
|
|
1124
|
+
let a$1 = class a extends V {
|
|
1088
1125
|
options;
|
|
1089
1126
|
cursor = 0;
|
|
1090
1127
|
get _value() {
|
|
1091
1128
|
return this.options[this.cursor].value;
|
|
1092
1129
|
}
|
|
1093
1130
|
get _enabledOptions() {
|
|
1094
|
-
return this.options.filter((
|
|
1131
|
+
return this.options.filter((e) => e.disabled !== true);
|
|
1095
1132
|
}
|
|
1096
1133
|
toggleAll() {
|
|
1097
|
-
const
|
|
1098
|
-
this.value =
|
|
1134
|
+
const e = this._enabledOptions, i = this.value !== void 0 && this.value.length === e.length;
|
|
1135
|
+
this.value = i ? [] : e.map((t) => t.value);
|
|
1099
1136
|
}
|
|
1100
1137
|
toggleInvert() {
|
|
1101
|
-
const
|
|
1102
|
-
if (!
|
|
1103
|
-
const
|
|
1104
|
-
this.value =
|
|
1138
|
+
const e = this.value;
|
|
1139
|
+
if (!e) return;
|
|
1140
|
+
const i = this._enabledOptions.filter((t) => !e.includes(t.value));
|
|
1141
|
+
this.value = i.map((t) => t.value);
|
|
1105
1142
|
}
|
|
1106
1143
|
toggleValue() {
|
|
1107
1144
|
this.value === void 0 && (this.value = []);
|
|
1108
|
-
const
|
|
1109
|
-
this.value =
|
|
1145
|
+
const e = this.value.includes(this._value);
|
|
1146
|
+
this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
|
|
1110
1147
|
}
|
|
1111
|
-
constructor(
|
|
1112
|
-
super(
|
|
1113
|
-
const
|
|
1114
|
-
this.cursor = this.options[
|
|
1115
|
-
|
|
1116
|
-
}), this.on("cursor", (
|
|
1117
|
-
switch (
|
|
1148
|
+
constructor(e) {
|
|
1149
|
+
super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
1150
|
+
const i = Math.max(this.options.findIndex(({ value: t }) => t === e.cursorAt), 0);
|
|
1151
|
+
this.cursor = this.options[i].disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t, l) => {
|
|
1152
|
+
l.name === "a" && this.toggleAll(), l.name === "i" && this.toggleInvert();
|
|
1153
|
+
}), this.on("cursor", (t) => {
|
|
1154
|
+
switch (t) {
|
|
1118
1155
|
case "left":
|
|
1119
1156
|
case "up":
|
|
1120
|
-
this.cursor =
|
|
1157
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
1121
1158
|
break;
|
|
1122
1159
|
case "down":
|
|
1123
1160
|
case "right":
|
|
1124
|
-
this.cursor =
|
|
1161
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
1125
1162
|
break;
|
|
1126
1163
|
case "space":
|
|
1127
1164
|
this.toggleValue();
|
|
@@ -1130,7 +1167,7 @@ let ut = class extends m {
|
|
|
1130
1167
|
});
|
|
1131
1168
|
}
|
|
1132
1169
|
};
|
|
1133
|
-
var
|
|
1170
|
+
var a = class extends V {
|
|
1134
1171
|
options;
|
|
1135
1172
|
cursor = 0;
|
|
1136
1173
|
get _selectedValue() {
|
|
@@ -1140,30 +1177,30 @@ var ht = class extends m {
|
|
|
1140
1177
|
this.value = this._selectedValue.value;
|
|
1141
1178
|
}
|
|
1142
1179
|
constructor(t) {
|
|
1143
|
-
super(t,
|
|
1144
|
-
const
|
|
1145
|
-
this.cursor = this.options[e].disabled ?
|
|
1146
|
-
switch (
|
|
1180
|
+
super(t, false), this.options = t.options;
|
|
1181
|
+
const i = this.options.findIndex(({ value: s }) => s === t.initialValue), e = i === -1 ? 0 : i;
|
|
1182
|
+
this.cursor = this.options[e].disabled ? findCursor(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (s) => {
|
|
1183
|
+
switch (s) {
|
|
1147
1184
|
case "left":
|
|
1148
1185
|
case "up":
|
|
1149
|
-
this.cursor =
|
|
1186
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
1150
1187
|
break;
|
|
1151
1188
|
case "down":
|
|
1152
1189
|
case "right":
|
|
1153
|
-
this.cursor =
|
|
1190
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
1154
1191
|
break;
|
|
1155
1192
|
}
|
|
1156
1193
|
this.changeValue();
|
|
1157
1194
|
});
|
|
1158
1195
|
}
|
|
1159
1196
|
};
|
|
1160
|
-
var
|
|
1197
|
+
var n = class extends V {
|
|
1161
1198
|
get userInputWithCursor() {
|
|
1162
1199
|
if (this.state === "submit") return this.userInput;
|
|
1163
1200
|
const t = this.userInput;
|
|
1164
1201
|
if (this.cursor >= t.length) return `${this.userInput}\u2588`;
|
|
1165
|
-
const
|
|
1166
|
-
return `${
|
|
1202
|
+
const e = t.slice(0, this.cursor), [s, ...r] = t.slice(this.cursor);
|
|
1203
|
+
return `${e}${styleText("inverse", s)}${r.join("")}`;
|
|
1167
1204
|
}
|
|
1168
1205
|
get cursor() {
|
|
1169
1206
|
return this._cursor;
|
|
@@ -1172,8 +1209,8 @@ var ct = class extends m {
|
|
|
1172
1209
|
super({
|
|
1173
1210
|
...t,
|
|
1174
1211
|
initialUserInput: t.initialUserInput ?? t.initialValue
|
|
1175
|
-
}), this.on("userInput", (
|
|
1176
|
-
this._setValue(
|
|
1212
|
+
}), this.on("userInput", (e) => {
|
|
1213
|
+
this._setValue(e);
|
|
1177
1214
|
}), this.on("finalize", () => {
|
|
1178
1215
|
this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
|
|
1179
1216
|
});
|
|
@@ -1583,11 +1620,11 @@ const trimLines = (groups, initialLineCount, startIndex, endIndex, maxLines) =>
|
|
|
1583
1620
|
const limitOptions = (params) => {
|
|
1584
1621
|
const { cursor, options, style } = params;
|
|
1585
1622
|
const output = params.output ?? process.stdout;
|
|
1586
|
-
const columns =
|
|
1623
|
+
const columns = getColumns(output);
|
|
1587
1624
|
const columnPadding = params.columnPadding ?? 0;
|
|
1588
1625
|
const rowPadding = params.rowPadding ?? 4;
|
|
1589
1626
|
const maxWidth = columns - columnPadding;
|
|
1590
|
-
const rows =
|
|
1627
|
+
const rows = getRows(output);
|
|
1591
1628
|
const overflowFormat = import_picocolors.default.dim("...");
|
|
1592
1629
|
const paramMaxItems = params.maxItems ?? Number.POSITIVE_INFINITY;
|
|
1593
1630
|
const outputMaxItems = Math.max(rows - rowPadding, 0);
|
|
@@ -1639,10 +1676,46 @@ const limitOptions = (params) => {
|
|
|
1639
1676
|
if (shouldRenderBottomEllipsis) result.push(overflowFormat);
|
|
1640
1677
|
return result;
|
|
1641
1678
|
};
|
|
1679
|
+
/**
|
|
1680
|
+
* Render-milestone markers for the PTY snapshot suite
|
|
1681
|
+
* (crates/vite_cli_snapshots): invisible OSC 8 hyperlinks the runner
|
|
1682
|
+
* synchronizes on via `expect-milestone` interactions. Emission is gated on
|
|
1683
|
+
* `VP_EMIT_MILESTONES=1`, which only the runner sets; real terminals and
|
|
1684
|
+
* piped output never see these bytes.
|
|
1685
|
+
*
|
|
1686
|
+
* Protocol (shared with vite-task's `pty_terminal_test_client` crate):
|
|
1687
|
+
* `OSC 8 ; ; https://milestone.invalid/<hex(name)> ST <ZWSP> OSC 8 ; ; ST`.
|
|
1688
|
+
* The zero-width anchor keeps the hyperlink observable through Windows
|
|
1689
|
+
* ConPTY, which can drop zero-length hyperlinks.
|
|
1690
|
+
*/
|
|
1691
|
+
const MILESTONE_URI_PREFIX = "https://milestone.invalid/";
|
|
1692
|
+
const OSC8_OPEN = "\x1B]8;;";
|
|
1693
|
+
const ST = "\x1B\\";
|
|
1694
|
+
const ZERO_WIDTH_ANCHOR = "";
|
|
1695
|
+
const MILESTONES_ENABLED = process.env.VP_EMIT_MILESTONES === "1";
|
|
1696
|
+
/**
|
|
1697
|
+
* Returns the encoded milestone byte sequence for `name`, or an empty string
|
|
1698
|
+
* when emission is disabled. Append the result to a rendered prompt frame so
|
|
1699
|
+
* the marker arrives in the output stream together with the render it marks.
|
|
1700
|
+
*/
|
|
1701
|
+
function milestone(name) {
|
|
1702
|
+
if (!MILESTONES_ENABLED) return "";
|
|
1703
|
+
const hex = Buffer.from(name, "utf8").toString("hex");
|
|
1704
|
+
return `${OSC8_OPEN}${MILESTONE_URI_PREFIX}${hex}${ST}${ZERO_WIDTH_ANCHOR}${OSC8_OPEN}${ST}`;
|
|
1705
|
+
}
|
|
1706
|
+
/**
|
|
1707
|
+
* Milestone for a prompt render, following the runner naming convention
|
|
1708
|
+
* `<kind>:<id>:<state>` (e.g. `select:template:1`, `confirm:approve:yes`,
|
|
1709
|
+
* `text:project-name:my-app`). `id` defaults to the prompt kind; pass
|
|
1710
|
+
* `testId` at ambiguous call sites (multiple prompts of one kind in a flow).
|
|
1711
|
+
*/
|
|
1712
|
+
function promptMilestone(kind, id, state) {
|
|
1713
|
+
return milestone(`${kind}:${id ?? kind}:${state}`);
|
|
1714
|
+
}
|
|
1642
1715
|
const confirm = (opts) => {
|
|
1643
1716
|
const active = opts.active ?? "Yes";
|
|
1644
1717
|
const inactive = opts.inactive ?? "No";
|
|
1645
|
-
return new
|
|
1718
|
+
return new r({
|
|
1646
1719
|
active,
|
|
1647
1720
|
inactive,
|
|
1648
1721
|
signal: opts.signal,
|
|
@@ -1655,12 +1728,12 @@ const confirm = (opts) => {
|
|
|
1655
1728
|
const title = `${hasGuide ? `${import_picocolors.default.gray(S_BAR)}\n` : ""}${symbol(this.state)} ${opts.message}\n`;
|
|
1656
1729
|
const value = this.value ? active : inactive;
|
|
1657
1730
|
switch (this.state) {
|
|
1658
|
-
case "submit": return `${title}${hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix}${import_picocolors.default.dim(value)}\n`;
|
|
1659
|
-
case "cancel": return `${title}${hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix}${import_picocolors.default.strikethrough(import_picocolors.default.dim(value))}${hasGuide ? `\n${import_picocolors.default.gray(S_BAR)}` : ""}\n`;
|
|
1731
|
+
case "submit": return `${title}${hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix}${import_picocolors.default.dim(value)}\n${promptMilestone("confirm", opts.testId, "submit")}`;
|
|
1732
|
+
case "cancel": return `${title}${hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix}${import_picocolors.default.strikethrough(import_picocolors.default.dim(value))}${hasGuide ? `\n${import_picocolors.default.gray(S_BAR)}` : ""}\n${promptMilestone("confirm", opts.testId, "cancel")}`;
|
|
1660
1733
|
default: {
|
|
1661
1734
|
const defaultPrefix = hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix;
|
|
1662
1735
|
const defaultPrefixEnd = hasGuide ? import_picocolors.default.blue(S_BAR_END) : "";
|
|
1663
|
-
return `${title}${defaultPrefix}${this.value ? `${import_picocolors.default.blue(S_POINTER_ACTIVE)} ${import_picocolors.default.bold(active)}` : `${import_picocolors.default.dim(" ")} ${import_picocolors.default.dim(active)}`}${opts.vertical ? hasGuide ? `\n${import_picocolors.default.blue(S_BAR)} ` : `\n${nestedPrefix}` : ` ${import_picocolors.default.dim("/")} `}${!this.value ? `${import_picocolors.default.blue(S_POINTER_ACTIVE)} ${import_picocolors.default.bold(inactive)}` : `${import_picocolors.default.dim(" ")} ${import_picocolors.default.dim(inactive)}`}\n${defaultPrefixEnd}\n`;
|
|
1736
|
+
return `${title}${defaultPrefix}${this.value ? `${import_picocolors.default.blue(S_POINTER_ACTIVE)} ${import_picocolors.default.bold(active)}` : `${import_picocolors.default.dim(" ")} ${import_picocolors.default.dim(active)}`}${opts.vertical ? hasGuide ? `\n${import_picocolors.default.blue(S_BAR)} ` : `\n${nestedPrefix}` : ` ${import_picocolors.default.dim("/")} `}${!this.value ? `${import_picocolors.default.blue(S_POINTER_ACTIVE)} ${import_picocolors.default.bold(inactive)}` : `${import_picocolors.default.dim(" ")} ${import_picocolors.default.dim(inactive)}`}\n${defaultPrefixEnd}\n${promptMilestone("confirm", opts.testId, this.value ? "yes" : "no")}`;
|
|
1664
1737
|
}
|
|
1665
1738
|
}
|
|
1666
1739
|
}
|
|
@@ -1752,7 +1825,7 @@ const multiselect = (opts) => {
|
|
|
1752
1825
|
};
|
|
1753
1826
|
const required = opts.required ?? true;
|
|
1754
1827
|
const hint = " " + import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`));
|
|
1755
|
-
return new
|
|
1828
|
+
return new a$1({
|
|
1756
1829
|
options: opts.options,
|
|
1757
1830
|
signal: opts.signal,
|
|
1758
1831
|
input: opts.input,
|
|
@@ -1769,7 +1842,7 @@ const multiselect = (opts) => {
|
|
|
1769
1842
|
const formatMessageLines = (message) => {
|
|
1770
1843
|
return message.split("\n").map((line, index) => `${index === 0 ? `${symbol(this.state)} ` : nestedPrefix}${line}`).join("\n");
|
|
1771
1844
|
};
|
|
1772
|
-
const wrappedMessage = hasGuide ?
|
|
1845
|
+
const wrappedMessage = hasGuide ? wrapTextWithPrefix(opts.output, opts.message, `${symbolBar(this.state)} `, `${symbol(this.state)} `) : formatMessageLines(opts.message);
|
|
1773
1846
|
const title = `${hasGuide ? `${import_picocolors.default.gray(S_BAR)}\n` : ""}${wrappedMessage}\n`;
|
|
1774
1847
|
const value = this.value ?? [];
|
|
1775
1848
|
const styleOption = (option, active) => {
|
|
@@ -1783,13 +1856,13 @@ const multiselect = (opts) => {
|
|
|
1783
1856
|
case "submit": {
|
|
1784
1857
|
const submitText = this.options.filter(({ value: optionValue }) => value.includes(optionValue)).map((option) => opt(option, "submitted")).join(import_picocolors.default.dim(", ")) || import_picocolors.default.dim("none");
|
|
1785
1858
|
const submitPrefix = hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix;
|
|
1786
|
-
return `${title}${
|
|
1859
|
+
return `${title}${wrapTextWithPrefix(opts.output, submitText, submitPrefix)}\n`;
|
|
1787
1860
|
}
|
|
1788
1861
|
case "cancel": {
|
|
1789
1862
|
const label = this.options.filter(({ value: optionValue }) => value.includes(optionValue)).map((option) => opt(option, "cancelled")).join(import_picocolors.default.dim(", "));
|
|
1790
1863
|
if (label.trim() === "") return hasGuide ? `${title}${import_picocolors.default.gray(S_BAR)}\n` : `${title.trimEnd()}\n`;
|
|
1791
1864
|
const cancelPrefix = hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix;
|
|
1792
|
-
const wrappedLabel =
|
|
1865
|
+
const wrappedLabel = wrapTextWithPrefix(opts.output, label, cancelPrefix);
|
|
1793
1866
|
return hasGuide ? `${title}${wrappedLabel}\n${import_picocolors.default.gray(S_BAR)}\n` : `${title}${wrappedLabel}\n`;
|
|
1794
1867
|
}
|
|
1795
1868
|
case "error": {
|
|
@@ -1855,14 +1928,14 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
|
|
|
1855
1928
|
let _prevMessage;
|
|
1856
1929
|
let _origin = performance.now();
|
|
1857
1930
|
let _elapsedMs = 0;
|
|
1858
|
-
const columns =
|
|
1931
|
+
const columns = getColumns(output);
|
|
1859
1932
|
const styleFn = opts?.styleFrame ?? defaultStyleFn;
|
|
1860
1933
|
const getElapsedMs = () => {
|
|
1861
1934
|
if (!isSpinnerActive) return _elapsedMs;
|
|
1862
1935
|
return _elapsedMs + (performance.now() - _origin);
|
|
1863
1936
|
};
|
|
1864
1937
|
const handleExit = (code) => {
|
|
1865
|
-
const msg = code > 1 ? errorMessage ??
|
|
1938
|
+
const msg = code > 1 ? errorMessage ?? settings.messages.error : cancelMessage ?? settings.messages.cancel;
|
|
1866
1939
|
isCancelled = code === 1;
|
|
1867
1940
|
if (isSpinnerActive) {
|
|
1868
1941
|
_stop(msg, code);
|
|
@@ -1901,14 +1974,14 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
|
|
|
1901
1974
|
const hasGuide = opts.withGuide ?? false;
|
|
1902
1975
|
const startLoop = () => {
|
|
1903
1976
|
isSpinnerActive = true;
|
|
1904
|
-
unblock =
|
|
1977
|
+
unblock = block({ output });
|
|
1905
1978
|
_origin = performance.now();
|
|
1906
1979
|
_prevMessage = void 0;
|
|
1907
1980
|
if (hasGuide) output.write(`${import_picocolors.default.gray(S_BAR)}\n`);
|
|
1908
1981
|
let frameIndex = 0;
|
|
1909
1982
|
let indicatorTimer = 0;
|
|
1910
1983
|
registerHooks();
|
|
1911
|
-
|
|
1984
|
+
const renderFrame = () => {
|
|
1912
1985
|
if (isCI$1 && _message === _prevMessage) return;
|
|
1913
1986
|
clearPrevMessage();
|
|
1914
1987
|
_prevMessage = _message;
|
|
@@ -1927,7 +2000,9 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
|
|
|
1927
2000
|
output.write(wrapped);
|
|
1928
2001
|
frameIndex = frameIndex + 1 < frames.length ? frameIndex + 1 : 0;
|
|
1929
2002
|
indicatorTimer = indicatorTimer < 4 ? indicatorTimer + .125 : 0;
|
|
1930
|
-
}
|
|
2003
|
+
};
|
|
2004
|
+
renderFrame();
|
|
2005
|
+
loop = setInterval(renderFrame, delay);
|
|
1931
2006
|
};
|
|
1932
2007
|
const start = (msg = "") => {
|
|
1933
2008
|
_elapsedMs = 0;
|
|
@@ -2002,7 +2077,7 @@ const select = (opts) => {
|
|
|
2002
2077
|
default: return withMarker(import_picocolors.default.dim(" "), label, (text) => text, hint);
|
|
2003
2078
|
}
|
|
2004
2079
|
};
|
|
2005
|
-
return new
|
|
2080
|
+
return new a({
|
|
2006
2081
|
options: opts.options,
|
|
2007
2082
|
signal: opts.signal,
|
|
2008
2083
|
input: opts.input,
|
|
@@ -2015,16 +2090,16 @@ const select = (opts) => {
|
|
|
2015
2090
|
return message.split("\n").map((line, index) => `${index === 0 ? `${symbol(this.state)} ` : nestedPrefix}${line}`).join("\n");
|
|
2016
2091
|
};
|
|
2017
2092
|
const hasMessage = opts.message.trim().length > 0;
|
|
2018
|
-
const messageLines = !hasMessage ? "" : hasGuide ?
|
|
2093
|
+
const messageLines = !hasMessage ? "" : hasGuide ? wrapTextWithPrefix(opts.output, opts.message, `${symbolBar(this.state)} `, `${symbol(this.state)} `) : formatMessageLines(opts.message);
|
|
2019
2094
|
const title = hasMessage ? `${hasGuide ? `${import_picocolors.default.gray(S_BAR)}\n` : ""}${messageLines}\n` : "";
|
|
2020
2095
|
switch (this.state) {
|
|
2021
2096
|
case "submit": {
|
|
2022
2097
|
const submitPrefix = hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix;
|
|
2023
|
-
return `${title}${
|
|
2098
|
+
return `${title}${wrapTextWithPrefix(opts.output, opt(this.options[this.cursor], "selected"), submitPrefix)}\n${promptMilestone("select", opts.testId, "submit")}`;
|
|
2024
2099
|
}
|
|
2025
2100
|
case "cancel": {
|
|
2026
2101
|
const cancelPrefix = hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix;
|
|
2027
|
-
return `${title}${
|
|
2102
|
+
return `${title}${wrapTextWithPrefix(opts.output, opt(this.options[this.cursor], "cancelled"), cancelPrefix)}${hasGuide ? `\n${import_picocolors.default.gray(S_BAR)}` : ""}\n${promptMilestone("select", opts.testId, "cancel")}`;
|
|
2028
2103
|
}
|
|
2029
2104
|
default: {
|
|
2030
2105
|
const prefix = hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix;
|
|
@@ -2039,14 +2114,14 @@ const select = (opts) => {
|
|
|
2039
2114
|
columnPadding: prefix.length,
|
|
2040
2115
|
rowPadding: titleLineCount + footerLineCount,
|
|
2041
2116
|
style: (item, active) => opt(item, item.disabled ? "disabled" : active ? "active" : "inactive")
|
|
2042
|
-
}).join(`\n${prefix}`)}\n${prefixEnd}\n`;
|
|
2117
|
+
}).join(`\n${prefix}`)}\n${prefixEnd}\n${promptMilestone("select", opts.testId, String(this.cursor))}`;
|
|
2043
2118
|
}
|
|
2044
2119
|
}
|
|
2045
2120
|
}
|
|
2046
2121
|
}).prompt();
|
|
2047
2122
|
};
|
|
2048
2123
|
const text = (opts) => {
|
|
2049
|
-
return new
|
|
2124
|
+
return new n({
|
|
2050
2125
|
validate: opts.validate,
|
|
2051
2126
|
placeholder: opts.placeholder,
|
|
2052
2127
|
defaultValue: opts.defaultValue,
|
|
@@ -2066,18 +2141,18 @@ const text = (opts) => {
|
|
|
2066
2141
|
const errorText = this.error ? ` ${import_picocolors.default.yellow(this.error)}` : "";
|
|
2067
2142
|
const errorPrefix = hasGuide ? `${import_picocolors.default.yellow(S_BAR)} ` : nestedPrefix;
|
|
2068
2143
|
const errorPrefixEnd = hasGuide ? import_picocolors.default.yellow(S_BAR_END) : "";
|
|
2069
|
-
return `${title.trim()}\n${errorPrefix}${userInput}\n${errorPrefixEnd}${errorText}\n`;
|
|
2144
|
+
return `${title.trim()}\n${errorPrefix}${userInput}\n${errorPrefixEnd}${errorText}\n${promptMilestone("text", opts.testId, "error")}`;
|
|
2070
2145
|
}
|
|
2071
2146
|
case "submit": {
|
|
2072
2147
|
const valueText = value ? import_picocolors.default.dim(value) : "";
|
|
2073
|
-
return `${title}${hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix}${valueText}\n`;
|
|
2148
|
+
return `${title}${hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix}${valueText}\n${promptMilestone("text", opts.testId, "submit")}`;
|
|
2074
2149
|
}
|
|
2075
2150
|
case "cancel": {
|
|
2076
2151
|
const valueText = value ? import_picocolors.default.strikethrough(import_picocolors.default.dim(value)) : "";
|
|
2077
2152
|
const cancelPrefix = hasGuide ? `${import_picocolors.default.gray(S_BAR)} ` : nestedPrefix;
|
|
2078
|
-
return `${title}${cancelPrefix}${valueText}${value.trim() ? `\n${cancelPrefix}` : ""}\n`;
|
|
2153
|
+
return `${title}${cancelPrefix}${valueText}${value.trim() ? `\n${cancelPrefix}` : ""}\n${promptMilestone("text", opts.testId, "cancel")}`;
|
|
2079
2154
|
}
|
|
2080
|
-
default: return `${title}${hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix}${userInput}\n${hasGuide ? import_picocolors.default.blue(S_BAR_END) : ""}\n`;
|
|
2155
|
+
default: return `${title}${hasGuide ? `${import_picocolors.default.blue(S_BAR)} ` : nestedPrefix}${userInput}\n${hasGuide ? import_picocolors.default.blue(S_BAR_END) : ""}\n${promptMilestone("text", opts.testId, this.value ?? "")}`;
|
|
2081
2156
|
}
|
|
2082
2157
|
}
|
|
2083
2158
|
}).prompt();
|
|
@@ -2664,7 +2739,11 @@ var require_coerce = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2664
2739
|
}
|
|
2665
2740
|
if (match === null) return null;
|
|
2666
2741
|
const major = match[2];
|
|
2667
|
-
|
|
2742
|
+
const minor = match[3] || "0";
|
|
2743
|
+
const patch = match[4] || "0";
|
|
2744
|
+
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
|
|
2745
|
+
const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
|
|
2746
|
+
return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
|
|
2668
2747
|
};
|
|
2669
2748
|
module.exports = coerce;
|
|
2670
2749
|
}));
|
|
@@ -2680,7 +2759,8 @@ var require_truncate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2680
2759
|
return clonedVersion && doTruncation(clonedVersion, truncation);
|
|
2681
2760
|
};
|
|
2682
2761
|
const cloneInputVersion = (version, options) => {
|
|
2683
|
-
|
|
2762
|
+
const versionStringToParse = version instanceof SemVer ? version.version : version;
|
|
2763
|
+
return parse(versionStringToParse, options);
|
|
2684
2764
|
};
|
|
2685
2765
|
const doTruncation = (version, truncation) => {
|
|
2686
2766
|
if (isPrerelease(truncation)) return version.version;
|
|
@@ -3664,7 +3744,7 @@ function pnpmSupportsPositionalApprove(version) {
|
|
|
3664
3744
|
return Number.isNaN(major) || major >= 11;
|
|
3665
3745
|
}
|
|
3666
3746
|
/** Package managers that gate build scripts and expose an approval workflow. */
|
|
3667
|
-
const GATED_BUILD_PACKAGE_MANAGERS = new Set([
|
|
3747
|
+
const GATED_BUILD_PACKAGE_MANAGERS = /* @__PURE__ */ new Set([
|
|
3668
3748
|
PackageManager.pnpm,
|
|
3669
3749
|
PackageManager.bun,
|
|
3670
3750
|
PackageManager.yarn
|
|
@@ -3826,7 +3906,7 @@ async function approveBuilds(options) {
|
|
|
3826
3906
|
initialValues: [],
|
|
3827
3907
|
required: false
|
|
3828
3908
|
});
|
|
3829
|
-
selected =
|
|
3909
|
+
selected = isCancel(answer) ? [] : answer;
|
|
3830
3910
|
} else selected = [];
|
|
3831
3911
|
if (selected.length === 0) {
|
|
3832
3912
|
printApproveBuildsGuidance(targets, packageManager);
|
|
@@ -3844,6 +3924,148 @@ async function approveBuilds(options) {
|
|
|
3844
3924
|
], cwd, selected, interactive, silent);
|
|
3845
3925
|
}
|
|
3846
3926
|
//#endregion
|
|
3927
|
+
//#region src/utils/yaml.ts
|
|
3928
|
+
var import_dist = require_dist();
|
|
3929
|
+
function readYamlFile(file) {
|
|
3930
|
+
return (0, import_dist.parse)(fs.readFileSync(file, "utf-8"));
|
|
3931
|
+
}
|
|
3932
|
+
function editYamlFile(file, callback) {
|
|
3933
|
+
const doc = (0, import_dist.parseDocument)(fs.readFileSync(file, "utf-8"));
|
|
3934
|
+
callback(doc);
|
|
3935
|
+
fs.writeFileSync(file, doc.toString({ singleQuote: true }), "utf-8");
|
|
3936
|
+
}
|
|
3937
|
+
function scalarString(value) {
|
|
3938
|
+
return new import_dist.Scalar(value);
|
|
3939
|
+
}
|
|
3940
|
+
//#endregion
|
|
3941
|
+
//#region src/utils/preview-registry.ts
|
|
3942
|
+
const DEFAULT_BRIDGE_REGISTRY = "https://registry-bridge.viteplus.dev/";
|
|
3943
|
+
const REGISTRY_MARKER = "# vite-plus preview build registry bridge (auto-added by vp)";
|
|
3944
|
+
const BRIDGE_HOST = "registry-bridge.viteplus.dev";
|
|
3945
|
+
/**
|
|
3946
|
+
* Registry bridge that serves PR preview builds as ordinary `0.0.0-commit.<sha>`
|
|
3947
|
+
* versions (and proxies everything else to npmjs). Only ever used for preview
|
|
3948
|
+
* builds (see {@link isPreviewVitePlusVersion}); real releases never resolve
|
|
3949
|
+
* through it. Overridable via `VP_REGISTRY_BRIDGE` for testing or an alternate
|
|
3950
|
+
* bridge host; read at call time so the override applies per process.
|
|
3951
|
+
*/
|
|
3952
|
+
function bridgeRegistry() {
|
|
3953
|
+
return process.env.VP_REGISTRY_BRIDGE || DEFAULT_BRIDGE_REGISTRY;
|
|
3954
|
+
}
|
|
3955
|
+
/**
|
|
3956
|
+
* A preview / test build is published as `0.0.0-commit.<sha>` (and, generally,
|
|
3957
|
+
* any `0.0.0-<prerelease>`). A real release is never `0.0.0`, so this reliably
|
|
3958
|
+
* flags a build under test with no false positives on real-user migrations.
|
|
3959
|
+
*/
|
|
3960
|
+
function isPreviewVitePlusVersion(version = process.env.VP_VERSION || VITE_PLUS_VERSION) {
|
|
3961
|
+
return version.startsWith("0.0.0-");
|
|
3962
|
+
}
|
|
3963
|
+
/**
|
|
3964
|
+
* Berry reads `.yarnrc.yml` and ignores `.npmrc`, so the registry must be
|
|
3965
|
+
* written to the right file. Detect Berry without an install: a `.yarnrc.yml`
|
|
3966
|
+
* is Berry-only, a Berry lockfile carries a `__metadata:` block, and a
|
|
3967
|
+
* `packageManager: "yarn@>=2"` pin selects Berry up front.
|
|
3968
|
+
*/
|
|
3969
|
+
function isYarnBerryProject(projectRoot) {
|
|
3970
|
+
if (fs.existsSync(path.join(projectRoot, ".yarnrc.yml"))) return true;
|
|
3971
|
+
const yarnLock = path.join(projectRoot, "yarn.lock");
|
|
3972
|
+
if (fs.existsSync(yarnLock)) try {
|
|
3973
|
+
if (fs.readFileSync(yarnLock, "utf8").includes("__metadata:")) return true;
|
|
3974
|
+
} catch {}
|
|
3975
|
+
try {
|
|
3976
|
+
const pkg = readJsonFile(path.join(projectRoot, "package.json"));
|
|
3977
|
+
const pm = typeof pkg.packageManager === "string" ? pkg.packageManager : "";
|
|
3978
|
+
const major = /^yarn@(\d+)/.exec(pm)?.[1];
|
|
3979
|
+
if (major && Number(major) >= 2) return true;
|
|
3980
|
+
} catch {}
|
|
3981
|
+
return false;
|
|
3982
|
+
}
|
|
3983
|
+
function ensureNpmrcRegistry(projectRoot) {
|
|
3984
|
+
const npmrc = path.join(projectRoot, ".npmrc");
|
|
3985
|
+
const bridge = bridgeRegistry();
|
|
3986
|
+
let content = "";
|
|
3987
|
+
if (fs.existsSync(npmrc)) {
|
|
3988
|
+
content = fs.readFileSync(npmrc, "utf8");
|
|
3989
|
+
if (content.includes(REGISTRY_MARKER) || content.includes(bridge)) return;
|
|
3990
|
+
}
|
|
3991
|
+
const prefix = content.length > 0 && !content.endsWith("\n") ? "\n" : "";
|
|
3992
|
+
fs.appendFileSync(npmrc, `${prefix}${REGISTRY_MARKER}\nregistry=${bridge}\n`);
|
|
3993
|
+
}
|
|
3994
|
+
const YARN_ORIGINAL_REGISTRY_COMMENT_PREFIX = " vite-plus preview bridge (auto-added by vp); original npmRegistryServer: ";
|
|
3995
|
+
function ensureYarnBerryRegistry(projectRoot) {
|
|
3996
|
+
const yarnrc = path.join(projectRoot, ".yarnrc.yml");
|
|
3997
|
+
if (!fs.existsSync(yarnrc)) fs.writeFileSync(yarnrc, "");
|
|
3998
|
+
editYamlFile(yarnrc, (doc) => {
|
|
3999
|
+
const current = doc.get("npmRegistryServer");
|
|
4000
|
+
if (current === bridgeRegistry()) return;
|
|
4001
|
+
doc.set("npmRegistryServer", bridgeRegistry());
|
|
4002
|
+
const node = doc.get("npmRegistryServer", true);
|
|
4003
|
+
if (node instanceof import_dist.Scalar && typeof current === "string" && !current.includes(BRIDGE_HOST)) node.comment = `${YARN_ORIGINAL_REGISTRY_COMMENT_PREFIX}${current}`;
|
|
4004
|
+
});
|
|
4005
|
+
}
|
|
4006
|
+
function clearNpmrcRegistry(projectRoot) {
|
|
4007
|
+
const npmrc = path.join(projectRoot, ".npmrc");
|
|
4008
|
+
if (!fs.existsSync(npmrc)) return false;
|
|
4009
|
+
const original = fs.readFileSync(npmrc, "utf8");
|
|
4010
|
+
if (!original.includes(REGISTRY_MARKER)) return false;
|
|
4011
|
+
const lines = original.split("\n");
|
|
4012
|
+
const kept = [];
|
|
4013
|
+
for (let i = 0; i < lines.length; i++) {
|
|
4014
|
+
if (lines[i].trim() === REGISTRY_MARKER) {
|
|
4015
|
+
if (lines[i + 1]?.startsWith("registry=")) i++;
|
|
4016
|
+
continue;
|
|
4017
|
+
}
|
|
4018
|
+
kept.push(lines[i]);
|
|
4019
|
+
}
|
|
4020
|
+
const result = kept.join("\n").replace(/\n{2,}$/, "\n");
|
|
4021
|
+
if (result.trim() === "") fs.rmSync(npmrc);
|
|
4022
|
+
else fs.writeFileSync(npmrc, result.endsWith("\n") ? result : `${result}\n`);
|
|
4023
|
+
return true;
|
|
4024
|
+
}
|
|
4025
|
+
function clearYarnBerryRegistry(projectRoot) {
|
|
4026
|
+
const yarnrc = path.join(projectRoot, ".yarnrc.yml");
|
|
4027
|
+
if (!fs.existsSync(yarnrc)) return false;
|
|
4028
|
+
const content = fs.readFileSync(yarnrc, "utf8");
|
|
4029
|
+
if (!content.includes(BRIDGE_HOST) && !content.includes(bridgeRegistry())) return false;
|
|
4030
|
+
let cleared = false;
|
|
4031
|
+
editYamlFile(yarnrc, (doc) => {
|
|
4032
|
+
const current = doc.get("npmRegistryServer");
|
|
4033
|
+
if (typeof current === "string" && (current.includes(BRIDGE_HOST) || current === bridgeRegistry())) {
|
|
4034
|
+
const node = doc.get("npmRegistryServer", true);
|
|
4035
|
+
const original = (node instanceof import_dist.Scalar ? node.comment : void 0)?.split(YARN_ORIGINAL_REGISTRY_COMMENT_PREFIX.trimStart())[1]?.trim();
|
|
4036
|
+
if (original) {
|
|
4037
|
+
doc.set("npmRegistryServer", original);
|
|
4038
|
+
const restored = doc.get("npmRegistryServer", true);
|
|
4039
|
+
if (restored instanceof import_dist.Scalar) restored.comment = void 0;
|
|
4040
|
+
} else doc.delete("npmRegistryServer");
|
|
4041
|
+
cleared = true;
|
|
4042
|
+
}
|
|
4043
|
+
});
|
|
4044
|
+
return cleared;
|
|
4045
|
+
}
|
|
4046
|
+
/**
|
|
4047
|
+
* Reconcile the project's registry config with the running build:
|
|
4048
|
+
*
|
|
4049
|
+
* - Preview / test build: point the project at the registry bridge (`.npmrc`, or
|
|
4050
|
+
* `.yarnrc.yml` for Yarn Berry) so the `0.0.0-commit.<sha>` versions that
|
|
4051
|
+
* migrate/create just pinned resolve during this install and in the project's
|
|
4052
|
+
* own CI.
|
|
4053
|
+
* - Real release: remove any bridge registry a PRIOR preview run left behind, so
|
|
4054
|
+
* real installs resolve from npmjs instead of the test bridge.
|
|
4055
|
+
*
|
|
4056
|
+
* No-op and idempotent in the common case. Returns true when it changed config.
|
|
4057
|
+
*/
|
|
4058
|
+
function reconcilePreviewBridgeRegistry(projectRoot, version = process.env.VP_VERSION || VITE_PLUS_VERSION, packageManager) {
|
|
4059
|
+
if (isPreviewVitePlusVersion(version)) {
|
|
4060
|
+
if (packageManager === PackageManager.yarn ? isYarnBerryProject(projectRoot) : packageManager === void 0 && isYarnBerryProject(projectRoot)) ensureYarnBerryRegistry(projectRoot);
|
|
4061
|
+
else ensureNpmrcRegistry(projectRoot);
|
|
4062
|
+
return true;
|
|
4063
|
+
}
|
|
4064
|
+
const clearedNpmrc = clearNpmrcRegistry(projectRoot);
|
|
4065
|
+
const clearedYarnrc = clearYarnBerryRegistry(projectRoot);
|
|
4066
|
+
return clearedNpmrc || clearedYarnrc;
|
|
4067
|
+
}
|
|
4068
|
+
//#endregion
|
|
3847
4069
|
//#region src/utils/prompts.ts
|
|
3848
4070
|
/**
|
|
3849
4071
|
* pnpm v11 promoted `ERR_PNPM_IGNORED_BUILDS` from a warning to a hard
|
|
@@ -3878,7 +4100,7 @@ async function selectPackageManager(interactive, silent = false) {
|
|
|
3878
4100
|
],
|
|
3879
4101
|
initialValue: PackageManager.pnpm
|
|
3880
4102
|
});
|
|
3881
|
-
if (
|
|
4103
|
+
if (isCancel(selected)) cancelAndExit();
|
|
3882
4104
|
return selected;
|
|
3883
4105
|
} else {
|
|
3884
4106
|
if (!silent) log.info(`Using default package manager: ${accent(PackageManager.pnpm)}`);
|
|
@@ -3896,6 +4118,7 @@ async function downloadPackageManager$1(packageManager, version, interactive, si
|
|
|
3896
4118
|
return downloadResult;
|
|
3897
4119
|
}
|
|
3898
4120
|
async function runViteInstall(cwd, interactive, extraArgs, options) {
|
|
4121
|
+
reconcilePreviewBridgeRegistry(cwd, void 0, options?.packageManager);
|
|
3899
4122
|
if (process.env.VP_SKIP_INSTALL) return {
|
|
3900
4123
|
durationMs: 0,
|
|
3901
4124
|
status: "skipped"
|
|
@@ -3940,10 +4163,10 @@ async function runViteFmt(cwd, interactive, paths, options) {
|
|
|
3940
4163
|
const startTime = Date.now();
|
|
3941
4164
|
spinner.start(`Formatting code...`);
|
|
3942
4165
|
const { exitCode, stderr, stdout } = await runCommandSilently({
|
|
3943
|
-
command: process.env.VP_CLI_BIN ?? "vp",
|
|
4166
|
+
command: options?.command ?? process.env.VP_CLI_BIN ?? "vp",
|
|
3944
4167
|
args: [
|
|
4168
|
+
...options?.commandArgs ?? [],
|
|
3945
4169
|
"fmt",
|
|
3946
|
-
"--write",
|
|
3947
4170
|
...paths ?? []
|
|
3948
4171
|
],
|
|
3949
4172
|
cwd,
|
|
@@ -3960,8 +4183,9 @@ async function runViteFmt(cwd, interactive, paths, options) {
|
|
|
3960
4183
|
spinner.stop(`Format failed`);
|
|
3961
4184
|
log.info(stdout.toString());
|
|
3962
4185
|
log.error(stderr.toString());
|
|
3963
|
-
const
|
|
3964
|
-
|
|
4186
|
+
const joinedPaths = (paths ?? []).join(" ");
|
|
4187
|
+
const hint = joinedPaths.length === 0 ? `You may need to run "vp fmt" manually in ${cwd}` : joinedPaths.length <= 256 ? `You may need to run "vp fmt ${joinedPaths}" manually in ${cwd}` : `You may need to run "vp fmt" manually on the ${paths?.length} changed files in ${cwd}`;
|
|
4188
|
+
log.info(hint);
|
|
3965
4189
|
return {
|
|
3966
4190
|
durationMs: Date.now() - startTime,
|
|
3967
4191
|
exitCode,
|
|
@@ -3997,7 +4221,7 @@ async function promptGitHooks(options) {
|
|
|
3997
4221
|
message: "Set up pre-commit hooks to run formatting, linting, and type checking with auto-fixes?",
|
|
3998
4222
|
initialValue: true
|
|
3999
4223
|
});
|
|
4000
|
-
if (
|
|
4224
|
+
if (isCancel(selected)) {
|
|
4001
4225
|
cancelAndExit();
|
|
4002
4226
|
return false;
|
|
4003
4227
|
}
|
|
@@ -4010,10 +4234,10 @@ async function promptGitInit(options) {
|
|
|
4010
4234
|
if (options.git === true) return true;
|
|
4011
4235
|
if (options.interactive) {
|
|
4012
4236
|
const selected = await confirm({
|
|
4013
|
-
message: "Initialize a git repository
|
|
4237
|
+
message: "Initialize a git repository?",
|
|
4014
4238
|
initialValue: true
|
|
4015
4239
|
});
|
|
4016
|
-
if (
|
|
4240
|
+
if (isCancel(selected)) {
|
|
4017
4241
|
cancelAndExit();
|
|
4018
4242
|
return false;
|
|
4019
4243
|
}
|
|
@@ -4063,7 +4287,7 @@ async function confirmBaseUrlFix(interactive) {
|
|
|
4063
4287
|
message: "Your tsconfig contains `baseUrl`, which prevents enabling type-aware linting.\n " + styleText("gray", "`baseUrl` is deprecated in TypeScript 6.0 and removed in TypeScript 7.0.") + `\n Download and run the external \`${BASEURL_TSCONFIG_FIX_PACKAGE}\` fixer now?\n ` + styleText("gray", `Equivalent command: \`vp dlx ${command}\``),
|
|
4064
4288
|
initialValue: true
|
|
4065
4289
|
});
|
|
4066
|
-
if (
|
|
4290
|
+
if (isCancel(confirmed)) cancelAndExit();
|
|
4067
4291
|
return confirmed;
|
|
4068
4292
|
}
|
|
4069
4293
|
async function fixBaseUrlInTsconfig(projectPath, options) {
|
|
@@ -4123,10 +4347,7 @@ function removeDeprecatedTsconfigFalseOption(filePath, optionName) {
|
|
|
4123
4347
|
fs.writeFileSync(filePath, newText);
|
|
4124
4348
|
return true;
|
|
4125
4349
|
}
|
|
4126
|
-
const TSCONFIG_TYPE_REPLACEMENTS = {
|
|
4127
|
-
"tsdown/client": "vite-plus/pack/client",
|
|
4128
|
-
"vite/client": "vite-plus/client"
|
|
4129
|
-
};
|
|
4350
|
+
const TSCONFIG_TYPE_REPLACEMENTS = { "tsdown/client": "vite-plus/pack/client" };
|
|
4130
4351
|
function hasTypesToRewriteInTsconfig(filePath) {
|
|
4131
4352
|
let text;
|
|
4132
4353
|
try {
|
|
@@ -4137,6 +4358,16 @@ function hasTypesToRewriteInTsconfig(filePath) {
|
|
|
4137
4358
|
const types = parse(text)?.compilerOptions?.types;
|
|
4138
4359
|
return Array.isArray(types) && types.some((t) => typeof t === "string" && t in TSCONFIG_TYPE_REPLACEMENTS);
|
|
4139
4360
|
}
|
|
4361
|
+
function hasVitestTypesInTsconfig(filePath) {
|
|
4362
|
+
let text;
|
|
4363
|
+
try {
|
|
4364
|
+
text = fs.readFileSync(filePath, "utf-8");
|
|
4365
|
+
} catch {
|
|
4366
|
+
return false;
|
|
4367
|
+
}
|
|
4368
|
+
const types = parse(text)?.compilerOptions?.types;
|
|
4369
|
+
return Array.isArray(types) && types.some((type) => typeof type === "string" ? type === "vitest" || type.startsWith("vitest/") : false);
|
|
4370
|
+
}
|
|
4140
4371
|
function rewriteTypesInTsconfig(filePath) {
|
|
4141
4372
|
let text;
|
|
4142
4373
|
try {
|
|
@@ -4165,4 +4396,4 @@ function rewriteTypesInTsconfig(filePath) {
|
|
|
4165
4396
|
return true;
|
|
4166
4397
|
}
|
|
4167
4398
|
//#endregion
|
|
4168
|
-
export {
|
|
4399
|
+
export { intro as A, runCommandSilently as B, resolveApproveBuildTargets as C, require_semver as D, PackageManager as E, spinner as F, text as I, require_picocolors as L, multiselect as M, outro as N, cancel as O, select as P, isCancel as R, detectGatedBuilds as S, DependencyType as T, require_cross_spawn as V, upgradeYarn as _, hasTypesToRewriteInTsconfig as a, scalarString as b, rewriteTypesInTsconfig as c, downloadPackageManager$1 as d, promptGitHooks as f, selectPackageManager as g, runViteInstall as h, hasBaseUrlInTsconfig as i, log as j, confirm as k, cancelAndExit as l, runViteFmt as m, findTsconfigFiles as n, hasVitestTypesInTsconfig as o, resolveGitInit as p, fixBaseUrlInTsconfig as r, removeDeprecatedTsconfigFalseOption as s, confirmBaseUrlFix as t, defaultInteractive as u, editYamlFile as v, getSpinner as w, approveBuilds as x, readYamlFile as y, runCommand$1 as z };
|