Skip to content

Commit

Permalink
allow you to define a semver tag when using prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Feb 11, 2025
1 parent a7eb9cc commit d674987
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/plan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,45 @@ describe('plan', function () {
]),
);
});

it('allows you to define semver tag', async () => {
project.pkg['release-plan'] = {
semverIncrementAs: {
major: 'premajor',
},
semverIncrementTag: 'alpha',
};

await project.write();

const solution = planVersionBumps({
sections: [
{
packages: ['test-package'],
impact: 'major',
heading: 'breaking',
},
],
});

expect(solution).to.deep.equal(
new Map([
[
'test-package',
{
constraints: [
{
impact: 'major',
reason: 'Appears in changelog section breaking',
},
],
impact: 'major',
newVersion: '2.0.0-alpha.0',
oldVersion: '1.2.3',
pkgJSONPath: './package.json',
},
],
]),
);
});
});
6 changes: 6 additions & 0 deletions src/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Plan {
const newVersion = inc(
entry.version,
this.#configureImpact(pkgName, impact),
this.#semverTag(pkgName),
)!;
solution.set(pkgName, {
impact,
Expand All @@ -89,6 +90,11 @@ class Plan {
return impact;
}

#semverTag(pkgName: string): Impact {
const packageJson = this.#pkgs.get(pkgName)?.pkg;
return packageJson?.['release-plan']?.semverIncrementTag;
}

#expandWorkspaceRange(
range: `workspace:${string}`,
availableVersion: string,
Expand Down

0 comments on commit d674987

Please sign in to comment.