diff --git a/packages/semver/src/executors/version/index.e2e.spec.ts b/packages/semver/src/executors/version/index.e2e.spec.ts index 5a385bc0e..17161d175 100644 --- a/packages/semver/src/executors/version/index.e2e.spec.ts +++ b/packages/semver/src/executors/version/index.e2e.spec.ts @@ -433,9 +433,9 @@ describe('@jscutlery/semver', () => { }); it('should bump package version', () => { - expect(readFile(`${testingWorkspace.root}/libs/b/package.json`)).toMatch( - /"version": "0.3.0"/, - ); + expect( + readFile(`${testingWorkspace.root}/dist/libs/b/package.json`), + ).toMatch(/"version": "0.3.0"/); }); it('should generate CHANGELOG.md', () => { diff --git a/packages/semver/src/generators/migrate-nx-release/index.spec.ts b/packages/semver/src/generators/migrate-nx-release/index.spec.ts index dfe68dcd5..26b95a30e 100644 --- a/packages/semver/src/generators/migrate-nx-release/index.spec.ts +++ b/packages/semver/src/generators/migrate-nx-release/index.spec.ts @@ -137,6 +137,14 @@ describe('Nx Release Migration', () => { expect(release!.projectsRelationship).toEqual('independent'); }); + it('should configure pre version command', async () => { + await setupSemver(); + + expect(release!.version!.preVersionCommand).toEqual( + 'npm run nx run-many -t build', + ); + }); + it('should configure git with --skipCommit', async () => { await setupSemver({ skipCommit: true }); diff --git a/packages/semver/src/generators/migrate-nx-release/index.ts b/packages/semver/src/generators/migrate-nx-release/index.ts index 8b53d11a1..c9cbf22c7 100644 --- a/packages/semver/src/generators/migrate-nx-release/index.ts +++ b/packages/semver/src/generators/migrate-nx-release/index.ts @@ -11,6 +11,7 @@ import { installPackagesTask, updateJson, NxJsonConfiguration, + detectPackageManager, } from '@nx/devkit'; import { VersionBuilderSchema } from '../../executors/version/schema'; import { defaultHeader } from '../../executors/version/utils/changelog'; @@ -176,11 +177,19 @@ function configureNxRelease( ({ executor }) => executor?.includes('semver:github') ?? false, ); - nxJson.release ??= { + if (nxJson.release) { + logger.info('Nx Release already configured, overwriting configuration.'); + } + + const pm = detectPackageManager(tree.root); + const runCmd = pm === 'yarn' ? 'yarn' : pm === 'npm' ? 'npx' : 'pnpm exec'; + + nxJson.release = { releaseTagPattern: `${tagPrefix}{version}`, projects: semverProjects.map(([projectName]) => projectName), projectsRelationship: 'independent', version: { + preVersionCommand: `${runCmd} nx run-many -t build`, conventionalCommits: true, }, git: {