Skip to content

Commit f51f8dd

Browse files
committed
Refactor check-versions script
1 parent ac2c0f5 commit f51f8dd

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

scripts/check-versions.ts

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
#!/usr/bin/env node
22

3-
import { readFileSync } from 'fs';
4-
import { fileURLToPath } from 'url';
5-
import { dirname, join } from 'path';
3+
import { readFileSync } from 'fs'
4+
import { fileURLToPath } from 'url'
5+
import { dirname, join } from 'path'
66

7-
const __filename = fileURLToPath(import.meta.url);
8-
const __dirname = dirname(__filename);
9-
const projectRoot = join(__dirname, '..');
7+
const __filename = fileURLToPath(import.meta.url)
8+
const __dirname = dirname(__filename)
9+
const projectRoot = join(__dirname, '..')
1010

1111
interface PackageJson {
12-
version: string;
13-
[key: string]: any;
12+
version: string
13+
[key: string]: any
1414
}
1515

1616
interface ManifestJson {
17-
version: string;
18-
[key: string]: any;
17+
version: string
18+
[key: string]: any
1919
}
2020

21-
function readJsonFile<T>(filePath: string): T {
21+
function readJsonFile<T> (filePath: string): T {
2222
try {
23-
const content = readFileSync(filePath, 'utf8');
24-
return JSON.parse(content) as T;
23+
const content = readFileSync(filePath, 'utf8')
24+
return JSON.parse(content) as T
2525
} catch (error) {
26-
console.error(`Error reading ${filePath}:`, (error as Error).message);
27-
process.exit(1);
26+
console.error(`Error reading ${filePath}:`, (error as Error).message)
27+
process.exit(1)
2828
}
2929
}
3030

31-
function main(): void {
32-
console.log('Checking version consistency between package.json and manifest.json...');
33-
34-
const packageJsonPath = join(projectRoot, 'package.json');
35-
const manifestJsonPath = join(projectRoot, 'manifest.json');
36-
37-
const packageJson = readJsonFile<PackageJson>(packageJsonPath);
38-
const manifestJson = readJsonFile<ManifestJson>(manifestJsonPath);
39-
40-
const packageVersion = packageJson.version;
41-
const manifestVersion = manifestJson.version;
42-
43-
console.log(`package.json version: ${packageVersion}`);
44-
console.log(`manifest.json version: ${manifestVersion}`);
45-
31+
function main (): void {
32+
console.log('Checking version consistency between package.json and manifest.json...')
33+
34+
const packageJsonPath = join(projectRoot, 'package.json')
35+
const manifestJsonPath = join(projectRoot, 'manifest.json')
36+
37+
const packageJson = readJsonFile<PackageJson>(packageJsonPath)
38+
const manifestJson = readJsonFile<ManifestJson>(manifestJsonPath)
39+
40+
const packageVersion = packageJson.version
41+
const manifestVersion = manifestJson.version
42+
43+
console.log(`package.json version: ${packageVersion}`)
44+
console.log(`manifest.json version: ${manifestVersion}`)
45+
4646
if (packageVersion === manifestVersion) {
47-
console.log('✅ Versions match!');
48-
process.exit(0);
47+
console.log('✅ Versions match!')
48+
process.exit(0)
4949
} else {
50-
console.error('❌ Version mismatch detected!');
51-
console.error(`Expected both files to have the same version, but found:`);
52-
console.error(` package.json: ${packageVersion}`);
53-
console.error(` manifest.json: ${manifestVersion}`);
54-
console.error('Please update both files to have matching versions.');
55-
process.exit(1);
50+
console.error('❌ Version mismatch detected!')
51+
console.error('Expected both files to have the same version, but found:')
52+
console.error(` package.json: ${packageVersion}`)
53+
console.error(` manifest.json: ${manifestVersion}`)
54+
console.error('Please update both files to have matching versions.')
55+
process.exit(1)
5656
}
5757
}
5858

59-
main();
59+
main()

0 commit comments

Comments
 (0)