MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / updateWorkspaceDeps

Function updateWorkspaceDeps

scripts/bump-version.js:8–35  ·  view source on GitHub ↗
(pkgPath, workspaceNames, newVersion, { bumpVersion } = {})

Source from the content-addressed store, hash-verified

6}
7
8function updateWorkspaceDeps(pkgPath, workspaceNames, newVersion, { bumpVersion } = {}) {
9 const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
10
11 if (bumpVersion) {
12 pkg.version = newVersion;
13 }
14
15 for (const depType of ['dependencies', 'devDependencies', 'peerDependencies']) {
16 if (!pkg[depType]) continue;
17
18 for (const [dep, ver] of Object.entries(pkg[depType])) {
19 if (workspaceNames.has(dep) && !ver.startsWith('workspace:')) {
20 pkg[depType][dep] = newVersion;
21 }
22 }
23 }
24
25 if (pkg.pnpm?.overrides) {
26 for (const [dep, value] of Object.entries(pkg.pnpm.overrides)) {
27 if (!workspaceNames.has(dep)) continue;
28
29 pkg.pnpm.overrides[dep] = value.replace(/(?<=sentry-[\w-]+-)\d+\.\d+\.\d+(-[\w.]+)?(?=\.tgz$)/, newVersion);
30 }
31 }
32
33 fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
34 return pkg;
35}
36
37/**
38 * Bumps the version of all workspace packages and their internal dependencies.

Callers 1

bumpVersionsFunction · 0.85

Calls 3

replaceMethod · 0.80
entriesMethod · 0.65
hasMethod · 0.65

Tested by

no test coverage detected