Skip to content
Merged
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
27 changes: 20 additions & 7 deletions tools/workspace-plugin/src/generators/version-bump/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,24 +145,37 @@ describe('version-string-replace generator', () => {
expect(packageJson.version).toMatchInlineSnapshot(`"0.0.0-nightly.0"`);
});

it('should remove beachball disallowedChangeType config when bumping nightly', async () => {
it.each([
{ scenario: 'bumping nightly', options: { bumpType: 'nightly', prereleaseTag: 'nightly' } },
{ scenario: 'using explicitVersion', options: { explicitVersion: '9.1.7-experimental.0' } },
] as const)('should remove beachball disallowedChangeType config when $scenario', async ({ options }) => {
const versionBumpKind = options.bumpType ?? 'explicitVersion';
tree = setupDummyPackage(tree, {
name: 'make-styles',
name: `make-styles-${versionBumpKind}`,
version: '9.0.0-alpha.0',
projectConfiguration: { tags: ['vNext', 'platform:web'], sourceRoot: 'packages/make-styles/src' },
projectConfiguration: {
tags: ['vNext', 'platform:web'],
sourceRoot: `packages/make-styles-${versionBumpKind}/src`,
},
beachball: {
disallowedChangeTypes: ['prerelease'],
},
});

expect(
readJson<PackageJsonWithBeachball>(tree, 'packages/make-styles/package.json').beachball?.disallowedChangeTypes,
readJson<PackageJsonWithBeachball>(tree, `packages/make-styles-${versionBumpKind}/package.json`).beachball
?.disallowedChangeTypes,
).toEqual(['prerelease']);

await generator(tree, { name: 'make-styles', bumpType: 'nightly', prereleaseTag: 'nightly' });
await generator(tree, { name: `make-styles-${versionBumpKind}`, ...options });

const packageJson = readJson<PackageJsonWithBeachball>(tree, 'packages/make-styles/package.json');
expect(packageJson.version).toMatchInlineSnapshot(`"0.0.0-nightly.0"`);
const packageJson = readJson<PackageJsonWithBeachball>(
tree,
`packages/make-styles-${versionBumpKind}/package.json`,
);
expect(packageJson.version).toEqual(
versionBumpKind === 'explicitVersion' ? '9.1.7-experimental.0' : '0.0.0-nightly.0',
);
expect(packageJson.beachball?.disallowedChangeTypes).toBeUndefined();
});

Expand Down
4 changes: 2 additions & 2 deletions tools/workspace-plugin/src/generators/version-bump/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ function runMigrationOnProject(tree: Tree, schema: ValidatedSchema, userLog: Use
updateJson(tree, packageJsonPath, (packageJson: PackageJson) => {
nextVersion = bumpVersion(packageJson, schema.bumpType, schema.prereleaseTag, schema.explicitVersion);

// nightly releases should bypass beachball disallowed changetypes
// explicitVersion or nightly releases should bypass beachball disallowed changetypes
if (
schema.bumpType === 'nightly' &&
(schema.explicitVersion || schema.bumpType === 'nightly') &&
packageJsonHasBeachballConfig(packageJson) &&
packageJson.beachball?.disallowedChangeTypes
) {
Expand Down
Loading