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(core): support changelog customizations and project changelogs #19704

Merged
merged 2 commits into from
Oct 20, 2023
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
22 changes: 5 additions & 17 deletions docs/generated/cli/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,6 @@ 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 All @@ -139,7 +123,11 @@ Show help

##### interactive

Type: `boolean`
Type: `string`

Choices: [all, workspace, projects]

Interactively modify changelog markdown contents in your code editor before applying the changes. You can set it to be interactive for all changelogs, or only the workspace level, or only the project level

##### tagVersionPrefix

Expand Down
4 changes: 2 additions & 2 deletions docs/generated/devkit/FileChange.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Description of a file change in the Nx virtual file system/
- [content](../../devkit/documents/FileChange#content): Buffer
- [options](../../devkit/documents/FileChange#options): TreeWriteOptions
- [path](../../devkit/documents/FileChange#path): string
- [type](../../devkit/documents/FileChange#type): "CREATE" | "DELETE" | "UPDATE"
- [type](../../devkit/documents/FileChange#type): "DELETE" | "CREATE" | "UPDATE"

## Properties

Expand Down Expand Up @@ -39,6 +39,6 @@ Path relative to the workspace root

### type

**type**: `"CREATE"` \| `"DELETE"` \| `"UPDATE"`
**type**: `"DELETE"` \| `"CREATE"` \| `"UPDATE"`

Type of change: 'CREATE' | 'DELETE' | 'UPDATE'
22 changes: 5 additions & 17 deletions docs/generated/packages/nx/documents/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,6 @@ 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 All @@ -139,7 +123,11 @@ Show help

##### interactive

Type: `boolean`
Type: `string`

Choices: [all, workspace, projects]

Interactively modify changelog markdown contents in your code editor before applying the changes. You can set it to be interactive for all changelogs, or only the workspace level, or only the project level

##### tagVersionPrefix

Expand Down
99 changes: 96 additions & 3 deletions e2e/release/src/release.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ expect.addSnapshotSerializer({
.replaceAll(/\d*B package\.json/g, 'XXXB package.json')
.replaceAll(/size:\s*\d*\s?B/g, 'size: XXXB')
.replaceAll(/\d*\.\d*\s?kB/g, 'XXX.XXX kb')
.replaceAll(/[a-fA-F0-9]{7}/g, '{COMMIT_SHA}')
// We trim each line to reduce the chances of snapshot flakiness
.split('\n')
.map((r) => r.trim())
Expand Down Expand Up @@ -122,10 +123,10 @@ describe('nx release', () => {
const changelogOutput = runCLI(`release changelog 999.9.9`);
expect(changelogOutput).toMatchInlineSnapshot(`
> NX Generating a CHANGELOG.md entry for v999.9.9
> NX Generating an entry in CHANGELOG.md for v999.9.9
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I switched round the structure of the log, because now that the path is fully customizable it could end up being reasonably long (depending on the level of nesting within the tree) and for longer paths it reads better this new way round

+ ## v999.9.9
+ ## 999.9.9
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was previously unintentional to have the v prefix within the changelog contents, other tools don't do it, so this small change is a fix really

+
+
+ ### 🚀 Features
Expand All @@ -140,7 +141,7 @@ describe('nx release', () => {
`);

expect(readFile('CHANGELOG.md')).toMatchInlineSnapshot(`
## v999.9.9
## 999.9.9
### 🚀 Features
Expand Down Expand Up @@ -544,6 +545,98 @@ describe('nx release', () => {
.trim()
).toEqual('1000.0.0-next.0');

// Update custom nx release config to demonstrate project level changelogs
updateJson<NxJsonConfiguration>('nx.json', (nxJson) => {
nxJson.release = {
groups: {
default: {
// @proj/source will be added as a project by the verdaccio setup, but we aren't versioning or publishing it, so we exclude it here
projects: ['*', '!@proj/source'],
changelog: {
// This should be merged with and take priority over the projectChangelogs config at the root of the config
createRelease: 'github',
},
},
},
changelog: {
projectChangelogs: {
renderOptions: {
createRelease: false, // will be overridden by the group
// Customize the changelog renderer to not print the Thank You section this time (not overridden by the group)
includeAuthors: false,
},
},
},
};
return nxJson;
});

// We need a valid git origin for the command to work when createRelease is set
await runCommandAsync(
`git remote add origin https://github.com/nrwl/fake-repo.git`
);

// Perform a dry-run this time to show that it works but also prevent making any requests to github within the test
const changelogDryRunOutput = runCLI(
`release changelog 1000.0.0-next.0 --dry-run`
);
expect(changelogDryRunOutput).toMatchInlineSnapshot(`
> NX Previewing an entry in CHANGELOG.md for v1000.0.0-next.0
+ ## 1000.0.0-next.0
+
+
+ ### 🚀 Features
+
+ - an awesome new feature
+
+ ### ❤️ Thank You
+
+ - Test
+
## 999.9.9
> NX Previewing a Github release and an entry in {project-name}/CHANGELOG.md for {project-name}@v1000.0.0-next.0
Copy link
Collaborator Author

@JamesHenry JamesHenry Oct 18, 2023

Choose a reason for hiding this comment

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

Just a reminder that the {project-name} here is normalized by the e2e snapshot serializer. I verified this produces the correct project name in real usage

+ ## 1000.0.0-next.0
+
+
+ ### 🚀 Features
+
+ - an awesome new feature ([{COMMIT_SHA}](https://github.com/nrwl/fake-repo/commit/{COMMIT_SHA}))
> NX Previewing a Github release and an entry in {project-name}/CHANGELOG.md for {project-name}@v1000.0.0-next.0
+ ## 1000.0.0-next.0
+
+
+ ### 🚀 Features
+
+ - an awesome new feature ([{COMMIT_SHA}](https://github.com/nrwl/fake-repo/commit/{COMMIT_SHA}))
> NX Previewing a Github release and an entry in {project-name}/CHANGELOG.md for {project-name}@v1000.0.0-next.0
+ ## 1000.0.0-next.0
+
+
+ ### 🚀 Features
+
+ - an awesome new feature ([{COMMIT_SHA}](https://github.com/nrwl/fake-repo/commit/{COMMIT_SHA}))
`);

// port and process cleanup
await killProcessAndPorts(process.pid, verdaccioPort);
}, 500000);
Expand Down
Loading