(pkgPath, workspaceNames, newVersion, { bumpVersion } = {})
| 6 | } |
| 7 | |
| 8 | function 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. |
no test coverage detected