vite-plus 0.2.8 → 0.3.0
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 +7 -0
- package/README.md +13 -6
- package/binding/index.cjs +57 -54
- package/binding/index.d.cts +100 -3
- package/dist/{agent-CI79DuSy.js → agent-Wqx0MPk0.js} +4 -188
- package/dist/bin.js +298 -278
- package/dist/command-CLJK5jGW.js +2 -0
- package/dist/command-CguLh2KL.js +471 -0
- package/dist/config/bin.js +29 -15
- package/dist/{constants-BppDcRc1.js → constants-Bn-U8o4v.js} +13 -3
- package/dist/create/bin.js +197 -247
- package/dist/{define-config-DPnHe1Mx.js → define-config-GXUdVT-0.js} +3 -3
- package/dist/{define-config-CEm_MtvJ.cjs → define-config-WiVlryJ2.cjs} +2 -2
- package/dist/define-config.cjs +1 -1
- package/dist/define-config.js +1 -1
- package/dist/{dist-CSQWHI6y.js → dist-BDYZP12R.js} +193 -149
- package/dist/dist-Dqv1-Clg.js +3 -0
- package/dist/{editor-CGWdbLgD.js → editor-CC4DqODz.js} +736 -153
- package/dist/{terminal-CrqqK8WT.js → help-BmKpeOP9.js} +27 -34
- package/dist/hooks/bin.d.ts +1 -0
- package/dist/hooks/bin.js +131 -0
- package/dist/hooks-DFqViZqZ.js +573 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{json-BU88uu6o.js → json-cULBl7Pi.js} +145 -139
- package/dist/migration/bin.js +67 -21
- package/dist/migration/compat/worker.js +1 -1
- package/dist/{oxlint-plugin-config-BHOzlwMw.js → oxlint-plugin-config-DX5ezKbB.js} +1 -1
- package/dist/oxlint-plugin.js +1 -1
- package/dist/pack-bin.js +5 -4
- package/dist/{package-hV-77cBb.js → package-CBe9EWPY.js} +2 -2
- package/dist/{prompts-DYap08te.js → prompts-DF3yU-eU.js} +136 -512
- package/dist/{report-BS7ULx7A.js → report-ZNR1Mk6h.js} +1 -0
- package/dist/{resolve-vite-config-EWXclqvV.js → resolve-vite-config-ipGb39Jo.js} +2 -9
- package/dist/staged/bin.js +299 -251
- package/dist/terminal-MKGAuy-p.js +39 -0
- package/dist/test/browser/providers/playwright/context.d.ts +1 -1
- package/dist/test/browser/providers/playwright.d.ts +6 -6
- package/dist/test/browser/providers/preview/context.d.ts +1 -1
- package/dist/test/browser/providers/preview.d.ts +4 -4
- package/dist/test/browser/providers/webdriverio/context.d.ts +1 -1
- package/dist/test/browser/providers/webdriverio.d.ts +6 -6
- package/dist/test/browser-playwright/context.d.ts +1 -1
- package/dist/test/browser-playwright.d.ts +6 -6
- package/dist/test/browser-preview/context.d.ts +1 -1
- package/dist/test/browser-preview.d.ts +4 -4
- package/dist/test/browser-webdriverio/context.d.ts +1 -1
- package/dist/test/browser-webdriverio.d.ts +6 -6
- package/dist/test/context.d.ts +3 -3
- package/dist/test/locators.d.ts +1 -1
- package/dist/toolchain.d.ts +25 -0
- package/dist/toolchain.js +194 -0
- package/dist/toolchain.json +193 -0
- package/dist/tsconfig-BVHG3DpR.js +2 -0
- package/dist/{tsconfig-CVUKLfL8.js → tsconfig-LD2QhQ0O.js} +5 -4
- package/dist/tsgolint-path.js +1 -1
- package/dist/version.js +5 -4
- package/dist/versions.d.ts +3 -3
- package/dist/versions.js +6 -6
- package/docs/guide/ci.md +37 -4
- package/docs/guide/commit-hooks.md +87 -14
- package/docs/guide/create.md +7 -4
- package/docs/guide/env.md +20 -6
- package/docs/guide/fmt.md +2 -2
- package/docs/guide/github-actions-cache.md +5 -1
- package/docs/guide/ide-integration.md +61 -2
- package/docs/guide/index.md +3 -1
- package/docs/guide/install.md +27 -1
- package/docs/guide/installer-env-vars.md +53 -6
- package/docs/guide/lint.md +3 -1
- package/docs/guide/migrate-rules.md +9 -0
- package/docs/guide/migrate.md +41 -4
- package/docs/guide/monorepo.md +4 -4
- package/docs/guide/test.md +8 -0
- package/docs/guide/troubleshooting.md +12 -4
- package/docs/guide/upgrade.md +75 -5
- package/package.json +36 -33
- package/rules/vite-tools.yml +0 -7
- package/dist/dist-DT25H9pj.js +0 -3
- package/docs/_data/team.ts +0 -131
- package/docs/package.json +0 -30
- package/docs/pnpm-lock.yaml +0 -4003
- package/docs/pnpm-workspace.yaml +0 -6
- package/docs/public/checkmark.svg +0 -1
- package/docs/public/cta-background.jpg +0 -0
- package/docs/public/favicon.svg +0 -1
- package/docs/public/icon.svg +0 -1
- package/docs/public/logo.svg +0 -1
- package/docs/public/og.jpg +0 -0
- package/docs/vite.config.ts +0 -17
- package/dist/{log-update-CoW8Z4Dl.js → log-update-DHZRyJ2m.js} +1 -1
- package/dist/{tsgolint-path-eMZT-oea.js → tsgolint-path-CbDReEOx.js} +1 -1
|
@@ -1,4 +1,111 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
//#region ../../node_modules/.pnpm/detect-indent@7.0.2/node_modules/detect-indent/index.js
|
|
3
|
+
const INDENT_REGEX = /^(?:( )+|\t+)/;
|
|
4
|
+
const INDENT_TYPE_SPACE = "space";
|
|
5
|
+
const INDENT_TYPE_TAB = "tab";
|
|
6
|
+
function shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, value) {
|
|
7
|
+
return ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && value === 1;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
Make a Map that counts how many indents/unindents have occurred for a given size and how many lines follow a given indentation.
|
|
11
|
+
|
|
12
|
+
The key is a concatenation of the indentation type (s = space and t = tab) and the size of the indents/unindents.
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
indents = {
|
|
16
|
+
t3: [1, 0],
|
|
17
|
+
t4: [1, 5],
|
|
18
|
+
s5: [1, 0],
|
|
19
|
+
s12: [1, 0],
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
*/
|
|
23
|
+
function makeIndentsMap(string, ignoreSingleSpaces) {
|
|
24
|
+
const indents = /* @__PURE__ */ new Map();
|
|
25
|
+
let previousSize = 0;
|
|
26
|
+
let previousIndentType;
|
|
27
|
+
let key;
|
|
28
|
+
for (const line of string.split(/\n/g)) {
|
|
29
|
+
if (!line) continue;
|
|
30
|
+
const matches = line.match(INDENT_REGEX);
|
|
31
|
+
if (matches === null) {
|
|
32
|
+
previousSize = 0;
|
|
33
|
+
previousIndentType = "";
|
|
34
|
+
} else {
|
|
35
|
+
const indent = matches[0].length;
|
|
36
|
+
const indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
|
|
37
|
+
if (shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, indent)) continue;
|
|
38
|
+
if (indentType !== previousIndentType) previousSize = 0;
|
|
39
|
+
previousIndentType = indentType;
|
|
40
|
+
let use = 1;
|
|
41
|
+
let weight = 0;
|
|
42
|
+
const indentDifference = indent - previousSize;
|
|
43
|
+
previousSize = indent;
|
|
44
|
+
if (indentDifference === 0) {
|
|
45
|
+
use = 0;
|
|
46
|
+
weight = 1;
|
|
47
|
+
} else {
|
|
48
|
+
const absoluteIndentDifference = Math.abs(indentDifference);
|
|
49
|
+
if (shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, absoluteIndentDifference)) continue;
|
|
50
|
+
key = encodeIndentsKey(indentType, absoluteIndentDifference);
|
|
51
|
+
}
|
|
52
|
+
const entry = indents.get(key);
|
|
53
|
+
indents.set(key, entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return indents;
|
|
57
|
+
}
|
|
58
|
+
function encodeIndentsKey(indentType, indentAmount) {
|
|
59
|
+
return (indentType === INDENT_TYPE_SPACE ? "s" : "t") + String(indentAmount);
|
|
60
|
+
}
|
|
61
|
+
function decodeIndentsKey(indentsKey) {
|
|
62
|
+
return {
|
|
63
|
+
type: indentsKey[0] === "s" ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB,
|
|
64
|
+
amount: Number(indentsKey.slice(1))
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function getMostUsedKey(indents) {
|
|
68
|
+
let result;
|
|
69
|
+
let maxUsed = 0;
|
|
70
|
+
let maxWeight = 0;
|
|
71
|
+
for (const [key, [usedCount, weight]] of indents) if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
|
|
72
|
+
maxUsed = usedCount;
|
|
73
|
+
maxWeight = weight;
|
|
74
|
+
result = key;
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
function makeIndentString(type, amount) {
|
|
79
|
+
return (type === INDENT_TYPE_SPACE ? " " : " ").repeat(amount);
|
|
80
|
+
}
|
|
81
|
+
function detectIndent(string) {
|
|
82
|
+
if (typeof string !== "string") throw new TypeError("Expected a string");
|
|
83
|
+
let indents = makeIndentsMap(string, true);
|
|
84
|
+
if (indents.size === 0) indents = makeIndentsMap(string, false);
|
|
85
|
+
const keyOfMostUsedIndent = getMostUsedKey(indents);
|
|
86
|
+
let type;
|
|
87
|
+
let amount = 0;
|
|
88
|
+
let indent = "";
|
|
89
|
+
if (keyOfMostUsedIndent !== void 0) {
|
|
90
|
+
({type, amount} = decodeIndentsKey(keyOfMostUsedIndent));
|
|
91
|
+
indent = makeIndentString(type, amount);
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
amount,
|
|
95
|
+
type,
|
|
96
|
+
indent
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region ../../node_modules/.pnpm/detect-newline@4.0.1/node_modules/detect-newline/index.js
|
|
101
|
+
function detectNewline(string) {
|
|
102
|
+
if (typeof string !== "string") throw new TypeError("Expected a string");
|
|
103
|
+
const newlines = string.match(/(?:\r?\n)/g) || [];
|
|
104
|
+
if (newlines.length === 0) return;
|
|
105
|
+
const crlf = newlines.filter((newline) => newline === "\r\n").length;
|
|
106
|
+
return crlf > newlines.length - crlf ? "\r\n" : "\n";
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
2
109
|
//#region ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
|
|
3
110
|
/**
|
|
4
111
|
* Creates a JSON scanner on the given text.
|
|
@@ -114,11 +221,13 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
114
221
|
start = pos;
|
|
115
222
|
continue;
|
|
116
223
|
}
|
|
117
|
-
if (ch >= 0 && ch <= 31)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
224
|
+
if (ch >= 0 && ch <= 31) {
|
|
225
|
+
if (isLineBreak(ch)) {
|
|
226
|
+
result += text.substring(start, pos);
|
|
227
|
+
scanError = 2;
|
|
228
|
+
break;
|
|
229
|
+
} else scanError = 6;
|
|
230
|
+
}
|
|
122
231
|
pos++;
|
|
123
232
|
}
|
|
124
233
|
return result;
|
|
@@ -539,8 +648,10 @@ function format(documentText, range, options) {
|
|
|
539
648
|
}
|
|
540
649
|
if (numberLineBreaks > 0 && (secondToken === 12 || secondToken === 13)) replaceContent = newLinesAndIndent();
|
|
541
650
|
}
|
|
542
|
-
if (secondToken === 17)
|
|
543
|
-
|
|
651
|
+
if (secondToken === 17) {
|
|
652
|
+
if (options.keepLines && numberLineBreaks > 0) replaceContent = newLinesAndIndent();
|
|
653
|
+
else replaceContent = options.insertFinalNewline ? eol : "";
|
|
654
|
+
}
|
|
544
655
|
const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
545
656
|
addEdit(replaceContent, firstTokenEnd, secondTokenStart);
|
|
546
657
|
firstToken = secondToken;
|
|
@@ -964,9 +1075,10 @@ function setProperty(text, originalPath, value, options) {
|
|
|
964
1075
|
while (path.length > 0) {
|
|
965
1076
|
lastSegment = path.pop();
|
|
966
1077
|
parent = findNodeAtLocation(root, path);
|
|
967
|
-
if (parent === void 0 && value !== void 0)
|
|
968
|
-
|
|
969
|
-
|
|
1078
|
+
if (parent === void 0 && value !== void 0) {
|
|
1079
|
+
if (typeof lastSegment === "string") value = { [lastSegment]: value };
|
|
1080
|
+
else value = [value];
|
|
1081
|
+
} else break;
|
|
970
1082
|
}
|
|
971
1083
|
if (!parent) {
|
|
972
1084
|
if (value === void 0) throw new Error("Can not delete in empty document");
|
|
@@ -977,29 +1089,30 @@ function setProperty(text, originalPath, value, options) {
|
|
|
977
1089
|
}, options);
|
|
978
1090
|
} else if (parent.type === "object" && typeof lastSegment === "string" && Array.isArray(parent.children)) {
|
|
979
1091
|
const existing = findNodeAtLocation(parent, [lastSegment]);
|
|
980
|
-
if (existing !== void 0)
|
|
981
|
-
if (
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1092
|
+
if (existing !== void 0) {
|
|
1093
|
+
if (value === void 0) {
|
|
1094
|
+
if (!existing.parent) throw new Error("Malformed AST");
|
|
1095
|
+
const propertyIndex = parent.children.indexOf(existing.parent);
|
|
1096
|
+
let removeBegin;
|
|
1097
|
+
let removeEnd = existing.parent.offset + existing.parent.length;
|
|
1098
|
+
if (propertyIndex > 0) {
|
|
1099
|
+
let previous = parent.children[propertyIndex - 1];
|
|
1100
|
+
removeBegin = previous.offset + previous.length;
|
|
1101
|
+
} else {
|
|
1102
|
+
removeBegin = parent.offset + 1;
|
|
1103
|
+
if (parent.children.length > 1) removeEnd = parent.children[1].offset;
|
|
1104
|
+
}
|
|
1105
|
+
return withFormatting(text, {
|
|
1106
|
+
offset: removeBegin,
|
|
1107
|
+
length: removeEnd - removeBegin,
|
|
1108
|
+
content: ""
|
|
1109
|
+
}, options);
|
|
1110
|
+
} else return withFormatting(text, {
|
|
1111
|
+
offset: existing.offset,
|
|
1112
|
+
length: existing.length,
|
|
1113
|
+
content: JSON.stringify(value)
|
|
996
1114
|
}, options);
|
|
997
|
-
} else
|
|
998
|
-
offset: existing.offset,
|
|
999
|
-
length: existing.length,
|
|
1000
|
-
content: JSON.stringify(value)
|
|
1001
|
-
}, options);
|
|
1002
|
-
else {
|
|
1115
|
+
} else {
|
|
1003
1116
|
if (value === void 0) return [];
|
|
1004
1117
|
const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
|
|
1005
1118
|
const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map((p) => p.children[0].value)) : parent.children.length;
|
|
@@ -1220,113 +1333,6 @@ function applyEdits(text, edits) {
|
|
|
1220
1333
|
return text;
|
|
1221
1334
|
}
|
|
1222
1335
|
//#endregion
|
|
1223
|
-
//#region ../../node_modules/.pnpm/detect-indent@7.0.2/node_modules/detect-indent/index.js
|
|
1224
|
-
const INDENT_REGEX = /^(?:( )+|\t+)/;
|
|
1225
|
-
const INDENT_TYPE_SPACE = "space";
|
|
1226
|
-
const INDENT_TYPE_TAB = "tab";
|
|
1227
|
-
function shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, value) {
|
|
1228
|
-
return ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && value === 1;
|
|
1229
|
-
}
|
|
1230
|
-
/**
|
|
1231
|
-
Make a Map that counts how many indents/unindents have occurred for a given size and how many lines follow a given indentation.
|
|
1232
|
-
|
|
1233
|
-
The key is a concatenation of the indentation type (s = space and t = tab) and the size of the indents/unindents.
|
|
1234
|
-
|
|
1235
|
-
```
|
|
1236
|
-
indents = {
|
|
1237
|
-
t3: [1, 0],
|
|
1238
|
-
t4: [1, 5],
|
|
1239
|
-
s5: [1, 0],
|
|
1240
|
-
s12: [1, 0],
|
|
1241
|
-
}
|
|
1242
|
-
```
|
|
1243
|
-
*/
|
|
1244
|
-
function makeIndentsMap(string, ignoreSingleSpaces) {
|
|
1245
|
-
const indents = /* @__PURE__ */ new Map();
|
|
1246
|
-
let previousSize = 0;
|
|
1247
|
-
let previousIndentType;
|
|
1248
|
-
let key;
|
|
1249
|
-
for (const line of string.split(/\n/g)) {
|
|
1250
|
-
if (!line) continue;
|
|
1251
|
-
const matches = line.match(INDENT_REGEX);
|
|
1252
|
-
if (matches === null) {
|
|
1253
|
-
previousSize = 0;
|
|
1254
|
-
previousIndentType = "";
|
|
1255
|
-
} else {
|
|
1256
|
-
const indent = matches[0].length;
|
|
1257
|
-
const indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
|
|
1258
|
-
if (shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, indent)) continue;
|
|
1259
|
-
if (indentType !== previousIndentType) previousSize = 0;
|
|
1260
|
-
previousIndentType = indentType;
|
|
1261
|
-
let use = 1;
|
|
1262
|
-
let weight = 0;
|
|
1263
|
-
const indentDifference = indent - previousSize;
|
|
1264
|
-
previousSize = indent;
|
|
1265
|
-
if (indentDifference === 0) {
|
|
1266
|
-
use = 0;
|
|
1267
|
-
weight = 1;
|
|
1268
|
-
} else {
|
|
1269
|
-
const absoluteIndentDifference = Math.abs(indentDifference);
|
|
1270
|
-
if (shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, absoluteIndentDifference)) continue;
|
|
1271
|
-
key = encodeIndentsKey(indentType, absoluteIndentDifference);
|
|
1272
|
-
}
|
|
1273
|
-
const entry = indents.get(key);
|
|
1274
|
-
indents.set(key, entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight]);
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
return indents;
|
|
1278
|
-
}
|
|
1279
|
-
function encodeIndentsKey(indentType, indentAmount) {
|
|
1280
|
-
return (indentType === INDENT_TYPE_SPACE ? "s" : "t") + String(indentAmount);
|
|
1281
|
-
}
|
|
1282
|
-
function decodeIndentsKey(indentsKey) {
|
|
1283
|
-
return {
|
|
1284
|
-
type: indentsKey[0] === "s" ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB,
|
|
1285
|
-
amount: Number(indentsKey.slice(1))
|
|
1286
|
-
};
|
|
1287
|
-
}
|
|
1288
|
-
function getMostUsedKey(indents) {
|
|
1289
|
-
let result;
|
|
1290
|
-
let maxUsed = 0;
|
|
1291
|
-
let maxWeight = 0;
|
|
1292
|
-
for (const [key, [usedCount, weight]] of indents) if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
|
|
1293
|
-
maxUsed = usedCount;
|
|
1294
|
-
maxWeight = weight;
|
|
1295
|
-
result = key;
|
|
1296
|
-
}
|
|
1297
|
-
return result;
|
|
1298
|
-
}
|
|
1299
|
-
function makeIndentString(type, amount) {
|
|
1300
|
-
return (type === INDENT_TYPE_SPACE ? " " : " ").repeat(amount);
|
|
1301
|
-
}
|
|
1302
|
-
function detectIndent(string) {
|
|
1303
|
-
if (typeof string !== "string") throw new TypeError("Expected a string");
|
|
1304
|
-
let indents = makeIndentsMap(string, true);
|
|
1305
|
-
if (indents.size === 0) indents = makeIndentsMap(string, false);
|
|
1306
|
-
const keyOfMostUsedIndent = getMostUsedKey(indents);
|
|
1307
|
-
let type;
|
|
1308
|
-
let amount = 0;
|
|
1309
|
-
let indent = "";
|
|
1310
|
-
if (keyOfMostUsedIndent !== void 0) {
|
|
1311
|
-
({type, amount} = decodeIndentsKey(keyOfMostUsedIndent));
|
|
1312
|
-
indent = makeIndentString(type, amount);
|
|
1313
|
-
}
|
|
1314
|
-
return {
|
|
1315
|
-
amount,
|
|
1316
|
-
type,
|
|
1317
|
-
indent
|
|
1318
|
-
};
|
|
1319
|
-
}
|
|
1320
|
-
//#endregion
|
|
1321
|
-
//#region ../../node_modules/.pnpm/detect-newline@4.0.1/node_modules/detect-newline/index.js
|
|
1322
|
-
function detectNewline(string) {
|
|
1323
|
-
if (typeof string !== "string") throw new TypeError("Expected a string");
|
|
1324
|
-
const newlines = string.match(/(?:\r?\n)/g) || [];
|
|
1325
|
-
if (newlines.length === 0) return;
|
|
1326
|
-
const crlf = newlines.filter((newline) => newline === "\r\n").length;
|
|
1327
|
-
return crlf > newlines.length - crlf ? "\r\n" : "\n";
|
|
1328
|
-
}
|
|
1329
|
-
//#endregion
|
|
1330
1336
|
//#region src/utils/json.ts
|
|
1331
1337
|
/**
|
|
1332
1338
|
* Derive `jsonc-parser` formatting options from existing file text so inserted
|
package/dist/migration/bin.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { r as __toESM } from "../rolldown-runtime-CMFfr-1z.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { i as hasBaseUrlInTsconfig, r as fixBaseUrlInTsconfig, t as confirmBaseUrlFix } from "../tsconfig-CVUKLfL8.js";
|
|
2
|
+
import { t as renderCliDoc } from "../help-BmKpeOP9.js";
|
|
3
|
+
import { a as muted, c as warnMsg, i as log, o as printHeader, r as formatDuration, t as accent } from "../terminal-MKGAuy-p.js";
|
|
4
|
+
import { f as VITE_PLUS_VERSION, m as isForceOverrideMode } from "../constants-Bn-U8o4v.js";
|
|
5
|
+
import { A as isCancel, C as log$1, D as spinner, E as select, T as outro, b as require_semver, c as selectPackageManager, i as promptGitHooks, l as upgradeYarn, n as defaultInteractive, o as runViteFmt, r as downloadPackageManager, s as runViteInstall, t as cancelAndExit, x as confirm, y as PackageManager } from "../prompts-DF3yU-eU.js";
|
|
7
6
|
import { t as lib_default } from "../lib-L3DWSRQp.js";
|
|
8
|
-
import { a as
|
|
9
|
-
import {
|
|
10
|
-
import { n as
|
|
11
|
-
import {
|
|
7
|
+
import { a as writeJsonFile, i as readJsonFile } from "../json-cULBl7Pi.js";
|
|
8
|
+
import { a as readNearestPackageJson, i as hasVitePlusDependency } from "../package-CBe9EWPY.js";
|
|
9
|
+
import { i as selectAgentTargetPaths, l as displayRelative, n as detectAgentConflicts, r as detectExistingAgentTargetPaths, s as writeAgentInstructions } from "../agent-Wqx0MPk0.js";
|
|
10
|
+
import { n as addMigrationWarning, r as createMigrationReport } from "../report-ZNR1Mk6h.js";
|
|
11
|
+
import { $ as warnLegacyEslintConfig, A as detectWorkspace, C as mergeTsdownConfigFile, D as ensureVitePlusBootstrap, E as detectVitePlusBootstrapPending, F as detectFramework, H as confirmPrettierMigration, I as hasFrameworkShim, J as detectEslintProject, K as warnPackageLevelPrettier, L as confirmTsupMigration, O as configureYarnNodeModulesMode, P as addFrameworkShim, Q as warnIncompatibleEslintIntegration, R as detectTsupProject, S as injectLintTypeCheckDefaults, T as collectToolchainVersionChanges, U as detectPrettierProject, V as warnMissingTsupConfig, W as migratePrettierToOxfmt, X as migrateEslintToOxlint, Y as detectIncompatibleEslintIntegration, _ as preflightGitHooksSetup, d as finalizeCoreMigrationForExistingVitePlus, et as warnPackageLevelEslint, f as detectNodeVersionManagerFile, g as installGitHooks, h as detectLegacyGitHooksMigrationCandidate, i as selectEditor, k as detectYarnPnpMode, l as rewriteStandaloneProject, nt as checkVitestVersion, o as writeEditorConfigs, p as migrateNodeVersionManagerFile, q as confirmEslintMigration, r as isJsonLikeFile, s as rewriteMonorepo, t as detectEditorConflicts, tt as checkViteVersion, u as detectPendingCoreMigration, v as shouldSkipStagedMigrationForHooks, w as mergeViteConfigFiles, z as migrateTsupToTsdown } from "../editor-CC4DqODz.js";
|
|
12
|
+
import { n as runCommandSilently } from "../command-CguLh2KL.js";
|
|
13
|
+
import { a as hasBaseUrlInTsconfig, i as fixBaseUrlInTsconfig, t as confirmBaseUrlFix } from "../tsconfig-LD2QhQ0O.js";
|
|
12
14
|
import { t as ROLLDOWN_COMPAT_RESULT_PREFIX } from "../protocol-D99W10Qi.js";
|
|
13
15
|
import path from "node:path";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
14
17
|
import { styleText } from "node:util";
|
|
15
18
|
import fs, { existsSync } from "node:fs";
|
|
16
|
-
import { fileURLToPath } from "node:url";
|
|
17
19
|
//#region src/migration/compat/runner.ts
|
|
18
20
|
var import_semver = /* @__PURE__ */ __toESM(require_semver(), 1);
|
|
19
21
|
/**
|
|
@@ -362,7 +364,7 @@ async function collectEditorConfigPlan(rootDir, options) {
|
|
|
362
364
|
});
|
|
363
365
|
if (isCancel(action)) cancelAndExit();
|
|
364
366
|
editorConflictDecisions.set(conflict.fileName, action);
|
|
365
|
-
} else editorConflictDecisions.set(conflict.fileName, "merge");
|
|
367
|
+
} else editorConflictDecisions.set(conflict.fileName, isJsonLikeFile(conflict.fileName) ? "merge" : "skip");
|
|
366
368
|
return {
|
|
367
369
|
selectedEditor,
|
|
368
370
|
editorConflictDecisions
|
|
@@ -381,6 +383,16 @@ async function collectEslintMigrationDecision(rootDir, options, packages) {
|
|
|
381
383
|
eslintConfigFile: eslintProject.configFile
|
|
382
384
|
};
|
|
383
385
|
}
|
|
386
|
+
async function collectTsupMigrationDecision(rootDir, options, packages) {
|
|
387
|
+
const tsupProject = detectTsupProject(rootDir, packages);
|
|
388
|
+
let migrateTsup = false;
|
|
389
|
+
if (tsupProject.hasDependency && tsupProject.hasConfig) migrateTsup = await confirmTsupMigration(options.interactive);
|
|
390
|
+
else if (tsupProject.hasDependency) warnMissingTsupConfig();
|
|
391
|
+
return {
|
|
392
|
+
migrateTsup,
|
|
393
|
+
tsupConfigFile: tsupProject.configFile
|
|
394
|
+
};
|
|
395
|
+
}
|
|
384
396
|
async function collectMigrationSetupPlan(rootDir, packageManager, options, packages, includeEslint = true) {
|
|
385
397
|
const shouldSetupHooks = await collectGitHooksDecision(rootDir, packageManager, options, packages);
|
|
386
398
|
const agentPlan = await collectAgentInstructionPlan(rootDir, options);
|
|
@@ -656,7 +668,8 @@ function hasExplicitExistingVitePlusSetupRequest(options) {
|
|
|
656
668
|
function hasExistingVitePlusMigrationCandidates(workspaceInfo, options) {
|
|
657
669
|
const eslintProject = detectEslintProject(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
658
670
|
const prettierProject = detectPrettierProject(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
659
|
-
|
|
671
|
+
const tsupProject = detectTsupProject(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
672
|
+
return hasExplicitExistingVitePlusSetupRequest(options) || detectLegacyGitHooksMigrationCandidate(workspaceInfo.rootDir) || hasBaseUrlInWorkspace(workspaceInfo) || eslintProject.hasDependency || prettierProject.hasDependency || tsupProject.hasDependency || detectNodeVersionManagerFile(workspaceInfo.rootDir) !== void 0 || getFrameworkShimCandidates(workspaceInfo.rootDir, workspaceInfo.packages).length > 0;
|
|
660
673
|
}
|
|
661
674
|
function getExistingVitePlusSetupOptions(options, useFullMigrationDefaults = false) {
|
|
662
675
|
if (useFullMigrationDefaults) return options;
|
|
@@ -675,6 +688,7 @@ async function collectMigrationPlan(rootDir, detectedPackageManager, detectedPac
|
|
|
675
688
|
let migratePrettier = false;
|
|
676
689
|
if (prettierProject.hasDependency && prettierProject.configFile) migratePrettier = await confirmPrettierMigration(options.interactive);
|
|
677
690
|
else if (prettierProject.hasDependency) warnPackageLevelPrettier();
|
|
691
|
+
const { migrateTsup, tsupConfigFile } = await collectTsupMigrationDecision(rootDir, options, packages);
|
|
678
692
|
const fixBaseUrl = hasBaseUrlInWorkspace({
|
|
679
693
|
rootDir,
|
|
680
694
|
packages
|
|
@@ -690,18 +704,14 @@ async function collectMigrationPlan(rootDir, detectedPackageManager, detectedPac
|
|
|
690
704
|
migratePrettier,
|
|
691
705
|
hasPrettierDependency: prettierProject.hasDependency,
|
|
692
706
|
prettierConfigFile: prettierProject.configFile,
|
|
707
|
+
migrateTsup,
|
|
708
|
+
tsupConfigFile,
|
|
693
709
|
fixBaseUrl,
|
|
694
710
|
migrateNodeVersionFile,
|
|
695
711
|
nodeVersionDetection,
|
|
696
712
|
frameworkShimFrameworks
|
|
697
713
|
};
|
|
698
714
|
}
|
|
699
|
-
function formatDuration(durationMs) {
|
|
700
|
-
if (durationMs < 1e3) return `${Math.max(1, durationMs)}ms`;
|
|
701
|
-
const durationSeconds = durationMs / 1e3;
|
|
702
|
-
if (durationSeconds < 10) return `${durationSeconds.toFixed(1)}s`;
|
|
703
|
-
return `${Math.round(durationSeconds)}s`;
|
|
704
|
-
}
|
|
705
715
|
/**
|
|
706
716
|
* Reconcile a CommandRunSummary from `runViteInstall` with the migration's
|
|
707
717
|
* duration counter and exit-code state. `runViteInstall` returns
|
|
@@ -751,6 +761,7 @@ function showMigrationSummary(options) {
|
|
|
751
761
|
if (report.preservedUpstreamVitestImportFileCount > 0) log(`${styleText("gray", "•")} Kept upstream \`vitest\` imports in ${report.preservedUpstreamVitestImportFileCount} ${report.preservedUpstreamVitestImportFileCount === 1 ? "file" : "files"} for @nuxt/test-utils compatibility`);
|
|
752
762
|
if (report.eslintMigrated) log(`${styleText("gray", "•")} ESLint rules migrated to Oxlint`);
|
|
753
763
|
if (report.prettierMigrated) log(`${styleText("gray", "•")} Prettier migrated to Oxfmt`);
|
|
764
|
+
if (report.tsupMigrated) log(`${styleText("gray", "•")} tsup config migrated to tsdown (\`vp pack\`)`);
|
|
754
765
|
if (report.nodeVersionFileMigrated) log(`${styleText("gray", "•")} Node version manager file migrated to .node-version`);
|
|
755
766
|
if (report.wrappedPluginConfigCount > 0) log(`${styleText("gray", "•")} Inline Vite plugins wrapped with lazyPlugins for check/lint/fmt`);
|
|
756
767
|
if (report.gitHooksConfigured) log(`${styleText("gray", "•")} Git hooks configured`);
|
|
@@ -866,6 +877,16 @@ async function executeMigrationPlan(workspaceInfoOptional, plan, interactive, pr
|
|
|
866
877
|
cancelAndExit("Prettier migration failed. Fix the issue and re-run `vp migrate`.", 1);
|
|
867
878
|
}
|
|
868
879
|
}
|
|
880
|
+
if (plan.migrateTsup) {
|
|
881
|
+
updateMigrationProgress("Migrating tsup");
|
|
882
|
+
if (!await migrateTsupToTsdown(workspaceInfo.rootDir, interactive, plan.packageManager, plan.tsupConfigFile, workspaceInfo.packages, {
|
|
883
|
+
silent: true,
|
|
884
|
+
report
|
|
885
|
+
})) {
|
|
886
|
+
failMigrationProgress("Migration failed");
|
|
887
|
+
cancelAndExit("Complete the tsup migration manually, then re-run `vp migrate`.", 1);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
869
890
|
const skipStagedMigration = shouldSkipStagedMigrationForHooks(workspaceInfo.rootDir, plan.shouldSetupHooks, plan.packageManager, workspaceInfo.packages);
|
|
870
891
|
updateMigrationProgress("Rewriting configs");
|
|
871
892
|
if (workspaceInfo.isMonorepo) rewriteMonorepo(workspaceInfo, skipStagedMigration, true, report);
|
|
@@ -888,7 +909,8 @@ async function executeMigrationPlan(workspaceInfoOptional, plan, interactive, pr
|
|
|
888
909
|
editorId: plan.selectedEditor,
|
|
889
910
|
interactive,
|
|
890
911
|
conflictDecisions: plan.editorConflictDecisions,
|
|
891
|
-
silent: true
|
|
912
|
+
silent: true,
|
|
913
|
+
packageManager: plan.packageManager
|
|
892
914
|
});
|
|
893
915
|
addFrameworkShimsForWorkspace(workspaceInfo.rootDir, plan.frameworkShimFrameworks, workspaceInfo.packages, report, updateMigrationProgress);
|
|
894
916
|
const installArgs = plan.packageManager === PackageManager.npm || plan.packageManager === PackageManager.bun ? ["--force"] : ["--no-frozen-lockfile"];
|
|
@@ -921,6 +943,7 @@ async function main() {
|
|
|
921
943
|
}
|
|
922
944
|
printHeader();
|
|
923
945
|
const workspaceInfoOptional = await detectWorkspace(projectPath);
|
|
946
|
+
if (workspaceInfoOptional.isMonorepo && path.resolve(projectPath) !== path.resolve(workspaceInfoOptional.rootDir)) cancelAndExit(`Vite+ cannot migrate a workspace member. Run \`vp migrate\` from the workspace root at ${workspaceInfoOptional.rootDir}.`, 1);
|
|
924
947
|
const initialChangedPaths = await collectChangedFormatPaths(workspaceInfoOptional.rootDir);
|
|
925
948
|
const preExistingChangedPaths = initialChangedPaths ? new Set(initialChangedPaths) : void 0;
|
|
926
949
|
const resolvedPackageManager = workspaceInfoOptional.packageManager ?? "unknown";
|
|
@@ -1053,6 +1076,23 @@ async function main() {
|
|
|
1053
1076
|
}
|
|
1054
1077
|
} else if (prettierProject.hasDependency) warnPackageLevelPrettier();
|
|
1055
1078
|
}
|
|
1079
|
+
let tsupMigrated = false;
|
|
1080
|
+
if (fullSetup) {
|
|
1081
|
+
if (options.interactive) clearMigrationProgress();
|
|
1082
|
+
const { migrateTsup, tsupConfigFile } = await collectTsupMigrationDecision(workspaceInfoOptional.rootDir, setupOptions, workspaceInfoOptional.packages);
|
|
1083
|
+
if (migrateTsup) {
|
|
1084
|
+
await ensureExistingPackageManager();
|
|
1085
|
+
updateMigrationProgress("Migrating tsup");
|
|
1086
|
+
if (!await migrateTsupToTsdown(workspaceInfoOptional.rootDir, options.interactive, packageManager, tsupConfigFile, workspaceInfoOptional.packages, {
|
|
1087
|
+
silent: true,
|
|
1088
|
+
report
|
|
1089
|
+
})) {
|
|
1090
|
+
clearMigrationProgress();
|
|
1091
|
+
cancelAndExit("Complete the tsup migration manually, then re-run `vp migrate`.", 1);
|
|
1092
|
+
}
|
|
1093
|
+
tsupMigrated = true;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1056
1096
|
if (fullSetup) {
|
|
1057
1097
|
const nodeVersionDetection = detectNodeVersionManagerFile(workspaceInfoOptional.rootDir);
|
|
1058
1098
|
if (nodeVersionDetection) {
|
|
@@ -1070,13 +1110,18 @@ async function main() {
|
|
|
1070
1110
|
}
|
|
1071
1111
|
}
|
|
1072
1112
|
if (addFrameworkShimsForWorkspace(workspaceInfoOptional.rootDir, frameworkShimFrameworks, workspaceInfoOptional.packages, report, updateMigrationProgress)) didMigrate = true;
|
|
1073
|
-
if (eslintMigrated || prettierMigrated) {
|
|
1113
|
+
if (eslintMigrated || prettierMigrated || tsupMigrated) {
|
|
1074
1114
|
updateMigrationProgress("Rewriting configs");
|
|
1075
1115
|
mergeViteConfigFiles(workspaceInfoOptional.rootDir, true, report, workspaceInfoOptional.packages);
|
|
1116
|
+
if (tsupMigrated) {
|
|
1117
|
+
mergeTsdownConfigFile(workspaceInfoOptional.rootDir, true, report);
|
|
1118
|
+
for (const pkg of workspaceInfoOptional.packages ?? []) mergeTsdownConfigFile(path.join(workspaceInfoOptional.rootDir, pkg.path), true, report);
|
|
1119
|
+
}
|
|
1076
1120
|
needsInstall = true;
|
|
1077
1121
|
didMigrate = true;
|
|
1078
1122
|
report.eslintMigrated = eslintMigrated;
|
|
1079
1123
|
report.prettierMigrated = prettierMigrated;
|
|
1124
|
+
report.tsupMigrated = tsupMigrated;
|
|
1080
1125
|
}
|
|
1081
1126
|
if (plan.shouldSetupHooks) {
|
|
1082
1127
|
await ensureExistingPackageManager();
|
|
@@ -1122,7 +1167,8 @@ async function main() {
|
|
|
1122
1167
|
editorId: plan.selectedEditor,
|
|
1123
1168
|
interactive: options.interactive,
|
|
1124
1169
|
conflictDecisions: plan.editorConflictDecisions,
|
|
1125
|
-
silent: true
|
|
1170
|
+
silent: true,
|
|
1171
|
+
packageManager
|
|
1126
1172
|
});
|
|
1127
1173
|
didMigrate = true;
|
|
1128
1174
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as addMigrationWarning, r as createMigrationReport } from "../../report-
|
|
1
|
+
import { n as addMigrationWarning, r as createMigrationReport } from "../../report-ZNR1Mk6h.js";
|
|
2
2
|
import { t as ROLLDOWN_COMPAT_RESULT_PREFIX } from "../../protocol-D99W10Qi.js";
|
|
3
3
|
import { writeSync } from "node:fs";
|
|
4
4
|
//#region src/migration/compat/manual-chunks.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { u as VITE_PLUS_NAME } from "./constants-Bn-U8o4v.js";
|
|
2
2
|
//#region src/oxlint-plugin-config.ts
|
|
3
3
|
const VITE_PLUS_OXLINT_PLUGIN_NAME = VITE_PLUS_NAME;
|
|
4
4
|
const VITE_PLUS_OXLINT_PLUGIN_SPECIFIER = `${VITE_PLUS_NAME}/oxlint-plugin`;
|
package/dist/oxlint-plugin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as VITE_PLUS_OXLINT_PLUGIN_NAME, t as PREFER_VITE_PLUS_IMPORTS_RULE_NAME } from "./oxlint-plugin-config-
|
|
1
|
+
import { n as VITE_PLUS_OXLINT_PLUGIN_NAME, t as PREFER_VITE_PLUS_IMPORTS_RULE_NAME } from "./oxlint-plugin-config-DX5ezKbB.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { definePlugin, defineRule } from "@oxlint/plugins";
|
package/dist/pack-bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as resolveViteConfig } from "./resolve-vite-config-
|
|
2
|
+
import { a as resolveViteConfig } from "./resolve-vite-config-ipGb39Jo.js";
|
|
3
3
|
import module from "node:module";
|
|
4
4
|
import { buildWithConfigs, enableDebug, globalLogger, resolveUserConfig } from "@voidzero-dev/vite-plus-core/pack";
|
|
5
5
|
//#region ../../node_modules/.pnpm/cac@7.0.0/node_modules/cac/dist/index.js
|
|
@@ -684,11 +684,11 @@ cli.command("[...files]", "Bundle files", {
|
|
|
684
684
|
if (input.length > 0) flags.entry = input;
|
|
685
685
|
if (flags.envPrefix === void 0) flags.envPrefix = DEFAULT_ENV_PREFIXES;
|
|
686
686
|
async function runBuild() {
|
|
687
|
-
const viteConfig = await resolveViteConfig(process.cwd(), { traverseUp:
|
|
687
|
+
const viteConfig = flags.config === false ? void 0 : await resolveViteConfig(process.cwd(), { traverseUp: true });
|
|
688
688
|
const configDeps = /* @__PURE__ */ new Set();
|
|
689
|
-
if (viteConfig
|
|
689
|
+
if (viteConfig?.configFile) configDeps.add(viteConfig.configFile);
|
|
690
690
|
const configs = [];
|
|
691
|
-
const packConfigs = Array.isArray(viteConfig
|
|
691
|
+
const packConfigs = Array.isArray(viteConfig?.pack) ? viteConfig.pack : [viteConfig?.pack ?? {}];
|
|
692
692
|
for (const packConfig of packConfigs) {
|
|
693
693
|
const merged = {
|
|
694
694
|
...packConfig,
|
|
@@ -696,6 +696,7 @@ cli.command("[...files]", "Bundle files", {
|
|
|
696
696
|
};
|
|
697
697
|
if (merged.dts) merged.plugins = [...Array.isArray(merged.plugins) ? merged.plugins : [], externalDtsTypeOnlyPlugin()];
|
|
698
698
|
const resolvedConfig = await resolveUserConfig(merged, flags, configDeps);
|
|
699
|
+
resolvedConfig.forEach((config) => config.configDeps.forEach((dep) => configDeps.add(dep)));
|
|
699
700
|
configs.push(...resolvedConfig);
|
|
700
701
|
}
|
|
701
702
|
await buildWithConfigs(configs, configDeps, runBuild);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./constants-
|
|
2
|
-
import { i as readJsonFile } from "./json-
|
|
1
|
+
import "./constants-Bn-U8o4v.js";
|
|
2
|
+
import { i as readJsonFile } from "./json-cULBl7Pi.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import fs from "node:fs";
|