-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Expand file tree
/
Copy pathset-version.ts
More file actions
184 lines (159 loc) · 4.55 KB
/
Copy pathset-version.ts
File metadata and controls
184 lines (159 loc) · 4.55 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// bun set-version.mjs 4.0.178
import {execSync} from 'child_process';
import {
existsSync,
lstatSync,
readFileSync,
readdirSync,
unlinkSync,
writeFileSync,
} from 'fs';
import path from 'path';
import {FEATURED_TEMPLATES} from './packages/create-video/src/templates.ts';
import {
moveRemovedDependenciesToDevDependencies,
shouldReleasePackage,
} from './packages/studio-shared/src/release-package-policy';
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);
}
// Ensure we are on the main branch
const currentBranch = execSync('git rev-parse --abbrev-ref HEAD', {
encoding: 'utf-8',
}).trim();
if (currentBranch !== 'main') {
throw new Error('Please be on the main branch');
}
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 tsconfigBuildPath = path.join(
process.cwd(),
'packages',
dir,
'tsconfig.tsbuildinfo',
);
if (existsSync(tsconfigBuildPath)) {
unlinkSync(tsconfigBuildPath);
}
let packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
if (
!shouldReleasePackage({
packageName: packageJson.name,
releaseVersion: version,
})
) {
continue;
}
if (!packageJson.private) {
packageJson = moveRemovedDependenciesToDevDependencies({
packageJson,
releaseVersion: version,
});
}
packageJson.version = version;
writeFileSync(
packageJsonPath,
JSON.stringify(packageJson, null, '\t') + '\n',
);
try {
console.log('setting version for', dir);
} catch (e) {
// console.log(e.message);
}
}
const skillsRoot = path.join(process.cwd(), 'packages', 'skills', 'skills');
for (const skillName of readdirSync(skillsRoot)) {
const skillFile = path.join(skillsRoot, skillName, 'SKILL.md');
if (!existsSync(skillFile)) {
continue;
}
const contents = readFileSync(skillFile, 'utf8');
const frontmatterEnd = contents.indexOf('\n---', 4);
if (frontmatterEnd === -1) {
throw new Error(`No frontmatter found in ${skillFile}`);
}
const frontmatter = contents.slice(0, frontmatterEnd);
const versionPattern = /^version:.*$/m;
const updatedFrontmatter = versionPattern.test(frontmatter)
? frontmatter.replace(versionPattern, `version: ${version}`)
: `${frontmatter}\nversion: ${version}`;
writeFileSync(skillFile, updatedFrontmatter + contents.slice(frontmatterEnd));
console.log('setting version for', path.join('skills', skillName));
}
const pluginManifestPaths = [
path.join('agent-plugin', 'plugin.json'),
path.join('agent-plugin', '.codex-plugin', 'plugin.json'),
path.join('claude-code-plugin', '.claude-plugin', 'plugin.json'),
path.join('kimi-code-plugin', '.kimi-plugin', 'plugin.json'),
];
for (const pluginManifestPath of pluginManifestPaths) {
const manifestPath = path.join(process.cwd(), 'packages', pluginManifestPath);
if (!existsSync(manifestPath)) {
continue;
}
const manifest = JSON.parse(readFileSync(manifestPath, 'utf-8'));
manifest.version = version;
writeFileSync(manifestPath, JSON.stringify(manifest, null, '\t') + '\n');
console.log('setting version for', pluginManifestPath);
}
execSync('bun ensure-correct-version.ts', {
cwd: 'packages/core',
});
execSync('bun ensure-correct-version.ts', {
cwd: 'packages/media-parser',
});
execSync('rm -rf dist && rm -rf tsconfig.tsbuildinfo', {
cwd: 'packages/studio',
});
execSync('bun run build', {
stdio: 'inherit',
});
execSync('bun run generate', {
stdio: 'inherit',
cwd: 'packages/google-fonts',
});
execSync('bun test src/monorepo', {
cwd: 'packages/it-tests',
stdio: 'inherit',
});
execSync('bun build.ts --all', {
cwd: 'packages/compositor',
stdio: 'inherit',
});
execSync('bun i', {
stdio: 'inherit',
});
if (!noCommit) {
execSync('git add .', {stdio: 'inherit'});
execSync(`git commit --allow-empty -m "v${version}"`, {stdio: 'inherit'});
execSync(`git tag -d v${version} 2>/dev/null || true`, {
stdio: 'inherit',
});
execSync(`git push --delete origin v${version} 2>/dev/null || true`, {
stdio: 'inherit',
});
execSync(`git tag v${version} 2>/dev/null || true`, {stdio: 'inherit'});
}