Skip to content

Commit

Permalink
Add release types for major and minor prereleases (#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjellknapen authored Apr 9, 2024
1 parent dbc7282 commit d99780c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
7 changes: 7 additions & 0 deletions change/beachball-acb1a827-f8e4-47bf-81aa-624ddcbe35ed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Add release types for major and minor prereleases",
"packageName": "beachball",
"email": "[email protected]",
"dependentChangeType": "patch"
}
6 changes: 3 additions & 3 deletions src/__tests__/changefile/changeTypes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ describe('getMaxChangeType', () => {
});

it('returns none if all given change types are disallowed', () => {
const changeType = getMaxChangeType('patch', 'major', ['major', 'minor', 'patch', 'prerelease']);
const changeType = getMaxChangeType('patch', 'major', ['major', 'minor', 'patch', 'prerelease', 'premajor', 'preminor', 'prepatch']);
expect(changeType).toBe('none');
});

it('returns next greatest change type if max is disallowed', () => {
const changeType = getMaxChangeType('patch', 'major', ['major']);
const changeType = getMaxChangeType('patch', 'major', ['major', 'premajor', 'preminor', 'prepatch']);
expect(changeType).toBe('minor');
});

it('handles prerelease only case', () => {
const changeType = getMaxChangeType('patch', 'major', ['major', 'minor', 'patch']);
const changeType = getMaxChangeType('patch', 'major', ['major', 'minor', 'patch', 'premajor', 'preminor', 'prepatch']);
expect(changeType).toBe('prerelease');
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/changefile/changeTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ChangeSet, ChangeType } from '../types/ChangeInfo';
/**
* List of all change types from least to most significant.
*/
export const SortedChangeTypes: ChangeType[] = ['none', 'prerelease', 'patch', 'minor', 'major'];
export const SortedChangeTypes: ChangeType[] = ['none', 'prerelease', 'prepatch', 'patch', 'preminor', 'minor', 'premajor', 'major'];

/**
* Change type with the smallest weight.
Expand Down
3 changes: 3 additions & 0 deletions src/changelog/renderPackageChangelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { ChangeType } from '../types/ChangeInfo';

const groupNames: { [k in ChangeType]: string } = {
major: 'Major changes',
premajor: 'Major changes (pre-release)',
minor: 'Minor changes',
preminor: 'Minor changes (pre-release)',
patch: 'Patches',
prepatch: 'Patches (pre-release)',
prerelease: 'Changes',
none: '', // not used
};
Expand Down
2 changes: 1 addition & 1 deletion src/types/ChangeInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type ChangeType = 'prerelease' | 'patch' | 'minor' | 'major' | 'none';
export type ChangeType = 'prerelease' | 'prepatch' |'patch' | 'preminor' |'minor' | 'premajor' |'major' | 'none';

/**
* Info saved in each change file.
Expand Down
2 changes: 1 addition & 1 deletion src/validation/isValidDependentChangeType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function isValidDependentChangeType(
const disallowedDependentChangeTypes = (disallowedChangeTypes || []).filter(t => t !== 'patch');

return (
['patch', 'major', 'minor', 'prerelease', 'none'].includes(dependentChangeType) &&
['patch', 'major', 'minor', 'prerelease', 'prepatch', 'praminor', 'premajor', 'none'].includes(dependentChangeType) &&
!disallowedDependentChangeTypes.includes(dependentChangeType)
);
}

0 comments on commit d99780c

Please sign in to comment.