Skip to content

Commit 9a751fd

Browse files
authored
feat(version): rewrite consumer pins on major bumps (#85)
When versionPackagesExplicit bumps a workspace package's major, walk every other workspace package.json and rewrite any \`dependencies\`/\`devDependencies\`/\`peerDependencies\` ref to the bumped package whose existing semver range no longer satisfies the new version. Preserves the existing range prefix (\`^\`, \`~\`, \`>=\`, …). Minor and patch bumps skip the walk entirely — the existing caret/tilde range already satisfies the new version, so yarn keeps resolving the workspace symlink and there's no need to touch any consumer's package.json. Why: lerna's \`version\` flow does this automatically. The explicit-bumps path in #82 lost the behavior, so a 2.x → 3.0.0 release on a workspace package would leave every consumer pinned to \`^2.0.1\`. yarn falls back to the published 2.x copy on the registry — still carrying the old pre-migration source — which broke optimistic-balances' build in exodus-hydra#16530. Skips refs that aren't semver ranges: - \`workspace:*\` / \`workspace:^\` - \`npm:@scope/alias@…\` - \`file:\` / \`link:\` / \`portal:\` - URLs (anything with \`://\`) - dist-tags (\`*\`, \`latest\`, \`next\`) Adds 13 new tests covering: basic rewrite, range-prefix preservation (^/~), staging into the release commit, the 8 skip protocols (each as its own .each row), cross-section rewrite (deps/devDeps/peerDeps), and the 5 non-major bump levels (minor/patch/preminor/prepatch/ prerelease) as a single .each — confirming non-major bumps leave consumers untouched. 181/181 tests passing (was 165, +16).
1 parent 9b99965 commit 9a751fd

5 files changed

Lines changed: 395 additions & 22 deletions

File tree

dist/version/index.js

Lines changed: 92 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/version/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export default async function version({
120120
core.info('Versioning packages')
121121
let commitsToReset = 1
122122
if (bumps) {
123-
commitsToReset = versionPackagesExplicit({ bumps, packages })
123+
commitsToReset = await versionPackagesExplicit({ bumps, packages })
124124
} else if (narrowedStrategy) {
125125
versionPackages({ extraArgs: versionExtraArgs, versionStrategy: narrowedStrategy })
126126
}

0 commit comments

Comments
 (0)