Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .yarn/versions/85173f62.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
releases:
"@yarnpkg/cli": patch
"@yarnpkg/plugin-version": patch

declined:
- "@yarnpkg/builder"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
- "@yarnpkg/nm"
- "@yarnpkg/pnpify"
- "@yarnpkg/sdks"
- "@yarnpkg/plugin-catalog"
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-jsr"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-workspace-tools"
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,21 @@ describe(`Commands`, () => {
});
}),
);

test(
`it should apply a literal semver bump against the stableVersion base when version is a prerelease (#7025)`,
makeTemporaryEnv({
version: `1.3.1-alpha`,
stableVersion: `1.2.1`,
}, async ({path, run, source}) => {
await expect(run(`version`, `1.3.1`)).resolves.toMatchObject({
code: 0,
});

await expect(xfs.readJsonPromise(`${path}/package.json` as PortablePath)).resolves.toMatchObject({
version: `1.3.1`,
});
}),
);
});
});
8 changes: 7 additions & 1 deletion packages/plugin-version/sources/commands/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ export default class VersionCommand extends BaseCommand {
let releaseStrategy: string | null;
if (isSemver) {
if (workspace.manifest.version !== null) {
const suggestedStrategy = versionUtils.suggestStrategy(workspace.manifest.version, this.strategy);
// `resolveVersionFiles` (used during `version apply`) bases the bump on
// `stableVersion ?? version` when `stableVersion` is set. The strategy
// suggested here must be expressed against the same base, otherwise a
// strategy like `patch` that fits `version` (`1.3.1-alpha` → `1.3.1`)
// would later be applied to `stableVersion` (`1.2.1` → `1.2.2`).
const baseVersion = workspace.manifest.raw.stableVersion ?? workspace.manifest.version;
const suggestedStrategy = versionUtils.suggestStrategy(baseVersion, this.strategy);

if (suggestedStrategy !== null) {
releaseStrategy = suggestedStrategy;
Expand Down
Loading