-
-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathupdate-sdk-versions.mjs
37 lines (29 loc) · 1.22 KB
/
update-sdk-versions.mjs
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
import latestVersion from 'latest-version';
import { spawnSync } from 'child_process';
import { readFileSync, writeFileSync } from 'fs';
import { join } from 'path';
import { fileURLToPath } from 'url';
const __dirname = fileURLToPath(new URL('.', import.meta.url));
const latest = await latestVersion('@sentry/core');
const packageJsonPath = join(__dirname, '..', 'package.json');
const packageJson = JSON.parse(readFileSync(packageJsonPath, { encoding: 'utf8' }));
const current = packageJson.dependencies['@sentry/core'];
if (current !== latest) {
console.log(`Updating Sentry deps from ${current} to ${latest}`);
const re = /^@sentry(-internal)?\//;
for (const dep of Object.keys(packageJson.dependencies)) {
if (dep.match(re)) {
packageJson.dependencies[dep] = latest;
}
}
for (const dep of Object.keys(packageJson.devDependencies)) {
if (dep.match(re)) {
packageJson.devDependencies[dep] = latest;
}
}
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
// Update yarn.lock
spawnSync('yarn', ['install'], { stdio: 'inherit' });
// Update parameter that has the version in it
spawnSync('yarn', ['build'], { stdio: 'inherit' });
}