Skip to content

Commit

Permalink
fix(semver): overwrite default nx release config + run build cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
edbzn committed May 10, 2024
1 parent 063b6f7 commit a061178
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/semver/src/executors/version/index.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand Down
11 changes: 10 additions & 1 deletion packages/semver/src/generators/migrate-nx-release/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit a061178

Please sign in to comment.