-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
set-version.ts
82 lines (71 loc) · 1.78 KB
/
set-version.ts
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// bun set-version.mjs 4.0.178
import {execSync} from 'child_process';
import {
existsSync,
lstatSync,
readFileSync,
readdirSync,
writeFileSync,
} from 'fs';
import path from 'path';
import {FEATURED_TEMPLATES} from './packages/create-video/src/templates.ts';
let version = process.argv[2];
let noCommit = process.argv.includes('--no-commit');
if (!version) {
throw new Error('Please specify a version');
}
if (version.startsWith('v')) {
version = version.slice(1);
}
const dirs = readdirSync('packages')
.filter((dir) =>
lstatSync(path.join(process.cwd(), 'packages', dir)).isDirectory(),
)
.filter((dir) =>
existsSync(path.join(process.cwd(), 'packages', dir, 'package.json')),
);
for (const dir of [path.join('cloudrun', 'container'), ...dirs]) {
const localTemplates = FEATURED_TEMPLATES.map(
(t) => t.templateInMonorepo,
).filter(Boolean) as string[];
if (localTemplates.includes(dir)) {
continue;
}
const packageJsonPath = path.join(
process.cwd(),
'packages',
dir,
'package.json',
);
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
packageJson.version = version;
writeFileSync(
packageJsonPath,
JSON.stringify(packageJson, null, '\t') + '\n',
);
try {
console.log('setting version for', dir);
} catch (e) {
// console.log(e.message);
}
}
execSync('bun ensure-correct-version.ts', {
cwd: 'packages/core',
});
execSync('bun test src/monorepo', {
cwd: 'packages/it-tests',
stdio: 'inherit',
});
execSync('bun build.ts --all', {
cwd: 'packages/compositor',
stdio: 'inherit',
});
execSync('pnpm run make', {
cwd: 'packages/cloudrun',
stdio: 'inherit',
});
if (!noCommit) {
execSync('git add .', {stdio: 'inherit'});
execSync(`git commit -m "v${version}"`, {stdio: 'inherit'});
execSync(`git tag v${version}`, {stdio: 'inherit'});
}