vite-plus 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding/index.cjs +2 -0
- package/binding/index.d.cts +32 -0
- package/dist/global/{prompts-CAIahN1u.js → agent-BE4Xze8Q.js} +380 -1280
- package/dist/global/{browser-CY4NBwxR.js → browser-CBapUTD0.js} +579 -1023
- package/dist/global/{browser-DFpJ6sKb.js → browser-EZnNDcaO.js} +2 -3
- package/dist/global/{chunk-CtfvYSle.js → chunk-CgnkrU7a.js} +13 -22
- package/dist/global/{cli-truncate-BxinOqz5.js → cli-truncate-Da6Y8aM8.js} +25 -74
- package/dist/global/config.js +95 -165
- package/dist/global/create.js +353 -496
- package/dist/global/{terminal-Cb-NuRkb.js → help-BAGHa8fD.js} +22 -54
- package/dist/global/{json-Bfvtp2rL.js → json-BRdVJ52a.js} +24 -58
- package/dist/global/{lib-CibYHP32.js → lib-DxappLRQ.js} +19 -43
- package/dist/global/{log-update-DdU6_LCN.js → log-update-C8WCYCbc.js} +102 -281
- package/dist/global/mcp.js +97 -169
- package/dist/global/migrate.js +223 -72
- package/dist/global/{package-Pq2biU7_.js → package-YAMvX5PJ.js} +6 -13
- package/dist/global/{slice-ansi-BhwAwMdF.js → slice-ansi-Fap0ehe9.js} +21 -52
- package/dist/global/{src-C6aLHRsS.js → src-DwSJ0s0I.js} +28 -110
- package/dist/global/staged.js +654 -1521
- package/dist/global/{strip-ansi-BL-dgd7n.js → strip-ansi-CE-VDMdw.js} +20 -67
- package/dist/global/version.js +16 -37
- package/dist/global/{workspace-De4OKHV7.js → workspace-lRm8huz4.js} +1645 -2806
- package/dist/global/wrap-ansi-Ou9oAs-a.js +3 -0
- package/dist/global/{wrap-ansi-Iww6Ak1s.js → wrap-ansi-eywLlPVQ.js} +29 -80
- package/dist/index.d.ts +1 -1
- package/dist/init-config.js +10 -2
- package/dist/run-config.d.ts +17 -0
- package/dist/utils/agent.d.ts +15 -1
- package/dist/utils/agent.js +104 -20
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +2 -0
- package/dist/utils/editor.d.ts +16 -3
- package/dist/utils/editor.js +55 -17
- package/dist/utils/prompts.d.ts +32 -3
- package/dist/utils/prompts.js +32 -8
- package/dist/utils/skills.js +18 -2
- package/dist/utils/tsconfig.d.ts +6 -0
- package/dist/utils/tsconfig.js +16 -0
- package/package.json +13 -13
- package/templates/monorepo/package.json +1 -1
- package/dist/global/wrap-ansi-BJxjUEQR.js +0 -4
- package/dist/oxlint-config.d.ts +0 -498
- package/dist/oxlint-config.js +0 -309
package/dist/global/migrate.js
CHANGED
|
@@ -1,22 +1,80 @@
|
|
|
1
|
-
import { i as __toESM } from "./chunk-
|
|
2
|
-
import {
|
|
3
|
-
import { t as lib_default } from "./lib-
|
|
4
|
-
import { a as
|
|
5
|
-
import "./browser-
|
|
6
|
-
import "./json-
|
|
7
|
-
import { i as readNearestPackageJson, r as hasVitePlusDependency } from "./package-
|
|
8
|
-
import {
|
|
1
|
+
import { i as __toESM } from "./chunk-CgnkrU7a.js";
|
|
2
|
+
import { A as select, E as log, M as Ct, S as PackageManager, T as intro, a as selectAgentTargetPaths, c as defaultInteractive, d as promptGitHooks, h as upgradeYarn, k as outro, l as downloadPackageManager$1, m as selectPackageManager, o as writeAgentInstructions, p as runViteInstall, s as cancelAndExit, t as detectAgentConflicts, w as confirm } from "./agent-BE4Xze8Q.js";
|
|
3
|
+
import { t as lib_default } from "./lib-DxappLRQ.js";
|
|
4
|
+
import { _ as preflightGitHooksSetup, a as detectEditorConflicts, b as rewriteStandaloneProject, c as writeEditorConfigs, d as detectEslintProject, f as detectPrettierProject, g as migratePrettierToOxfmt, h as migrateEslintToOxlint, i as EDITORS, l as checkViteVersion, m as mergeViteConfigFiles, p as installGitHooks, s as selectEditor, t as detectWorkspace$1, u as checkVitestVersion, v as rewriteMonorepo, x as require_semver } from "./workspace-lRm8huz4.js";
|
|
5
|
+
import "./browser-CBapUTD0.js";
|
|
6
|
+
import "./json-BRdVJ52a.js";
|
|
7
|
+
import { i as readNearestPackageJson, r as hasVitePlusDependency } from "./package-YAMvX5PJ.js";
|
|
8
|
+
import { i as muted, n as accent, r as log$1, t as renderCliDoc } from "./help-BAGHa8fD.js";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { styleText } from "node:util";
|
|
11
11
|
import colors from "picocolors";
|
|
12
12
|
import { vitePlusHeader } from "../../binding/index.js";
|
|
13
|
-
|
|
14
13
|
//#region src/migration/bin.ts
|
|
15
14
|
var import_semver = /* @__PURE__ */ __toESM(require_semver(), 1);
|
|
16
15
|
const { green } = colors;
|
|
16
|
+
function warnPackageLevelEslint() {
|
|
17
|
+
log.warn("ESLint detected in workspace packages but no root config found. Package-level ESLint must be migrated manually.");
|
|
18
|
+
}
|
|
19
|
+
function warnLegacyEslintConfig(legacyConfigFile) {
|
|
20
|
+
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`);
|
|
21
|
+
}
|
|
22
|
+
async function confirmEslintMigration(interactive) {
|
|
23
|
+
if (interactive) {
|
|
24
|
+
const confirmed = await confirm({
|
|
25
|
+
message: "Migrate ESLint rules to Oxlint using @oxlint/migrate?",
|
|
26
|
+
initialValue: true
|
|
27
|
+
});
|
|
28
|
+
if (Ct(confirmed)) cancelAndExit();
|
|
29
|
+
return !!confirmed;
|
|
30
|
+
}
|
|
31
|
+
log.info("ESLint configuration detected. Auto-migrating to Oxlint...");
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
async function promptEslintMigration(projectPath, interactive, packages) {
|
|
35
|
+
const eslintProject = detectEslintProject(projectPath, packages);
|
|
36
|
+
if (eslintProject.hasDependency && !eslintProject.configFile && eslintProject.legacyConfigFile) {
|
|
37
|
+
warnLegacyEslintConfig(eslintProject.legacyConfigFile);
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (!eslintProject.hasDependency) return false;
|
|
41
|
+
if (!eslintProject.configFile) {
|
|
42
|
+
warnPackageLevelEslint();
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (!await confirmEslintMigration(interactive)) return false;
|
|
46
|
+
if (!await migrateEslintToOxlint(projectPath, interactive, eslintProject.configFile, packages)) cancelAndExit("ESLint migration failed. Fix the issue and re-run `vp migrate`.", 1);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
function warnPackageLevelPrettier() {
|
|
50
|
+
log.warn("Prettier detected in workspace packages but no root config found. Package-level Prettier must be migrated manually.");
|
|
51
|
+
}
|
|
52
|
+
async function confirmPrettierMigration(interactive) {
|
|
53
|
+
if (interactive) {
|
|
54
|
+
const confirmed = await confirm({
|
|
55
|
+
message: "Migrate Prettier to Oxfmt?",
|
|
56
|
+
initialValue: true
|
|
57
|
+
});
|
|
58
|
+
if (Ct(confirmed)) cancelAndExit();
|
|
59
|
+
return !!confirmed;
|
|
60
|
+
}
|
|
61
|
+
log.info("Prettier configuration detected. Auto-migrating to Oxfmt...");
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
async function promptPrettierMigration(projectPath, interactive, packages) {
|
|
65
|
+
const prettierProject = detectPrettierProject(projectPath, packages);
|
|
66
|
+
if (!prettierProject.hasDependency) return false;
|
|
67
|
+
if (!prettierProject.configFile) {
|
|
68
|
+
warnPackageLevelPrettier();
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if (!await confirmPrettierMigration(interactive)) return false;
|
|
72
|
+
if (!await migratePrettierToOxfmt(projectPath, interactive, prettierProject.configFile, packages)) cancelAndExit("Prettier migration failed. Fix the issue and re-run `vp migrate`.", 1);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
17
75
|
const helpMessage = renderCliDoc({
|
|
18
76
|
usage: "vp migrate [PATH] [OPTIONS]",
|
|
19
|
-
summary: "Migrate standalone Vite, Vitest, Oxlint, and
|
|
77
|
+
summary: "Migrate standalone Vite, Vitest, Oxlint, Oxfmt, and Prettier projects to unified Vite+.",
|
|
20
78
|
sections: [
|
|
21
79
|
{
|
|
22
80
|
title: "Arguments",
|
|
@@ -78,8 +136,7 @@ const helpMessage = renderCliDoc({
|
|
|
78
136
|
]
|
|
79
137
|
});
|
|
80
138
|
function parseArgs() {
|
|
81
|
-
const
|
|
82
|
-
const parsed = lib_default(args, {
|
|
139
|
+
const parsed = lib_default(process.argv.slice(3), {
|
|
83
140
|
alias: { h: "help" },
|
|
84
141
|
boolean: [
|
|
85
142
|
"help",
|
|
@@ -90,11 +147,8 @@ function parseArgs() {
|
|
|
90
147
|
});
|
|
91
148
|
const interactive = parsed.interactive;
|
|
92
149
|
let projectPath = parsed._[0];
|
|
93
|
-
if (projectPath)
|
|
94
|
-
|
|
95
|
-
} else {
|
|
96
|
-
projectPath = process.cwd();
|
|
97
|
-
}
|
|
150
|
+
if (projectPath) projectPath = path.resolve(process.cwd(), projectPath);
|
|
151
|
+
else projectPath = process.cwd();
|
|
98
152
|
return {
|
|
99
153
|
projectPath,
|
|
100
154
|
options: {
|
|
@@ -106,101 +160,198 @@ function parseArgs() {
|
|
|
106
160
|
}
|
|
107
161
|
};
|
|
108
162
|
}
|
|
109
|
-
async function
|
|
110
|
-
const { projectPath, options } = parseArgs();
|
|
111
|
-
if (options.help) {
|
|
112
|
-
log$1(vitePlusHeader() + "\n");
|
|
113
|
-
log$1(helpMessage);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
intro(vitePlusHeader());
|
|
117
|
-
const workspaceInfoOptional = await detectWorkspace$1(projectPath);
|
|
118
|
-
if (hasVitePlusDependency(readNearestPackageJson(workspaceInfoOptional.rootDir))) {
|
|
119
|
-
outro(`This project is already using Vite+! ${accent(`Happy coding!`)}`);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
163
|
+
async function collectMigrationPlan(rootDir, detectedPackageManager, options, packages) {
|
|
122
164
|
if (options.interactive) {
|
|
123
|
-
log.info([
|
|
124
|
-
styleText("bold", "Migration plan:"),
|
|
125
|
-
"- Inspect workspace and package manager",
|
|
126
|
-
`- Run ${accent("vp install")} to prepare dependencies`,
|
|
127
|
-
"- Rewrite configs and dependencies for Vite+"
|
|
128
|
-
].join("\n") + "\n");
|
|
129
165
|
const approved = await confirm({
|
|
130
166
|
message: "Migrate this project to Vite+?",
|
|
131
167
|
initialValue: true
|
|
132
168
|
});
|
|
133
|
-
if (Ct(approved) || !approved)
|
|
134
|
-
cancelAndExit("Migration cancelled");
|
|
135
|
-
}
|
|
169
|
+
if (Ct(approved) || !approved) cancelAndExit("Migration cancelled");
|
|
136
170
|
}
|
|
137
|
-
const packageManager =
|
|
171
|
+
const packageManager = detectedPackageManager ?? await selectPackageManager(options.interactive);
|
|
138
172
|
let shouldSetupHooks = await promptGitHooks(options);
|
|
173
|
+
if (shouldSetupHooks) {
|
|
174
|
+
const reason = preflightGitHooksSetup(rootDir);
|
|
175
|
+
if (reason) {
|
|
176
|
+
log.warn(`⚠ ${reason}`);
|
|
177
|
+
shouldSetupHooks = false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
139
180
|
const selectedAgentTargetPaths = await selectAgentTargetPaths({
|
|
140
181
|
interactive: options.interactive,
|
|
141
182
|
agent: options.agent,
|
|
142
183
|
onCancel: () => cancelAndExit()
|
|
143
184
|
});
|
|
185
|
+
const agentConflicts = await detectAgentConflicts({
|
|
186
|
+
projectRoot: rootDir,
|
|
187
|
+
targetPaths: selectedAgentTargetPaths
|
|
188
|
+
});
|
|
189
|
+
const agentConflictDecisions = /* @__PURE__ */ new Map();
|
|
190
|
+
for (const conflict of agentConflicts) if (options.interactive) {
|
|
191
|
+
const action = await select({
|
|
192
|
+
message: `Agent instructions already exist at ${conflict.targetPath}.`,
|
|
193
|
+
options: [{
|
|
194
|
+
label: "Append",
|
|
195
|
+
value: "append",
|
|
196
|
+
hint: "Add template content to the end"
|
|
197
|
+
}, {
|
|
198
|
+
label: "Skip",
|
|
199
|
+
value: "skip",
|
|
200
|
+
hint: "Leave existing file unchanged"
|
|
201
|
+
}],
|
|
202
|
+
initialValue: "skip"
|
|
203
|
+
});
|
|
204
|
+
if (Ct(action)) cancelAndExit();
|
|
205
|
+
agentConflictDecisions.set(conflict.targetPath, action);
|
|
206
|
+
} else agentConflictDecisions.set(conflict.targetPath, "skip");
|
|
144
207
|
const selectedEditor = await selectEditor({
|
|
145
208
|
interactive: options.interactive,
|
|
146
209
|
editor: options.editor,
|
|
147
210
|
onCancel: () => cancelAndExit()
|
|
148
211
|
});
|
|
149
|
-
const
|
|
212
|
+
const editorConflicts = detectEditorConflicts({
|
|
213
|
+
projectRoot: rootDir,
|
|
214
|
+
editorId: selectedEditor
|
|
215
|
+
});
|
|
216
|
+
const editorConflictDecisions = /* @__PURE__ */ new Map();
|
|
217
|
+
for (const conflict of editorConflicts) if (options.interactive) {
|
|
218
|
+
const action = await select({
|
|
219
|
+
message: `${conflict.displayPath} already exists.`,
|
|
220
|
+
options: [{
|
|
221
|
+
label: "Merge",
|
|
222
|
+
value: "merge",
|
|
223
|
+
hint: "Merge new settings into existing file"
|
|
224
|
+
}, {
|
|
225
|
+
label: "Skip",
|
|
226
|
+
value: "skip",
|
|
227
|
+
hint: "Leave existing file unchanged"
|
|
228
|
+
}],
|
|
229
|
+
initialValue: "skip"
|
|
230
|
+
});
|
|
231
|
+
if (Ct(action)) cancelAndExit();
|
|
232
|
+
editorConflictDecisions.set(conflict.fileName, action);
|
|
233
|
+
} else editorConflictDecisions.set(conflict.fileName, "merge");
|
|
234
|
+
const eslintProject = detectEslintProject(rootDir, packages);
|
|
235
|
+
let migrateEslint = false;
|
|
236
|
+
if (eslintProject.hasDependency && !eslintProject.configFile && eslintProject.legacyConfigFile) warnLegacyEslintConfig(eslintProject.legacyConfigFile);
|
|
237
|
+
else if (eslintProject.hasDependency && eslintProject.configFile) migrateEslint = await confirmEslintMigration(options.interactive);
|
|
238
|
+
else if (eslintProject.hasDependency) warnPackageLevelEslint();
|
|
239
|
+
const prettierProject = detectPrettierProject(rootDir, packages);
|
|
240
|
+
let migratePrettier = false;
|
|
241
|
+
if (prettierProject.hasDependency && prettierProject.configFile) migratePrettier = await confirmPrettierMigration(options.interactive);
|
|
242
|
+
else if (prettierProject.hasDependency) warnPackageLevelPrettier();
|
|
243
|
+
const plan = {
|
|
244
|
+
packageManager,
|
|
245
|
+
shouldSetupHooks,
|
|
246
|
+
selectedAgentTargetPaths,
|
|
247
|
+
agentConflictDecisions,
|
|
248
|
+
selectedEditor,
|
|
249
|
+
editorConflictDecisions,
|
|
250
|
+
migrateEslint,
|
|
251
|
+
eslintConfigFile: eslintProject.configFile,
|
|
252
|
+
migratePrettier,
|
|
253
|
+
prettierConfigFile: prettierProject.configFile
|
|
254
|
+
};
|
|
255
|
+
if (options.interactive) displayMigrationSummary(plan);
|
|
256
|
+
return plan;
|
|
257
|
+
}
|
|
258
|
+
function displayMigrationSummary(plan) {
|
|
259
|
+
const lines = [`- Install ${plan.packageManager} and dependencies`, "- Rewrite configs and dependencies for Vite+"];
|
|
260
|
+
if (plan.migrateEslint) lines.push("- Migrate ESLint rules to Oxlint");
|
|
261
|
+
if (plan.migratePrettier) lines.push("- Migrate Prettier to Oxfmt");
|
|
262
|
+
if (plan.shouldSetupHooks) lines.push("- Set up pre-commit hooks");
|
|
263
|
+
if (plan.selectedAgentTargetPaths && plan.selectedAgentTargetPaths.length > 0) {
|
|
264
|
+
const parts = plan.selectedAgentTargetPaths.map((tp) => {
|
|
265
|
+
const action = plan.agentConflictDecisions.get(tp);
|
|
266
|
+
return action ? `${tp}, ${action}` : tp;
|
|
267
|
+
});
|
|
268
|
+
lines.push(`- Write agent instructions (${parts.join("; ")})`);
|
|
269
|
+
}
|
|
270
|
+
if (plan.selectedEditor) {
|
|
271
|
+
const targetDir = EDITORS.find((e) => e.id === plan.selectedEditor)?.targetDir ?? plan.selectedEditor;
|
|
272
|
+
const decisions = [...plan.editorConflictDecisions.values()];
|
|
273
|
+
const uniqueActions = [...new Set(decisions)];
|
|
274
|
+
const actionStr = uniqueActions.length > 0 ? `, ${uniqueActions.join("/")}` : "";
|
|
275
|
+
lines.push(`- Write editor config (${targetDir}/${actionStr})`);
|
|
276
|
+
}
|
|
277
|
+
log.info([styleText("bold", "Migration plan:"), ...lines].join("\n") + "\n");
|
|
278
|
+
}
|
|
279
|
+
async function executeMigrationPlan(workspaceInfoOptional, plan, interactive) {
|
|
280
|
+
const downloadResult = await downloadPackageManager$1(plan.packageManager, workspaceInfoOptional.packageManagerVersion, interactive);
|
|
150
281
|
const workspaceInfo = {
|
|
151
282
|
...workspaceInfoOptional,
|
|
152
|
-
packageManager,
|
|
283
|
+
packageManager: plan.packageManager,
|
|
153
284
|
downloadPackageManager: downloadResult
|
|
154
285
|
};
|
|
155
|
-
if (packageManager === PackageManager.yarn && import_semver.default.satisfies(downloadResult.version, ">=4.0.0 <4.10.0"))
|
|
156
|
-
|
|
157
|
-
} else if (packageManager === PackageManager.pnpm && import_semver.default.satisfies(downloadResult.version, "< 9.5.0")) {
|
|
286
|
+
if (plan.packageManager === PackageManager.yarn && import_semver.default.satisfies(downloadResult.version, ">=4.0.0 <4.10.0")) await upgradeYarn(workspaceInfo.rootDir, interactive);
|
|
287
|
+
else if (plan.packageManager === PackageManager.pnpm && import_semver.default.satisfies(downloadResult.version, "< 9.5.0")) {
|
|
158
288
|
log.error(`✘ pnpm@${downloadResult.version} is not supported by auto migration, please upgrade pnpm to >=9.5.0 first`);
|
|
159
289
|
cancelAndExit("Vite+ cannot automatically migrate this project yet.", 1);
|
|
160
|
-
} else if (packageManager === PackageManager.npm && import_semver.default.satisfies(downloadResult.version, "< 8.3.0")) {
|
|
290
|
+
} else if (plan.packageManager === PackageManager.npm && import_semver.default.satisfies(downloadResult.version, "< 8.3.0")) {
|
|
161
291
|
log.error(`✘ npm@${downloadResult.version} is not supported by auto migration, please upgrade npm to >=8.3.0 first`);
|
|
162
292
|
cancelAndExit("Vite+ cannot automatically migrate this project yet.", 1);
|
|
163
293
|
}
|
|
164
|
-
await runViteInstall(workspaceInfo.rootDir,
|
|
294
|
+
await runViteInstall(workspaceInfo.rootDir, interactive);
|
|
165
295
|
const isViteSupported = checkViteVersion(workspaceInfo.rootDir);
|
|
166
296
|
const isVitestSupported = checkVitestVersion(workspaceInfo.rootDir);
|
|
167
|
-
if (!isViteSupported || !isVitestSupported)
|
|
168
|
-
|
|
297
|
+
if (!isViteSupported || !isVitestSupported) cancelAndExit("Vite+ cannot automatically migrate this project yet.", 1);
|
|
298
|
+
if (plan.migrateEslint) {
|
|
299
|
+
if (!await migrateEslintToOxlint(workspaceInfo.rootDir, interactive, plan.eslintConfigFile, workspaceInfo.packages)) cancelAndExit("ESLint migration failed. Fix the issue and re-run `vp migrate`.", 1);
|
|
169
300
|
}
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
if (reason) {
|
|
173
|
-
log.warn(`⚠ ${reason}`);
|
|
174
|
-
shouldSetupHooks = false;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
const skipStagedMigration = !shouldSetupHooks;
|
|
178
|
-
if (workspaceInfo.isMonorepo) {
|
|
179
|
-
rewriteMonorepo(workspaceInfo, skipStagedMigration);
|
|
180
|
-
} else {
|
|
181
|
-
rewriteStandaloneProject(workspaceInfo.rootDir, workspaceInfo, skipStagedMigration);
|
|
182
|
-
}
|
|
183
|
-
if (shouldSetupHooks) {
|
|
184
|
-
installGitHooks(workspaceInfo.rootDir);
|
|
301
|
+
if (plan.migratePrettier) {
|
|
302
|
+
if (!await migratePrettierToOxfmt(workspaceInfo.rootDir, interactive, plan.prettierConfigFile, workspaceInfo.packages)) cancelAndExit("Prettier migration failed. Fix the issue and re-run `vp migrate`.", 1);
|
|
185
303
|
}
|
|
304
|
+
const skipStagedMigration = !plan.shouldSetupHooks;
|
|
305
|
+
if (workspaceInfo.isMonorepo) rewriteMonorepo(workspaceInfo, skipStagedMigration);
|
|
306
|
+
else rewriteStandaloneProject(workspaceInfo.rootDir, workspaceInfo, skipStagedMigration);
|
|
307
|
+
if (plan.shouldSetupHooks) installGitHooks(workspaceInfo.rootDir);
|
|
186
308
|
await writeAgentInstructions({
|
|
187
309
|
projectRoot: workspaceInfo.rootDir,
|
|
188
|
-
targetPaths: selectedAgentTargetPaths,
|
|
189
|
-
interactive
|
|
310
|
+
targetPaths: plan.selectedAgentTargetPaths,
|
|
311
|
+
interactive,
|
|
312
|
+
conflictDecisions: plan.agentConflictDecisions
|
|
190
313
|
});
|
|
191
314
|
await writeEditorConfigs({
|
|
192
315
|
projectRoot: workspaceInfo.rootDir,
|
|
193
|
-
editorId: selectedEditor,
|
|
194
|
-
interactive
|
|
316
|
+
editorId: plan.selectedEditor,
|
|
317
|
+
interactive,
|
|
318
|
+
conflictDecisions: plan.editorConflictDecisions
|
|
195
319
|
});
|
|
196
|
-
const installArgs = packageManager === PackageManager.npm ? ["--force"] :
|
|
197
|
-
await runViteInstall(workspaceInfo.rootDir,
|
|
320
|
+
const installArgs = plan.packageManager === PackageManager.npm ? ["--force"] : void 0;
|
|
321
|
+
await runViteInstall(workspaceInfo.rootDir, interactive, installArgs);
|
|
198
322
|
outro(green("✔ Migration completed!"));
|
|
199
323
|
}
|
|
324
|
+
async function main() {
|
|
325
|
+
const { projectPath, options } = parseArgs();
|
|
326
|
+
if (options.help) {
|
|
327
|
+
log$1(vitePlusHeader() + "\n");
|
|
328
|
+
log$1(helpMessage);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
intro(vitePlusHeader());
|
|
332
|
+
const workspaceInfoOptional = await detectWorkspace$1(projectPath);
|
|
333
|
+
const rootPkg = readNearestPackageJson(workspaceInfoOptional.rootDir);
|
|
334
|
+
if (hasVitePlusDependency(rootPkg)) {
|
|
335
|
+
let didMigrate = false;
|
|
336
|
+
const eslintMigrated = await promptEslintMigration(workspaceInfoOptional.rootDir, options.interactive, workspaceInfoOptional.packages);
|
|
337
|
+
const prettierMigrated = await promptPrettierMigration(workspaceInfoOptional.rootDir, options.interactive, workspaceInfoOptional.packages);
|
|
338
|
+
if (eslintMigrated || prettierMigrated) {
|
|
339
|
+
mergeViteConfigFiles(workspaceInfoOptional.rootDir);
|
|
340
|
+
await runViteInstall(workspaceInfoOptional.rootDir, options.interactive);
|
|
341
|
+
didMigrate = true;
|
|
342
|
+
}
|
|
343
|
+
if (rootPkg?.devDependencies?.husky || rootPkg?.dependencies?.husky || rootPkg?.devDependencies?.["lint-staged"] || rootPkg?.dependencies?.["lint-staged"]) {
|
|
344
|
+
if (await promptGitHooks(options) && installGitHooks(workspaceInfoOptional.rootDir)) didMigrate = true;
|
|
345
|
+
}
|
|
346
|
+
if (didMigrate) outro(green("✔ Migration completed!"));
|
|
347
|
+
else outro(`This project is already using Vite+! ${accent(`Happy coding!`)}`);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
await executeMigrationPlan(workspaceInfoOptional, await collectMigrationPlan(workspaceInfoOptional.rootDir, workspaceInfoOptional.packageManager, options, workspaceInfoOptional.packages), options.interactive);
|
|
351
|
+
}
|
|
200
352
|
main().catch((err) => {
|
|
201
353
|
log.error(err.message);
|
|
202
354
|
console.error(err);
|
|
203
355
|
process.exit(1);
|
|
204
356
|
});
|
|
205
|
-
|
|
206
|
-
//#endregion
|
|
357
|
+
//#endregion
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as readJsonFile } from "./json-BRdVJ52a.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
|
-
|
|
6
5
|
//#region src/utils/package.ts
|
|
7
6
|
function getScopeFromPackageName(packageName) {
|
|
8
|
-
if (packageName.startsWith("@"))
|
|
9
|
-
return packageName.split("/")[0];
|
|
10
|
-
}
|
|
7
|
+
if (packageName.startsWith("@")) return packageName.split("/")[0];
|
|
11
8
|
return "";
|
|
12
9
|
}
|
|
13
10
|
function detectPackageMetadata(projectPath, packageName) {
|
|
14
11
|
try {
|
|
15
|
-
const
|
|
16
|
-
const pkgFilePath = require.resolve(`${packageName}/package.json`);
|
|
12
|
+
const pkgFilePath = createRequire(path.join(projectPath, "noop.js")).resolve(`${packageName}/package.json`);
|
|
17
13
|
const pkg = JSON.parse(fs.readFileSync(pkgFilePath, "utf8"));
|
|
18
14
|
return {
|
|
19
15
|
name: pkg.name,
|
|
@@ -32,16 +28,13 @@ function detectPackageMetadata(projectPath, packageName) {
|
|
|
32
28
|
function readNearestPackageJson(currentDir) {
|
|
33
29
|
do {
|
|
34
30
|
const packageJsonPath = path.join(currentDir, "package.json");
|
|
35
|
-
if (fs.existsSync(packageJsonPath))
|
|
36
|
-
return readJsonFile(packageJsonPath);
|
|
37
|
-
}
|
|
31
|
+
if (fs.existsSync(packageJsonPath)) return readJsonFile(packageJsonPath);
|
|
38
32
|
currentDir = path.dirname(currentDir);
|
|
39
33
|
} while (currentDir !== path.dirname(currentDir));
|
|
40
34
|
return null;
|
|
41
35
|
}
|
|
42
36
|
function hasVitePlusDependency(pkg) {
|
|
43
|
-
return Boolean(pkg?.dependencies?.[
|
|
37
|
+
return Boolean(pkg?.dependencies?.["vite-plus"] || pkg?.devDependencies?.["vite-plus"]);
|
|
44
38
|
}
|
|
45
|
-
|
|
46
39
|
//#endregion
|
|
47
|
-
export { readNearestPackageJson as i, getScopeFromPackageName as n, hasVitePlusDependency as r, detectPackageMetadata as t };
|
|
40
|
+
export { readNearestPackageJson as i, getScopeFromPackageName as n, hasVitePlusDependency as r, detectPackageMetadata as t };
|
|
@@ -1,48 +1,34 @@
|
|
|
1
|
-
import { a as ansiStyles, i as isWide, r as isFullWidth } from "./strip-ansi-
|
|
2
|
-
|
|
1
|
+
import { a as ansiStyles, i as isWide, r as isFullWidth } from "./strip-ansi-CE-VDMdw.js";
|
|
3
2
|
//#region ../../node_modules/.pnpm/is-fullwidth-code-point@5.1.0/node_modules/is-fullwidth-code-point/index.js
|
|
4
3
|
function isFullwidthCodePoint(codePoint) {
|
|
5
|
-
if (!Number.isInteger(codePoint))
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
4
|
+
if (!Number.isInteger(codePoint)) return false;
|
|
8
5
|
return isFullWidth(codePoint) || isWide(codePoint);
|
|
9
6
|
}
|
|
10
|
-
|
|
11
7
|
//#endregion
|
|
12
8
|
//#region ../../node_modules/.pnpm/slice-ansi@7.1.2/node_modules/slice-ansi/index.js
|
|
13
9
|
const ESCAPES = new Set([27, 155]);
|
|
14
10
|
const CODE_POINT_0 = "0".codePointAt(0);
|
|
15
11
|
const CODE_POINT_9 = "9".codePointAt(0);
|
|
16
12
|
const MAX_ANSI_SEQUENCE_LENGTH = 19;
|
|
17
|
-
const endCodesSet = new Set();
|
|
18
|
-
const endCodesMap = new Map();
|
|
13
|
+
const endCodesSet = /* @__PURE__ */ new Set();
|
|
14
|
+
const endCodesMap = /* @__PURE__ */ new Map();
|
|
19
15
|
for (const [start, end] of ansiStyles.codes) {
|
|
20
16
|
endCodesSet.add(ansiStyles.color.ansi(end));
|
|
21
17
|
endCodesMap.set(ansiStyles.color.ansi(start), ansiStyles.color.ansi(end));
|
|
22
18
|
}
|
|
23
19
|
function getEndCode(code) {
|
|
24
|
-
if (endCodesSet.has(code))
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
if (endCodesMap.has(code)) {
|
|
28
|
-
return endCodesMap.get(code);
|
|
29
|
-
}
|
|
20
|
+
if (endCodesSet.has(code)) return code;
|
|
21
|
+
if (endCodesMap.has(code)) return endCodesMap.get(code);
|
|
30
22
|
code = code.slice(2);
|
|
31
|
-
if (code.includes(";"))
|
|
32
|
-
code = code[0] + "0";
|
|
33
|
-
}
|
|
23
|
+
if (code.includes(";")) code = code[0] + "0";
|
|
34
24
|
const returnValue = ansiStyles.codes.get(Number.parseInt(code, 10));
|
|
35
|
-
if (returnValue)
|
|
36
|
-
return ansiStyles.color.ansi(returnValue);
|
|
37
|
-
}
|
|
25
|
+
if (returnValue) return ansiStyles.color.ansi(returnValue);
|
|
38
26
|
return ansiStyles.reset.open;
|
|
39
27
|
}
|
|
40
28
|
function findNumberIndex(string) {
|
|
41
29
|
for (let index = 0; index < string.length; index++) {
|
|
42
30
|
const codePoint = string.codePointAt(index);
|
|
43
|
-
if (codePoint >= CODE_POINT_0 && codePoint <= CODE_POINT_9)
|
|
44
|
-
return index;
|
|
45
|
-
}
|
|
31
|
+
if (codePoint >= CODE_POINT_0 && codePoint <= CODE_POINT_9) return index;
|
|
46
32
|
}
|
|
47
33
|
return -1;
|
|
48
34
|
}
|
|
@@ -51,9 +37,7 @@ function parseAnsiCode(string, offset) {
|
|
|
51
37
|
const startIndex = findNumberIndex(string);
|
|
52
38
|
if (startIndex !== -1) {
|
|
53
39
|
let endIndex = string.indexOf("m", startIndex);
|
|
54
|
-
if (endIndex === -1)
|
|
55
|
-
endIndex = string.length;
|
|
56
|
-
}
|
|
40
|
+
if (endIndex === -1) endIndex = string.length;
|
|
57
41
|
return string.slice(0, endIndex + 1);
|
|
58
42
|
}
|
|
59
43
|
}
|
|
@@ -84,30 +68,22 @@ function tokenize(string, endCharacter = Number.POSITIVE_INFINITY) {
|
|
|
84
68
|
});
|
|
85
69
|
index += character.length;
|
|
86
70
|
visibleCount += isFullWidth ? 2 : character.length;
|
|
87
|
-
if (visibleCount >= endCharacter)
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
71
|
+
if (visibleCount >= endCharacter) break;
|
|
90
72
|
}
|
|
91
73
|
return returnValue;
|
|
92
74
|
}
|
|
93
75
|
function reduceAnsiCodes(codes) {
|
|
94
76
|
let returnValue = [];
|
|
95
|
-
for (const code of codes)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
} else {
|
|
101
|
-
returnValue = returnValue.filter((returnValueCode) => returnValueCode.endCode !== code.endCode);
|
|
102
|
-
returnValue.push(code);
|
|
103
|
-
}
|
|
77
|
+
for (const code of codes) if (code.code === ansiStyles.reset.open) returnValue = [];
|
|
78
|
+
else if (endCodesSet.has(code.code)) returnValue = returnValue.filter((returnValueCode) => returnValueCode.endCode !== code.code);
|
|
79
|
+
else {
|
|
80
|
+
returnValue = returnValue.filter((returnValueCode) => returnValueCode.endCode !== code.endCode);
|
|
81
|
+
returnValue.push(code);
|
|
104
82
|
}
|
|
105
83
|
return returnValue;
|
|
106
84
|
}
|
|
107
85
|
function undoAnsiCodes(codes) {
|
|
108
|
-
|
|
109
|
-
const endCodes = reduced.map(({ endCode }) => endCode);
|
|
110
|
-
return endCodes.reverse().join("");
|
|
86
|
+
return reduceAnsiCodes(codes).map(({ endCode }) => endCode).reverse().join("");
|
|
111
87
|
}
|
|
112
88
|
function sliceAnsi(string, start, end) {
|
|
113
89
|
const tokens = tokenize(string, end);
|
|
@@ -116,29 +92,22 @@ function sliceAnsi(string, start, end) {
|
|
|
116
92
|
let returnValue = "";
|
|
117
93
|
let include = false;
|
|
118
94
|
for (const token of tokens) {
|
|
119
|
-
if (end !==
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
95
|
+
if (end !== void 0 && position >= end) break;
|
|
122
96
|
if (token.type === "ansi") {
|
|
123
97
|
activeCodes.push(token);
|
|
124
|
-
if (include)
|
|
125
|
-
returnValue += token.code;
|
|
126
|
-
}
|
|
98
|
+
if (include) returnValue += token.code;
|
|
127
99
|
} else {
|
|
128
100
|
if (!include && position >= start) {
|
|
129
101
|
include = true;
|
|
130
102
|
activeCodes = reduceAnsiCodes(activeCodes);
|
|
131
103
|
returnValue = activeCodes.map(({ code }) => code).join("");
|
|
132
104
|
}
|
|
133
|
-
if (include)
|
|
134
|
-
returnValue += token.value;
|
|
135
|
-
}
|
|
105
|
+
if (include) returnValue += token.value;
|
|
136
106
|
position += token.isFullWidth ? 2 : token.value.length;
|
|
137
107
|
}
|
|
138
108
|
}
|
|
139
109
|
returnValue += undoAnsiCodes(activeCodes);
|
|
140
110
|
return returnValue;
|
|
141
111
|
}
|
|
142
|
-
|
|
143
112
|
//#endregion
|
|
144
|
-
export { sliceAnsi as t };
|
|
113
|
+
export { sliceAnsi as t };
|