forked from getsentry/XcodeBuildMCP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-version.ts
More file actions
29 lines (23 loc) · 872 Bytes
/
generate-version.ts
File metadata and controls
29 lines (23 loc) · 872 Bytes
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
import { readFile, writeFile } from 'node:fs/promises';
import path from 'node:path';
interface PackageJson {
version: string;
iOSTemplateVersion: string;
macOSTemplateVersion: string;
}
async function main(): Promise<void> {
const repoRoot = process.cwd();
const packagePath = path.join(repoRoot, 'package.json');
const versionPath = path.join(repoRoot, 'src', 'version.ts');
const raw = await readFile(packagePath, 'utf8');
const pkg = JSON.parse(raw) as PackageJson;
const content =
`export const version = '${pkg.version}';\n` +
`export const iOSTemplateVersion = '${pkg.iOSTemplateVersion}';\n` +
`export const macOSTemplateVersion = '${pkg.macOSTemplateVersion}';\n`;
await writeFile(versionPath, content, 'utf8');
}
main().catch((error) => {
console.error('Failed to generate src/version.ts:', error);
process.exit(1);
});