Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: native Nx release migration #761

Merged
merged 22 commits into from
Feb 12, 2024
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
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
'style',
'test',
'release',
'wip',
],
],
},
Expand Down
5 changes: 5 additions & 0 deletions packages/semver/generators.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"schema": "./src/generators/install/schema.json",
"factory": "./src/generators/install",
"description": "Add @jscutlery/semver to the workspace."
},
"migrate-nx-release": {
"schema": "./src/generators/migrate-nx-release/schema.json",
"factory": "./src/generators/migrate-nx-release/index",
"description": "Migrate @jscutlery/semver to Nx release."
}
},
"required": [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`@jscutlery/semver @jscutlery/semver:migrate-nx-release should generate CHANGELOG.md: b-0.3.0 1`] = `
"## 0.3.0 (yyyy-mm-dd)


### 🚀 Features

- **b:** 🚀 new feature


### ❤️ Thank You

- Test Bot

## [0.2.0](///compare/b-0.1.0...b-0.2.0) (yyyy-mm-dd)

### Features

- **b:** 🚀 new feature xxxxxxx

## 0.1.0 (yyyy-mm-dd)

### Features

- **b:** 🚀 new feature xxxxxxx

### Bug Fixes

- **b:** 🐞 fix bug xxxxxxx
"
`;

exports[`@jscutlery/semver @jscutlery/semver:version when libs/a changed (breaking change) should generate CHANGELOG.md: a-1.0.0 1`] = `
"# Changelog

Expand Down
52 changes: 52 additions & 0 deletions packages/semver/src/executors/version/index.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,58 @@ describe('@jscutlery/semver', () => {
});
});
});

describe('@jscutlery/semver:migrate-nx-release', () => {
beforeAll(() => {
testingWorkspace.runNx(`g @jscutlery/semver:migrate-nx-release`);
testingWorkspace.exec(
`
git add .
git commit -m "build: 🛠️ migrate to nx release"
`,
);
testingWorkspace.exec(
`
echo feat > libs/b/b.txt
git add .
git commit -m "feat(b): 🚀 new feature"
`,
);
testingWorkspace.runNx(`release --skip-publish`);
});

it('should commit with description', () => {
expect(getLastCommitDescription(testingWorkspace.root)).toBe(
`chore(release): publish

- project: b 0.3.0`,
);
});

it('should tag with version', () => {
expect(getLastTag(testingWorkspace.root)).toBe('b-0.3.0');
});

it('should bump package version', () => {
expect(readFile(`${testingWorkspace.root}/libs/b/package.json`)).toMatch(
/"version": "0.3.0"/,
);
});

it('should generate CHANGELOG.md', () => {
expect(
deterministicChangelog(
readFile(`${testingWorkspace.root}/libs/b/CHANGELOG.md`),
),
).toMatchSnapshot('b-0.3.0');
});

it('should version projects independently', () => {
expect(getTags(testingWorkspace.root)).toEqual(
expect.arrayContaining(['a-1.2.0-alpha.0', 'b-0.3.0', 'd-0.1.0']),
);
});
});
});

function getLastTag(dir: string) {
Expand Down
Loading
Loading