Skip to content

Commit f4f7e71

Browse files
committed
fix(cli/create): only reorder install when template ships ESLint/Prettier
CI failure: vp create library (npm/yarn/bun) was failing with ERR_PNPM_NO_MATCHING_VERSION for @voidzero-dev/vite-plus-core@0.0.0. The previous commit added an unconditional pre-rewrite install so that `@oxlint/migrate` could resolve the template's ESLint plugin imports. That broke builtin templates (vite:library, vite:application, vite:monorepo) — their scaffold already references vite-plus and relies on `rewrite*Project` to add the tarball overrides BEFORE the first install. Running install first made pnpm fall back to the npm registry for vite-plus-core@0.0.0, which CI publishes only as a local tarball. Gate the migrate-before-rewrite reorder on `detectEslintProject` / `detectPrettierProject`. Builtin templates have neither, so they keep the original rewrite → install → fmt flow (unchanged from main). Remote templates like `create-vite --template react-ts` do ship ESLint/Prettier, so they still get the reorder that merges .oxlintrc /.oxfmtrc into vite.config.ts.
1 parent f63066b commit f4f7e71

1 file changed

Lines changed: 28 additions & 14 deletions

File tree

packages/cli/src/create/bin.ts

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import mri from 'mri';
77
import { vitePlusHeader } from '../../binding/index.js';
88
import {
99
addFrameworkShim,
10+
detectEslintProject,
1011
detectFramework,
12+
detectPrettierProject,
1113
hasFrameworkShim,
1214
installGitHooks,
1315
promptEslintMigration,
@@ -912,6 +914,15 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
912914
resumeCreateProgress();
913915
};
914916

917+
// The migrate-before-rewrite reorder is only needed when the template
918+
// actually ships ESLint or Prettier (e.g. `create-vite --template
919+
// react-ts`). Builtin templates (vite:library, vite:application,
920+
// vite:monorepo) don't — their package.json already references vite-plus
921+
// and relies on `rewrite*Project` to add tarball overrides BEFORE the
922+
// first install, so install-first would break CI's local-tarball resolve.
923+
const shouldMigrateLintFmtTools =
924+
detectEslintProject(fullPath).hasDependency || detectPrettierProject(fullPath).hasDependency;
925+
915926
let installSummary: CommandRunSummary | undefined;
916927
if (isMonorepo) {
917928
if (!compactOutput) {
@@ -977,20 +988,23 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
977988
}
978989

979990
updateWorkspaceConfig(projectDir, workspaceInfo);
980-
updateCreateProgress('Installing dependencies');
981-
installSummary = await runViteInstall(workspaceInfo.rootDir, options.interactive, installArgs, {
982-
silent: compactOutput,
983-
});
984-
await migrateLintFmtTools(installSummary.status === 'installed');
991+
if (shouldMigrateLintFmtTools) {
992+
updateCreateProgress('Installing dependencies');
993+
installSummary = await runViteInstall(
994+
workspaceInfo.rootDir,
995+
options.interactive,
996+
installArgs,
997+
{ silent: compactOutput },
998+
);
999+
await migrateLintFmtTools(installSummary.status === 'installed');
1000+
}
9851001
updateCreateProgress('Integrating into monorepo');
9861002
rewriteMonorepoProject(fullPath, workspaceInfo.packageManager, undefined, compactOutput);
9871003
for (const framework of detectFramework(fullPath)) {
9881004
if (!hasFrameworkShim(fullPath, framework)) {
9891005
addFrameworkShim(fullPath, framework);
9901006
}
9911007
}
992-
// Re-install so the package manager fetches vite-plus (added by the
993-
// rewrite) and prunes the eslint/prettier deps that migration removed.
9941008
updateCreateProgress('Installing dependencies');
9951009
installSummary = await runViteInstall(workspaceInfo.rootDir, options.interactive, installArgs, {
9961010
silent: compactOutput,
@@ -1000,11 +1014,13 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
10001014
silent: compactOutput,
10011015
});
10021016
} else {
1003-
updateCreateProgress('Installing dependencies');
1004-
installSummary = await runViteInstall(fullPath, options.interactive, installArgs, {
1005-
silent: compactOutput,
1006-
});
1007-
await migrateLintFmtTools(installSummary.status === 'installed');
1017+
if (shouldMigrateLintFmtTools) {
1018+
updateCreateProgress('Installing dependencies');
1019+
installSummary = await runViteInstall(fullPath, options.interactive, installArgs, {
1020+
silent: compactOutput,
1021+
});
1022+
await migrateLintFmtTools(installSummary.status === 'installed');
1023+
}
10081024
updateCreateProgress('Applying Vite+ project setup');
10091025
rewriteStandaloneProject(fullPath, workspaceInfo, undefined, compactOutput);
10101026
for (const framework of detectFramework(fullPath)) {
@@ -1015,8 +1031,6 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
10151031
if (shouldSetupHooks) {
10161032
installGitHooks(fullPath, compactOutput);
10171033
}
1018-
// Re-install so the package manager fetches vite-plus (added by the
1019-
// rewrite) and prunes the eslint/prettier deps that migration removed.
10201034
updateCreateProgress('Installing dependencies');
10211035
installSummary = await runViteInstall(fullPath, options.interactive, installArgs, {
10221036
silent: compactOutput,

0 commit comments

Comments
 (0)