diff --git a/tools/workspace-plugin/src/generators/version-bump/index.spec.ts b/tools/workspace-plugin/src/generators/version-bump/index.spec.ts index 5ace0adb39c0a..c297c6a5a6ade 100644 --- a/tools/workspace-plugin/src/generators/version-bump/index.spec.ts +++ b/tools/workspace-plugin/src/generators/version-bump/index.spec.ts @@ -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(tree, 'packages/make-styles/package.json').beachball?.disallowedChangeTypes, + readJson(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(tree, 'packages/make-styles/package.json'); - expect(packageJson.version).toMatchInlineSnapshot(`"0.0.0-nightly.0"`); + const packageJson = readJson( + 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(); }); diff --git a/tools/workspace-plugin/src/generators/version-bump/index.ts b/tools/workspace-plugin/src/generators/version-bump/index.ts index d89d66e71d523..c6f05c1e3ba6e 100644 --- a/tools/workspace-plugin/src/generators/version-bump/index.ts +++ b/tools/workspace-plugin/src/generators/version-bump/index.ts @@ -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 ) {