-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathpatch-project.ts
More file actions
39 lines (31 loc) · 1.22 KB
/
patch-project.ts
File metadata and controls
39 lines (31 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { execSync } from 'node:child_process';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import repos from './repo.json' with { type: 'json' };
const projectDir = dirname(fileURLToPath(import.meta.url));
const projects = Object.keys(repos);
const project = process.argv[2];
if (!projects.includes(project)) {
console.error(`Project ${project} is not defined in repo.json`);
process.exit(1);
}
const tgzPath = join(projectDir, '..', 'tmp', 'tgz');
async function migrateProject(project: string) {
const repoRoot = join(projectDir, project);
// run vite migrate
execSync('vite migrate', {
cwd: repoRoot,
stdio: 'inherit',
env: {
...process.env,
VITE_PLUS_OVERRIDE_PACKAGES: JSON.stringify({
vite: `file:${tgzPath}/voidzero-dev-vite-plus-core-0.0.0.tgz`,
vitest: `file:${tgzPath}/voidzero-dev-vite-plus-test-0.0.0.tgz`,
'@voidzero-dev/vite-plus-core': `file:${tgzPath}/voidzero-dev-vite-plus-core-0.0.0.tgz`,
'@voidzero-dev/vite-plus-test': `file:${tgzPath}/voidzero-dev-vite-plus-test-0.0.0.tgz`,
}),
VITE_PLUS_VERSION: `file:${tgzPath}/voidzero-dev-vite-plus-0.0.0.tgz`,
},
});
}
await migrateProject(project);