Skip to content

Commit 747f4cc

Browse files
branchseerclaude
andcommitted
fix: create vite.config.ts when migration doesn't produce one
Some projects (vue-mini, vitepress, frm-stack, dify) have no lint/fmt/pack config to merge, so migration doesn't create a vite config. Create a minimal one with cacheScripts enabled. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7f53e92 commit 747f4cc

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

ecosystem-ci/patch-project.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,21 @@ execSync(`${cli} migrate --no-agent --no-interactive`, {
4747
});
4848

4949
// Enable cacheScripts so e2e tests exercise the cache hit/miss paths.
50-
// Migration preserves the existing config extension (.ts or .js).
51-
const viteConfigPath = existsSync(join(cwd, 'vite.config.ts'))
52-
? join(cwd, 'vite.config.ts')
53-
: join(cwd, 'vite.config.js');
54-
const viteConfig = await readFile(viteConfigPath, 'utf-8');
55-
await writeFile(
56-
viteConfigPath,
57-
viteConfig.replace('defineConfig({', 'defineConfig({\n run: { cacheScripts: true },'),
58-
'utf-8',
59-
);
50+
// Migration may create vite.config.ts, preserve an existing .ts/.js, or create none at all.
51+
const tsPath = join(cwd, 'vite.config.ts');
52+
const jsPath = join(cwd, 'vite.config.js');
53+
if (existsSync(tsPath) || existsSync(jsPath)) {
54+
const viteConfigPath = existsSync(tsPath) ? tsPath : jsPath;
55+
const viteConfig = await readFile(viteConfigPath, 'utf-8');
56+
await writeFile(
57+
viteConfigPath,
58+
viteConfig.replace('defineConfig({', 'defineConfig({\n run: { cacheScripts: true },'),
59+
'utf-8',
60+
);
61+
} else {
62+
await writeFile(
63+
tsPath,
64+
`import { defineConfig } from 'vite-plus';\n\nexport default defineConfig({\n run: { cacheScripts: true },\n});\n`,
65+
'utf-8',
66+
);
67+
}

0 commit comments

Comments
 (0)