vite-plus 0.1.21 → 0.1.23
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/AGENTS.md +1 -0
- package/binding/index.cjs +120 -52
- package/binding/index.d.cts +3232 -2
- package/dist/agent-aSGY0osq.js +2461 -0
- package/dist/bin.js +9 -14
- package/dist/cli-truncate-CWsmbK3p.js +867 -0
- package/dist/{compat-DdC7fHjB.js → compat-DXZgnEyq.js} +1 -1
- package/dist/config/bin.js +18 -5
- package/dist/constants-DCBWlNrn.js +33 -0
- package/dist/create/bin.js +215 -77
- package/dist/{define-config-cWg3Z2bC.d.ts → define-config-COdn-tsn.d.ts} +7 -5
- package/dist/define-config.cjs +1 -1
- package/dist/define-config.d.ts +1 -1
- package/dist/define-config.js +1 -1
- package/dist/dist-Bapm49IR.js +3 -0
- package/dist/{dist-DjG9AYbK.js → dist-BgQuvbtq.js} +136 -110
- package/dist/fmt.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/is-fullwidth-code-point-BUNlIICg.js +8 -0
- package/dist/lint.d.ts +1 -1
- package/dist/{log-update-CLxR0iRf.js → log-update-lyIiuflf.js} +111 -24
- package/dist/{main-A6UrSTYb.js → main-DpJl3LoU.js} +1 -28
- package/dist/migration/bin.js +71 -30
- package/dist/oxlint-plugin-config-B89iKTKN.js +37 -0
- package/dist/oxlint-plugin.d.ts +6 -0
- package/dist/oxlint-plugin.js +91 -0
- package/dist/pack-bin.js +1 -1
- package/dist/pack.d.ts +1 -1
- package/dist/{package-CrKanQYM.js → package-PmBUZ-ve.js} +2 -1
- package/dist/staged/bin.js +10 -10
- package/dist/strip-ansi-C3wrWz9t.js +853 -0
- package/dist/{agent-D2ocSU01.js → tsconfig-DlUVXT3J.js} +666 -2090
- package/dist/version.js +5 -5
- package/dist/versions.js +6 -6
- package/dist/{workspace-QXeJWs3P.js → workspace-DElv730L.js} +15 -15
- package/dist/wrap-ansi-CeQuiQ31.js +2 -0
- package/dist/{wrap-ansi-Dy0LjO7Q.js → wrap-ansi-k7Dn4VtV.js} +1 -1
- package/docs/config/run.md +39 -4
- package/docs/guide/cache.md +10 -1
- package/docs/guide/create.md +3 -1
- package/docs/guide/env.md +26 -1
- package/docs/guide/ide-integration.md +2 -2
- package/docs/guide/install.md +6 -0
- package/docs/guide/run.md +2 -0
- package/docs/guide/troubleshooting.md +5 -2
- package/docs/package.json +3 -1
- package/docs/pnpm-lock.yaml +798 -62
- package/package.json +27 -19
- package/templates/monorepo/_gitignore +1 -0
- package/dist/cli-truncate-DJcN4dJ8.js +0 -138
- package/dist/dist-D2_BiE1V.js +0 -3
- package/dist/slice-ansi-CwJYd1aw.js +0 -113
- package/dist/strip-ansi-D86nYqKl.js +0 -198
- package/dist/tsconfig-lBAWm4sf.js +0 -517
- package/dist/wrap-ansi-DbY7Idw_.js +0 -2
- /package/dist/{chunk-q7NCDQ7-.js → chunk-DnnnRqeS.js} +0 -0
- /package/dist/{define-config-GqLoRwH9.cjs → define-config-BR1Y88zz.cjs} +0 -0
- /package/dist/{define-config-B62DkkqH.js → define-config-BRC7qPNE.js} +0 -0
- /package/dist/{help-BtkjXtRM.js → help-YP84FSEz.js} +0 -0
- /package/dist/{lib-BamM40b7.js → lib-L3DWSRQp.js} +0 -0
- /package/dist/{pack-BcBvbQgt.d.ts → pack-Ciiho0Tq.d.ts} +0 -0
- /package/dist/{report-DbrfjWiP.js → report-DgSBQUdz.js} +0 -0
- /package/dist/{resolve-vite-config-C1KX9CZU.js → resolve-vite-config-TTvhycU1.js} +0 -0
- /package/dist/{terminal-CxTMfsxZ.js → terminal-uTv0ZaMr.js} +0 -0
|
@@ -1,19 +1,460 @@
|
|
|
1
|
-
import { r as __toESM, t as __commonJSMin } from "./chunk-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as require_dist } from "./dist-DjG9AYbK.js";
|
|
6
|
-
import { c as editJsonFile, l as isJsonFile, n as detectPackageMetadata, u as readJsonFile } from "./package-CrKanQYM.js";
|
|
7
|
-
import { n as addMigrationWarning, t as addManualStep } from "./report-DbrfjWiP.js";
|
|
1
|
+
import { n as __require, r as __toESM, t as __commonJSMin } from "./chunk-DnnnRqeS.js";
|
|
2
|
+
import { s as createBaseUrlTsconfigFixArgs, t as BASEURL_TSCONFIG_FIX_PACKAGE } from "./constants-DCBWlNrn.js";
|
|
3
|
+
import { t as accent } from "./terminal-uTv0ZaMr.js";
|
|
4
|
+
import { n as modify, r as parse, t as applyEdits } from "./main-DpJl3LoU.js";
|
|
8
5
|
import path from "node:path";
|
|
9
|
-
import { downloadPackageManager
|
|
6
|
+
import { downloadPackageManager } from "../binding/index.js";
|
|
10
7
|
import fs from "node:fs";
|
|
11
8
|
import { styleText } from "node:util";
|
|
12
9
|
import process$1, { stdin, stdout } from "node:process";
|
|
13
10
|
import * as b from "node:readline";
|
|
14
11
|
import E from "node:readline";
|
|
15
12
|
import { ReadStream } from "node:tty";
|
|
16
|
-
|
|
13
|
+
//#region ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
|
|
14
|
+
var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
15
|
+
module.exports = isexe;
|
|
16
|
+
isexe.sync = sync;
|
|
17
|
+
var fs$3 = __require("fs");
|
|
18
|
+
function checkPathExt(path, options) {
|
|
19
|
+
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
20
|
+
if (!pathext) return true;
|
|
21
|
+
pathext = pathext.split(";");
|
|
22
|
+
if (pathext.indexOf("") !== -1) return true;
|
|
23
|
+
for (var i = 0; i < pathext.length; i++) {
|
|
24
|
+
var p = pathext[i].toLowerCase();
|
|
25
|
+
if (p && path.substr(-p.length).toLowerCase() === p) return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
function checkStat(stat, path, options) {
|
|
30
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) return false;
|
|
31
|
+
return checkPathExt(path, options);
|
|
32
|
+
}
|
|
33
|
+
function isexe(path, options, cb) {
|
|
34
|
+
fs$3.stat(path, function(er, stat) {
|
|
35
|
+
cb(er, er ? false : checkStat(stat, path, options));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function sync(path, options) {
|
|
39
|
+
return checkStat(fs$3.statSync(path), path, options);
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
|
|
44
|
+
var require_mode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
45
|
+
module.exports = isexe;
|
|
46
|
+
isexe.sync = sync;
|
|
47
|
+
var fs$2 = __require("fs");
|
|
48
|
+
function isexe(path, options, cb) {
|
|
49
|
+
fs$2.stat(path, function(er, stat) {
|
|
50
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function sync(path, options) {
|
|
54
|
+
return checkStat(fs$2.statSync(path), options);
|
|
55
|
+
}
|
|
56
|
+
function checkStat(stat, options) {
|
|
57
|
+
return stat.isFile() && checkMode(stat, options);
|
|
58
|
+
}
|
|
59
|
+
function checkMode(stat, options) {
|
|
60
|
+
var mod = stat.mode;
|
|
61
|
+
var uid = stat.uid;
|
|
62
|
+
var gid = stat.gid;
|
|
63
|
+
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
|
|
64
|
+
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
|
|
65
|
+
var u = parseInt("100", 8);
|
|
66
|
+
var g = parseInt("010", 8);
|
|
67
|
+
var o = parseInt("001", 8);
|
|
68
|
+
var ug = u | g;
|
|
69
|
+
return mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
|
|
74
|
+
var require_isexe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
75
|
+
__require("fs");
|
|
76
|
+
var core;
|
|
77
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) core = require_windows();
|
|
78
|
+
else core = require_mode();
|
|
79
|
+
module.exports = isexe;
|
|
80
|
+
isexe.sync = sync;
|
|
81
|
+
function isexe(path, options, cb) {
|
|
82
|
+
if (typeof options === "function") {
|
|
83
|
+
cb = options;
|
|
84
|
+
options = {};
|
|
85
|
+
}
|
|
86
|
+
if (!cb) {
|
|
87
|
+
if (typeof Promise !== "function") throw new TypeError("callback not provided");
|
|
88
|
+
return new Promise(function(resolve, reject) {
|
|
89
|
+
isexe(path, options || {}, function(er, is) {
|
|
90
|
+
if (er) reject(er);
|
|
91
|
+
else resolve(is);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
core(path, options || {}, function(er, is) {
|
|
96
|
+
if (er) {
|
|
97
|
+
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
98
|
+
er = null;
|
|
99
|
+
is = false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
cb(er, is);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function sync(path, options) {
|
|
106
|
+
try {
|
|
107
|
+
return core.sync(path, options || {});
|
|
108
|
+
} catch (er) {
|
|
109
|
+
if (options && options.ignoreErrors || er.code === "EACCES") return false;
|
|
110
|
+
else throw er;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}));
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
|
|
116
|
+
var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
117
|
+
const isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
118
|
+
const path$3 = __require("path");
|
|
119
|
+
const COLON = isWindows ? ";" : ":";
|
|
120
|
+
const isexe = require_isexe();
|
|
121
|
+
const getNotFoundError = (cmd) => Object.assign(/* @__PURE__ */ new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
122
|
+
const getPathInfo = (cmd, opt) => {
|
|
123
|
+
const colon = opt.colon || COLON;
|
|
124
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [...isWindows ? [process.cwd()] : [], ...(opt.path || process.env.PATH || "").split(colon)];
|
|
125
|
+
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
126
|
+
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
127
|
+
if (isWindows) {
|
|
128
|
+
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "") pathExt.unshift("");
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
pathEnv,
|
|
132
|
+
pathExt,
|
|
133
|
+
pathExtExe
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
const which = (cmd, opt, cb) => {
|
|
137
|
+
if (typeof opt === "function") {
|
|
138
|
+
cb = opt;
|
|
139
|
+
opt = {};
|
|
140
|
+
}
|
|
141
|
+
if (!opt) opt = {};
|
|
142
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
143
|
+
const found = [];
|
|
144
|
+
const step = (i) => new Promise((resolve, reject) => {
|
|
145
|
+
if (i === pathEnv.length) return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
146
|
+
const ppRaw = pathEnv[i];
|
|
147
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
148
|
+
const pCmd = path$3.join(pathPart, cmd);
|
|
149
|
+
resolve(subStep(!pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd, i, 0));
|
|
150
|
+
});
|
|
151
|
+
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
152
|
+
if (ii === pathExt.length) return resolve(step(i + 1));
|
|
153
|
+
const ext = pathExt[ii];
|
|
154
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
155
|
+
if (!er && is) if (opt.all) found.push(p + ext);
|
|
156
|
+
else return resolve(p + ext);
|
|
157
|
+
return resolve(subStep(p, i, ii + 1));
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
161
|
+
};
|
|
162
|
+
const whichSync = (cmd, opt) => {
|
|
163
|
+
opt = opt || {};
|
|
164
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
165
|
+
const found = [];
|
|
166
|
+
for (let i = 0; i < pathEnv.length; i++) {
|
|
167
|
+
const ppRaw = pathEnv[i];
|
|
168
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
169
|
+
const pCmd = path$3.join(pathPart, cmd);
|
|
170
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
171
|
+
for (let j = 0; j < pathExt.length; j++) {
|
|
172
|
+
const cur = p + pathExt[j];
|
|
173
|
+
try {
|
|
174
|
+
if (isexe.sync(cur, { pathExt: pathExtExe })) if (opt.all) found.push(cur);
|
|
175
|
+
else return cur;
|
|
176
|
+
} catch (ex) {}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (opt.all && found.length) return found;
|
|
180
|
+
if (opt.nothrow) return null;
|
|
181
|
+
throw getNotFoundError(cmd);
|
|
182
|
+
};
|
|
183
|
+
module.exports = which;
|
|
184
|
+
which.sync = whichSync;
|
|
185
|
+
}));
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region ../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
|
|
188
|
+
var require_path_key = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
189
|
+
const pathKey = (options = {}) => {
|
|
190
|
+
const environment = options.env || process.env;
|
|
191
|
+
if ((options.platform || process.platform) !== "win32") return "PATH";
|
|
192
|
+
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
193
|
+
};
|
|
194
|
+
module.exports = pathKey;
|
|
195
|
+
module.exports.default = pathKey;
|
|
196
|
+
}));
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
199
|
+
var require_resolveCommand = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
200
|
+
const path$2 = __require("path");
|
|
201
|
+
const which = require_which();
|
|
202
|
+
const getPathKey = require_path_key();
|
|
203
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
204
|
+
const env = parsed.options.env || process.env;
|
|
205
|
+
const cwd = process.cwd();
|
|
206
|
+
const hasCustomCwd = parsed.options.cwd != null;
|
|
207
|
+
const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
|
|
208
|
+
if (shouldSwitchCwd) try {
|
|
209
|
+
process.chdir(parsed.options.cwd);
|
|
210
|
+
} catch (err) {}
|
|
211
|
+
let resolved;
|
|
212
|
+
try {
|
|
213
|
+
resolved = which.sync(parsed.command, {
|
|
214
|
+
path: env[getPathKey({ env })],
|
|
215
|
+
pathExt: withoutPathExt ? path$2.delimiter : void 0
|
|
216
|
+
});
|
|
217
|
+
} catch (e) {} finally {
|
|
218
|
+
if (shouldSwitchCwd) process.chdir(cwd);
|
|
219
|
+
}
|
|
220
|
+
if (resolved) resolved = path$2.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
221
|
+
return resolved;
|
|
222
|
+
}
|
|
223
|
+
function resolveCommand(parsed) {
|
|
224
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
225
|
+
}
|
|
226
|
+
module.exports = resolveCommand;
|
|
227
|
+
}));
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
|
|
230
|
+
var require_escape = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
231
|
+
const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
232
|
+
function escapeCommand(arg) {
|
|
233
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
234
|
+
return arg;
|
|
235
|
+
}
|
|
236
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
237
|
+
arg = `${arg}`;
|
|
238
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
|
|
239
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
240
|
+
arg = `"${arg}"`;
|
|
241
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
242
|
+
if (doubleEscapeMetaChars) arg = arg.replace(metaCharsRegExp, "^$1");
|
|
243
|
+
return arg;
|
|
244
|
+
}
|
|
245
|
+
module.exports.command = escapeCommand;
|
|
246
|
+
module.exports.argument = escapeArgument;
|
|
247
|
+
}));
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region ../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
|
|
250
|
+
var require_shebang_regex = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
251
|
+
module.exports = /^#!(.*)/;
|
|
252
|
+
}));
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region ../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
|
|
255
|
+
var require_shebang_command = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
256
|
+
const shebangRegex = require_shebang_regex();
|
|
257
|
+
module.exports = (string = "") => {
|
|
258
|
+
const match = string.match(shebangRegex);
|
|
259
|
+
if (!match) return null;
|
|
260
|
+
const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
261
|
+
const binary = path.split("/").pop();
|
|
262
|
+
if (binary === "env") return argument;
|
|
263
|
+
return argument ? `${binary} ${argument}` : binary;
|
|
264
|
+
};
|
|
265
|
+
}));
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
|
|
268
|
+
var require_readShebang = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
269
|
+
const fs$1 = __require("fs");
|
|
270
|
+
const shebangCommand = require_shebang_command();
|
|
271
|
+
function readShebang(command) {
|
|
272
|
+
const size = 150;
|
|
273
|
+
const buffer = Buffer.alloc(size);
|
|
274
|
+
let fd;
|
|
275
|
+
try {
|
|
276
|
+
fd = fs$1.openSync(command, "r");
|
|
277
|
+
fs$1.readSync(fd, buffer, 0, size, 0);
|
|
278
|
+
fs$1.closeSync(fd);
|
|
279
|
+
} catch (e) {}
|
|
280
|
+
return shebangCommand(buffer.toString());
|
|
281
|
+
}
|
|
282
|
+
module.exports = readShebang;
|
|
283
|
+
}));
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
|
|
286
|
+
var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
287
|
+
const path$1 = __require("path");
|
|
288
|
+
const resolveCommand = require_resolveCommand();
|
|
289
|
+
const escape = require_escape();
|
|
290
|
+
const readShebang = require_readShebang();
|
|
291
|
+
const isWin = process.platform === "win32";
|
|
292
|
+
const isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
293
|
+
const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
294
|
+
function detectShebang(parsed) {
|
|
295
|
+
parsed.file = resolveCommand(parsed);
|
|
296
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
297
|
+
if (shebang) {
|
|
298
|
+
parsed.args.unshift(parsed.file);
|
|
299
|
+
parsed.command = shebang;
|
|
300
|
+
return resolveCommand(parsed);
|
|
301
|
+
}
|
|
302
|
+
return parsed.file;
|
|
303
|
+
}
|
|
304
|
+
function parseNonShell(parsed) {
|
|
305
|
+
if (!isWin) return parsed;
|
|
306
|
+
const commandFile = detectShebang(parsed);
|
|
307
|
+
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
308
|
+
if (parsed.options.forceShell || needsShell) {
|
|
309
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
310
|
+
parsed.command = path$1.normalize(parsed.command);
|
|
311
|
+
parsed.command = escape.command(parsed.command);
|
|
312
|
+
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
313
|
+
parsed.args = [
|
|
314
|
+
"/d",
|
|
315
|
+
"/s",
|
|
316
|
+
"/c",
|
|
317
|
+
`"${[parsed.command].concat(parsed.args).join(" ")}"`
|
|
318
|
+
];
|
|
319
|
+
parsed.command = process.env.comspec || "cmd.exe";
|
|
320
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
321
|
+
}
|
|
322
|
+
return parsed;
|
|
323
|
+
}
|
|
324
|
+
function parse(command, args, options) {
|
|
325
|
+
if (args && !Array.isArray(args)) {
|
|
326
|
+
options = args;
|
|
327
|
+
args = null;
|
|
328
|
+
}
|
|
329
|
+
args = args ? args.slice(0) : [];
|
|
330
|
+
options = Object.assign({}, options);
|
|
331
|
+
const parsed = {
|
|
332
|
+
command,
|
|
333
|
+
args,
|
|
334
|
+
options,
|
|
335
|
+
file: void 0,
|
|
336
|
+
original: {
|
|
337
|
+
command,
|
|
338
|
+
args
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
return options.shell ? parsed : parseNonShell(parsed);
|
|
342
|
+
}
|
|
343
|
+
module.exports = parse;
|
|
344
|
+
}));
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
|
|
347
|
+
var require_enoent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
348
|
+
const isWin = process.platform === "win32";
|
|
349
|
+
function notFoundError(original, syscall) {
|
|
350
|
+
return Object.assign(/* @__PURE__ */ new Error(`${syscall} ${original.command} ENOENT`), {
|
|
351
|
+
code: "ENOENT",
|
|
352
|
+
errno: "ENOENT",
|
|
353
|
+
syscall: `${syscall} ${original.command}`,
|
|
354
|
+
path: original.command,
|
|
355
|
+
spawnargs: original.args
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
function hookChildProcess(cp, parsed) {
|
|
359
|
+
if (!isWin) return;
|
|
360
|
+
const originalEmit = cp.emit;
|
|
361
|
+
cp.emit = function(name, arg1) {
|
|
362
|
+
if (name === "exit") {
|
|
363
|
+
const err = verifyENOENT(arg1, parsed);
|
|
364
|
+
if (err) return originalEmit.call(cp, "error", err);
|
|
365
|
+
}
|
|
366
|
+
return originalEmit.apply(cp, arguments);
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
function verifyENOENT(status, parsed) {
|
|
370
|
+
if (isWin && status === 1 && !parsed.file) return notFoundError(parsed.original, "spawn");
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
function verifyENOENTSync(status, parsed) {
|
|
374
|
+
if (isWin && status === 1 && !parsed.file) return notFoundError(parsed.original, "spawnSync");
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
module.exports = {
|
|
378
|
+
hookChildProcess,
|
|
379
|
+
verifyENOENT,
|
|
380
|
+
verifyENOENTSync,
|
|
381
|
+
notFoundError
|
|
382
|
+
};
|
|
383
|
+
}));
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js
|
|
386
|
+
var require_cross_spawn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
387
|
+
const cp = __require("child_process");
|
|
388
|
+
const parse = require_parse$1();
|
|
389
|
+
const enoent = require_enoent();
|
|
390
|
+
function spawn(command, args, options) {
|
|
391
|
+
const parsed = parse(command, args, options);
|
|
392
|
+
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
393
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
394
|
+
return spawned;
|
|
395
|
+
}
|
|
396
|
+
function spawnSync(command, args, options) {
|
|
397
|
+
const parsed = parse(command, args, options);
|
|
398
|
+
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
399
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
400
|
+
return result;
|
|
401
|
+
}
|
|
402
|
+
module.exports = spawn;
|
|
403
|
+
module.exports.spawn = spawn;
|
|
404
|
+
module.exports.sync = spawnSync;
|
|
405
|
+
module.exports._parse = parse;
|
|
406
|
+
module.exports._enoent = enoent;
|
|
407
|
+
}));
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/utils/command.ts
|
|
410
|
+
var import_cross_spawn = /* @__PURE__ */ __toESM(require_cross_spawn(), 1);
|
|
411
|
+
async function runCommandSilently(options) {
|
|
412
|
+
const child = (0, import_cross_spawn.default)(options.command, options.args, {
|
|
413
|
+
stdio: [
|
|
414
|
+
"ignore",
|
|
415
|
+
"pipe",
|
|
416
|
+
"pipe"
|
|
417
|
+
],
|
|
418
|
+
cwd: options.cwd,
|
|
419
|
+
env: options.envs
|
|
420
|
+
});
|
|
421
|
+
return await new Promise((resolve, reject) => {
|
|
422
|
+
const stdout = [];
|
|
423
|
+
const stderr = [];
|
|
424
|
+
child.stdout?.on("data", (data) => {
|
|
425
|
+
stdout.push(data);
|
|
426
|
+
});
|
|
427
|
+
child.stderr?.on("data", (data) => {
|
|
428
|
+
stderr.push(data);
|
|
429
|
+
});
|
|
430
|
+
child.on("close", (code) => {
|
|
431
|
+
resolve({
|
|
432
|
+
exitCode: code ?? 0,
|
|
433
|
+
stdout: Buffer.concat(stdout),
|
|
434
|
+
stderr: Buffer.concat(stderr)
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
child.on("error", (err) => {
|
|
438
|
+
reject(err);
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
async function runCommand$1(options) {
|
|
443
|
+
const child = (0, import_cross_spawn.default)(options.command, options.args, {
|
|
444
|
+
stdio: "inherit",
|
|
445
|
+
cwd: options.cwd,
|
|
446
|
+
env: options.envs
|
|
447
|
+
});
|
|
448
|
+
return new Promise((resolve, reject) => {
|
|
449
|
+
child.on("close", (code) => {
|
|
450
|
+
resolve({ exitCode: code ?? 0 });
|
|
451
|
+
});
|
|
452
|
+
child.on("error", (err) => {
|
|
453
|
+
reject(err);
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
//#endregion
|
|
17
458
|
//#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
18
459
|
const getCodePointsLength = (() => {
|
|
19
460
|
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
@@ -296,7 +737,7 @@ function wrapAnsi$1(string, columns, options) {
|
|
|
296
737
|
return String(string).normalize().split(CRLF_OR_LF$1).map((line) => exec$1(line, columns, options)).join("\n");
|
|
297
738
|
}
|
|
298
739
|
//#endregion
|
|
299
|
-
//#region ../../node_modules/.pnpm/@clack+core@1.3.
|
|
740
|
+
//#region ../../node_modules/.pnpm/@clack+core@1.3.1/node_modules/@clack/core/dist/index.mjs
|
|
300
741
|
var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
301
742
|
const ESC = "\x1B";
|
|
302
743
|
const CSI = `${ESC}[`;
|
|
@@ -349,10 +790,10 @@ var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
349
790
|
beep
|
|
350
791
|
};
|
|
351
792
|
})))();
|
|
352
|
-
function
|
|
793
|
+
function f(r, t, s) {
|
|
353
794
|
if (!s.some((o) => !o.disabled)) return r;
|
|
354
795
|
const e = r + t, i = Math.max(s.length - 1, 0), n = e < 0 ? i : e > i ? 0 : e;
|
|
355
|
-
return s[n].disabled ?
|
|
796
|
+
return s[n].disabled ? f(n, t < 0 ? -1 : 1, s) : n;
|
|
356
797
|
}
|
|
357
798
|
const h = {
|
|
358
799
|
actions: new Set([
|
|
@@ -445,8 +886,8 @@ function R({ input: r = stdin, output: t = stdout, overwrite: s = !0, hideCursor
|
|
|
445
886
|
return;
|
|
446
887
|
}
|
|
447
888
|
if (!s) return;
|
|
448
|
-
const
|
|
449
|
-
b.moveCursor(t,
|
|
889
|
+
const c = u === "return" ? 0 : -1, y = u === "return" ? -1 : 0;
|
|
890
|
+
b.moveCursor(t, c, y, () => {
|
|
450
891
|
b.clearLine(t, 1, () => {
|
|
451
892
|
r.once("keypress", n);
|
|
452
893
|
});
|
|
@@ -457,18 +898,18 @@ function R({ input: r = stdin, output: t = stdout, overwrite: s = !0, hideCursor
|
|
|
457
898
|
};
|
|
458
899
|
}
|
|
459
900
|
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;
|
|
460
|
-
function W(r, t, s, e = s, i) {
|
|
901
|
+
function W(r, t, s, e = s, i = s, n) {
|
|
461
902
|
return wrapAnsi$1(t, A(r ?? stdout) - s.length, {
|
|
462
903
|
hard: !0,
|
|
463
904
|
trim: !1
|
|
464
905
|
}).split(`
|
|
465
|
-
`).map((
|
|
466
|
-
const
|
|
467
|
-
return
|
|
906
|
+
`).map((u, a, l) => {
|
|
907
|
+
const c = n ? n(u, a) : u;
|
|
908
|
+
return a === 0 ? `${e}${c}` : a === l.length - 1 ? `${i}${c}` : `${s}${c}`;
|
|
468
909
|
}).join(`
|
|
469
910
|
`);
|
|
470
911
|
}
|
|
471
|
-
let
|
|
912
|
+
let m = class {
|
|
472
913
|
input;
|
|
473
914
|
output;
|
|
474
915
|
_abortSignal;
|
|
@@ -618,7 +1059,7 @@ let p = class {
|
|
|
618
1059
|
}
|
|
619
1060
|
}
|
|
620
1061
|
};
|
|
621
|
-
var X = class extends
|
|
1062
|
+
var X = class extends m {
|
|
622
1063
|
get cursor() {
|
|
623
1064
|
return this.value ? 0 : 1;
|
|
624
1065
|
}
|
|
@@ -635,7 +1076,7 @@ var X = class extends p {
|
|
|
635
1076
|
});
|
|
636
1077
|
}
|
|
637
1078
|
};
|
|
638
|
-
let nt = class extends
|
|
1079
|
+
let nt = class extends m {
|
|
639
1080
|
options;
|
|
640
1081
|
cursor = 0;
|
|
641
1082
|
get _value() {
|
|
@@ -662,17 +1103,17 @@ let nt = class extends p {
|
|
|
662
1103
|
constructor(t) {
|
|
663
1104
|
super(t, !1), this.options = t.options, this.value = [...t.initialValues ?? []];
|
|
664
1105
|
const s = Math.max(this.options.findIndex(({ value: e }) => e === t.cursorAt), 0);
|
|
665
|
-
this.cursor = this.options[s].disabled ?
|
|
1106
|
+
this.cursor = this.options[s].disabled ? f(s, 1, this.options) : s, this.on("key", (e) => {
|
|
666
1107
|
e === "a" && this.toggleAll(), e === "i" && this.toggleInvert();
|
|
667
1108
|
}), this.on("cursor", (e) => {
|
|
668
1109
|
switch (e) {
|
|
669
1110
|
case "left":
|
|
670
1111
|
case "up":
|
|
671
|
-
this.cursor =
|
|
1112
|
+
this.cursor = f(this.cursor, -1, this.options);
|
|
672
1113
|
break;
|
|
673
1114
|
case "down":
|
|
674
1115
|
case "right":
|
|
675
|
-
this.cursor =
|
|
1116
|
+
this.cursor = f(this.cursor, 1, this.options);
|
|
676
1117
|
break;
|
|
677
1118
|
case "space":
|
|
678
1119
|
this.toggleValue();
|
|
@@ -681,7 +1122,7 @@ let nt = class extends p {
|
|
|
681
1122
|
});
|
|
682
1123
|
}
|
|
683
1124
|
};
|
|
684
|
-
var ut = class extends
|
|
1125
|
+
var ut = class extends m {
|
|
685
1126
|
options;
|
|
686
1127
|
cursor = 0;
|
|
687
1128
|
get _selectedValue() {
|
|
@@ -693,22 +1134,22 @@ var ut = class extends p {
|
|
|
693
1134
|
constructor(t) {
|
|
694
1135
|
super(t, !1), this.options = t.options;
|
|
695
1136
|
const s = this.options.findIndex(({ value: i }) => i === t.initialValue), e = s === -1 ? 0 : s;
|
|
696
|
-
this.cursor = this.options[e].disabled ?
|
|
1137
|
+
this.cursor = this.options[e].disabled ? f(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (i) => {
|
|
697
1138
|
switch (i) {
|
|
698
1139
|
case "left":
|
|
699
1140
|
case "up":
|
|
700
|
-
this.cursor =
|
|
1141
|
+
this.cursor = f(this.cursor, -1, this.options);
|
|
701
1142
|
break;
|
|
702
1143
|
case "down":
|
|
703
1144
|
case "right":
|
|
704
|
-
this.cursor =
|
|
1145
|
+
this.cursor = f(this.cursor, 1, this.options);
|
|
705
1146
|
break;
|
|
706
1147
|
}
|
|
707
1148
|
this.changeValue();
|
|
708
1149
|
});
|
|
709
1150
|
}
|
|
710
1151
|
};
|
|
711
|
-
var ht = class extends
|
|
1152
|
+
var ht = class extends m {
|
|
712
1153
|
get userInputWithCursor() {
|
|
713
1154
|
if (this.state === "submit") return this.userInput;
|
|
714
1155
|
const t = this.userInput;
|
|
@@ -1672,7 +2113,7 @@ const text = (opts) => {
|
|
|
1672
2113
|
}).prompt();
|
|
1673
2114
|
};
|
|
1674
2115
|
//#endregion
|
|
1675
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2116
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/constants.js
|
|
1676
2117
|
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1677
2118
|
const SEMVER_SPEC_VERSION = "2.0.0";
|
|
1678
2119
|
const MAX_LENGTH = 256;
|
|
@@ -1697,12 +2138,12 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1697
2138
|
};
|
|
1698
2139
|
}));
|
|
1699
2140
|
//#endregion
|
|
1700
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2141
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/debug.js
|
|
1701
2142
|
var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1702
2143
|
module.exports = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
|
|
1703
2144
|
}));
|
|
1704
2145
|
//#endregion
|
|
1705
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2146
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/re.js
|
|
1706
2147
|
var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1707
2148
|
const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants();
|
|
1708
2149
|
const debug = require_debug();
|
|
@@ -1781,7 +2222,7 @@ var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1781
2222
|
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
1782
2223
|
}));
|
|
1783
2224
|
//#endregion
|
|
1784
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2225
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/parse-options.js
|
|
1785
2226
|
var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1786
2227
|
const looseOption = Object.freeze({ loose: true });
|
|
1787
2228
|
const emptyOpts = Object.freeze({});
|
|
@@ -1793,7 +2234,7 @@ var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
1793
2234
|
module.exports = parseOptions;
|
|
1794
2235
|
}));
|
|
1795
2236
|
//#endregion
|
|
1796
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2237
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/identifiers.js
|
|
1797
2238
|
var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1798
2239
|
const numeric = /^[0-9]+$/;
|
|
1799
2240
|
const compareIdentifiers = (a, b) => {
|
|
@@ -1813,7 +2254,7 @@ var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1813
2254
|
};
|
|
1814
2255
|
}));
|
|
1815
2256
|
//#endregion
|
|
1816
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2257
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/classes/semver.js
|
|
1817
2258
|
var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1818
2259
|
const debug = require_debug();
|
|
1819
2260
|
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
@@ -1991,7 +2432,7 @@ var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1991
2432
|
};
|
|
1992
2433
|
}));
|
|
1993
2434
|
//#endregion
|
|
1994
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2435
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/parse.js
|
|
1995
2436
|
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1996
2437
|
const SemVer = require_semver$1();
|
|
1997
2438
|
const parse = (version, options, throwErrors = false) => {
|
|
@@ -2006,7 +2447,7 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2006
2447
|
module.exports = parse;
|
|
2007
2448
|
}));
|
|
2008
2449
|
//#endregion
|
|
2009
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2450
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/valid.js
|
|
2010
2451
|
var require_valid$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2011
2452
|
const parse = require_parse();
|
|
2012
2453
|
const valid = (version, options) => {
|
|
@@ -2016,7 +2457,7 @@ var require_valid$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2016
2457
|
module.exports = valid;
|
|
2017
2458
|
}));
|
|
2018
2459
|
//#endregion
|
|
2019
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2460
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/clean.js
|
|
2020
2461
|
var require_clean = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2021
2462
|
const parse = require_parse();
|
|
2022
2463
|
const clean = (version, options) => {
|
|
@@ -2026,7 +2467,7 @@ var require_clean = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2026
2467
|
module.exports = clean;
|
|
2027
2468
|
}));
|
|
2028
2469
|
//#endregion
|
|
2029
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2470
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/inc.js
|
|
2030
2471
|
var require_inc = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2031
2472
|
const SemVer = require_semver$1();
|
|
2032
2473
|
const inc = (version, release, options, identifier, identifierBase) => {
|
|
@@ -2044,7 +2485,7 @@ var require_inc = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2044
2485
|
module.exports = inc;
|
|
2045
2486
|
}));
|
|
2046
2487
|
//#endregion
|
|
2047
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2488
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/diff.js
|
|
2048
2489
|
var require_diff = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2049
2490
|
const parse = require_parse();
|
|
2050
2491
|
const diff = (version1, version2) => {
|
|
@@ -2072,28 +2513,28 @@ var require_diff = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2072
2513
|
module.exports = diff;
|
|
2073
2514
|
}));
|
|
2074
2515
|
//#endregion
|
|
2075
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2516
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/major.js
|
|
2076
2517
|
var require_major = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2077
2518
|
const SemVer = require_semver$1();
|
|
2078
2519
|
const major = (a, loose) => new SemVer(a, loose).major;
|
|
2079
2520
|
module.exports = major;
|
|
2080
2521
|
}));
|
|
2081
2522
|
//#endregion
|
|
2082
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2523
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/minor.js
|
|
2083
2524
|
var require_minor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2084
2525
|
const SemVer = require_semver$1();
|
|
2085
2526
|
const minor = (a, loose) => new SemVer(a, loose).minor;
|
|
2086
2527
|
module.exports = minor;
|
|
2087
2528
|
}));
|
|
2088
2529
|
//#endregion
|
|
2089
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2530
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/patch.js
|
|
2090
2531
|
var require_patch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2091
2532
|
const SemVer = require_semver$1();
|
|
2092
2533
|
const patch = (a, loose) => new SemVer(a, loose).patch;
|
|
2093
2534
|
module.exports = patch;
|
|
2094
2535
|
}));
|
|
2095
2536
|
//#endregion
|
|
2096
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2537
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/prerelease.js
|
|
2097
2538
|
var require_prerelease = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2098
2539
|
const parse = require_parse();
|
|
2099
2540
|
const prerelease = (version, options) => {
|
|
@@ -2103,28 +2544,28 @@ var require_prerelease = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2103
2544
|
module.exports = prerelease;
|
|
2104
2545
|
}));
|
|
2105
2546
|
//#endregion
|
|
2106
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2547
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/compare.js
|
|
2107
2548
|
var require_compare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2108
2549
|
const SemVer = require_semver$1();
|
|
2109
2550
|
const compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
2110
2551
|
module.exports = compare;
|
|
2111
2552
|
}));
|
|
2112
2553
|
//#endregion
|
|
2113
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2554
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/rcompare.js
|
|
2114
2555
|
var require_rcompare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2115
2556
|
const compare = require_compare();
|
|
2116
2557
|
const rcompare = (a, b, loose) => compare(b, a, loose);
|
|
2117
2558
|
module.exports = rcompare;
|
|
2118
2559
|
}));
|
|
2119
2560
|
//#endregion
|
|
2120
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2561
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/compare-loose.js
|
|
2121
2562
|
var require_compare_loose = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2122
2563
|
const compare = require_compare();
|
|
2123
2564
|
const compareLoose = (a, b) => compare(a, b, true);
|
|
2124
2565
|
module.exports = compareLoose;
|
|
2125
2566
|
}));
|
|
2126
2567
|
//#endregion
|
|
2127
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2568
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/compare-build.js
|
|
2128
2569
|
var require_compare_build = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2129
2570
|
const SemVer = require_semver$1();
|
|
2130
2571
|
const compareBuild = (a, b, loose) => {
|
|
@@ -2135,63 +2576,63 @@ var require_compare_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
2135
2576
|
module.exports = compareBuild;
|
|
2136
2577
|
}));
|
|
2137
2578
|
//#endregion
|
|
2138
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2579
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/sort.js
|
|
2139
2580
|
var require_sort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2140
2581
|
const compareBuild = require_compare_build();
|
|
2141
2582
|
const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
2142
2583
|
module.exports = sort;
|
|
2143
2584
|
}));
|
|
2144
2585
|
//#endregion
|
|
2145
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2586
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/rsort.js
|
|
2146
2587
|
var require_rsort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2147
2588
|
const compareBuild = require_compare_build();
|
|
2148
2589
|
const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
2149
2590
|
module.exports = rsort;
|
|
2150
2591
|
}));
|
|
2151
2592
|
//#endregion
|
|
2152
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2593
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/gt.js
|
|
2153
2594
|
var require_gt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2154
2595
|
const compare = require_compare();
|
|
2155
2596
|
const gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
2156
2597
|
module.exports = gt;
|
|
2157
2598
|
}));
|
|
2158
2599
|
//#endregion
|
|
2159
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2600
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/lt.js
|
|
2160
2601
|
var require_lt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2161
2602
|
const compare = require_compare();
|
|
2162
2603
|
const lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
2163
2604
|
module.exports = lt;
|
|
2164
2605
|
}));
|
|
2165
2606
|
//#endregion
|
|
2166
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2607
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/eq.js
|
|
2167
2608
|
var require_eq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2168
2609
|
const compare = require_compare();
|
|
2169
2610
|
const eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
2170
2611
|
module.exports = eq;
|
|
2171
2612
|
}));
|
|
2172
2613
|
//#endregion
|
|
2173
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2614
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/neq.js
|
|
2174
2615
|
var require_neq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2175
2616
|
const compare = require_compare();
|
|
2176
2617
|
const neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
2177
2618
|
module.exports = neq;
|
|
2178
2619
|
}));
|
|
2179
2620
|
//#endregion
|
|
2180
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2621
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/gte.js
|
|
2181
2622
|
var require_gte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2182
2623
|
const compare = require_compare();
|
|
2183
2624
|
const gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
2184
2625
|
module.exports = gte;
|
|
2185
2626
|
}));
|
|
2186
2627
|
//#endregion
|
|
2187
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2628
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/lte.js
|
|
2188
2629
|
var require_lte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2189
2630
|
const compare = require_compare();
|
|
2190
2631
|
const lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
2191
2632
|
module.exports = lte;
|
|
2192
2633
|
}));
|
|
2193
2634
|
//#endregion
|
|
2194
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2635
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/cmp.js
|
|
2195
2636
|
var require_cmp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2196
2637
|
const eq = require_eq();
|
|
2197
2638
|
const neq = require_neq();
|
|
@@ -2223,7 +2664,7 @@ var require_cmp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2223
2664
|
module.exports = cmp;
|
|
2224
2665
|
}));
|
|
2225
2666
|
//#endregion
|
|
2226
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2667
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/coerce.js
|
|
2227
2668
|
var require_coerce = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2228
2669
|
const SemVer = require_semver$1();
|
|
2229
2670
|
const parse = require_parse();
|
|
@@ -2251,7 +2692,40 @@ var require_coerce = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2251
2692
|
module.exports = coerce;
|
|
2252
2693
|
}));
|
|
2253
2694
|
//#endregion
|
|
2254
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2695
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/truncate.js
|
|
2696
|
+
var require_truncate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2697
|
+
const parse = require_parse();
|
|
2698
|
+
const constants = require_constants();
|
|
2699
|
+
const SemVer = require_semver$1();
|
|
2700
|
+
const truncate = (version, truncation, options) => {
|
|
2701
|
+
if (!constants.RELEASE_TYPES.includes(truncation)) return null;
|
|
2702
|
+
const clonedVersion = cloneInputVersion(version, options);
|
|
2703
|
+
return clonedVersion && doTruncation(clonedVersion, truncation);
|
|
2704
|
+
};
|
|
2705
|
+
const cloneInputVersion = (version, options) => {
|
|
2706
|
+
return parse(version instanceof SemVer ? version.version : version, options);
|
|
2707
|
+
};
|
|
2708
|
+
const doTruncation = (version, truncation) => {
|
|
2709
|
+
if (isPrerelease(truncation)) return version.version;
|
|
2710
|
+
version.prerelease = [];
|
|
2711
|
+
switch (truncation) {
|
|
2712
|
+
case "major":
|
|
2713
|
+
version.minor = 0;
|
|
2714
|
+
version.patch = 0;
|
|
2715
|
+
break;
|
|
2716
|
+
case "minor":
|
|
2717
|
+
version.patch = 0;
|
|
2718
|
+
break;
|
|
2719
|
+
}
|
|
2720
|
+
return version.format();
|
|
2721
|
+
};
|
|
2722
|
+
const isPrerelease = (type) => {
|
|
2723
|
+
return type.startsWith("pre");
|
|
2724
|
+
};
|
|
2725
|
+
module.exports = truncate;
|
|
2726
|
+
}));
|
|
2727
|
+
//#endregion
|
|
2728
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/lrucache.js
|
|
2255
2729
|
var require_lrucache = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2256
2730
|
var LRUCache = class {
|
|
2257
2731
|
constructor() {
|
|
@@ -2284,7 +2758,7 @@ var require_lrucache = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2284
2758
|
module.exports = LRUCache;
|
|
2285
2759
|
}));
|
|
2286
2760
|
//#endregion
|
|
2287
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
2761
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/classes/range.js
|
|
2288
2762
|
var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2289
2763
|
const SPACE_CHARACTERS = /\s+/g;
|
|
2290
2764
|
module.exports = class Range {
|
|
@@ -2556,7 +3030,7 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2556
3030
|
};
|
|
2557
3031
|
}));
|
|
2558
3032
|
//#endregion
|
|
2559
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
3033
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/classes/comparator.js
|
|
2560
3034
|
var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2561
3035
|
const ANY = Symbol("SemVer ANY");
|
|
2562
3036
|
module.exports = class Comparator {
|
|
@@ -2626,7 +3100,7 @@ var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2626
3100
|
const Range = require_range();
|
|
2627
3101
|
}));
|
|
2628
3102
|
//#endregion
|
|
2629
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
3103
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/satisfies.js
|
|
2630
3104
|
var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2631
3105
|
const Range = require_range();
|
|
2632
3106
|
const satisfies = (version, range, options) => {
|
|
@@ -2640,14 +3114,14 @@ var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2640
3114
|
module.exports = satisfies;
|
|
2641
3115
|
}));
|
|
2642
3116
|
//#endregion
|
|
2643
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
3117
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/to-comparators.js
|
|
2644
3118
|
var require_to_comparators = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2645
3119
|
const Range = require_range();
|
|
2646
3120
|
const toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
2647
3121
|
module.exports = toComparators;
|
|
2648
3122
|
}));
|
|
2649
3123
|
//#endregion
|
|
2650
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
3124
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/max-satisfying.js
|
|
2651
3125
|
var require_max_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2652
3126
|
const SemVer = require_semver$1();
|
|
2653
3127
|
const Range = require_range();
|
|
@@ -2673,7 +3147,7 @@ var require_max_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
2673
3147
|
module.exports = maxSatisfying;
|
|
2674
3148
|
}));
|
|
2675
3149
|
//#endregion
|
|
2676
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
3150
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/min-satisfying.js
|
|
2677
3151
|
var require_min_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2678
3152
|
const SemVer = require_semver$1();
|
|
2679
3153
|
const Range = require_range();
|
|
@@ -2699,7 +3173,7 @@ var require_min_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
2699
3173
|
module.exports = minSatisfying;
|
|
2700
3174
|
}));
|
|
2701
3175
|
//#endregion
|
|
2702
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
3176
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/min-version.js
|
|
2703
3177
|
var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2704
3178
|
const SemVer = require_semver$1();
|
|
2705
3179
|
const Range = require_range();
|
|
@@ -2739,7 +3213,7 @@ var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2739
3213
|
module.exports = minVersion;
|
|
2740
3214
|
}));
|
|
2741
3215
|
//#endregion
|
|
2742
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
3216
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/valid.js
|
|
2743
3217
|
var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2744
3218
|
const Range = require_range();
|
|
2745
3219
|
const validRange = (range, options) => {
|
|
@@ -2752,7 +3226,7 @@ var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2752
3226
|
module.exports = validRange;
|
|
2753
3227
|
}));
|
|
2754
3228
|
//#endregion
|
|
2755
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
3229
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/outside.js
|
|
2756
3230
|
var require_outside = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2757
3231
|
const SemVer = require_semver$1();
|
|
2758
3232
|
const Comparator = require_comparator();
|
|
@@ -2805,21 +3279,21 @@ var require_outside = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2805
3279
|
module.exports = outside;
|
|
2806
3280
|
}));
|
|
2807
3281
|
//#endregion
|
|
2808
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
3282
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/gtr.js
|
|
2809
3283
|
var require_gtr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2810
3284
|
const outside = require_outside();
|
|
2811
3285
|
const gtr = (version, range, options) => outside(version, range, ">", options);
|
|
2812
3286
|
module.exports = gtr;
|
|
2813
3287
|
}));
|
|
2814
3288
|
//#endregion
|
|
2815
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
3289
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/ltr.js
|
|
2816
3290
|
var require_ltr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2817
3291
|
const outside = require_outside();
|
|
2818
3292
|
const ltr = (version, range, options) => outside(version, range, "<", options);
|
|
2819
3293
|
module.exports = ltr;
|
|
2820
3294
|
}));
|
|
2821
3295
|
//#endregion
|
|
2822
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
3296
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/intersects.js
|
|
2823
3297
|
var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2824
3298
|
const Range = require_range();
|
|
2825
3299
|
const intersects = (r1, r2, options) => {
|
|
@@ -2830,7 +3304,7 @@ var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2830
3304
|
module.exports = intersects;
|
|
2831
3305
|
}));
|
|
2832
3306
|
//#endregion
|
|
2833
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
3307
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/simplify.js
|
|
2834
3308
|
var require_simplify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2835
3309
|
const satisfies = require_satisfies();
|
|
2836
3310
|
const compare = require_compare();
|
|
@@ -2860,7 +3334,7 @@ var require_simplify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2860
3334
|
};
|
|
2861
3335
|
}));
|
|
2862
3336
|
//#endregion
|
|
2863
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
3337
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/subset.js
|
|
2864
3338
|
var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2865
3339
|
const Range = require_range();
|
|
2866
3340
|
const Comparator = require_comparator();
|
|
@@ -2955,7 +3429,7 @@ var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2955
3429
|
module.exports = subset;
|
|
2956
3430
|
}));
|
|
2957
3431
|
//#endregion
|
|
2958
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
3432
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/index.js
|
|
2959
3433
|
var require_semver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2960
3434
|
const internalRe = require_re();
|
|
2961
3435
|
const constants = require_constants();
|
|
@@ -2985,6 +3459,7 @@ var require_semver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2985
3459
|
lte: require_lte(),
|
|
2986
3460
|
cmp: require_cmp(),
|
|
2987
3461
|
coerce: require_coerce(),
|
|
3462
|
+
truncate: require_truncate(),
|
|
2988
3463
|
Comparator: require_comparator(),
|
|
2989
3464
|
Range: require_range(),
|
|
2990
3465
|
satisfies: require_satisfies(),
|
|
@@ -3024,26 +3499,8 @@ const DependencyType = {
|
|
|
3024
3499
|
optionalDependencies: "optionalDependencies"
|
|
3025
3500
|
};
|
|
3026
3501
|
//#endregion
|
|
3027
|
-
//#region src/utils/path.ts
|
|
3028
|
-
var import_cross_spawn = /* @__PURE__ */ __toESM(require_cross_spawn(), 1);
|
|
3029
|
-
var import_semver = /* @__PURE__ */ __toESM(require_semver(), 1);
|
|
3030
|
-
var import_dist = require_dist();
|
|
3031
|
-
function findPkgRoot() {
|
|
3032
|
-
let dir = import.meta.dirname;
|
|
3033
|
-
while (dir !== path.dirname(dir)) {
|
|
3034
|
-
if (fs.existsSync(path.join(dir, "package.json"))) return dir;
|
|
3035
|
-
dir = path.dirname(dir);
|
|
3036
|
-
}
|
|
3037
|
-
return dir;
|
|
3038
|
-
}
|
|
3039
|
-
const pkgRoot = findPkgRoot();
|
|
3040
|
-
const templatesDir = path.join(pkgRoot, "templates");
|
|
3041
|
-
const rulesDir = path.join(pkgRoot, "rules");
|
|
3042
|
-
function displayRelative(to, from = process.cwd()) {
|
|
3043
|
-
return path.relative(from, to).replaceAll("\\", "/");
|
|
3044
|
-
}
|
|
3045
|
-
//#endregion
|
|
3046
3502
|
//#region src/utils/prompts.ts
|
|
3503
|
+
var import_semver = /* @__PURE__ */ __toESM(require_semver(), 1);
|
|
3047
3504
|
/**
|
|
3048
3505
|
* pnpm v11 promoted `ERR_PNPM_IGNORED_BUILDS` from a warning to a hard
|
|
3049
3506
|
* exit-1. Auto-installs run by `vp migrate` / `vp create` happen before the
|
|
@@ -3199,6 +3656,22 @@ async function promptGitHooks(options) {
|
|
|
3199
3656
|
}
|
|
3200
3657
|
return true;
|
|
3201
3658
|
}
|
|
3659
|
+
async function promptGitInit(options) {
|
|
3660
|
+
if (options.git === false) return false;
|
|
3661
|
+
if (options.git === true) return true;
|
|
3662
|
+
if (options.interactive) {
|
|
3663
|
+
const selected = await confirm({
|
|
3664
|
+
message: "Initialize a git repository with an initial commit?",
|
|
3665
|
+
initialValue: true
|
|
3666
|
+
});
|
|
3667
|
+
if (q(selected)) {
|
|
3668
|
+
cancelAndExit();
|
|
3669
|
+
return false;
|
|
3670
|
+
}
|
|
3671
|
+
return selected;
|
|
3672
|
+
}
|
|
3673
|
+
return false;
|
|
3674
|
+
}
|
|
3202
3675
|
function defaultInteractive() {
|
|
3203
3676
|
return !process.env.CI && process.stdin.isTTY;
|
|
3204
3677
|
}
|
|
@@ -3224,2027 +3697,130 @@ function getSilentSpinner() {
|
|
|
3224
3697
|
};
|
|
3225
3698
|
}
|
|
3226
3699
|
//#endregion
|
|
3227
|
-
//#region src/utils/
|
|
3228
|
-
function readYamlFile(file) {
|
|
3229
|
-
return (0, import_dist.parse)(fs.readFileSync(file, "utf-8"));
|
|
3230
|
-
}
|
|
3231
|
-
function editYamlFile(file, callback) {
|
|
3232
|
-
const doc = (0, import_dist.parseDocument)(fs.readFileSync(file, "utf-8"));
|
|
3233
|
-
callback(doc);
|
|
3234
|
-
fs.writeFileSync(file, doc.toString({ singleQuote: true }), "utf-8");
|
|
3235
|
-
}
|
|
3236
|
-
function scalarString(value) {
|
|
3237
|
-
return new import_dist.Scalar(value);
|
|
3238
|
-
}
|
|
3239
|
-
//#endregion
|
|
3240
|
-
//#region src/migration/detector.ts
|
|
3241
|
-
const PRETTIER_PACKAGE_JSON_CONFIG = "package.json#prettier";
|
|
3242
|
-
const PRETTIER_CONFIG_FILES = [
|
|
3243
|
-
".prettierrc",
|
|
3244
|
-
".prettierrc.json",
|
|
3245
|
-
".prettierrc.jsonc",
|
|
3246
|
-
".prettierrc.yaml",
|
|
3247
|
-
".prettierrc.yml",
|
|
3248
|
-
".prettierrc.toml",
|
|
3249
|
-
".prettierrc.js",
|
|
3250
|
-
".prettierrc.cjs",
|
|
3251
|
-
".prettierrc.mjs",
|
|
3252
|
-
".prettierrc.ts",
|
|
3253
|
-
".prettierrc.cts",
|
|
3254
|
-
".prettierrc.mts",
|
|
3255
|
-
"prettier.config.js",
|
|
3256
|
-
"prettier.config.cjs",
|
|
3257
|
-
"prettier.config.mjs",
|
|
3258
|
-
"prettier.config.ts",
|
|
3259
|
-
"prettier.config.cts",
|
|
3260
|
-
"prettier.config.mts"
|
|
3261
|
-
];
|
|
3262
|
-
function detectConfigs(projectPath) {
|
|
3263
|
-
const configs = {};
|
|
3264
|
-
for (const config of [
|
|
3265
|
-
"vite.config.ts",
|
|
3266
|
-
"vite.config.mts",
|
|
3267
|
-
"vite.config.cts",
|
|
3268
|
-
"vite.config.js",
|
|
3269
|
-
"vite.config.mjs",
|
|
3270
|
-
"vite.config.cjs"
|
|
3271
|
-
]) if (fs.existsSync(path.join(projectPath, config))) {
|
|
3272
|
-
configs.viteConfig = config;
|
|
3273
|
-
break;
|
|
3274
|
-
}
|
|
3275
|
-
for (const config of [
|
|
3276
|
-
"vitest.config.ts",
|
|
3277
|
-
"vitest.config.mts",
|
|
3278
|
-
"vitest.config.cts",
|
|
3279
|
-
"vitest.config.js",
|
|
3280
|
-
"vitest.config.mjs",
|
|
3281
|
-
"vitest.config.cjs"
|
|
3282
|
-
]) if (fs.existsSync(path.join(projectPath, config))) {
|
|
3283
|
-
configs.vitestConfig = config;
|
|
3284
|
-
break;
|
|
3285
|
-
}
|
|
3286
|
-
for (const config of [
|
|
3287
|
-
"tsdown.config.ts",
|
|
3288
|
-
"tsdown.config.mts",
|
|
3289
|
-
"tsdown.config.cts",
|
|
3290
|
-
"tsdown.config.js",
|
|
3291
|
-
"tsdown.config.mjs",
|
|
3292
|
-
"tsdown.config.cjs",
|
|
3293
|
-
"tsdown.config.json",
|
|
3294
|
-
"tsdown.config"
|
|
3295
|
-
]) if (fs.existsSync(path.join(projectPath, config))) {
|
|
3296
|
-
configs.tsdownConfig = config;
|
|
3297
|
-
break;
|
|
3298
|
-
}
|
|
3299
|
-
for (const config of [".oxlintrc.json", ".oxlintrc.jsonc"]) if (fs.existsSync(path.join(projectPath, config))) {
|
|
3300
|
-
configs.oxlintConfig = config;
|
|
3301
|
-
break;
|
|
3302
|
-
}
|
|
3303
|
-
for (const config of [".oxfmtrc.json", ".oxfmtrc.jsonc"]) if (fs.existsSync(path.join(projectPath, config))) {
|
|
3304
|
-
configs.oxfmtConfig = config;
|
|
3305
|
-
break;
|
|
3306
|
-
}
|
|
3307
|
-
for (const config of [
|
|
3308
|
-
"eslint.config.js",
|
|
3309
|
-
"eslint.config.mjs",
|
|
3310
|
-
"eslint.config.cjs",
|
|
3311
|
-
"eslint.config.ts",
|
|
3312
|
-
"eslint.config.mts",
|
|
3313
|
-
"eslint.config.cts"
|
|
3314
|
-
]) if (fs.existsSync(path.join(projectPath, config))) {
|
|
3315
|
-
configs.eslintConfig = config;
|
|
3316
|
-
break;
|
|
3317
|
-
}
|
|
3318
|
-
for (const config of [
|
|
3319
|
-
".eslintrc",
|
|
3320
|
-
".eslintrc.json",
|
|
3321
|
-
".eslintrc.js",
|
|
3322
|
-
".eslintrc.cjs",
|
|
3323
|
-
".eslintrc.yaml",
|
|
3324
|
-
".eslintrc.yml"
|
|
3325
|
-
]) if (fs.existsSync(path.join(projectPath, config))) {
|
|
3326
|
-
configs.eslintLegacyConfig = config;
|
|
3327
|
-
break;
|
|
3328
|
-
}
|
|
3329
|
-
for (const config of PRETTIER_CONFIG_FILES) if (fs.existsSync(path.join(projectPath, config))) {
|
|
3330
|
-
configs.prettierConfig = config;
|
|
3331
|
-
break;
|
|
3332
|
-
}
|
|
3333
|
-
if (fs.existsSync(path.join(projectPath, ".prettierignore"))) configs.prettierIgnore = true;
|
|
3334
|
-
if (fs.existsSync(path.join(projectPath, ".nvmrc"))) configs.nvmrcFile = true;
|
|
3335
|
-
const packageJsonPath = path.join(projectPath, "package.json");
|
|
3336
|
-
if (fs.existsSync(packageJsonPath)) try {
|
|
3337
|
-
const content = fs.readFileSync(packageJsonPath, "utf8");
|
|
3338
|
-
const pkg = JSON.parse(content);
|
|
3339
|
-
if (!configs.prettierConfig && pkg.prettier) configs.prettierConfig = PRETTIER_PACKAGE_JSON_CONFIG;
|
|
3340
|
-
const voltaNode = pkg.volta?.node;
|
|
3341
|
-
if (typeof voltaNode === "string") configs.voltaNode = voltaNode;
|
|
3342
|
-
} catch {}
|
|
3343
|
-
return configs;
|
|
3344
|
-
}
|
|
3345
|
-
//#endregion
|
|
3346
|
-
//#region src/migration/migrator.ts
|
|
3347
|
-
const LINT_STAGED_JSON_CONFIG_FILES = [".lintstagedrc.json", ".lintstagedrc"];
|
|
3348
|
-
const LINT_STAGED_OTHER_CONFIG_FILES = [
|
|
3349
|
-
".lintstagedrc.yaml",
|
|
3350
|
-
".lintstagedrc.yml",
|
|
3351
|
-
".lintstagedrc.mjs",
|
|
3352
|
-
"lint-staged.config.mjs",
|
|
3353
|
-
".lintstagedrc.cjs",
|
|
3354
|
-
"lint-staged.config.cjs",
|
|
3355
|
-
".lintstagedrc.js",
|
|
3356
|
-
"lint-staged.config.js",
|
|
3357
|
-
".lintstagedrc.ts",
|
|
3358
|
-
"lint-staged.config.ts",
|
|
3359
|
-
".lintstagedrc.mts",
|
|
3360
|
-
"lint-staged.config.mts",
|
|
3361
|
-
".lintstagedrc.cts",
|
|
3362
|
-
"lint-staged.config.cts"
|
|
3363
|
-
];
|
|
3364
|
-
const LINT_STAGED_ALL_CONFIG_FILES = [...LINT_STAGED_JSON_CONFIG_FILES, ...LINT_STAGED_OTHER_CONFIG_FILES];
|
|
3365
|
-
const REMOVE_PACKAGES = [
|
|
3366
|
-
"oxlint",
|
|
3367
|
-
"oxlint-tsgolint",
|
|
3368
|
-
"oxfmt",
|
|
3369
|
-
"tsdown",
|
|
3370
|
-
"@vitest/browser",
|
|
3371
|
-
"@vitest/browser-preview",
|
|
3372
|
-
"@vitest/browser-playwright",
|
|
3373
|
-
"@vitest/browser-webdriverio"
|
|
3374
|
-
];
|
|
3375
|
-
const BROWSER_PROVIDER_PEER_DEPS = {
|
|
3376
|
-
"@vitest/browser-playwright": "playwright",
|
|
3377
|
-
"@vitest/browser-webdriverio": "webdriverio"
|
|
3378
|
-
};
|
|
3379
|
-
const PUBLIC_PEER_DEPENDENCY_FALLBACKS = {
|
|
3380
|
-
vite: "*",
|
|
3381
|
-
vitest: "*"
|
|
3382
|
-
};
|
|
3383
|
-
function warnMigration(message, report) {
|
|
3384
|
-
addMigrationWarning(report, message);
|
|
3385
|
-
if (!report) log.warn(message);
|
|
3386
|
-
}
|
|
3387
|
-
function infoMigration(message, report) {
|
|
3388
|
-
addManualStep(report, message);
|
|
3389
|
-
if (!report) log.info(message);
|
|
3390
|
-
}
|
|
3391
|
-
function checkViteVersion(projectPath) {
|
|
3392
|
-
return checkPackageVersion(projectPath, "vite", "7.0.0");
|
|
3393
|
-
}
|
|
3394
|
-
function checkVitestVersion(projectPath) {
|
|
3395
|
-
return checkPackageVersion(projectPath, "vitest", "4.0.0");
|
|
3396
|
-
}
|
|
3700
|
+
//#region src/utils/tsconfig.ts
|
|
3397
3701
|
/**
|
|
3398
|
-
* Check
|
|
3399
|
-
*
|
|
3400
|
-
*
|
|
3401
|
-
* @param minVersion - The minimum version of the package
|
|
3402
|
-
* @returns true if the package version is supported by auto migration
|
|
3702
|
+
* Check if tsconfig.json has compilerOptions.baseUrl set.
|
|
3703
|
+
* oxlint's TypeScript checker (tsgolint) does not support baseUrl,
|
|
3704
|
+
* so typeAware/typeCheck must be disabled when it is present.
|
|
3403
3705
|
*/
|
|
3404
|
-
function
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
const packageJsonFilePath = path.join(projectPath, "package.json");
|
|
3409
|
-
log.error(`✘ ${name}@${metadata.version} in ${displayRelative(packageJsonFilePath)} is not supported by auto migration`);
|
|
3410
|
-
log.info(`Please upgrade ${name} to version >=${minVersion} first`);
|
|
3706
|
+
function hasBaseUrlInTsconfigFile(filePath) {
|
|
3707
|
+
try {
|
|
3708
|
+
return parse(fs.readFileSync(filePath, "utf-8"))?.compilerOptions?.baseUrl != null;
|
|
3709
|
+
} catch {
|
|
3411
3710
|
return false;
|
|
3412
3711
|
}
|
|
3413
|
-
return true;
|
|
3414
|
-
}
|
|
3415
|
-
function detectEslintProject(projectPath, packages) {
|
|
3416
|
-
const packageJsonPath = path.join(projectPath, "package.json");
|
|
3417
|
-
if (!fs.existsSync(packageJsonPath)) return { hasDependency: false };
|
|
3418
|
-
const pkg = readJsonFile(packageJsonPath);
|
|
3419
|
-
let hasDependency = !!(pkg.devDependencies?.eslint || pkg.dependencies?.eslint);
|
|
3420
|
-
const configs = detectConfigs(projectPath);
|
|
3421
|
-
let configFile = configs.eslintConfig;
|
|
3422
|
-
const legacyConfigFile = configs.eslintLegacyConfig;
|
|
3423
|
-
if (!hasDependency && packages) for (const wp of packages) {
|
|
3424
|
-
const pkgJsonPath = path.join(projectPath, wp.path, "package.json");
|
|
3425
|
-
if (!fs.existsSync(pkgJsonPath)) continue;
|
|
3426
|
-
const wpPkg = readJsonFile(pkgJsonPath);
|
|
3427
|
-
if (wpPkg.devDependencies?.eslint || wpPkg.dependencies?.eslint) {
|
|
3428
|
-
hasDependency = true;
|
|
3429
|
-
break;
|
|
3430
|
-
}
|
|
3431
|
-
}
|
|
3432
|
-
return {
|
|
3433
|
-
hasDependency,
|
|
3434
|
-
configFile,
|
|
3435
|
-
legacyConfigFile
|
|
3436
|
-
};
|
|
3437
3712
|
}
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
* Returns true on success, false on failure (spawn error or non-zero exit).
|
|
3441
|
-
*/
|
|
3442
|
-
async function runOxlintMigrateStep(vpBin, cwd, migratePackage, args, spinner, failMessage, manualHint) {
|
|
3713
|
+
const TSCONFIG_FILE_RE = /^tsconfig(\.[\w-]+)?\.json$/i;
|
|
3714
|
+
function findTsconfigFiles(projectPath) {
|
|
3443
3715
|
try {
|
|
3444
|
-
|
|
3445
|
-
command: vpBin,
|
|
3446
|
-
args: [
|
|
3447
|
-
"dlx",
|
|
3448
|
-
migratePackage,
|
|
3449
|
-
...args
|
|
3450
|
-
],
|
|
3451
|
-
cwd,
|
|
3452
|
-
envs: process.env
|
|
3453
|
-
});
|
|
3454
|
-
if (result.exitCode !== 0) {
|
|
3455
|
-
spinner.stop(failMessage);
|
|
3456
|
-
const stderr = result.stderr.toString().trim();
|
|
3457
|
-
if (stderr) log.warn(`⚠ ${stderr}`);
|
|
3458
|
-
log.info(manualHint);
|
|
3459
|
-
return false;
|
|
3460
|
-
}
|
|
3461
|
-
return true;
|
|
3716
|
+
return fs.readdirSync(projectPath).filter((name) => TSCONFIG_FILE_RE.test(name)).map((name) => path.join(projectPath, name));
|
|
3462
3717
|
} catch {
|
|
3463
|
-
|
|
3464
|
-
log.info(manualHint);
|
|
3465
|
-
return false;
|
|
3718
|
+
return [];
|
|
3466
3719
|
}
|
|
3467
3720
|
}
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
const spinner = options?.silent ? {
|
|
3471
|
-
start: () => {},
|
|
3472
|
-
stop: () => {},
|
|
3473
|
-
pause: () => {},
|
|
3474
|
-
resume: () => {},
|
|
3475
|
-
cancel: () => {},
|
|
3476
|
-
error: () => {},
|
|
3477
|
-
clear: () => {},
|
|
3478
|
-
message: () => {},
|
|
3479
|
-
isCancelled: false
|
|
3480
|
-
} : getSpinner(interactive);
|
|
3481
|
-
if (eslintConfigFile) {
|
|
3482
|
-
const { versions } = await import("./versions.js");
|
|
3483
|
-
const migratePackage = `@oxlint/migrate@${versions.oxlint}`;
|
|
3484
|
-
spinner.start("Migrating ESLint config to Oxlint...");
|
|
3485
|
-
if (!await runOxlintMigrateStep(vpBin, projectPath, migratePackage, [
|
|
3486
|
-
"--merge",
|
|
3487
|
-
"--type-aware",
|
|
3488
|
-
"--with-nursery",
|
|
3489
|
-
"--details"
|
|
3490
|
-
], spinner, "ESLint migration failed", `You can run \`vp dlx ${migratePackage} --merge --type-aware --with-nursery --details\` manually later`)) return false;
|
|
3491
|
-
spinner.stop("ESLint config migrated to .oxlintrc.json");
|
|
3492
|
-
spinner.start("Replacing ESLint comments with Oxlint equivalents...");
|
|
3493
|
-
if (await runOxlintMigrateStep(vpBin, projectPath, migratePackage, ["--replace-eslint-comments"], spinner, "ESLint comment replacement failed", `You can run \`vp dlx ${migratePackage} --replace-eslint-comments\` manually later`)) spinner.stop("ESLint comments replaced");
|
|
3494
|
-
}
|
|
3495
|
-
if (options?.report) options.report.eslintMigrated = true;
|
|
3496
|
-
deleteEslintConfigFiles(projectPath, options?.report, options?.silent);
|
|
3497
|
-
rewriteEslintPackageJson(path.join(projectPath, "package.json"));
|
|
3498
|
-
if (packages) for (const pkg of packages) rewriteEslintPackageJson(path.join(projectPath, pkg.path, "package.json"));
|
|
3499
|
-
rewriteEslintLintStagedConfigFiles(projectPath, options?.report);
|
|
3500
|
-
return true;
|
|
3721
|
+
function hasBaseUrlInTsconfig(projectPath) {
|
|
3722
|
+
return findTsconfigFiles(projectPath).some((filePath) => hasBaseUrlInTsconfigFile(filePath));
|
|
3501
3723
|
}
|
|
3502
|
-
function
|
|
3503
|
-
|
|
3504
|
-
for (const file of [configs.eslintConfig, configs.eslintLegacyConfig]) if (file) {
|
|
3505
|
-
const configPath = path.join(basePath, file);
|
|
3506
|
-
if (fs.existsSync(configPath)) {
|
|
3507
|
-
fs.unlinkSync(configPath);
|
|
3508
|
-
if (report) report.removedConfigCount++;
|
|
3509
|
-
if (!silent) log.success(`✔ Removed ${displayRelative(configPath)}`);
|
|
3510
|
-
}
|
|
3511
|
-
}
|
|
3724
|
+
function findTsconfigFilesWithBaseUrl(projectPath) {
|
|
3725
|
+
return findTsconfigFiles(projectPath).filter((filePath) => hasBaseUrlInTsconfigFile(filePath));
|
|
3512
3726
|
}
|
|
3513
|
-
function
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
}
|
|
3520
|
-
if (pkg.dependencies?.eslint) {
|
|
3521
|
-
delete pkg.dependencies.eslint;
|
|
3522
|
-
changed = true;
|
|
3523
|
-
}
|
|
3524
|
-
if (pkg.scripts) {
|
|
3525
|
-
const updated = rewriteEslint(JSON.stringify(pkg.scripts));
|
|
3526
|
-
if (updated) {
|
|
3527
|
-
pkg.scripts = JSON.parse(updated);
|
|
3528
|
-
changed = true;
|
|
3529
|
-
}
|
|
3530
|
-
}
|
|
3531
|
-
if (pkg["lint-staged"]) {
|
|
3532
|
-
const updated = rewriteEslint(JSON.stringify(pkg["lint-staged"]));
|
|
3533
|
-
if (updated) {
|
|
3534
|
-
pkg["lint-staged"] = JSON.parse(updated);
|
|
3535
|
-
changed = true;
|
|
3536
|
-
}
|
|
3537
|
-
}
|
|
3538
|
-
return changed ? pkg : void 0;
|
|
3727
|
+
async function confirmBaseUrlFix(interactive) {
|
|
3728
|
+
if (!interactive) return true;
|
|
3729
|
+
const command = [BASEURL_TSCONFIG_FIX_PACKAGE, ...createBaseUrlTsconfigFixArgs("<tsconfig path>")].join(" ");
|
|
3730
|
+
const confirmed = await confirm({
|
|
3731
|
+
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}\``),
|
|
3732
|
+
initialValue: true
|
|
3539
3733
|
});
|
|
3734
|
+
if (q(confirmed)) cancelAndExit();
|
|
3735
|
+
return confirmed;
|
|
3540
3736
|
}
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
const configPath = path.join(projectPath, filename);
|
|
3548
|
-
if (!fs.existsSync(configPath)) continue;
|
|
3549
|
-
if (filename === ".lintstagedrc" && !isJsonFile(configPath)) {
|
|
3550
|
-
warnMigration(`${displayRelative(configPath)} is not JSON — please update ${toolName} references manually`, report);
|
|
3551
|
-
continue;
|
|
3552
|
-
}
|
|
3553
|
-
editJsonFile(configPath, (config) => {
|
|
3554
|
-
const updated = rewriteFn(JSON.stringify(config));
|
|
3555
|
-
if (updated) return JSON.parse(updated);
|
|
3556
|
-
});
|
|
3737
|
+
async function fixBaseUrlInTsconfig(projectPath, options) {
|
|
3738
|
+
const files = findTsconfigFilesWithBaseUrl(projectPath);
|
|
3739
|
+
if (files.length === 0) return "not-needed";
|
|
3740
|
+
if (!(options?.confirmed ?? await confirmBaseUrlFix(options?.interactive ?? false))) {
|
|
3741
|
+
options?.onStatus?.("declined", projectPath);
|
|
3742
|
+
return "declined";
|
|
3557
3743
|
}
|
|
3558
|
-
|
|
3559
|
-
const
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3744
|
+
try {
|
|
3745
|
+
for (const filePath of files) {
|
|
3746
|
+
const fixArgs = createBaseUrlTsconfigFixArgs(path.relative(projectPath, filePath) || filePath);
|
|
3747
|
+
if (!options?.silent) log.info(`Running vp dlx ${BASEURL_TSCONFIG_FIX_PACKAGE} ${fixArgs.join(" ")}`);
|
|
3748
|
+
const result = await runCommandSilently({
|
|
3749
|
+
command: process.env.VP_CLI_BIN ?? "vp",
|
|
3750
|
+
args: [
|
|
3751
|
+
"dlx",
|
|
3752
|
+
BASEURL_TSCONFIG_FIX_PACKAGE,
|
|
3753
|
+
...fixArgs
|
|
3754
|
+
],
|
|
3755
|
+
cwd: projectPath,
|
|
3756
|
+
envs: process.env
|
|
3757
|
+
});
|
|
3758
|
+
if (result.exitCode !== 0) {
|
|
3759
|
+
if (!options?.silent) {
|
|
3760
|
+
const output = `${result.stdout.toString()}${result.stderr.toString()}`.trim();
|
|
3761
|
+
if (output) log.warn(output);
|
|
3762
|
+
}
|
|
3763
|
+
options?.onStatus?.("failed", projectPath);
|
|
3764
|
+
return "failed";
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
if (hasBaseUrlInTsconfig(projectPath)) {
|
|
3768
|
+
if (!options?.silent) log.warn("tsconfig still contains baseUrl after running the fixer.");
|
|
3769
|
+
options?.onStatus?.("failed", projectPath);
|
|
3770
|
+
return "failed";
|
|
3580
3771
|
}
|
|
3772
|
+
} catch (error) {
|
|
3773
|
+
if (!options?.silent && error instanceof Error) log.warn(error.message);
|
|
3774
|
+
options?.onStatus?.("failed", projectPath);
|
|
3775
|
+
return "failed";
|
|
3581
3776
|
}
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
configFile
|
|
3585
|
-
};
|
|
3777
|
+
options?.onStatus?.("fixed", projectPath);
|
|
3778
|
+
return "fixed";
|
|
3586
3779
|
}
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
* Returns true on success, false on failure.
|
|
3590
|
-
*/
|
|
3591
|
-
async function runPrettierMigrateStep(vpBin, cwd, spinner, failMessage, manualHint) {
|
|
3780
|
+
function removeDeprecatedTsconfigFalseOption(filePath, optionName) {
|
|
3781
|
+
let text;
|
|
3592
3782
|
try {
|
|
3593
|
-
|
|
3594
|
-
command: vpBin,
|
|
3595
|
-
args: ["fmt", "--migrate=prettier"],
|
|
3596
|
-
cwd,
|
|
3597
|
-
envs: process.env
|
|
3598
|
-
});
|
|
3599
|
-
if (result.exitCode !== 0) {
|
|
3600
|
-
spinner.stop(failMessage);
|
|
3601
|
-
const stderr = result.stderr.toString().trim();
|
|
3602
|
-
if (stderr) log.warn(`⚠ ${stderr}`);
|
|
3603
|
-
log.info(manualHint);
|
|
3604
|
-
return false;
|
|
3605
|
-
}
|
|
3606
|
-
return true;
|
|
3783
|
+
text = fs.readFileSync(filePath, "utf-8");
|
|
3607
3784
|
} catch {
|
|
3608
|
-
spinner.stop(failMessage);
|
|
3609
|
-
log.info(manualHint);
|
|
3610
3785
|
return false;
|
|
3611
3786
|
}
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
const
|
|
3616
|
-
|
|
3617
|
-
stop: () => {},
|
|
3618
|
-
pause: () => {},
|
|
3619
|
-
resume: () => {},
|
|
3620
|
-
cancel: () => {},
|
|
3621
|
-
error: () => {},
|
|
3622
|
-
clear: () => {},
|
|
3623
|
-
message: () => {},
|
|
3624
|
-
isCancelled: false
|
|
3625
|
-
} : getSpinner(interactive);
|
|
3626
|
-
if (prettierConfigFile) {
|
|
3627
|
-
let tempPrettierConfig;
|
|
3628
|
-
if (prettierConfigFile === "package.json#prettier") {
|
|
3629
|
-
const pkg = readJsonFile(path.join(projectPath, "package.json"));
|
|
3630
|
-
if (pkg.prettier) {
|
|
3631
|
-
tempPrettierConfig = path.join(projectPath, ".prettierrc.json");
|
|
3632
|
-
fs.writeFileSync(tempPrettierConfig, JSON.stringify(pkg.prettier, null, 2));
|
|
3633
|
-
} else return true;
|
|
3634
|
-
}
|
|
3635
|
-
try {
|
|
3636
|
-
spinner.start("Migrating Prettier config to Oxfmt...");
|
|
3637
|
-
if (!await runPrettierMigrateStep(vpBin, projectPath, spinner, "Prettier migration failed", "You can run `vp fmt --migrate=prettier` manually later")) return false;
|
|
3638
|
-
spinner.stop("Prettier config migrated to .oxfmtrc.json");
|
|
3639
|
-
} finally {
|
|
3640
|
-
if (tempPrettierConfig) try {
|
|
3641
|
-
fs.unlinkSync(tempPrettierConfig);
|
|
3642
|
-
} catch {}
|
|
3643
|
-
}
|
|
3644
|
-
}
|
|
3645
|
-
if (options?.report) options.report.prettierMigrated = true;
|
|
3646
|
-
deletePrettierConfigFiles(projectPath, options?.report, options?.silent);
|
|
3647
|
-
rewritePrettierPackageJson(path.join(projectPath, "package.json"));
|
|
3648
|
-
if (packages) for (const pkg of packages) rewritePrettierPackageJson(path.join(projectPath, pkg.path, "package.json"));
|
|
3649
|
-
rewritePrettierLintStagedConfigFiles(projectPath, options?.report);
|
|
3650
|
-
const prettierIgnorePath = path.join(projectPath, ".prettierignore");
|
|
3651
|
-
if (fs.existsSync(prettierIgnorePath)) warnMigration(`${displayRelative(prettierIgnorePath)} found — Oxfmt supports .prettierignore, but using the \`ignorePatterns\` option is recommended.`, options?.report);
|
|
3787
|
+
if (parse(text)?.compilerOptions?.[optionName] !== false) return false;
|
|
3788
|
+
const edits = modify(text, ["compilerOptions", optionName], void 0, {});
|
|
3789
|
+
if (edits.length === 0) return false;
|
|
3790
|
+
const newText = applyEdits(text, edits);
|
|
3791
|
+
fs.writeFileSync(filePath, newText);
|
|
3652
3792
|
return true;
|
|
3653
3793
|
}
|
|
3654
|
-
function
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
if (report) report.removedConfigCount++;
|
|
3661
|
-
if (!silent) log.success(`✔ Removed ${displayRelative(configPath)}`);
|
|
3662
|
-
}
|
|
3663
|
-
}
|
|
3664
|
-
for (const file of PRETTIER_CONFIG_FILES) {
|
|
3665
|
-
if (file === configs.prettierConfig) continue;
|
|
3666
|
-
const configPath = path.join(basePath, file);
|
|
3667
|
-
if (fs.existsSync(configPath)) {
|
|
3668
|
-
fs.unlinkSync(configPath);
|
|
3669
|
-
if (report) report.removedConfigCount++;
|
|
3670
|
-
if (!silent) log.success(`✔ Removed ${displayRelative(configPath)}`);
|
|
3671
|
-
}
|
|
3672
|
-
}
|
|
3673
|
-
editJsonFile(path.join(basePath, "package.json"), (pkg) => {
|
|
3674
|
-
if (pkg.prettier) {
|
|
3675
|
-
delete pkg.prettier;
|
|
3676
|
-
return pkg;
|
|
3677
|
-
}
|
|
3678
|
-
});
|
|
3679
|
-
}
|
|
3680
|
-
function rewritePrettierPackageJson(packageJsonPath) {
|
|
3681
|
-
if (!fs.existsSync(packageJsonPath)) return;
|
|
3682
|
-
editJsonFile(packageJsonPath, (pkg) => {
|
|
3683
|
-
let changed = false;
|
|
3684
|
-
if (pkg.devDependencies) {
|
|
3685
|
-
for (const dep of Object.keys(pkg.devDependencies)) if (dep === "prettier" || dep.startsWith("prettier-plugin-")) {
|
|
3686
|
-
delete pkg.devDependencies[dep];
|
|
3687
|
-
changed = true;
|
|
3688
|
-
}
|
|
3689
|
-
}
|
|
3690
|
-
if (pkg.dependencies) {
|
|
3691
|
-
for (const dep of Object.keys(pkg.dependencies)) if (dep === "prettier" || dep.startsWith("prettier-plugin-")) {
|
|
3692
|
-
delete pkg.dependencies[dep];
|
|
3693
|
-
changed = true;
|
|
3694
|
-
}
|
|
3695
|
-
}
|
|
3696
|
-
if (pkg.scripts) {
|
|
3697
|
-
const updated = rewritePrettier(JSON.stringify(pkg.scripts));
|
|
3698
|
-
if (updated) {
|
|
3699
|
-
pkg.scripts = JSON.parse(updated);
|
|
3700
|
-
changed = true;
|
|
3701
|
-
}
|
|
3702
|
-
}
|
|
3703
|
-
if (pkg["lint-staged"]) {
|
|
3704
|
-
const updated = rewritePrettier(JSON.stringify(pkg["lint-staged"]));
|
|
3705
|
-
if (updated) {
|
|
3706
|
-
pkg["lint-staged"] = JSON.parse(updated);
|
|
3707
|
-
changed = true;
|
|
3708
|
-
}
|
|
3709
|
-
}
|
|
3710
|
-
return changed ? pkg : void 0;
|
|
3711
|
-
});
|
|
3712
|
-
}
|
|
3713
|
-
function rewritePrettierLintStagedConfigFiles(projectPath, report) {
|
|
3714
|
-
rewriteToolLintStagedConfigFiles(projectPath, rewritePrettier, "prettier", report);
|
|
3715
|
-
}
|
|
3716
|
-
function cleanupDeprecatedTsconfigOptions(projectPath, silent = false, report) {
|
|
3717
|
-
const deprecatedOptions = ["esModuleInterop", "allowSyntheticDefaultImports"];
|
|
3718
|
-
const files = findTsconfigFiles(projectPath);
|
|
3719
|
-
for (const filePath of files) for (const name of deprecatedOptions) if (removeDeprecatedTsconfigFalseOption(filePath, name)) {
|
|
3720
|
-
if (report) report.removedConfigCount++;
|
|
3721
|
-
if (!silent) log.success(`✔ Removed ${name}: false from ${displayRelative(filePath)}`);
|
|
3722
|
-
warnMigration(`Removed \`"${name}": false\` from ${displayRelative(filePath)} — this option has been deprecated. See https://github.com/oxc-project/tsgolint/issues/351, https://github.com/microsoft/TypeScript/issues/62529`, report);
|
|
3723
|
-
}
|
|
3724
|
-
}
|
|
3725
|
-
function rewriteTsconfigTypes(projectPath, silent = false, report) {
|
|
3726
|
-
const files = findTsconfigFiles(projectPath);
|
|
3727
|
-
for (const filePath of files) if (rewriteTypesInTsconfig(filePath)) {
|
|
3728
|
-
if (report) report.removedConfigCount++;
|
|
3729
|
-
if (!silent) log.success(`✔ Rewrote types in ${displayRelative(filePath)}`);
|
|
3730
|
-
}
|
|
3731
|
-
}
|
|
3732
|
-
const FRAMEWORK_SHIMS = {
|
|
3733
|
-
vue: [
|
|
3734
|
-
"declare module '*.vue' {",
|
|
3735
|
-
" import type { DefineComponent } from 'vue';",
|
|
3736
|
-
" const component: DefineComponent<{}, {}, unknown>;",
|
|
3737
|
-
" export default component;",
|
|
3738
|
-
"}"
|
|
3739
|
-
].join("\n"),
|
|
3740
|
-
astro: "/// <reference types=\"astro/client\" />"
|
|
3741
|
-
};
|
|
3742
|
-
function detectFramework(projectPath) {
|
|
3743
|
-
const packageJsonPath = path.join(projectPath, "package.json");
|
|
3744
|
-
if (!fs.existsSync(packageJsonPath)) return [];
|
|
3745
|
-
const pkg = readJsonFile(packageJsonPath);
|
|
3746
|
-
const allDeps = {
|
|
3747
|
-
...pkg.dependencies,
|
|
3748
|
-
...pkg.devDependencies
|
|
3749
|
-
};
|
|
3750
|
-
return ["vue", "astro"].filter((framework) => !!allDeps[framework]);
|
|
3751
|
-
}
|
|
3752
|
-
function getEnvDtsPath(projectPath) {
|
|
3753
|
-
const srcEnvDts = path.join(projectPath, "src", "env.d.ts");
|
|
3754
|
-
const rootEnvDts = path.join(projectPath, "env.d.ts");
|
|
3755
|
-
for (const candidate of [srcEnvDts, rootEnvDts]) if (fs.existsSync(candidate)) return candidate;
|
|
3756
|
-
return fs.existsSync(path.join(projectPath, "src")) ? srcEnvDts : rootEnvDts;
|
|
3757
|
-
}
|
|
3758
|
-
function hasFrameworkShim(projectPath, framework) {
|
|
3759
|
-
const dirsToScan = [projectPath, path.join(projectPath, "src")];
|
|
3760
|
-
for (const dir of dirsToScan) {
|
|
3761
|
-
if (!fs.existsSync(dir)) continue;
|
|
3762
|
-
let entries;
|
|
3763
|
-
try {
|
|
3764
|
-
entries = fs.readdirSync(dir);
|
|
3765
|
-
} catch {
|
|
3766
|
-
continue;
|
|
3767
|
-
}
|
|
3768
|
-
for (const entry of entries) {
|
|
3769
|
-
if (!entry.endsWith(".d.ts")) continue;
|
|
3770
|
-
const content = fs.readFileSync(path.join(dir, entry), "utf-8");
|
|
3771
|
-
if (framework === "astro") {
|
|
3772
|
-
if (content.includes("astro/client")) return true;
|
|
3773
|
-
} else if (content.includes(`'*.${framework}'`) || content.includes(`"*.${framework}"`)) return true;
|
|
3774
|
-
}
|
|
3775
|
-
}
|
|
3776
|
-
return false;
|
|
3777
|
-
}
|
|
3778
|
-
function addFrameworkShim(projectPath, framework, report) {
|
|
3779
|
-
const envDtsPath = getEnvDtsPath(projectPath);
|
|
3780
|
-
const shim = FRAMEWORK_SHIMS[framework];
|
|
3781
|
-
if (fs.existsSync(envDtsPath)) {
|
|
3782
|
-
const existing = fs.readFileSync(envDtsPath, "utf-8");
|
|
3783
|
-
fs.writeFileSync(envDtsPath, `${existing.trimEnd()}\n\n${shim}\n`, "utf-8");
|
|
3784
|
-
} else {
|
|
3785
|
-
fs.mkdirSync(path.dirname(envDtsPath), { recursive: true });
|
|
3786
|
-
fs.writeFileSync(envDtsPath, `${shim}\n`, "utf-8");
|
|
3787
|
-
}
|
|
3788
|
-
if (report) report.frameworkShimAdded = true;
|
|
3789
|
-
}
|
|
3790
|
-
/**
|
|
3791
|
-
* Rewrite standalone project to add vite-plus dependencies
|
|
3792
|
-
* @param projectPath - The path to the project
|
|
3793
|
-
*/
|
|
3794
|
-
function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigration, silent = false, report) {
|
|
3795
|
-
const packageJsonPath = path.join(projectPath, "package.json");
|
|
3796
|
-
if (!fs.existsSync(packageJsonPath)) return;
|
|
3797
|
-
const packageManager = workspaceInfo.packageManager;
|
|
3798
|
-
const catalogDependencyResolver = createCatalogDependencyResolver(projectPath, packageManager);
|
|
3799
|
-
let extractedStagedConfig = null;
|
|
3800
|
-
let remainingPnpmOverrides;
|
|
3801
|
-
let shouldRewritePnpmWorkspaceYaml = false;
|
|
3802
|
-
let shouldAddPnpmWorkspaceVitePlusOverride = false;
|
|
3803
|
-
let usePnpmWorkspaceYaml = false;
|
|
3804
|
-
editJsonFile(packageJsonPath, (pkg) => {
|
|
3805
|
-
if (packageManager === PackageManager.yarn) pkg.resolutions = {
|
|
3806
|
-
...pkg.resolutions,
|
|
3807
|
-
...VITE_PLUS_OVERRIDE_PACKAGES
|
|
3808
|
-
};
|
|
3809
|
-
else if (packageManager === PackageManager.npm || packageManager === PackageManager.bun) pkg.overrides = {
|
|
3810
|
-
...pkg.overrides,
|
|
3811
|
-
...VITE_PLUS_OVERRIDE_PACKAGES
|
|
3812
|
-
};
|
|
3813
|
-
else if (packageManager === PackageManager.pnpm) {
|
|
3814
|
-
usePnpmWorkspaceYaml = !pkg.pnpm;
|
|
3815
|
-
if (usePnpmWorkspaceYaml) {
|
|
3816
|
-
shouldRewritePnpmWorkspaceYaml = true;
|
|
3817
|
-
shouldAddPnpmWorkspaceVitePlusOverride = isForceOverrideMode();
|
|
3818
|
-
}
|
|
3819
|
-
const overrideKeys = Object.keys(VITE_PLUS_OVERRIDE_PACKAGES);
|
|
3820
|
-
if (!usePnpmWorkspaceYaml) pkg.pnpm = {
|
|
3821
|
-
...pkg.pnpm,
|
|
3822
|
-
overrides: {
|
|
3823
|
-
...pkg.pnpm?.overrides,
|
|
3824
|
-
...VITE_PLUS_OVERRIDE_PACKAGES,
|
|
3825
|
-
...isForceOverrideMode() ? { [VITE_PLUS_NAME]: VITE_PLUS_VERSION } : {}
|
|
3826
|
-
},
|
|
3827
|
-
peerDependencyRules: {
|
|
3828
|
-
...pkg.pnpm?.peerDependencyRules,
|
|
3829
|
-
allowAny: [...new Set([...pkg.pnpm?.peerDependencyRules?.allowAny ?? [], ...overrideKeys])],
|
|
3830
|
-
allowedVersions: {
|
|
3831
|
-
...pkg.pnpm?.peerDependencyRules?.allowedVersions,
|
|
3832
|
-
...Object.fromEntries(overrideKeys.map((key) => [key, "*"]))
|
|
3833
|
-
}
|
|
3834
|
-
}
|
|
3835
|
-
};
|
|
3836
|
-
else remainingPnpmOverrides = cleanupPnpmOverridesForWorkspaceYaml(pkg, overrideKeys);
|
|
3837
|
-
for (const key in pkg.pnpm?.overrides) if (key.includes(">")) {
|
|
3838
|
-
const splits = key.split(">");
|
|
3839
|
-
if (splits[splits.length - 1].trim() === "vite") delete pkg.pnpm.overrides[key];
|
|
3840
|
-
}
|
|
3841
|
-
for (const key of [...overrideKeys, ...REMOVE_PACKAGES]) if (pkg.resolutions?.[key]) delete pkg.resolutions[key];
|
|
3842
|
-
}
|
|
3843
|
-
extractedStagedConfig = rewritePackageJson(pkg, packageManager, usePnpmWorkspaceYaml, skipStagedMigration, catalogDependencyResolver);
|
|
3844
|
-
if (!pkg.devDependencies?.["vite-plus"] || isForceOverrideMode()) {
|
|
3845
|
-
const version = usePnpmWorkspaceYaml && !VITE_PLUS_VERSION.startsWith("file:") ? "catalog:" : VITE_PLUS_VERSION;
|
|
3846
|
-
pkg.devDependencies = {
|
|
3847
|
-
...pkg.devDependencies,
|
|
3848
|
-
[VITE_PLUS_NAME]: version
|
|
3849
|
-
};
|
|
3850
|
-
}
|
|
3851
|
-
return pkg;
|
|
3852
|
-
});
|
|
3853
|
-
if (shouldRewritePnpmWorkspaceYaml) rewritePnpmWorkspaceYaml(projectPath);
|
|
3854
|
-
if (remainingPnpmOverrides) migratePnpmOverridesToWorkspaceYaml(projectPath, remainingPnpmOverrides);
|
|
3855
|
-
if (shouldAddPnpmWorkspaceVitePlusOverride) migratePnpmOverridesToWorkspaceYaml(projectPath, { [VITE_PLUS_NAME]: VITE_PLUS_VERSION });
|
|
3856
|
-
if (packageManager === PackageManager.yarn) rewriteYarnrcYml(projectPath);
|
|
3857
|
-
if (extractedStagedConfig) {
|
|
3858
|
-
if (mergeStagedConfigToViteConfig(projectPath, extractedStagedConfig, silent, report)) removeLintStagedFromPackageJson(packageJsonPath);
|
|
3794
|
+
function rewriteTypesInTsconfig(filePath) {
|
|
3795
|
+
let text;
|
|
3796
|
+
try {
|
|
3797
|
+
text = fs.readFileSync(filePath, "utf-8");
|
|
3798
|
+
} catch {
|
|
3799
|
+
return false;
|
|
3859
3800
|
}
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
}
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
cleanupDeprecatedTsconfigOptions(workspaceInfo.rootDir, silent, report);
|
|
3883
|
-
rewriteTsconfigTypes(workspaceInfo.rootDir, silent, report);
|
|
3884
|
-
mergeViteConfigFiles(workspaceInfo.rootDir, silent, report);
|
|
3885
|
-
injectLintTypeCheckDefaults(workspaceInfo.rootDir, silent, report);
|
|
3886
|
-
injectFmtDefaults(workspaceInfo.rootDir, silent, report);
|
|
3887
|
-
mergeTsdownConfigFile(workspaceInfo.rootDir, silent, report);
|
|
3888
|
-
rewriteAllImports(workspaceInfo.rootDir, silent, report);
|
|
3889
|
-
setPackageManager(workspaceInfo.rootDir, workspaceInfo.downloadPackageManager);
|
|
3890
|
-
}
|
|
3891
|
-
/**
|
|
3892
|
-
* Rewrite monorepo project to add vite-plus dependencies
|
|
3893
|
-
* @param projectPath - The path to the project
|
|
3894
|
-
*/
|
|
3895
|
-
function rewriteMonorepoProject(projectPath, packageManager, skipStagedMigration, silent = false, report, catalogDependencyResolver) {
|
|
3896
|
-
cleanupDeprecatedTsconfigOptions(projectPath, silent, report);
|
|
3897
|
-
rewriteTsconfigTypes(projectPath, silent, report);
|
|
3898
|
-
mergeViteConfigFiles(projectPath, silent, report);
|
|
3899
|
-
mergeTsdownConfigFile(projectPath, silent, report);
|
|
3900
|
-
const packageJsonPath = path.join(projectPath, "package.json");
|
|
3901
|
-
if (!fs.existsSync(packageJsonPath)) return;
|
|
3902
|
-
let extractedStagedConfig = null;
|
|
3903
|
-
editJsonFile(packageJsonPath, (pkg) => {
|
|
3904
|
-
extractedStagedConfig = rewritePackageJson(pkg, packageManager, true, skipStagedMigration, catalogDependencyResolver);
|
|
3905
|
-
return pkg;
|
|
3906
|
-
});
|
|
3907
|
-
if (extractedStagedConfig) {
|
|
3908
|
-
if (mergeStagedConfigToViteConfig(projectPath, extractedStagedConfig, silent, report)) removeLintStagedFromPackageJson(packageJsonPath);
|
|
3909
|
-
}
|
|
3910
|
-
}
|
|
3911
|
-
/**
|
|
3912
|
-
* Rewrite pnpm-workspace.yaml to add vite-plus dependencies
|
|
3913
|
-
* @param projectPath - The path to the project
|
|
3914
|
-
*/
|
|
3915
|
-
function rewritePnpmWorkspaceYaml(projectPath) {
|
|
3916
|
-
const pnpmWorkspaceYamlPath = path.join(projectPath, "pnpm-workspace.yaml");
|
|
3917
|
-
if (!fs.existsSync(pnpmWorkspaceYamlPath)) fs.writeFileSync(pnpmWorkspaceYamlPath, "");
|
|
3918
|
-
editYamlFile(pnpmWorkspaceYamlPath, (doc) => {
|
|
3919
|
-
rewriteCatalog(doc);
|
|
3920
|
-
const overrides = doc.getIn(["overrides"]);
|
|
3921
|
-
for (const key of Object.keys(VITE_PLUS_OVERRIDE_PACKAGES)) {
|
|
3922
|
-
const version = getCatalogDependencySpec(getYamlMapScalarStringValue(overrides, key), VITE_PLUS_OVERRIDE_PACKAGES[key], true);
|
|
3923
|
-
doc.setIn(["overrides", scalarString(key)], scalarString(version));
|
|
3924
|
-
}
|
|
3925
|
-
const updatedOverrides = doc.getIn(["overrides"]);
|
|
3926
|
-
for (const item of updatedOverrides.items) if (item.key.value.includes(">")) {
|
|
3927
|
-
const splits = item.key.value.split(">");
|
|
3928
|
-
if (splits[splits.length - 1].trim() === "vite") updatedOverrides.delete(item.key);
|
|
3929
|
-
}
|
|
3930
|
-
let allowAny = doc.getIn(["peerDependencyRules", "allowAny"]);
|
|
3931
|
-
if (!allowAny) allowAny = new import_dist.YAMLSeq();
|
|
3932
|
-
const existing = new Set(allowAny.items.map((n) => n.value));
|
|
3933
|
-
for (const key of Object.keys(VITE_PLUS_OVERRIDE_PACKAGES)) if (!existing.has(key)) allowAny.add(scalarString(key));
|
|
3934
|
-
doc.setIn(["peerDependencyRules", "allowAny"], allowAny);
|
|
3935
|
-
let allowedVersions = doc.getIn(["peerDependencyRules", "allowedVersions"]);
|
|
3936
|
-
if (!allowedVersions) allowedVersions = new import_dist.YAMLMap();
|
|
3937
|
-
for (const key of Object.keys(VITE_PLUS_OVERRIDE_PACKAGES)) allowedVersions.set(scalarString(key), scalarString("*"));
|
|
3938
|
-
doc.setIn(["peerDependencyRules", "allowedVersions"], allowedVersions);
|
|
3939
|
-
if (doc.has("minimumReleaseAge")) {
|
|
3940
|
-
const excludes = [
|
|
3941
|
-
"vite-plus",
|
|
3942
|
-
"@voidzero-dev/*",
|
|
3943
|
-
"oxlint",
|
|
3944
|
-
"@oxlint/*",
|
|
3945
|
-
"oxlint-tsgolint",
|
|
3946
|
-
"@oxlint-tsgolint/*",
|
|
3947
|
-
"oxfmt",
|
|
3948
|
-
"@oxfmt/*"
|
|
3949
|
-
];
|
|
3950
|
-
let minimumReleaseAgeExclude = doc.getIn(["minimumReleaseAgeExclude"]);
|
|
3951
|
-
if (!minimumReleaseAgeExclude) minimumReleaseAgeExclude = new import_dist.YAMLSeq();
|
|
3952
|
-
const existing = new Set(minimumReleaseAgeExclude.items.map((n) => n.value));
|
|
3953
|
-
for (const exclude of excludes) if (!existing.has(exclude)) minimumReleaseAgeExclude.add(scalarString(exclude));
|
|
3954
|
-
doc.setIn(["minimumReleaseAgeExclude"], minimumReleaseAgeExclude);
|
|
3955
|
-
}
|
|
3956
|
-
});
|
|
3957
|
-
}
|
|
3958
|
-
/**
|
|
3959
|
-
* Clean up pnpm.overrides and peerDependencyRules from package.json when migrating
|
|
3960
|
-
* to pnpm-workspace.yaml. Returns any remaining non-Vite overrides that need to be
|
|
3961
|
-
* moved to pnpm-workspace.yaml.
|
|
3962
|
-
*/
|
|
3963
|
-
function cleanupPnpmOverridesForWorkspaceYaml(pkg, overrideKeys) {
|
|
3964
|
-
const catalogOverrides = {};
|
|
3965
|
-
const overrides = pkg.pnpm?.overrides;
|
|
3966
|
-
for (const key of [...overrideKeys, ...REMOVE_PACKAGES]) {
|
|
3967
|
-
const value = overrides?.[key];
|
|
3968
|
-
if (value) {
|
|
3969
|
-
if (overrideKeys.includes(key) && value.startsWith("catalog:")) catalogOverrides[key] = value;
|
|
3970
|
-
delete overrides[key];
|
|
3971
|
-
}
|
|
3972
|
-
}
|
|
3973
|
-
for (const key in pkg.pnpm?.overrides) if (key.includes(">")) {
|
|
3974
|
-
const splits = key.split(">");
|
|
3975
|
-
if (splits[splits.length - 1].trim() === "vite") delete pkg.pnpm.overrides[key];
|
|
3976
|
-
}
|
|
3977
|
-
let remaining;
|
|
3978
|
-
if (Object.keys(catalogOverrides).length > 0) remaining = { ...catalogOverrides };
|
|
3979
|
-
if (pkg.pnpm?.overrides && Object.keys(pkg.pnpm.overrides).length > 0) remaining = {
|
|
3980
|
-
...remaining,
|
|
3981
|
-
...pkg.pnpm.overrides
|
|
3982
|
-
};
|
|
3983
|
-
delete pkg.pnpm?.overrides;
|
|
3984
|
-
cleanupPeerDependencyRules(pkg.pnpm?.peerDependencyRules, overrideKeys);
|
|
3985
|
-
if (pkg.pnpm?.peerDependencyRules && Object.keys(pkg.pnpm.peerDependencyRules).length === 0) delete pkg.pnpm.peerDependencyRules;
|
|
3986
|
-
if (pkg.pnpm && Object.keys(pkg.pnpm).length === 0) delete pkg.pnpm;
|
|
3987
|
-
return remaining;
|
|
3988
|
-
}
|
|
3989
|
-
/**
|
|
3990
|
-
* Move remaining non-Vite pnpm.overrides from package.json to pnpm-workspace.yaml.
|
|
3991
|
-
* pnpm ignores workspace-level overrides when pnpm.overrides exists in package.json,
|
|
3992
|
-
* so all overrides must live in pnpm-workspace.yaml.
|
|
3993
|
-
*/
|
|
3994
|
-
function migratePnpmOverridesToWorkspaceYaml(projectPath, overrides) {
|
|
3995
|
-
editYamlFile(path.join(projectPath, "pnpm-workspace.yaml"), (doc) => {
|
|
3996
|
-
for (const [key, value] of Object.entries(overrides)) doc.setIn(["overrides", scalarString(key)], scalarString(value));
|
|
3997
|
-
});
|
|
3998
|
-
}
|
|
3999
|
-
/**
|
|
4000
|
-
* Remove only Vite-managed entries from peerDependencyRules, preserving custom ones.
|
|
4001
|
-
*/
|
|
4002
|
-
function cleanupPeerDependencyRules(peerDependencyRules, overrideKeys) {
|
|
4003
|
-
if (!peerDependencyRules) return;
|
|
4004
|
-
if (Array.isArray(peerDependencyRules.allowAny)) {
|
|
4005
|
-
peerDependencyRules.allowAny = peerDependencyRules.allowAny.filter((key) => !overrideKeys.includes(key));
|
|
4006
|
-
if (peerDependencyRules.allowAny.length === 0) delete peerDependencyRules.allowAny;
|
|
4007
|
-
}
|
|
4008
|
-
if (peerDependencyRules.allowedVersions) {
|
|
4009
|
-
for (const key of overrideKeys) delete peerDependencyRules.allowedVersions[key];
|
|
4010
|
-
if (Object.keys(peerDependencyRules.allowedVersions).length === 0) delete peerDependencyRules.allowedVersions;
|
|
4011
|
-
}
|
|
4012
|
-
}
|
|
4013
|
-
/**
|
|
4014
|
-
* Rewrite .yarnrc.yml to add vite-plus dependencies
|
|
4015
|
-
* @param projectPath - The path to the project
|
|
4016
|
-
*/
|
|
4017
|
-
function rewriteYarnrcYml(projectPath) {
|
|
4018
|
-
const yarnrcYmlPath = path.join(projectPath, ".yarnrc.yml");
|
|
4019
|
-
if (!fs.existsSync(yarnrcYmlPath)) fs.writeFileSync(yarnrcYmlPath, "");
|
|
4020
|
-
editYamlFile(yarnrcYmlPath, (doc) => {
|
|
4021
|
-
if (!doc.has("nodeLinker")) doc.set("nodeLinker", "node-modules");
|
|
4022
|
-
rewriteCatalog(doc);
|
|
4023
|
-
});
|
|
4024
|
-
}
|
|
4025
|
-
/**
|
|
4026
|
-
* Rewrite catalog in pnpm-workspace.yaml or .yarnrc.yml
|
|
4027
|
-
* @param doc - The document to rewrite
|
|
4028
|
-
*/
|
|
4029
|
-
function getCatalogDependencySpec(currentValue, version, supportCatalog, options) {
|
|
4030
|
-
if (options?.dependencyField === "peerDependencies") {
|
|
4031
|
-
if (currentValue?.startsWith("catalog:") && options.dependencyName) {
|
|
4032
|
-
const resolved = options.catalogDependencyResolver?.(currentValue, options.dependencyName);
|
|
4033
|
-
if (resolved && !isVitePlusOverrideSpec(resolved)) return resolved;
|
|
4034
|
-
return PUBLIC_PEER_DEPENDENCY_FALLBACKS[options.dependencyName] ?? currentValue;
|
|
4035
|
-
}
|
|
4036
|
-
return currentValue ?? version;
|
|
4037
|
-
}
|
|
4038
|
-
if (options?.dependencyField === "optionalDependencies" && options?.packageManager === PackageManager.yarn) return version;
|
|
4039
|
-
if (!supportCatalog || version.startsWith("file:")) return version;
|
|
4040
|
-
return currentValue?.startsWith("catalog:") ? currentValue : "catalog:";
|
|
4041
|
-
}
|
|
4042
|
-
function isVitePlusOverrideSpec(value) {
|
|
4043
|
-
return Object.values(VITE_PLUS_OVERRIDE_PACKAGES).includes(value) || value.startsWith("npm:@voidzero-dev/vite-plus-");
|
|
4044
|
-
}
|
|
4045
|
-
function createCatalogDependencyResolver(projectPath, packageManager) {
|
|
4046
|
-
if (packageManager === PackageManager.pnpm) {
|
|
4047
|
-
const pnpmWorkspaceYamlPath = path.join(projectPath, "pnpm-workspace.yaml");
|
|
4048
|
-
if (!fs.existsSync(pnpmWorkspaceYamlPath)) return;
|
|
4049
|
-
const doc = readYamlFile(pnpmWorkspaceYamlPath);
|
|
4050
|
-
return createCatalogDependencyResolverFromCatalogs(doc?.catalog, doc?.catalogs);
|
|
4051
|
-
}
|
|
4052
|
-
if (packageManager === PackageManager.yarn) {
|
|
4053
|
-
const yarnrcYmlPath = path.join(projectPath, ".yarnrc.yml");
|
|
4054
|
-
if (!fs.existsSync(yarnrcYmlPath)) return;
|
|
4055
|
-
const doc = readYamlFile(yarnrcYmlPath);
|
|
4056
|
-
return createCatalogDependencyResolverFromCatalogs(doc?.catalog, doc?.catalogs);
|
|
4057
|
-
}
|
|
4058
|
-
if (packageManager === PackageManager.bun) {
|
|
4059
|
-
const packageJsonPath = path.join(projectPath, "package.json");
|
|
4060
|
-
if (!fs.existsSync(packageJsonPath)) return;
|
|
4061
|
-
const pkg = readJsonFile(packageJsonPath);
|
|
4062
|
-
const workspacesObj = pkg.workspaces && !Array.isArray(pkg.workspaces) ? pkg.workspaces : void 0;
|
|
4063
|
-
return (catalogSpec, dependencyName) => {
|
|
4064
|
-
const catalogName = catalogSpec.slice(8);
|
|
4065
|
-
if (catalogName) return workspacesObj?.catalogs?.[catalogName]?.[dependencyName] ?? pkg.catalogs?.[catalogName]?.[dependencyName];
|
|
4066
|
-
return workspacesObj?.catalog?.[dependencyName] ?? pkg.catalog?.[dependencyName];
|
|
4067
|
-
};
|
|
4068
|
-
}
|
|
4069
|
-
}
|
|
4070
|
-
function createCatalogDependencyResolverFromCatalogs(catalog, catalogs) {
|
|
4071
|
-
return (catalogSpec, dependencyName) => {
|
|
4072
|
-
const catalogName = catalogSpec.slice(8);
|
|
4073
|
-
if (catalogName) return catalogs?.[catalogName]?.[dependencyName];
|
|
4074
|
-
return catalog?.[dependencyName];
|
|
4075
|
-
};
|
|
4076
|
-
}
|
|
4077
|
-
function getYamlMapScalarStringValue(map, key) {
|
|
4078
|
-
if (!(map instanceof import_dist.YAMLMap)) return;
|
|
4079
|
-
for (const item of map.items) if (item.key instanceof import_dist.Scalar && item.key.value === key && item.value instanceof import_dist.Scalar && typeof item.value.value === "string") return item.value.value;
|
|
4080
|
-
}
|
|
4081
|
-
function rewriteCatalog(doc) {
|
|
4082
|
-
for (const [key, value] of Object.entries(VITE_PLUS_OVERRIDE_PACKAGES)) {
|
|
4083
|
-
if (value.startsWith("file:")) continue;
|
|
4084
|
-
doc.setIn(["catalog", key], scalarString(value));
|
|
4085
|
-
}
|
|
4086
|
-
if (!VITE_PLUS_VERSION.startsWith("file:")) doc.setIn(["catalog", VITE_PLUS_NAME], scalarString(VITE_PLUS_VERSION));
|
|
4087
|
-
for (const name of REMOVE_PACKAGES) {
|
|
4088
|
-
const path = ["catalog", name];
|
|
4089
|
-
if (doc.hasIn(path)) doc.deleteIn(path);
|
|
4090
|
-
}
|
|
4091
|
-
const catalogs = doc.getIn(["catalogs"]);
|
|
4092
|
-
if (!(catalogs instanceof import_dist.YAMLMap)) return;
|
|
4093
|
-
for (const item of catalogs.items) {
|
|
4094
|
-
const catalogName = item.key instanceof import_dist.Scalar ? item.key.value : void 0;
|
|
4095
|
-
if (typeof catalogName !== "string" || !(item.value instanceof import_dist.YAMLMap)) continue;
|
|
4096
|
-
for (const [key, value] of Object.entries(VITE_PLUS_OVERRIDE_PACKAGES)) {
|
|
4097
|
-
const catalogPath = [
|
|
4098
|
-
"catalogs",
|
|
4099
|
-
catalogName,
|
|
4100
|
-
key
|
|
4101
|
-
];
|
|
4102
|
-
if (!value.startsWith("file:") && doc.hasIn(catalogPath)) doc.setIn(catalogPath, scalarString(value));
|
|
4103
|
-
}
|
|
4104
|
-
const vitePlusPath = [
|
|
4105
|
-
"catalogs",
|
|
4106
|
-
catalogName,
|
|
4107
|
-
VITE_PLUS_NAME
|
|
4108
|
-
];
|
|
4109
|
-
if (!VITE_PLUS_VERSION.startsWith("file:") && doc.hasIn(vitePlusPath)) doc.setIn(vitePlusPath, scalarString(VITE_PLUS_VERSION));
|
|
4110
|
-
for (const name of REMOVE_PACKAGES) {
|
|
4111
|
-
const catalogPath = [
|
|
4112
|
-
"catalogs",
|
|
4113
|
-
catalogName,
|
|
4114
|
-
name
|
|
4115
|
-
];
|
|
4116
|
-
if (doc.hasIn(catalogPath)) doc.deleteIn(catalogPath);
|
|
4117
|
-
}
|
|
4118
|
-
}
|
|
4119
|
-
}
|
|
4120
|
-
function rewriteCatalogObject(catalog, addMissing) {
|
|
4121
|
-
for (const [key, value] of Object.entries(VITE_PLUS_OVERRIDE_PACKAGES)) {
|
|
4122
|
-
if (value.startsWith("file:") || !addMissing && !(key in catalog)) continue;
|
|
4123
|
-
catalog[key] = value;
|
|
4124
|
-
}
|
|
4125
|
-
if (!VITE_PLUS_VERSION.startsWith("file:") && (addMissing || "vite-plus" in catalog)) catalog[VITE_PLUS_NAME] = VITE_PLUS_VERSION;
|
|
4126
|
-
for (const name of REMOVE_PACKAGES) delete catalog[name];
|
|
4127
|
-
}
|
|
4128
|
-
function rewriteCatalogsObject(catalogs) {
|
|
4129
|
-
for (const catalog of Object.values(catalogs)) rewriteCatalogObject(catalog, false);
|
|
4130
|
-
}
|
|
4131
|
-
/**
|
|
4132
|
-
* Write catalog entries to root package.json for bun.
|
|
4133
|
-
* Bun stores catalogs in package.json under the `catalog` key,
|
|
4134
|
-
* unlike pnpm which uses pnpm-workspace.yaml.
|
|
4135
|
-
* @see https://bun.sh/docs/pm/catalogs
|
|
4136
|
-
*/
|
|
4137
|
-
function rewriteBunCatalog(projectPath) {
|
|
4138
|
-
const packageJsonPath = path.join(projectPath, "package.json");
|
|
4139
|
-
if (!fs.existsSync(packageJsonPath)) return;
|
|
4140
|
-
editJsonFile(packageJsonPath, (pkg) => {
|
|
4141
|
-
const workspacesObj = pkg.workspaces && !Array.isArray(pkg.workspaces) ? pkg.workspaces : void 0;
|
|
4142
|
-
const useWorkspacesCatalog = workspacesObj?.catalog != null || pkg.catalog == null && workspacesObj?.catalogs != null;
|
|
4143
|
-
const catalog = { ...useWorkspacesCatalog ? workspacesObj?.catalog : pkg.catalog };
|
|
4144
|
-
rewriteCatalogObject(catalog, true);
|
|
4145
|
-
if (useWorkspacesCatalog) {
|
|
4146
|
-
workspacesObj.catalog = catalog;
|
|
4147
|
-
if (pkg.catalog) rewriteCatalogObject(pkg.catalog, false);
|
|
4148
|
-
} else {
|
|
4149
|
-
pkg.catalog = catalog;
|
|
4150
|
-
if (workspacesObj?.catalog) rewriteCatalogObject(workspacesObj.catalog, false);
|
|
4151
|
-
}
|
|
4152
|
-
if (workspacesObj?.catalogs) rewriteCatalogsObject(workspacesObj.catalogs);
|
|
4153
|
-
if (pkg.catalogs) rewriteCatalogsObject(pkg.catalogs);
|
|
4154
|
-
const overrides = { ...pkg.overrides };
|
|
4155
|
-
for (const [key, value] of Object.entries(VITE_PLUS_OVERRIDE_PACKAGES)) overrides[key] = getCatalogDependencySpec(overrides[key], value, true);
|
|
4156
|
-
pkg.overrides = overrides;
|
|
4157
|
-
return pkg;
|
|
4158
|
-
});
|
|
4159
|
-
}
|
|
4160
|
-
/**
|
|
4161
|
-
* Rewrite root workspace package.json to add vite-plus dependencies
|
|
4162
|
-
* @param projectPath - The path to the project
|
|
4163
|
-
*/
|
|
4164
|
-
function rewriteRootWorkspacePackageJson(projectPath, packageManager, skipStagedMigration, catalogDependencyResolver) {
|
|
4165
|
-
const packageJsonPath = path.join(projectPath, "package.json");
|
|
4166
|
-
if (!fs.existsSync(packageJsonPath)) return;
|
|
4167
|
-
let remainingPnpmOverrides;
|
|
4168
|
-
editJsonFile(packageJsonPath, (pkg) => {
|
|
4169
|
-
if (packageManager === PackageManager.yarn) pkg.resolutions = {
|
|
4170
|
-
...pkg.resolutions,
|
|
4171
|
-
...VITE_PLUS_OVERRIDE_PACKAGES
|
|
4172
|
-
};
|
|
4173
|
-
else if (packageManager === PackageManager.npm) pkg.overrides = {
|
|
4174
|
-
...pkg.overrides,
|
|
4175
|
-
...VITE_PLUS_OVERRIDE_PACKAGES
|
|
4176
|
-
};
|
|
4177
|
-
else if (packageManager === PackageManager.bun) {} else if (packageManager === PackageManager.pnpm) {
|
|
4178
|
-
const overrideKeys = Object.keys(VITE_PLUS_OVERRIDE_PACKAGES);
|
|
4179
|
-
if (isForceOverrideMode()) pkg.pnpm = {
|
|
4180
|
-
...pkg.pnpm,
|
|
4181
|
-
overrides: {
|
|
4182
|
-
...pkg.pnpm?.overrides,
|
|
4183
|
-
...VITE_PLUS_OVERRIDE_PACKAGES,
|
|
4184
|
-
[VITE_PLUS_NAME]: VITE_PLUS_VERSION
|
|
4185
|
-
}
|
|
4186
|
-
};
|
|
4187
|
-
else {
|
|
4188
|
-
for (const key of [...overrideKeys, ...REMOVE_PACKAGES]) if (pkg.resolutions?.[key]) delete pkg.resolutions[key];
|
|
4189
|
-
remainingPnpmOverrides = cleanupPnpmOverridesForWorkspaceYaml(pkg, overrideKeys);
|
|
4190
|
-
}
|
|
4191
|
-
for (const key in pkg.pnpm?.overrides) if (key.includes(">")) {
|
|
4192
|
-
const splits = key.split(">");
|
|
4193
|
-
if (splits[splits.length - 1].trim() === "vite") delete pkg.pnpm.overrides[key];
|
|
4194
|
-
}
|
|
4195
|
-
}
|
|
4196
|
-
if (!pkg.devDependencies?.["vite-plus"]) pkg.devDependencies = {
|
|
4197
|
-
...pkg.devDependencies,
|
|
4198
|
-
[VITE_PLUS_NAME]: packageManager === PackageManager.npm || VITE_PLUS_VERSION.startsWith("file:") ? VITE_PLUS_VERSION : "catalog:"
|
|
4199
|
-
};
|
|
4200
|
-
return pkg;
|
|
4201
|
-
});
|
|
4202
|
-
if (remainingPnpmOverrides) migratePnpmOverridesToWorkspaceYaml(projectPath, remainingPnpmOverrides);
|
|
4203
|
-
rewriteMonorepoProject(projectPath, packageManager, skipStagedMigration, void 0, void 0, catalogDependencyResolver);
|
|
4204
|
-
}
|
|
4205
|
-
const RULES_YAML_PATH = path.join(rulesDir, "vite-tools.yml");
|
|
4206
|
-
const PREPARE_RULES_YAML_PATH = path.join(rulesDir, "vite-prepare.yml");
|
|
4207
|
-
let cachedRulesYaml;
|
|
4208
|
-
let cachedRulesYamlNoLintStaged;
|
|
4209
|
-
let cachedPrepareRulesYaml;
|
|
4210
|
-
function readRulesYaml() {
|
|
4211
|
-
cachedRulesYaml ??= fs.readFileSync(RULES_YAML_PATH, "utf8");
|
|
4212
|
-
return cachedRulesYaml;
|
|
4213
|
-
}
|
|
4214
|
-
function getScriptRulesYaml(skipStagedMigration) {
|
|
4215
|
-
const yaml = readRulesYaml();
|
|
4216
|
-
if (!skipStagedMigration) return yaml;
|
|
4217
|
-
cachedRulesYamlNoLintStaged ??= yaml.split("\n\n\n").filter((block) => !block.includes("id: replace-lint-staged")).join("\n\n\n");
|
|
4218
|
-
return cachedRulesYamlNoLintStaged;
|
|
4219
|
-
}
|
|
4220
|
-
function readPrepareRulesYaml() {
|
|
4221
|
-
cachedPrepareRulesYaml ??= fs.readFileSync(PREPARE_RULES_YAML_PATH, "utf8");
|
|
4222
|
-
return cachedPrepareRulesYaml;
|
|
4223
|
-
}
|
|
4224
|
-
function rewritePackageJson(pkg, packageManager, isMonorepo, skipStagedMigration, catalogDependencyResolver) {
|
|
4225
|
-
if (pkg.scripts) {
|
|
4226
|
-
const updated = rewriteScripts(JSON.stringify(pkg.scripts), getScriptRulesYaml(skipStagedMigration));
|
|
4227
|
-
if (updated) pkg.scripts = JSON.parse(updated);
|
|
4228
|
-
}
|
|
4229
|
-
let extractedStagedConfig = null;
|
|
4230
|
-
if (!skipStagedMigration && pkg["lint-staged"]) {
|
|
4231
|
-
const config = pkg["lint-staged"];
|
|
4232
|
-
const updated = rewriteScripts(JSON.stringify(config), readRulesYaml());
|
|
4233
|
-
extractedStagedConfig = updated ? JSON.parse(updated) : config;
|
|
4234
|
-
}
|
|
4235
|
-
const supportCatalog = !!isMonorepo && packageManager !== PackageManager.npm;
|
|
4236
|
-
let needVitePlus = false;
|
|
4237
|
-
const dependencyGroups = [
|
|
4238
|
-
{
|
|
4239
|
-
dependencyField: "devDependencies",
|
|
4240
|
-
dependencies: pkg.devDependencies
|
|
4241
|
-
},
|
|
4242
|
-
{
|
|
4243
|
-
dependencyField: "dependencies",
|
|
4244
|
-
dependencies: pkg.dependencies
|
|
4245
|
-
},
|
|
4246
|
-
{
|
|
4247
|
-
dependencyField: "peerDependencies",
|
|
4248
|
-
dependencies: pkg.peerDependencies
|
|
4249
|
-
},
|
|
4250
|
-
{
|
|
4251
|
-
dependencyField: "optionalDependencies",
|
|
4252
|
-
dependencies: pkg.optionalDependencies
|
|
4253
|
-
}
|
|
4254
|
-
];
|
|
4255
|
-
for (const [key, version] of Object.entries(VITE_PLUS_OVERRIDE_PACKAGES)) for (const { dependencyField, dependencies } of dependencyGroups) if (dependencies?.[key]) {
|
|
4256
|
-
dependencies[key] = getCatalogDependencySpec(dependencies[key], version, supportCatalog, {
|
|
4257
|
-
dependencyField,
|
|
4258
|
-
dependencyName: key,
|
|
4259
|
-
packageManager,
|
|
4260
|
-
catalogDependencyResolver
|
|
4261
|
-
});
|
|
4262
|
-
needVitePlus = true;
|
|
4263
|
-
}
|
|
4264
|
-
for (const name of REMOVE_PACKAGES) {
|
|
4265
|
-
let wasRemoved = false;
|
|
4266
|
-
for (const { dependencies } of dependencyGroups) if (dependencies?.[name]) {
|
|
4267
|
-
delete dependencies[name];
|
|
4268
|
-
wasRemoved = true;
|
|
4269
|
-
}
|
|
4270
|
-
if (wasRemoved) needVitePlus = true;
|
|
4271
|
-
const peerDep = BROWSER_PROVIDER_PEER_DEPS[name];
|
|
4272
|
-
if (wasRemoved && peerDep && !pkg.devDependencies?.[peerDep] && !pkg.dependencies?.[peerDep] && !pkg.peerDependencies?.[peerDep] && !pkg.optionalDependencies?.[peerDep]) {
|
|
4273
|
-
pkg.devDependencies ??= {};
|
|
4274
|
-
pkg.devDependencies[peerDep] = "*";
|
|
4275
|
-
}
|
|
4276
|
-
}
|
|
4277
|
-
if (needVitePlus) {
|
|
4278
|
-
const version = supportCatalog && !VITE_PLUS_VERSION.startsWith("file:") ? "catalog:" : VITE_PLUS_VERSION;
|
|
4279
|
-
pkg.devDependencies = {
|
|
4280
|
-
...pkg.devDependencies,
|
|
4281
|
-
[VITE_PLUS_NAME]: version
|
|
4282
|
-
};
|
|
4283
|
-
const installableDeps = {
|
|
4284
|
-
...pkg.dependencies,
|
|
4285
|
-
...pkg.devDependencies,
|
|
4286
|
-
...pkg.optionalDependencies
|
|
4287
|
-
};
|
|
4288
|
-
if (!installableDeps.vitest && Object.keys(installableDeps).some((name) => name.includes("vitest"))) {
|
|
4289
|
-
const ver = VITE_PLUS_OVERRIDE_PACKAGES.vitest;
|
|
4290
|
-
pkg.devDependencies.vitest = getCatalogDependencySpec(void 0, ver, supportCatalog);
|
|
4291
|
-
}
|
|
4292
|
-
}
|
|
4293
|
-
return extractedStagedConfig;
|
|
4294
|
-
}
|
|
4295
|
-
function removeLintStagedFromPackageJson(packageJsonPath) {
|
|
4296
|
-
editJsonFile(packageJsonPath, (pkg) => {
|
|
4297
|
-
if (pkg["lint-staged"]) {
|
|
4298
|
-
delete pkg["lint-staged"];
|
|
4299
|
-
return pkg;
|
|
4300
|
-
}
|
|
4301
|
-
});
|
|
4302
|
-
}
|
|
4303
|
-
function rewriteLintStagedConfigFile(projectPath, report) {
|
|
4304
|
-
let hasUnsupported = false;
|
|
4305
|
-
for (const filename of LINT_STAGED_JSON_CONFIG_FILES) {
|
|
4306
|
-
const configPath = path.join(projectPath, filename);
|
|
4307
|
-
if (!fs.existsSync(configPath)) continue;
|
|
4308
|
-
if (filename === ".lintstagedrc" && !isJsonFile(configPath)) {
|
|
4309
|
-
warnMigration(`${displayRelative(configPath)} is not JSON format — please migrate to "staged" in vite.config.ts manually`, report);
|
|
4310
|
-
hasUnsupported = true;
|
|
4311
|
-
continue;
|
|
4312
|
-
}
|
|
4313
|
-
if (!hasStagedConfigInViteConfig(projectPath)) {
|
|
4314
|
-
const config = readJsonFile(configPath);
|
|
4315
|
-
const updated = rewriteScripts(JSON.stringify(config), readRulesYaml());
|
|
4316
|
-
if (!mergeStagedConfigToViteConfig(projectPath, updated ? JSON.parse(updated) : config, true, report)) continue;
|
|
4317
|
-
fs.unlinkSync(configPath);
|
|
4318
|
-
if (report) report.inlinedLintStagedConfigCount++;
|
|
4319
|
-
} else warnMigration(`${displayRelative(configPath)} found but "staged" already exists in vite.config.ts — please merge manually`, report);
|
|
4320
|
-
}
|
|
4321
|
-
for (const filename of LINT_STAGED_OTHER_CONFIG_FILES) {
|
|
4322
|
-
const configPath = path.join(projectPath, filename);
|
|
4323
|
-
if (!fs.existsSync(configPath)) continue;
|
|
4324
|
-
warnMigration(`${displayRelative(configPath)} — please migrate to "staged" in vite.config.ts manually`, report);
|
|
4325
|
-
hasUnsupported = true;
|
|
4326
|
-
}
|
|
4327
|
-
if (hasUnsupported) infoMigration("Only \"staged\" in vite.config.ts is supported. See https://viteplus.dev/guide/migrate#lint-staged", report);
|
|
4328
|
-
}
|
|
4329
|
-
/**
|
|
4330
|
-
* Ensure vite.config.ts exists, create it if not
|
|
4331
|
-
* @returns The vite config filename
|
|
4332
|
-
*/
|
|
4333
|
-
function ensureViteConfig(projectPath, configs, silent = false, report) {
|
|
4334
|
-
if (!configs.viteConfig) {
|
|
4335
|
-
configs.viteConfig = "vite.config.ts";
|
|
4336
|
-
const viteConfigPath = path.join(projectPath, "vite.config.ts");
|
|
4337
|
-
fs.writeFileSync(viteConfigPath, `import { defineConfig } from '${VITE_PLUS_NAME}';
|
|
4338
|
-
|
|
4339
|
-
export default defineConfig({});
|
|
4340
|
-
`);
|
|
4341
|
-
if (report) report.createdViteConfigCount++;
|
|
4342
|
-
if (!silent) log.success(`✔ Created vite.config.ts in ${displayRelative(viteConfigPath)}`);
|
|
4343
|
-
}
|
|
4344
|
-
return configs.viteConfig;
|
|
4345
|
-
}
|
|
4346
|
-
/**
|
|
4347
|
-
* Merge tsdown.config.* into vite.config.ts
|
|
4348
|
-
* - For JSON files: merge content directly into `pack` field and delete the JSON file
|
|
4349
|
-
* - For TS/JS files: import the config file
|
|
4350
|
-
*/
|
|
4351
|
-
function mergeTsdownConfigFile(projectPath, silent = false, report) {
|
|
4352
|
-
const configs = detectConfigs(projectPath);
|
|
4353
|
-
if (!configs.tsdownConfig) return;
|
|
4354
|
-
const viteConfig = ensureViteConfig(projectPath, configs, silent, report);
|
|
4355
|
-
const fullViteConfigPath = path.join(projectPath, viteConfig);
|
|
4356
|
-
const fullTsdownConfigPath = path.join(projectPath, configs.tsdownConfig);
|
|
4357
|
-
if (configs.tsdownConfig.endsWith(".json")) {
|
|
4358
|
-
mergeAndRemoveJsonConfig(projectPath, viteConfig, configs.tsdownConfig, "pack", silent, report);
|
|
4359
|
-
return;
|
|
4360
|
-
}
|
|
4361
|
-
const result = mergeTsdownConfig(fullViteConfigPath, `./${configs.tsdownConfig}`);
|
|
4362
|
-
if (result.updated) {
|
|
4363
|
-
fs.writeFileSync(fullViteConfigPath, result.content);
|
|
4364
|
-
if (report) report.tsdownImportCount++;
|
|
4365
|
-
if (!silent) log.success(`✔ Added import for ${displayRelative(fullTsdownConfigPath)} in ${displayRelative(fullViteConfigPath)}`);
|
|
4366
|
-
}
|
|
4367
|
-
infoMigration(`Please manually merge ${displayRelative(fullTsdownConfigPath)} into ${displayRelative(fullViteConfigPath)}, see https://viteplus.dev/guide/migrate#tsdown`, report);
|
|
4368
|
-
}
|
|
4369
|
-
/**
|
|
4370
|
-
* Merge oxlint and oxfmt config into vite.config.ts
|
|
4371
|
-
*/
|
|
4372
|
-
function mergeViteConfigFiles(projectPath, silent = false, report) {
|
|
4373
|
-
const configs = detectConfigs(projectPath);
|
|
4374
|
-
if (!configs.oxfmtConfig && !configs.oxlintConfig) return;
|
|
4375
|
-
const viteConfig = ensureViteConfig(projectPath, configs, silent, report);
|
|
4376
|
-
if (configs.oxlintConfig) {
|
|
4377
|
-
const fullOxlintPath = path.join(projectPath, configs.oxlintConfig);
|
|
4378
|
-
const oxlintJson = readJsonFile(fullOxlintPath, true);
|
|
4379
|
-
if (!oxlintJson.options) oxlintJson.options = {};
|
|
4380
|
-
if (!hasBaseUrlInTsconfig(projectPath)) {
|
|
4381
|
-
if (oxlintJson.options.typeAware === void 0) oxlintJson.options.typeAware = true;
|
|
4382
|
-
if (oxlintJson.options.typeCheck === void 0) oxlintJson.options.typeCheck = true;
|
|
4383
|
-
} else warnMigration(BASEURL_TSCONFIG_WARNING, report);
|
|
4384
|
-
fs.writeFileSync(fullOxlintPath, JSON.stringify(oxlintJson, null, 2));
|
|
4385
|
-
mergeAndRemoveJsonConfig(projectPath, viteConfig, configs.oxlintConfig, "lint", silent, report);
|
|
4386
|
-
}
|
|
4387
|
-
if (configs.oxfmtConfig) mergeAndRemoveJsonConfig(projectPath, viteConfig, configs.oxfmtConfig, "fmt", silent, report);
|
|
4388
|
-
}
|
|
4389
|
-
/**
|
|
4390
|
-
* Inject typeAware and typeCheck defaults into vite.config.ts lint config.
|
|
4391
|
-
* Called after mergeViteConfigFiles() to handle the case where no .oxlintrc.json exists
|
|
4392
|
-
* (e.g., newly created projects from create-vite templates).
|
|
4393
|
-
*/
|
|
4394
|
-
function injectLintTypeCheckDefaults(projectPath, silent = false, report) {
|
|
4395
|
-
if (hasBaseUrlInTsconfig(projectPath)) return;
|
|
4396
|
-
injectConfigDefaults(projectPath, "lint", ".vite-plus-lint-init.oxlintrc.json", JSON.stringify({ options: {
|
|
4397
|
-
typeAware: true,
|
|
4398
|
-
typeCheck: true
|
|
4399
|
-
} }), silent, report);
|
|
4400
|
-
}
|
|
4401
|
-
function injectFmtDefaults(projectPath, silent = false, report) {
|
|
4402
|
-
injectConfigDefaults(projectPath, "fmt", ".vite-plus-fmt-init.oxfmtrc.json", JSON.stringify({}), silent, report);
|
|
4403
|
-
}
|
|
4404
|
-
/**
|
|
4405
|
-
* Wire `create.defaultTemplate: '<scope>'` into the new monorepo's
|
|
4406
|
-
* `vite.config.ts`. The caller is `bin.ts`, only when scaffolding a
|
|
4407
|
-
* monorepo from a bundled `@org` manifest entry — that's the case where
|
|
4408
|
-
* the user just picked a template from a specific org and naturally
|
|
4409
|
-
* wants subsequent `vp create` invocations from the workspace to default
|
|
4410
|
-
* to that same org's picker.
|
|
4411
|
-
*/
|
|
4412
|
-
function injectCreateDefaultTemplate(projectPath, scope, silent = false, report) {
|
|
4413
|
-
if (!scope) return;
|
|
4414
|
-
injectConfigDefaults(projectPath, "create", ".vite-plus-create-init.json", JSON.stringify({ defaultTemplate: scope }), silent, report);
|
|
4415
|
-
}
|
|
4416
|
-
function injectConfigDefaults(projectPath, configKey, tempFileName, tempFileContent, silent, report) {
|
|
4417
|
-
const configs = detectConfigs(projectPath);
|
|
4418
|
-
if (configs.viteConfig) {
|
|
4419
|
-
const content = fs.readFileSync(path.join(projectPath, configs.viteConfig), "utf8");
|
|
4420
|
-
if (new RegExp(`\\b${configKey}\\s*:`).test(content)) return;
|
|
4421
|
-
}
|
|
4422
|
-
const viteConfig = ensureViteConfig(projectPath, configs, silent, report);
|
|
4423
|
-
const tempConfigPath = path.join(projectPath, tempFileName);
|
|
4424
|
-
fs.writeFileSync(tempConfigPath, tempFileContent);
|
|
4425
|
-
const fullViteConfigPath = path.join(projectPath, viteConfig);
|
|
4426
|
-
let result;
|
|
4427
|
-
try {
|
|
4428
|
-
result = mergeJsonConfig(fullViteConfigPath, tempConfigPath, configKey);
|
|
4429
|
-
} finally {
|
|
4430
|
-
fs.rmSync(tempConfigPath, { force: true });
|
|
4431
|
-
}
|
|
4432
|
-
if (result.updated) fs.writeFileSync(fullViteConfigPath, result.content);
|
|
4433
|
-
}
|
|
4434
|
-
function mergeAndRemoveJsonConfig(projectPath, viteConfigPath, jsonConfigPath, configKey, silent = false, report) {
|
|
4435
|
-
const fullViteConfigPath = path.join(projectPath, viteConfigPath);
|
|
4436
|
-
const fullJsonConfigPath = path.join(projectPath, jsonConfigPath);
|
|
4437
|
-
const result = mergeJsonConfig(fullViteConfigPath, fullJsonConfigPath, configKey);
|
|
4438
|
-
if (result.updated) {
|
|
4439
|
-
fs.writeFileSync(fullViteConfigPath, result.content);
|
|
4440
|
-
fs.unlinkSync(fullJsonConfigPath);
|
|
4441
|
-
if (report) report.mergedConfigCount++;
|
|
4442
|
-
if (!silent) log.success(`✔ Merged ${displayRelative(fullJsonConfigPath)} into ${displayRelative(fullViteConfigPath)}`);
|
|
4443
|
-
} else {
|
|
4444
|
-
warnMigration(`Failed to merge ${displayRelative(fullJsonConfigPath)} into ${displayRelative(fullViteConfigPath)}`, report);
|
|
4445
|
-
infoMigration("Please complete the merge manually and follow the instructions in the documentation: https://viteplus.dev/config/", report);
|
|
4446
|
-
}
|
|
4447
|
-
}
|
|
4448
|
-
/**
|
|
4449
|
-
* Merge a staged config object into vite.config.ts as `staged: { ... }`.
|
|
4450
|
-
* Writes the config to a temp JSON file, calls mergeJsonConfig NAPI, then cleans up.
|
|
4451
|
-
*/
|
|
4452
|
-
function mergeStagedConfigToViteConfig(projectPath, stagedConfig, silent = false, report) {
|
|
4453
|
-
const viteConfig = ensureViteConfig(projectPath, detectConfigs(projectPath), silent, report);
|
|
4454
|
-
const fullViteConfigPath = path.join(projectPath, viteConfig);
|
|
4455
|
-
const tempJsonPath = path.join(projectPath, ".staged-config-temp.json");
|
|
4456
|
-
fs.writeFileSync(tempJsonPath, JSON.stringify(stagedConfig, null, 2));
|
|
4457
|
-
let result;
|
|
4458
|
-
try {
|
|
4459
|
-
result = mergeJsonConfig(fullViteConfigPath, tempJsonPath, "staged");
|
|
4460
|
-
} finally {
|
|
4461
|
-
fs.unlinkSync(tempJsonPath);
|
|
4462
|
-
}
|
|
4463
|
-
if (result.updated) {
|
|
4464
|
-
fs.writeFileSync(fullViteConfigPath, result.content);
|
|
4465
|
-
if (report) report.mergedStagedConfigCount++;
|
|
4466
|
-
if (!silent) log.success(`✔ Merged staged config into ${displayRelative(fullViteConfigPath)}`);
|
|
4467
|
-
return true;
|
|
4468
|
-
} else {
|
|
4469
|
-
warnMigration(`Failed to merge staged config into ${displayRelative(fullViteConfigPath)}`, report);
|
|
4470
|
-
infoMigration(`Please add staged config to ${displayRelative(fullViteConfigPath)} manually, see https://viteplus.dev/guide/migrate#lint-staged`, report);
|
|
4471
|
-
return false;
|
|
4472
|
-
}
|
|
4473
|
-
}
|
|
4474
|
-
/**
|
|
4475
|
-
* Check if vite.config.ts already has a `staged` config key.
|
|
4476
|
-
*/
|
|
4477
|
-
function hasStagedConfigInViteConfig(projectPath) {
|
|
4478
|
-
const configs = detectConfigs(projectPath);
|
|
4479
|
-
if (!configs.viteConfig) return false;
|
|
4480
|
-
const viteConfigPath = path.join(projectPath, configs.viteConfig);
|
|
4481
|
-
const content = fs.readFileSync(viteConfigPath, "utf8");
|
|
4482
|
-
return /\bstaged\s*:/.test(content);
|
|
4483
|
-
}
|
|
4484
|
-
/**
|
|
4485
|
-
* Rewrite imports in all TypeScript/JavaScript files under a directory
|
|
4486
|
-
* This rewrites vite/vitest imports to @voidzero-dev/vite-plus
|
|
4487
|
-
* @param projectPath - The root directory to search for files
|
|
4488
|
-
*/
|
|
4489
|
-
function rewriteAllImports(projectPath, silent = false, report) {
|
|
4490
|
-
const result = rewriteImportsInDirectory(projectPath);
|
|
4491
|
-
const modified = result.modifiedFiles.length;
|
|
4492
|
-
const errors = result.errors.length;
|
|
4493
|
-
if (report) {
|
|
4494
|
-
report.rewrittenImportFileCount += modified;
|
|
4495
|
-
report.rewrittenImportErrors.push(...result.errors.map((error) => ({
|
|
4496
|
-
path: displayRelative(error.path),
|
|
4497
|
-
message: error.message
|
|
4498
|
-
})));
|
|
4499
|
-
}
|
|
4500
|
-
if (!silent && modified > 0) {
|
|
4501
|
-
log.success(`Rewrote imports in ${modified === 1 ? "one file" : `${modified} files`}`);
|
|
4502
|
-
log.info(result.modifiedFiles.map((file) => ` ${displayRelative(file)}`).join("\n"));
|
|
4503
|
-
}
|
|
4504
|
-
if (errors > 0) if (report) warnMigration(`${errors === 1 ? "one file had an error" : `${errors} files had errors`} while rewriting imports`, report);
|
|
4505
|
-
else {
|
|
4506
|
-
log.warn(`⚠ ${errors === 1 ? "one file had an error" : `${errors} files had errors`}:`);
|
|
4507
|
-
for (const error of result.errors) log.error(` ${displayRelative(error.path)}: ${error.message}`);
|
|
4508
|
-
}
|
|
4509
|
-
}
|
|
4510
|
-
/**
|
|
4511
|
-
* Check if the project has an unsupported husky version (<9.0.0).
|
|
4512
|
-
* Uses `semver.coerce` to handle ranges like `^8.0.0` → `8.0.0`.
|
|
4513
|
-
* When the specifier is not coercible (e.g. `"latest"`), falls back to
|
|
4514
|
-
* the installed version in node_modules via `detectPackageMetadata`.
|
|
4515
|
-
* Returns a reason string if hooks migration should be skipped, or null
|
|
4516
|
-
* if husky is absent or compatible.
|
|
4517
|
-
*/
|
|
4518
|
-
function checkUnsupportedHuskyVersion(projectPath, deps, prodDeps) {
|
|
4519
|
-
const huskyVersion = deps?.husky ?? prodDeps?.husky;
|
|
4520
|
-
if (!huskyVersion) return null;
|
|
4521
|
-
let coerced = import_semver.default.coerce(huskyVersion);
|
|
4522
|
-
if (coerced == null) {
|
|
4523
|
-
const installed = detectPackageMetadata(projectPath, "husky");
|
|
4524
|
-
if (installed) coerced = import_semver.default.coerce(installed.version);
|
|
4525
|
-
if (coerced == null) return `Could not determine husky version from "${huskyVersion}" — please specify a semver-compatible version (e.g., "^9.0.0") and re-run migration.`;
|
|
4526
|
-
}
|
|
4527
|
-
if (import_semver.default.satisfies(coerced, "<9.0.0")) return "Detected husky <9.0.0 — please upgrade to husky v9+ first, then re-run migration.";
|
|
4528
|
-
return null;
|
|
4529
|
-
}
|
|
4530
|
-
const OTHER_HOOK_TOOLS = [
|
|
4531
|
-
"simple-git-hooks",
|
|
4532
|
-
"lefthook",
|
|
4533
|
-
"yorkie"
|
|
4534
|
-
];
|
|
4535
|
-
const REPLACED_HOOK_PACKAGES = ["husky", "lint-staged"];
|
|
4536
|
-
function removeReplacedHookPackages(packageJsonPath) {
|
|
4537
|
-
editJsonFile(packageJsonPath, (pkg) => {
|
|
4538
|
-
for (const name of REPLACED_HOOK_PACKAGES) {
|
|
4539
|
-
if (pkg.devDependencies?.[name]) delete pkg.devDependencies[name];
|
|
4540
|
-
if (pkg.dependencies?.[name]) delete pkg.dependencies[name];
|
|
4541
|
-
}
|
|
4542
|
-
return pkg;
|
|
4543
|
-
});
|
|
4544
|
-
}
|
|
4545
|
-
/**
|
|
4546
|
-
* Walk up from `startPath` looking for `.git` (directory or file — submodules
|
|
4547
|
-
* use a `.git` file). Returns the directory that contains `.git`, or `null`.
|
|
4548
|
-
*/
|
|
4549
|
-
function findGitRoot(startPath) {
|
|
4550
|
-
let dir = startPath;
|
|
4551
|
-
while (true) {
|
|
4552
|
-
if (fs.existsSync(path.join(dir, ".git"))) return dir;
|
|
4553
|
-
const parent = path.dirname(dir);
|
|
4554
|
-
if (parent === dir) return null;
|
|
4555
|
-
dir = parent;
|
|
4556
|
-
}
|
|
4557
|
-
}
|
|
4558
|
-
/**
|
|
4559
|
-
* Normalize "husky install [dir]" → "husky [dir]" so downstream regex
|
|
4560
|
-
* and ast-grep rules can match a single pattern.
|
|
4561
|
-
*/
|
|
4562
|
-
function collapseHuskyInstall(script) {
|
|
4563
|
-
return script.replace("husky install ", "husky ").replace("husky install", "husky");
|
|
4564
|
-
}
|
|
4565
|
-
/**
|
|
4566
|
-
* High-level helper: detect old hooks dir, set up git hooks, and rewrite
|
|
4567
|
-
* the prepare script. Returns true if hooks were successfully installed.
|
|
4568
|
-
*/
|
|
4569
|
-
function installGitHooks(projectPath, silent = false, report) {
|
|
4570
|
-
if (setupGitHooks(projectPath, getOldHooksDir(projectPath), silent, report)) {
|
|
4571
|
-
rewritePrepareScript(projectPath);
|
|
4572
|
-
return true;
|
|
4573
|
-
}
|
|
4574
|
-
return false;
|
|
4575
|
-
}
|
|
4576
|
-
/**
|
|
4577
|
-
* Read-only probe: extract the old husky hooks directory from `scripts.prepare`
|
|
4578
|
-
* without modifying package.json. Returns undefined when no husky reference is found.
|
|
4579
|
-
*/
|
|
4580
|
-
function getOldHooksDir(rootDir) {
|
|
4581
|
-
const packageJsonPath = path.join(rootDir, "package.json");
|
|
4582
|
-
if (!fs.existsSync(packageJsonPath)) return;
|
|
4583
|
-
const pkg = readJsonFile(packageJsonPath);
|
|
4584
|
-
if (!pkg.scripts?.prepare) return;
|
|
4585
|
-
const match = collapseHuskyInstall(pkg.scripts.prepare).match(/\bhusky(?:\s+([\w./-]+))?/);
|
|
4586
|
-
if (!match) return;
|
|
4587
|
-
return match[1] ?? ".husky";
|
|
4588
|
-
}
|
|
4589
|
-
/**
|
|
4590
|
-
* Pre-flight check: verify that git hooks can be set up for this project.
|
|
4591
|
-
* Returns `null` if hooks setup can proceed, or a warning reason string
|
|
4592
|
-
* explaining why hooks setup should be skipped.
|
|
4593
|
-
*
|
|
4594
|
-
* These checks are deterministic and read-only — they do not modify
|
|
4595
|
-
* the project in any way, making them safe to call before migration.
|
|
4596
|
-
*/
|
|
4597
|
-
function preflightGitHooksSetup(projectPath) {
|
|
4598
|
-
const gitRoot = findGitRoot(projectPath);
|
|
4599
|
-
if (gitRoot && path.resolve(projectPath) !== path.resolve(gitRoot)) return "Subdirectory project detected — skipping git hooks setup. Configure hooks at the repository root.";
|
|
4600
|
-
const packageJsonPath = path.join(projectPath, "package.json");
|
|
4601
|
-
if (!fs.existsSync(packageJsonPath)) return null;
|
|
4602
|
-
const pkgContent = readJsonFile(packageJsonPath);
|
|
4603
|
-
const deps = pkgContent.devDependencies;
|
|
4604
|
-
const prodDeps = pkgContent.dependencies;
|
|
4605
|
-
for (const tool of OTHER_HOOK_TOOLS) if (deps?.[tool] || prodDeps?.[tool] || pkgContent[tool]) return `Detected ${tool} — skipping git hooks setup. Please configure git hooks manually.`;
|
|
4606
|
-
const huskyReason = checkUnsupportedHuskyVersion(projectPath, deps, prodDeps);
|
|
4607
|
-
if (huskyReason) return huskyReason;
|
|
4608
|
-
if (hasUnsupportedLintStagedConfig(projectPath)) return "Unsupported lint-staged config format — skipping git hooks setup. Please configure git hooks manually.";
|
|
4609
|
-
return null;
|
|
4610
|
-
}
|
|
4611
|
-
/**
|
|
4612
|
-
* Set up git hooks with husky + lint-staged via vp commands.
|
|
4613
|
-
* Skips if another hook tool is detected (warns user).
|
|
4614
|
-
* Returns true if hooks were successfully set up, false if skipped.
|
|
4615
|
-
*/
|
|
4616
|
-
function setupGitHooks(projectPath, oldHooksDir, silent = false, report) {
|
|
4617
|
-
const reason = preflightGitHooksSetup(projectPath);
|
|
4618
|
-
if (reason) {
|
|
4619
|
-
warnMigration(reason, report);
|
|
4620
|
-
return false;
|
|
4621
|
-
}
|
|
4622
|
-
const packageJsonPath = path.join(projectPath, "package.json");
|
|
4623
|
-
if (!fs.existsSync(packageJsonPath)) return false;
|
|
4624
|
-
const gitRoot = findGitRoot(projectPath);
|
|
4625
|
-
const isCustomDir = oldHooksDir != null && oldHooksDir !== ".husky";
|
|
4626
|
-
const hooksDir = isCustomDir ? oldHooksDir : ".vite-hooks";
|
|
4627
|
-
editJsonFile(packageJsonPath, (pkg) => {
|
|
4628
|
-
if (!pkg.scripts) pkg.scripts = {};
|
|
4629
|
-
if (!pkg.scripts.prepare) pkg.scripts.prepare = "vp config";
|
|
4630
|
-
else if (!pkg.scripts.prepare.includes("vp config") && !/\bhusky\b/.test(pkg.scripts.prepare)) pkg.scripts.prepare = `vp config && ${pkg.scripts.prepare}`;
|
|
4631
|
-
return pkg;
|
|
4632
|
-
});
|
|
4633
|
-
let stagedMerged = hasStagedConfigInViteConfig(projectPath);
|
|
4634
|
-
const hasStandaloneConfig = hasStandaloneLintStagedConfig(projectPath);
|
|
4635
|
-
if (!stagedMerged && !hasStandaloneConfig) {
|
|
4636
|
-
const stagedConfig = readJsonFile(packageJsonPath)?.["lint-staged"] ?? DEFAULT_STAGED_CONFIG;
|
|
4637
|
-
const updated = rewriteScripts(JSON.stringify(stagedConfig), readRulesYaml());
|
|
4638
|
-
stagedMerged = mergeStagedConfigToViteConfig(projectPath, updated ? JSON.parse(updated) : stagedConfig, silent, report);
|
|
4639
|
-
}
|
|
4640
|
-
if (stagedMerged) removeLintStagedFromPackageJson(packageJsonPath);
|
|
4641
|
-
if (oldHooksDir && !isCustomDir) {
|
|
4642
|
-
const oldDir = path.join(projectPath, oldHooksDir);
|
|
4643
|
-
if (fs.existsSync(oldDir)) {
|
|
4644
|
-
const targetDir = path.join(projectPath, hooksDir);
|
|
4645
|
-
fs.mkdirSync(targetDir, { recursive: true });
|
|
4646
|
-
for (const entry of fs.readdirSync(oldDir, { withFileTypes: true })) {
|
|
4647
|
-
if (entry.isDirectory() || entry.name.startsWith(".")) continue;
|
|
4648
|
-
const src = path.join(oldDir, entry.name);
|
|
4649
|
-
const dest = path.join(targetDir, entry.name);
|
|
4650
|
-
fs.copyFileSync(src, dest);
|
|
4651
|
-
fs.chmodSync(dest, 493);
|
|
4652
|
-
}
|
|
4653
|
-
fs.rmSync(oldDir, {
|
|
4654
|
-
recursive: true,
|
|
4655
|
-
force: true
|
|
4656
|
-
});
|
|
4657
|
-
}
|
|
4658
|
-
}
|
|
4659
|
-
if (stagedMerged) createPreCommitHook(projectPath, hooksDir);
|
|
4660
|
-
if (!gitRoot) {
|
|
4661
|
-
removeReplacedHookPackages(packageJsonPath);
|
|
4662
|
-
return true;
|
|
4663
|
-
}
|
|
4664
|
-
if (oldHooksDir) {
|
|
4665
|
-
const checkResult = import_cross_spawn.default.sync("git", [
|
|
4666
|
-
"config",
|
|
4667
|
-
"--local",
|
|
4668
|
-
"core.hooksPath"
|
|
4669
|
-
], {
|
|
4670
|
-
cwd: projectPath,
|
|
4671
|
-
stdio: "pipe"
|
|
4672
|
-
});
|
|
4673
|
-
const existingPath = checkResult.status === 0 ? checkResult.stdout?.toString().trim() : "";
|
|
4674
|
-
if (existingPath === `${oldHooksDir}/_` || existingPath === oldHooksDir) import_cross_spawn.default.sync("git", [
|
|
4675
|
-
"config",
|
|
4676
|
-
"--local",
|
|
4677
|
-
"--unset",
|
|
4678
|
-
"core.hooksPath"
|
|
4679
|
-
], {
|
|
4680
|
-
cwd: projectPath,
|
|
4681
|
-
stdio: "pipe"
|
|
4682
|
-
});
|
|
4683
|
-
}
|
|
4684
|
-
const vpBin = process.env.VP_CLI_BIN ?? "vp";
|
|
4685
|
-
const configArgs = isCustomDir ? [
|
|
4686
|
-
"config",
|
|
4687
|
-
"--hooks-only",
|
|
4688
|
-
"--hooks-dir",
|
|
4689
|
-
hooksDir
|
|
4690
|
-
] : ["config", "--hooks-only"];
|
|
4691
|
-
const configResult = import_cross_spawn.default.sync(vpBin, configArgs, {
|
|
4692
|
-
cwd: projectPath,
|
|
4693
|
-
stdio: "pipe"
|
|
4694
|
-
});
|
|
4695
|
-
if (configResult.status === 0) {
|
|
4696
|
-
const stdout = configResult.stdout?.toString().trim() ?? "";
|
|
4697
|
-
if (stdout) {
|
|
4698
|
-
warnMigration(`Git hooks not configured — ${stdout}`, report);
|
|
4699
|
-
return false;
|
|
4700
|
-
}
|
|
4701
|
-
removeReplacedHookPackages(packageJsonPath);
|
|
4702
|
-
if (report) report.gitHooksConfigured = true;
|
|
4703
|
-
if (!silent) log.success("✔ Git hooks configured");
|
|
4704
|
-
return true;
|
|
4705
|
-
}
|
|
4706
|
-
warnMigration("Failed to install git hooks", report);
|
|
4707
|
-
return false;
|
|
4708
|
-
}
|
|
4709
|
-
/**
|
|
4710
|
-
* Check if a standalone lint-staged config file exists
|
|
4711
|
-
*/
|
|
4712
|
-
function hasStandaloneLintStagedConfig(projectPath) {
|
|
4713
|
-
return LINT_STAGED_ALL_CONFIG_FILES.some((file) => fs.existsSync(path.join(projectPath, file)));
|
|
4714
|
-
}
|
|
4715
|
-
/**
|
|
4716
|
-
* Check if a standalone lint-staged config exists in a format that can't be
|
|
4717
|
-
* auto-migrated to "staged" in vite.config.ts (non-JSON files like .yaml,
|
|
4718
|
-
* .mjs, .cjs, .js, or a non-JSON .lintstagedrc).
|
|
4719
|
-
*/
|
|
4720
|
-
function hasUnsupportedLintStagedConfig(projectPath) {
|
|
4721
|
-
for (const filename of LINT_STAGED_OTHER_CONFIG_FILES) if (fs.existsSync(path.join(projectPath, filename))) return true;
|
|
4722
|
-
const lintstagedrcPath = path.join(projectPath, ".lintstagedrc");
|
|
4723
|
-
if (fs.existsSync(lintstagedrcPath) && !isJsonFile(lintstagedrcPath)) return true;
|
|
4724
|
-
return false;
|
|
4725
|
-
}
|
|
4726
|
-
/**
|
|
4727
|
-
* Create pre-commit hook file in the hooks directory.
|
|
4728
|
-
*/
|
|
4729
|
-
const STALE_LINT_STAGED_PATTERNS = [/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)(pnpm|pnpm exec|npx|yarn|yarn run|npm exec|npm run|bunx|bun run|bun x)\s+lint-staged\b/, /^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)lint-staged\b/];
|
|
4730
|
-
const DEFAULT_STAGED_CONFIG = { "*": "vp check --fix" };
|
|
4731
|
-
/**
|
|
4732
|
-
* Ensure the pre-commit hook exists with `vp staged`, and that
|
|
4733
|
-
* vite.config.ts contains a `staged` block (using the default config
|
|
4734
|
-
* if none is present). Called by `vp config` after hook installation.
|
|
4735
|
-
*/
|
|
4736
|
-
function ensurePreCommitHook(projectPath, dir = ".vite-hooks") {
|
|
4737
|
-
if (!hasStagedConfigInViteConfig(projectPath)) mergeStagedConfigToViteConfig(projectPath, DEFAULT_STAGED_CONFIG, true);
|
|
4738
|
-
createPreCommitHook(projectPath, dir);
|
|
4739
|
-
}
|
|
4740
|
-
function createPreCommitHook(projectPath, dir = ".vite-hooks") {
|
|
4741
|
-
const huskyDir = path.join(projectPath, dir);
|
|
4742
|
-
fs.mkdirSync(huskyDir, { recursive: true });
|
|
4743
|
-
const hookPath = path.join(huskyDir, "pre-commit");
|
|
4744
|
-
if (fs.existsSync(hookPath)) {
|
|
4745
|
-
const existing = fs.readFileSync(hookPath, "utf8");
|
|
4746
|
-
if (existing.includes("vp staged")) return;
|
|
4747
|
-
const lines = existing.split("\n");
|
|
4748
|
-
let replaced = false;
|
|
4749
|
-
const result = [];
|
|
4750
|
-
for (const line of lines) {
|
|
4751
|
-
const trimmed = line.trim();
|
|
4752
|
-
if (!replaced) {
|
|
4753
|
-
let matched = false;
|
|
4754
|
-
for (const pattern of STALE_LINT_STAGED_PATTERNS) {
|
|
4755
|
-
const match = pattern.exec(trimmed);
|
|
4756
|
-
if (match) {
|
|
4757
|
-
const parts = [
|
|
4758
|
-
match[1]?.trim() ?? "",
|
|
4759
|
-
"vp staged",
|
|
4760
|
-
trimmed.slice(match[0].length).trim()
|
|
4761
|
-
].filter(Boolean);
|
|
4762
|
-
result.push(parts.join(" "));
|
|
4763
|
-
replaced = true;
|
|
4764
|
-
matched = true;
|
|
4765
|
-
break;
|
|
4766
|
-
}
|
|
4767
|
-
}
|
|
4768
|
-
if (matched) continue;
|
|
4769
|
-
}
|
|
4770
|
-
result.push(line);
|
|
4771
|
-
}
|
|
4772
|
-
if (!replaced) fs.writeFileSync(hookPath, `${result.join("\n").trimEnd()}\nvp staged\n`);
|
|
4773
|
-
else fs.writeFileSync(hookPath, result.join("\n"));
|
|
4774
|
-
} else {
|
|
4775
|
-
fs.writeFileSync(hookPath, "vp staged\n");
|
|
4776
|
-
fs.chmodSync(hookPath, 493);
|
|
4777
|
-
}
|
|
4778
|
-
}
|
|
4779
|
-
/**
|
|
4780
|
-
* Rewrite only `scripts.prepare` in the root package.json using vite-prepare.yml rules.
|
|
4781
|
-
* Collapses "husky install" → "husky" before applying ast-grep so that the
|
|
4782
|
-
* replace-husky rule produces "vp config" with any directory argument preserved.
|
|
4783
|
-
* Returns the old husky hooks dir (if any) for migration to .vite-hooks.
|
|
4784
|
-
* Called only when hooks are being set up (not with --no-hooks).
|
|
4785
|
-
*/
|
|
4786
|
-
function rewritePrepareScript(rootDir) {
|
|
4787
|
-
const packageJsonPath = path.join(rootDir, "package.json");
|
|
4788
|
-
if (!fs.existsSync(packageJsonPath)) return;
|
|
4789
|
-
let oldDir;
|
|
4790
|
-
editJsonFile(packageJsonPath, (pkg) => {
|
|
4791
|
-
if (!pkg.scripts?.prepare) return pkg;
|
|
4792
|
-
const prepare = collapseHuskyInstall(pkg.scripts.prepare);
|
|
4793
|
-
const updated = rewriteScripts(JSON.stringify({ prepare }), readPrepareRulesYaml());
|
|
4794
|
-
if (updated) {
|
|
4795
|
-
let newPrepare = JSON.parse(updated).prepare;
|
|
4796
|
-
newPrepare = newPrepare.replace(/\bvp config(?:\s+(?!-)([\w./-]+))?/, (_match, dir) => {
|
|
4797
|
-
oldDir = dir ?? ".husky";
|
|
4798
|
-
return dir ? `vp config --hooks-dir ${dir}` : "vp config";
|
|
4799
|
-
});
|
|
4800
|
-
pkg.scripts.prepare = newPrepare;
|
|
4801
|
-
} else if (prepare !== pkg.scripts.prepare) pkg.scripts.prepare = prepare;
|
|
4802
|
-
return pkg;
|
|
4803
|
-
});
|
|
4804
|
-
return oldDir;
|
|
4805
|
-
}
|
|
4806
|
-
function setPackageManager(projectDir, downloadPackageManager) {
|
|
4807
|
-
editJsonFile(path.join(projectDir, "package.json"), (pkg) => {
|
|
4808
|
-
if (!pkg.packageManager) pkg.packageManager = `${downloadPackageManager.name}@${downloadPackageManager.version}`;
|
|
4809
|
-
return pkg;
|
|
4810
|
-
});
|
|
4811
|
-
}
|
|
4812
|
-
/**
|
|
4813
|
-
* Detect a .nvmrc file in the project directory.
|
|
4814
|
-
* If not found, check for a Volta node version in package.json.
|
|
4815
|
-
* If either is found, return the relevant info for migration.
|
|
4816
|
-
* Returns undefined if not found or .node-version already exists.
|
|
4817
|
-
*/
|
|
4818
|
-
function detectNodeVersionManagerFile(projectPath) {
|
|
4819
|
-
if (fs.existsSync(path.join(projectPath, ".node-version"))) return;
|
|
4820
|
-
const configs = detectConfigs(projectPath);
|
|
4821
|
-
if (configs.nvmrcFile) return configs.voltaNode ? {
|
|
4822
|
-
file: ".nvmrc",
|
|
4823
|
-
voltaPresent: true
|
|
4824
|
-
} : { file: ".nvmrc" };
|
|
4825
|
-
if (configs.voltaNode) return {
|
|
4826
|
-
file: "package.json",
|
|
4827
|
-
voltaNodeVersion: configs.voltaNode
|
|
4828
|
-
};
|
|
4829
|
-
}
|
|
4830
|
-
/**
|
|
4831
|
-
* Parse a version alias from a .nvmrc file into a .node-version compatible string.
|
|
4832
|
-
* Accepts the first line of .nvmrc (pre-trimmed).
|
|
4833
|
-
* Returns null for unsupported aliases like "system", "default", "iojs".
|
|
4834
|
-
*/
|
|
4835
|
-
function parseNvmrcVersion(alias) {
|
|
4836
|
-
const version = alias.trim();
|
|
4837
|
-
if (!version) return null;
|
|
4838
|
-
if (version === "node" || version === "stable") return "lts/*";
|
|
4839
|
-
if (version === "iojs" || version === "system" || version === "default") return null;
|
|
4840
|
-
if (version.startsWith("lts/")) return version;
|
|
4841
|
-
const normalized = version.startsWith("v") ? version.slice(1) : version;
|
|
4842
|
-
if (!normalized || !import_semver.default.validRange(normalized)) return null;
|
|
4843
|
-
return normalized;
|
|
4844
|
-
}
|
|
4845
|
-
/**
|
|
4846
|
-
* Migrate .nvmrc or Volta node version from package.json to .node-version.
|
|
4847
|
-
* - For .nvmrc: the source file is removed after migration.
|
|
4848
|
-
* - For package.json (Volta): the volta field is left as-is; removal is left to the user's discretion.
|
|
4849
|
-
* Returns true on success, false if migration was skipped or failed.
|
|
4850
|
-
*/
|
|
4851
|
-
function migrateNodeVersionManagerFile(projectPath, detection, report) {
|
|
4852
|
-
const nodeVersionPath = path.join(projectPath, ".node-version");
|
|
4853
|
-
if (detection.file === "package.json") {
|
|
4854
|
-
const { voltaNodeVersion } = detection;
|
|
4855
|
-
const resolvedVersion = voltaNodeVersion === "lts" ? "lts/*" : voltaNodeVersion;
|
|
4856
|
-
if (!import_semver.default.valid(resolvedVersion) && resolvedVersion !== "lts/*") {
|
|
4857
|
-
warnMigration(`package.json volta.node "${voltaNodeVersion}" is not an exact version. Pin an exact version (e.g. ${voltaNodeVersion}.0 or run \`volta pin node@${voltaNodeVersion}\`) then re-run migration.`, report);
|
|
4858
|
-
return false;
|
|
4859
|
-
}
|
|
4860
|
-
fs.writeFileSync(nodeVersionPath, `${resolvedVersion}\n`);
|
|
4861
|
-
if (report) {
|
|
4862
|
-
report.manualSteps.push("Remove the \"volta\" field from package.json");
|
|
4863
|
-
report.nodeVersionFileMigrated = true;
|
|
4864
|
-
} else log.info("You can now remove the \"volta\" field from package.json manually.");
|
|
4865
|
-
return true;
|
|
4866
|
-
}
|
|
4867
|
-
const sourcePath = path.join(projectPath, ".nvmrc");
|
|
4868
|
-
const originalAlias = fs.readFileSync(sourcePath, "utf8").split("\n")[0]?.trim() ?? "";
|
|
4869
|
-
const version = parseNvmrcVersion(originalAlias);
|
|
4870
|
-
if (!version) {
|
|
4871
|
-
warnMigration(".nvmrc contains an unsupported version alias. Create .node-version manually with your desired Node.js version.", report);
|
|
4872
|
-
return false;
|
|
4873
|
-
}
|
|
4874
|
-
if (version === "lts/*" && (originalAlias === "node" || originalAlias === "stable")) log.info(`"${originalAlias}" in .nvmrc is not a specific version; automatically mapping to "lts/*"`);
|
|
4875
|
-
fs.writeFileSync(nodeVersionPath, `${version}\n`);
|
|
4876
|
-
fs.unlinkSync(sourcePath);
|
|
4877
|
-
if (report) {
|
|
4878
|
-
report.nodeVersionFileMigrated = true;
|
|
4879
|
-
if (detection.voltaPresent) report.manualSteps.push("Remove the \"volta\" field from package.json");
|
|
4880
|
-
} else if (detection.voltaPresent) log.info("You can now remove the \"volta\" field from package.json manually.");
|
|
4881
|
-
return true;
|
|
4882
|
-
}
|
|
4883
|
-
function warnPackageLevelEslint() {
|
|
4884
|
-
log.warn("ESLint detected in workspace packages but no root config found. Package-level ESLint must be migrated manually.");
|
|
4885
|
-
}
|
|
4886
|
-
function warnLegacyEslintConfig(legacyConfigFile) {
|
|
4887
|
-
log.warn(`Legacy ESLint configuration detected (${legacyConfigFile}). Automatic migration to Oxlint requires ESLint v9+ with flat config format (eslint.config.*). Please upgrade to ESLint v9 first: https://eslint.org/docs/latest/use/migrate-to-9.0.0`);
|
|
4888
|
-
}
|
|
4889
|
-
async function confirmEslintMigration(interactive) {
|
|
4890
|
-
if (interactive) {
|
|
4891
|
-
const confirmed = await confirm({
|
|
4892
|
-
message: "Migrate ESLint rules to Oxlint using @oxlint/migrate?\n " + styleText("gray", "Oxlint is Vite+'s built-in linter — significantly faster than ESLint with compatible rule support. @oxlint/migrate converts your existing rules automatically."),
|
|
4893
|
-
initialValue: true
|
|
4894
|
-
});
|
|
4895
|
-
if (q(confirmed)) cancelAndExit();
|
|
4896
|
-
return confirmed;
|
|
4897
|
-
}
|
|
4898
|
-
return true;
|
|
4899
|
-
}
|
|
4900
|
-
async function promptEslintMigration(projectPath, interactive, packages) {
|
|
4901
|
-
const eslintProject = detectEslintProject(projectPath, packages);
|
|
4902
|
-
if (eslintProject.hasDependency && !eslintProject.configFile && eslintProject.legacyConfigFile) {
|
|
4903
|
-
warnLegacyEslintConfig(eslintProject.legacyConfigFile);
|
|
4904
|
-
return false;
|
|
4905
|
-
}
|
|
4906
|
-
if (!eslintProject.hasDependency) return false;
|
|
4907
|
-
if (!eslintProject.configFile) {
|
|
4908
|
-
warnPackageLevelEslint();
|
|
4909
|
-
return false;
|
|
4910
|
-
}
|
|
4911
|
-
if (!await confirmEslintMigration(interactive)) return false;
|
|
4912
|
-
if (!await migrateEslintToOxlint(projectPath, interactive, eslintProject.configFile, packages)) cancelAndExit("ESLint migration failed.", 1);
|
|
4913
|
-
return true;
|
|
4914
|
-
}
|
|
4915
|
-
function warnPackageLevelPrettier() {
|
|
4916
|
-
log.warn("Prettier detected in workspace packages but no root config found. Package-level Prettier must be migrated manually.");
|
|
4917
|
-
}
|
|
4918
|
-
async function confirmPrettierMigration(interactive) {
|
|
4919
|
-
if (interactive) {
|
|
4920
|
-
const confirmed = await confirm({
|
|
4921
|
-
message: "Migrate Prettier to Oxfmt?\n " + styleText("gray", "Oxfmt is Vite+'s built-in formatter that replaces Prettier with faster performance. Your configuration will be converted automatically."),
|
|
4922
|
-
initialValue: true
|
|
4923
|
-
});
|
|
4924
|
-
if (q(confirmed)) cancelAndExit();
|
|
4925
|
-
return confirmed;
|
|
4926
|
-
}
|
|
4927
|
-
log.info("Prettier configuration detected. Auto-migrating to Oxfmt...");
|
|
4928
|
-
return true;
|
|
4929
|
-
}
|
|
4930
|
-
async function promptPrettierMigration(projectPath, interactive, packages) {
|
|
4931
|
-
const prettierProject = detectPrettierProject(projectPath, packages);
|
|
4932
|
-
if (!prettierProject.hasDependency) return false;
|
|
4933
|
-
if (!prettierProject.configFile) {
|
|
4934
|
-
warnPackageLevelPrettier();
|
|
4935
|
-
return false;
|
|
4936
|
-
}
|
|
4937
|
-
if (!await confirmPrettierMigration(interactive)) return false;
|
|
4938
|
-
if (!await migratePrettierToOxfmt(projectPath, interactive, prettierProject.configFile, packages)) cancelAndExit("Prettier migration failed.", 1);
|
|
3801
|
+
const types = parse(text)?.compilerOptions?.types;
|
|
3802
|
+
if (!Array.isArray(types)) return false;
|
|
3803
|
+
const REPLACEMENTS = {
|
|
3804
|
+
"tsdown/client": "vite-plus/pack/client",
|
|
3805
|
+
"vite/client": "vite-plus/client"
|
|
3806
|
+
};
|
|
3807
|
+
const toReplace = types.map((t, i) => typeof t === "string" && t in REPLACEMENTS ? {
|
|
3808
|
+
i,
|
|
3809
|
+
newVal: REPLACEMENTS[t]
|
|
3810
|
+
} : null).filter((x) => x !== null);
|
|
3811
|
+
if (toReplace.length === 0) return false;
|
|
3812
|
+
let currentText = text;
|
|
3813
|
+
for (let j = toReplace.length - 1; j >= 0; j--) {
|
|
3814
|
+
const { i, newVal } = toReplace[j];
|
|
3815
|
+
const edits = modify(currentText, [
|
|
3816
|
+
"compilerOptions",
|
|
3817
|
+
"types",
|
|
3818
|
+
i
|
|
3819
|
+
], newVal, {});
|
|
3820
|
+
if (edits.length > 0) currentText = applyEdits(currentText, edits);
|
|
3821
|
+
}
|
|
3822
|
+
fs.writeFileSync(filePath, currentText);
|
|
4939
3823
|
return true;
|
|
4940
3824
|
}
|
|
4941
3825
|
//#endregion
|
|
4942
|
-
|
|
4943
|
-
const AGENTS = [
|
|
4944
|
-
{
|
|
4945
|
-
id: "agents",
|
|
4946
|
-
label: "AGENTS.md",
|
|
4947
|
-
targetPath: "AGENTS.md",
|
|
4948
|
-
hint: "Codex, Amp, OpenCode, and similar agents",
|
|
4949
|
-
aliases: [
|
|
4950
|
-
"agents.md",
|
|
4951
|
-
"chatgpt",
|
|
4952
|
-
"chatgpt-codex",
|
|
4953
|
-
"codex",
|
|
4954
|
-
"amp",
|
|
4955
|
-
"kilo",
|
|
4956
|
-
"kilo-code",
|
|
4957
|
-
"kiro",
|
|
4958
|
-
"kiro-cli",
|
|
4959
|
-
"opencode",
|
|
4960
|
-
"other"
|
|
4961
|
-
]
|
|
4962
|
-
},
|
|
4963
|
-
{
|
|
4964
|
-
id: "claude",
|
|
4965
|
-
label: "CLAUDE.md",
|
|
4966
|
-
targetPath: "CLAUDE.md",
|
|
4967
|
-
hint: "Claude Code",
|
|
4968
|
-
aliases: ["claude.md", "claude-code"]
|
|
4969
|
-
},
|
|
4970
|
-
{
|
|
4971
|
-
id: "gemini",
|
|
4972
|
-
label: "GEMINI.md",
|
|
4973
|
-
targetPath: "GEMINI.md",
|
|
4974
|
-
hint: "Gemini CLI",
|
|
4975
|
-
aliases: ["gemini.md", "gemini-cli"]
|
|
4976
|
-
},
|
|
4977
|
-
{
|
|
4978
|
-
id: "copilot",
|
|
4979
|
-
label: ".github/copilot-instructions.md",
|
|
4980
|
-
targetPath: ".github/copilot-instructions.md",
|
|
4981
|
-
hint: "GitHub Copilot",
|
|
4982
|
-
aliases: ["github-copilot", "copilot-instructions.md"]
|
|
4983
|
-
},
|
|
4984
|
-
{
|
|
4985
|
-
id: "cursor",
|
|
4986
|
-
label: ".cursor/rules/viteplus.mdc",
|
|
4987
|
-
targetPath: ".cursor/rules/viteplus.mdc",
|
|
4988
|
-
hint: "Cursor",
|
|
4989
|
-
aliases: ["viteplus.mdc"]
|
|
4990
|
-
},
|
|
4991
|
-
{
|
|
4992
|
-
id: "jetbrains",
|
|
4993
|
-
label: ".aiassistant/rules/viteplus.md",
|
|
4994
|
-
targetPath: ".aiassistant/rules/viteplus.md",
|
|
4995
|
-
hint: "JetBrains AI Assistant",
|
|
4996
|
-
aliases: [
|
|
4997
|
-
"jetbrains",
|
|
4998
|
-
"jetbrains-ai-assistant",
|
|
4999
|
-
"aiassistant",
|
|
5000
|
-
"viteplus.md"
|
|
5001
|
-
]
|
|
5002
|
-
}
|
|
5003
|
-
];
|
|
5004
|
-
const AGENT_DEFAULT_ID = "agents";
|
|
5005
|
-
const AGENT_STANDARD_PATH = "AGENTS.md";
|
|
5006
|
-
const AGENT_INSTRUCTIONS_START_MARKER = "<!--VITE PLUS START-->";
|
|
5007
|
-
const AGENT_INSTRUCTIONS_END_MARKER = "<!--VITE PLUS END-->";
|
|
5008
|
-
const AGENT_ALIASES = Object.fromEntries(AGENTS.flatMap((option) => (option.aliases ?? []).map((alias) => [normalizeAgentName(alias), option.id])));
|
|
5009
|
-
async function selectAgentTargetPaths({ interactive, agent, onCancel }) {
|
|
5010
|
-
if (agent === false) return;
|
|
5011
|
-
if (interactive && !agent) {
|
|
5012
|
-
const selectedAgents = await multiselect({
|
|
5013
|
-
message: "Which coding agent instruction files should Vite+ create?",
|
|
5014
|
-
options: AGENTS.map((option) => ({
|
|
5015
|
-
label: option.label,
|
|
5016
|
-
value: option.id,
|
|
5017
|
-
hint: option.hint
|
|
5018
|
-
})),
|
|
5019
|
-
initialValues: [AGENT_DEFAULT_ID],
|
|
5020
|
-
required: false
|
|
5021
|
-
});
|
|
5022
|
-
if (q(selectedAgents)) {
|
|
5023
|
-
onCancel();
|
|
5024
|
-
return;
|
|
5025
|
-
}
|
|
5026
|
-
if (selectedAgents.length === 0) return;
|
|
5027
|
-
return resolveAgentTargetPaths(selectedAgents);
|
|
5028
|
-
}
|
|
5029
|
-
return resolveAgentTargetPaths(agent ?? AGENT_DEFAULT_ID);
|
|
5030
|
-
}
|
|
5031
|
-
function detectExistingAgentTargetPaths(projectRoot) {
|
|
5032
|
-
const detectedPaths = [];
|
|
5033
|
-
const seenTargetPaths = /* @__PURE__ */ new Set();
|
|
5034
|
-
for (const option of AGENTS) {
|
|
5035
|
-
if (seenTargetPaths.has(option.targetPath)) continue;
|
|
5036
|
-
seenTargetPaths.add(option.targetPath);
|
|
5037
|
-
const targetPath = path.join(projectRoot, option.targetPath);
|
|
5038
|
-
if (fs.existsSync(targetPath) && !fs.lstatSync(targetPath).isSymbolicLink()) detectedPaths.push(option.targetPath);
|
|
5039
|
-
}
|
|
5040
|
-
return detectedPaths.length > 0 ? detectedPaths : void 0;
|
|
5041
|
-
}
|
|
5042
|
-
/**
|
|
5043
|
-
* Silently update agent instruction files that contain Vite+ markers.
|
|
5044
|
-
* - No agent files → no writes
|
|
5045
|
-
* - No Vite+ markers → no writes
|
|
5046
|
-
* - Markers present, content up to date → no writes
|
|
5047
|
-
* - Markers present, content outdated → update marked section
|
|
5048
|
-
*/
|
|
5049
|
-
function updateExistingAgentInstructions(projectRoot) {
|
|
5050
|
-
const targetPaths = detectExistingAgentTargetPaths(projectRoot);
|
|
5051
|
-
if (!targetPaths) return;
|
|
5052
|
-
const templatePath = path.join(pkgRoot, "AGENTS.md");
|
|
5053
|
-
if (!fs.existsSync(templatePath)) return;
|
|
5054
|
-
const templateContent = fs.readFileSync(templatePath, "utf-8");
|
|
5055
|
-
for (const targetPath of targetPaths) try {
|
|
5056
|
-
const fullPath = path.join(projectRoot, targetPath);
|
|
5057
|
-
const existing = fs.readFileSync(fullPath, "utf-8");
|
|
5058
|
-
const updated = replaceMarkedAgentInstructionsSection(existing, templateContent);
|
|
5059
|
-
if (updated !== void 0 && updated !== existing) fs.writeFileSync(fullPath, updated);
|
|
5060
|
-
} catch {}
|
|
5061
|
-
}
|
|
5062
|
-
function resolveAgentTargetPaths(agent) {
|
|
5063
|
-
const agentNames = parseAgentNames(agent);
|
|
5064
|
-
const resolvedAgentNames = agentNames.length > 0 ? agentNames : ["other"];
|
|
5065
|
-
const dedupedTargetPaths = [];
|
|
5066
|
-
const seenTargetPaths = /* @__PURE__ */ new Set();
|
|
5067
|
-
for (const name of resolvedAgentNames) {
|
|
5068
|
-
const targetPath = resolveSingleAgentTargetPath(name);
|
|
5069
|
-
if (seenTargetPaths.has(targetPath)) continue;
|
|
5070
|
-
seenTargetPaths.add(targetPath);
|
|
5071
|
-
dedupedTargetPaths.push(targetPath);
|
|
5072
|
-
}
|
|
5073
|
-
return dedupedTargetPaths;
|
|
5074
|
-
}
|
|
5075
|
-
function parseAgentNames(agent) {
|
|
5076
|
-
if (!agent) return [];
|
|
5077
|
-
return (Array.isArray(agent) ? agent : [agent]).filter((value) => typeof value === "string").flatMap((value) => value.split(",")).map((value) => value.trim()).filter((value) => value.length > 0);
|
|
5078
|
-
}
|
|
5079
|
-
function resolveSingleAgentTargetPath(agent) {
|
|
5080
|
-
const normalized = normalizeAgentName(agent);
|
|
5081
|
-
const alias = AGENT_ALIASES[normalized];
|
|
5082
|
-
const resolved = alias ? normalizeAgentName(alias) : normalized;
|
|
5083
|
-
return AGENTS.find((option) => normalizeAgentName(option.id) === resolved || normalizeAgentName(option.label) === resolved || normalizeAgentName(option.targetPath) === resolved || option.aliases?.some((candidate) => normalizeAgentName(candidate) === resolved))?.targetPath ?? AGENT_STANDARD_PATH;
|
|
5084
|
-
}
|
|
5085
|
-
/**
|
|
5086
|
-
* Detect agent instruction files that would conflict (exist without markers).
|
|
5087
|
-
* Returns only files that need a user decision (append or skip).
|
|
5088
|
-
* Read-only — does not write or modify any files.
|
|
5089
|
-
*/
|
|
5090
|
-
async function detectAgentConflicts({ projectRoot, targetPaths }) {
|
|
5091
|
-
if (!targetPaths || targetPaths.length === 0) return [];
|
|
5092
|
-
const sourcePath = path.join(pkgRoot, "AGENTS.md");
|
|
5093
|
-
if (!fs.existsSync(sourcePath)) return [];
|
|
5094
|
-
const incomingContent = await fsPromises.readFile(sourcePath, "utf-8");
|
|
5095
|
-
const shouldLinkToAgents = targetPaths.includes(AGENT_STANDARD_PATH);
|
|
5096
|
-
const orderedPaths = shouldLinkToAgents ? [AGENT_STANDARD_PATH, ...targetPaths.filter((p) => p !== AGENT_STANDARD_PATH)] : targetPaths;
|
|
5097
|
-
const conflicts = [];
|
|
5098
|
-
const seenDestinationPaths = /* @__PURE__ */ new Set();
|
|
5099
|
-
const seenRealPaths = /* @__PURE__ */ new Set();
|
|
5100
|
-
for (const targetPathToCheck of orderedPaths) {
|
|
5101
|
-
const destinationPath = path.join(projectRoot, targetPathToCheck);
|
|
5102
|
-
const destinationKey = path.resolve(destinationPath);
|
|
5103
|
-
if (seenDestinationPaths.has(destinationKey)) continue;
|
|
5104
|
-
seenDestinationPaths.add(destinationKey);
|
|
5105
|
-
if (shouldLinkToAgents && targetPathToCheck !== AGENT_STANDARD_PATH) {
|
|
5106
|
-
if (await getExistingPathKind(destinationPath) !== "file") continue;
|
|
5107
|
-
}
|
|
5108
|
-
if (fs.existsSync(destinationPath)) {
|
|
5109
|
-
if (fs.lstatSync(destinationPath).isSymbolicLink()) continue;
|
|
5110
|
-
const destinationRealPath = await fsPromises.realpath(destinationPath);
|
|
5111
|
-
if (seenRealPaths.has(destinationRealPath)) continue;
|
|
5112
|
-
if (replaceMarkedAgentInstructionsSection(await fsPromises.readFile(destinationPath, "utf-8"), incomingContent) !== void 0) {
|
|
5113
|
-
seenRealPaths.add(destinationRealPath);
|
|
5114
|
-
continue;
|
|
5115
|
-
}
|
|
5116
|
-
conflicts.push({ targetPath: targetPathToCheck });
|
|
5117
|
-
seenRealPaths.add(destinationRealPath);
|
|
5118
|
-
}
|
|
5119
|
-
}
|
|
5120
|
-
return conflicts;
|
|
5121
|
-
}
|
|
5122
|
-
async function writeAgentInstructions({ projectRoot, targetPath, targetPaths, interactive, conflictDecisions, silent = false }) {
|
|
5123
|
-
const paths = [...targetPaths ?? [], ...targetPath ? [targetPath] : []];
|
|
5124
|
-
if (paths.length === 0) return;
|
|
5125
|
-
const sourcePath = path.join(pkgRoot, "AGENTS.md");
|
|
5126
|
-
if (!fs.existsSync(sourcePath)) {
|
|
5127
|
-
if (!silent) log.warn("Agent instructions template not found; skipping.");
|
|
5128
|
-
return;
|
|
5129
|
-
}
|
|
5130
|
-
const seenDestinationPaths = /* @__PURE__ */ new Set();
|
|
5131
|
-
const seenRealPaths = /* @__PURE__ */ new Set();
|
|
5132
|
-
const incomingContent = await fsPromises.readFile(sourcePath, "utf-8");
|
|
5133
|
-
const shouldLinkToAgents = paths.includes(AGENT_STANDARD_PATH);
|
|
5134
|
-
const orderedPaths = shouldLinkToAgents ? [AGENT_STANDARD_PATH, ...paths.filter((p) => p !== AGENT_STANDARD_PATH)] : paths;
|
|
5135
|
-
for (const targetPathToWrite of orderedPaths) {
|
|
5136
|
-
const destinationPath = path.join(projectRoot, targetPathToWrite);
|
|
5137
|
-
const destinationKey = path.resolve(destinationPath);
|
|
5138
|
-
if (seenDestinationPaths.has(destinationKey)) continue;
|
|
5139
|
-
seenDestinationPaths.add(destinationKey);
|
|
5140
|
-
await fsPromises.mkdir(path.dirname(destinationPath), { recursive: true });
|
|
5141
|
-
if (shouldLinkToAgents && targetPathToWrite !== AGENT_STANDARD_PATH) {
|
|
5142
|
-
if (await tryLinkTargetToAgents(projectRoot, targetPathToWrite, silent)) continue;
|
|
5143
|
-
}
|
|
5144
|
-
if (fs.existsSync(destinationPath)) {
|
|
5145
|
-
if (fs.lstatSync(destinationPath).isSymbolicLink()) {
|
|
5146
|
-
if (!silent) log.info(`Skipped writing ${targetPathToWrite} (symlink)`);
|
|
5147
|
-
continue;
|
|
5148
|
-
}
|
|
5149
|
-
const destinationRealPath = await fsPromises.realpath(destinationPath);
|
|
5150
|
-
if (seenRealPaths.has(destinationRealPath)) {
|
|
5151
|
-
if (!silent) log.info(`Skipped writing ${targetPathToWrite} (duplicate target)`);
|
|
5152
|
-
continue;
|
|
5153
|
-
}
|
|
5154
|
-
const existingContent = await fsPromises.readFile(destinationPath, "utf-8");
|
|
5155
|
-
const updatedContent = replaceMarkedAgentInstructionsSection(existingContent, incomingContent);
|
|
5156
|
-
if (updatedContent !== void 0) {
|
|
5157
|
-
if (updatedContent !== existingContent) await fsPromises.writeFile(destinationPath, updatedContent);
|
|
5158
|
-
seenRealPaths.add(destinationRealPath);
|
|
5159
|
-
continue;
|
|
5160
|
-
}
|
|
5161
|
-
let conflictAction;
|
|
5162
|
-
const preResolved = conflictDecisions?.get(targetPathToWrite);
|
|
5163
|
-
if (preResolved) conflictAction = preResolved;
|
|
5164
|
-
else if (interactive) {
|
|
5165
|
-
const action = await select({
|
|
5166
|
-
message: `Agent instructions already exist at ${targetPathToWrite}.\n ` + styleText("gray", "The Vite+ template includes guidance on `vp` commands, the build pipeline, and project conventions."),
|
|
5167
|
-
options: [{
|
|
5168
|
-
label: "Append",
|
|
5169
|
-
value: "append",
|
|
5170
|
-
hint: "Add template content to the end"
|
|
5171
|
-
}, {
|
|
5172
|
-
label: "Skip",
|
|
5173
|
-
value: "skip",
|
|
5174
|
-
hint: "Leave existing file unchanged"
|
|
5175
|
-
}],
|
|
5176
|
-
initialValue: "skip"
|
|
5177
|
-
});
|
|
5178
|
-
conflictAction = q(action) || action === "skip" ? "skip" : "append";
|
|
5179
|
-
} else conflictAction = "skip";
|
|
5180
|
-
if (conflictAction === "append") await appendAgentContent(destinationPath, targetPathToWrite, existingContent, incomingContent, silent);
|
|
5181
|
-
else {
|
|
5182
|
-
const suffix = !preResolved && !interactive ? " (already exists)" : "";
|
|
5183
|
-
if (!silent) log.info(`Skipped writing ${targetPathToWrite}${suffix}`);
|
|
5184
|
-
}
|
|
5185
|
-
seenRealPaths.add(destinationRealPath);
|
|
5186
|
-
continue;
|
|
5187
|
-
}
|
|
5188
|
-
await fsPromises.writeFile(destinationPath, incomingContent);
|
|
5189
|
-
if (!silent) log.success(`Wrote agent instructions to ${targetPathToWrite}`);
|
|
5190
|
-
seenRealPaths.add(await fsPromises.realpath(destinationPath));
|
|
5191
|
-
}
|
|
5192
|
-
}
|
|
5193
|
-
async function appendAgentContent(destinationPath, targetPath, existingContent, incomingContent, silent = false) {
|
|
5194
|
-
const separator = existingContent.endsWith("\n") ? "" : "\n";
|
|
5195
|
-
await fsPromises.appendFile(destinationPath, `${separator}\n${incomingContent}`);
|
|
5196
|
-
if (!silent) log.success(`Appended agent instructions to ${targetPath}`);
|
|
5197
|
-
}
|
|
5198
|
-
function normalizeAgentName(value) {
|
|
5199
|
-
return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "");
|
|
5200
|
-
}
|
|
5201
|
-
function replaceMarkedAgentInstructionsSection(existing, incoming) {
|
|
5202
|
-
const existingRange = getMarkedRange(existing, AGENT_INSTRUCTIONS_START_MARKER, AGENT_INSTRUCTIONS_END_MARKER);
|
|
5203
|
-
if (!existingRange) return;
|
|
5204
|
-
const incomingRange = getMarkedRange(incoming, AGENT_INSTRUCTIONS_START_MARKER, AGENT_INSTRUCTIONS_END_MARKER);
|
|
5205
|
-
if (!incomingRange) return;
|
|
5206
|
-
return `${existing.slice(0, existingRange.start)}${incoming.slice(incomingRange.start, incomingRange.end)}${existing.slice(existingRange.end)}`;
|
|
5207
|
-
}
|
|
5208
|
-
async function tryLinkTargetToAgents(projectRoot, targetPath, silent = false) {
|
|
5209
|
-
const destinationPath = path.join(projectRoot, targetPath);
|
|
5210
|
-
const agentsPath = path.join(projectRoot, AGENT_STANDARD_PATH);
|
|
5211
|
-
const symlinkTarget = path.relative(path.dirname(destinationPath), agentsPath);
|
|
5212
|
-
const existing = await getExistingPathKind(destinationPath);
|
|
5213
|
-
if (existing === "file") return false;
|
|
5214
|
-
if (existing === "symlink") {
|
|
5215
|
-
const currentLink = await fsPromises.readlink(destinationPath);
|
|
5216
|
-
if (path.resolve(path.dirname(destinationPath), currentLink) === agentsPath) {
|
|
5217
|
-
if (!silent) log.info(`Skipped linking ${targetPath} (already linked to ${AGENT_STANDARD_PATH})`);
|
|
5218
|
-
return true;
|
|
5219
|
-
}
|
|
5220
|
-
await fsPromises.unlink(destinationPath);
|
|
5221
|
-
}
|
|
5222
|
-
try {
|
|
5223
|
-
await fsPromises.symlink(symlinkTarget, destinationPath);
|
|
5224
|
-
} catch (err) {
|
|
5225
|
-
if (err.code === "EPERM") {
|
|
5226
|
-
await fsPromises.copyFile(agentsPath, destinationPath);
|
|
5227
|
-
if (!silent) log.success(`Copied ${AGENT_STANDARD_PATH} to ${targetPath}`);
|
|
5228
|
-
return true;
|
|
5229
|
-
}
|
|
5230
|
-
throw err;
|
|
5231
|
-
}
|
|
5232
|
-
if (!silent) log.success(`Linked ${targetPath} to ${AGENT_STANDARD_PATH}`);
|
|
5233
|
-
return true;
|
|
5234
|
-
}
|
|
5235
|
-
async function getExistingPathKind(filePath) {
|
|
5236
|
-
if (!fs.existsSync(filePath)) return "missing";
|
|
5237
|
-
return (await fsPromises.lstat(filePath)).isSymbolicLink() ? "symlink" : "file";
|
|
5238
|
-
}
|
|
5239
|
-
function getMarkedRange(content, startMarker, endMarker) {
|
|
5240
|
-
const start = content.indexOf(startMarker);
|
|
5241
|
-
if (start === -1) return;
|
|
5242
|
-
const endMarkerIndex = content.indexOf(endMarker, start + startMarker.length);
|
|
5243
|
-
if (endMarkerIndex === -1) return;
|
|
5244
|
-
return {
|
|
5245
|
-
start,
|
|
5246
|
-
end: endMarkerIndex + endMarker.length
|
|
5247
|
-
};
|
|
5248
|
-
}
|
|
5249
|
-
//#endregion
|
|
5250
|
-
export { multiselect as $, setPackageManager as A, runViteFmt as B, migratePrettierToOxfmt as C, rewriteMonorepo as D, promptPrettierMigration as E, readYamlFile as F, templatesDir as G, selectPackageManager as H, cancelAndExit as I, require_semver as J, DependencyType as K, defaultInteractive as L, warnPackageLevelEslint as M, warnPackageLevelPrettier as N, rewriteMonorepoProject as O, editYamlFile as P, log as Q, downloadPackageManager$1 as R, migrateNodeVersionManagerFile as S, promptEslintMigration as T, upgradeYarn as U, runViteInstall as V, displayRelative as W, confirm as X, cancel as Y, intro as Z, hasStagedConfigInViteConfig as _, writeAgentInstructions as a, q as at, mergeViteConfigFiles as b, checkVitestVersion as c, detectEslintProject as d, outro as et, detectFramework as f, hasFrameworkShim as g, ensurePreCommitHook as h, updateExistingAgentInstructions as i, require_picocolors as it, warnLegacyEslintConfig as j, rewriteStandaloneProject as k, confirmEslintMigration as l, detectPrettierProject as m, detectExistingAgentTargetPaths as n, spinner as nt, addFrameworkShim as o, detectNodeVersionManagerFile as p, PackageManager as q, selectAgentTargetPaths as r, text as rt, checkViteVersion as s, detectAgentConflicts as t, select as tt, confirmPrettierMigration as u, injectCreateDefaultTemplate as v, preflightGitHooksSetup as w, migrateEslintToOxlint as x, installGitHooks as y, promptGitHooks as z };
|
|
3826
|
+
export { q as A, log as C, spinner as D, select as E, runCommandSilently as M, require_cross_spawn as N, text as O, intro as S, outro as T, DependencyType as _, removeDeprecatedTsconfigFalseOption as a, cancel as b, defaultInteractive as c, promptGitHooks as d, promptGitInit as f, upgradeYarn as g, selectPackageManager as h, hasBaseUrlInTsconfig as i, runCommand$1 as j, require_picocolors as k, downloadPackageManager$1 as l, runViteInstall as m, findTsconfigFiles as n, rewriteTypesInTsconfig as o, runViteFmt as p, fixBaseUrlInTsconfig as r, cancelAndExit as s, confirmBaseUrlFix as t, getSpinner as u, PackageManager as v, multiselect as w, confirm as x, require_semver as y };
|