Skip to content

Commit

Permalink
feat(core): switch nx release changelog to offline first with CHANG…
Browse files Browse the repository at this point in the history
…ELOG.md files (#19327)
  • Loading branch information
JamesHenry authored Oct 3, 2023
1 parent d97a8d2 commit 2d70eb0
Show file tree
Hide file tree
Showing 12 changed files with 908 additions and 279 deletions.
16 changes: 16 additions & 0 deletions docs/generated/cli/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ nx release changelog [version]

#### Options

##### createRelease

Type: `string`

Choices: [github]

Create a release for the given version on a supported source control service provider, such as Github.

##### file

Type: `string`

Default: `CHANGELOG.md`

The name of the file to write the changelog to. It can also be set to `false` to disable file generation. Defaults to CHANGELOG.md.

##### from

Type: `string`
Expand Down
16 changes: 16 additions & 0 deletions docs/generated/packages/nx/documents/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ nx release changelog [version]

#### Options

##### createRelease

Type: `string`

Choices: [github]

Create a release for the given version on a supported source control service provider, such as Github.

##### file

Type: `string`

Default: `CHANGELOG.md`

The name of the file to write the changelog to. It can also be set to `false` to disable file generation. Defaults to CHANGELOG.md.

##### from

Type: `string`
Expand Down
3 changes: 2 additions & 1 deletion e2e/release/src/private-js-packages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ expect.addSnapshotSerializer({
.replaceAll('/private/', '')
.replaceAll(/public-pkg-\d+/g, '{public-project-name}')
.replaceAll(/private-pkg\d+/g, '{private-project-name}')
.replaceAll(/\s\/{private-project-name}/g, ' {private-project-name}')
.replaceAll(
/integrity:\s*.*/g,
'integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
Expand Down Expand Up @@ -147,7 +148,7 @@ describe('nx release - private JS packages', () => {
> nx run {private-project-name}:nx-release-publish
Skipping package "@proj/{private-project-name}" from project "{private-project-name}", because it has \`"private": true\` in /{private-project-name}/package.json
Skipping package "@proj/{private-project-name}" from project "{private-project-name}", because it has \`"private": true\` in {private-project-name}/package.json
> nx run {public-project-name}:nx-release-publish
Expand Down
52 changes: 52 additions & 0 deletions e2e/release/src/release.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { NxJsonConfiguration } from '@nx/devkit';
import {
cleanupProject,
createFile,
exists,
killProcessAndPorts,
newProject,
readFile,
runCLI,
runCommandAsync,
runCommandUntil,
uniq,
updateJson,
Expand Down Expand Up @@ -66,6 +70,18 @@ describe('nx release', () => {
afterAll(() => cleanupProject());

it('should version and publish multiple related npm packages with zero config', async () => {
// Normalize git committer information so it is deterministic in snapshots
await runCommandAsync(`git config user.email "[email protected]"`);
await runCommandAsync(`git config user.name "Test"`);
// Create a baseline version tag
await runCommandAsync(`git tag v0.0.0`);

// Add an example feature so that we can generate a CHANGELOG.md for it
createFile('an-awesome-new-thing.js', 'console.log("Hello world!");');
await runCommandAsync(
`git add --all && git commit -m "feat: an awesome new feature"`
);

const versionOutput = runCLI(`release version 999.9.9`);

/**
Expand Down Expand Up @@ -100,6 +116,42 @@ describe('nx release', () => {
).length
).toEqual(1);

// Generate a changelog for the new version
expect(exists('CHANGELOG.md')).toEqual(false);

const changelogOutput = runCLI(`release changelog 999.9.9`);
expect(changelogOutput).toMatchInlineSnapshot(`
> NX Generating a CHANGELOG.md entry for v999.9.9
+ ## v999.9.9
+
+
+ ### 🚀 Features
+
+ - an awesome new feature
+
+ ### ❤️ Thank You
+
+ - Test
`);

expect(readFile('CHANGELOG.md')).toMatchInlineSnapshot(`
## v999.9.9
### 🚀 Features
- an awesome new feature
### ❤️ Thank You
- Test
`);

// This is the verdaccio instance that the e2e tests themselves are working from
const e2eRegistryUrl = execSync('npm config get registry')
.toString()
Expand Down
Loading

1 comment on commit 2d70eb0

@vercel
Copy link

@vercel vercel bot commented on 2d70eb0 Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx.dev
nx-five.vercel.app
nx-dev-nrwl.vercel.app

Please sign in to comment.