Skip to content

Commit 2c0994a

Browse files
authored
feat(release)!: rewrite ChangelogRenderer to a class API and remove deprecated config (#28229)
BREAKING CHANGE In Nx v19, implementing a custom changelog renderer would involve a lot of work on the user side. They would need to create an additional function making every property available in its declaration and then call the underlying default one and customize the final string (or reimplement the whole thing). E.g. ```js const changelogRenderer = async ({ projectGraph, commits, releaseVersion, project, entryWhenNoChanges, changelogRenderOptions, repoSlug, conventionalCommitsConfig, changes, }) => { const defaultChangelog = await defaultChangelogRenderer({ projectGraph, commits, releaseVersion, project, entryWhenNoChanges, changelogRenderOptions, repoSlug, conventionalCommitsConfig, changes, }); // ...Do custom stuff and return final string... }; module.exports = changelogRenderer; ``` In Nx v20, changelog renderer are classes. The DefaultChangelogRenderer can therefore easily and granularly be extended and customized, and the config does not need to be redeclared on the user side at all. We will improve things even further in this area, but this breaking change is an important stepping stone. E.g. for manipulating the final string equivalent to the previous example: ```js module.exports = class CustomChangelogRenderer extends ( DefaultChangelogRenderer ) { async render() { const defaultChangelogEntry = await super.render(); // ...Do custom stuff and return final string... } }; ``` E.g. for customizing just how titles get rendered: ```js class CustomChangelogRenderer extends DefaultChangelogRenderer { renderVersionTitle(): string { return 'Custom Version Title'; } } ```
1 parent fe01c61 commit 2c0994a

File tree

8 files changed

+1017
-1086
lines changed

8 files changed

+1017
-1086
lines changed

e2e/release/src/circular-dependencies.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,6 @@ describe('nx release circular dependencies', () => {
544544
545545
+ # 2.0.0 (YYYY-MM-DD)
546546
+
547-
+
548547
+ ### 🧱 Updated Dependencies
549548
+
550549
+ - Updated {project-name} to 2.0.0
@@ -556,7 +555,6 @@ describe('nx release circular dependencies', () => {
556555
557556
+ # 2.0.0 (YYYY-MM-DD)
558557
+
559-
+
560558
+ ### 🧱 Updated Dependencies
561559
+
562560
+ - Updated {project-name} to 2.0.0
@@ -867,7 +865,6 @@ describe('nx release circular dependencies', () => {
867865
868866
+ # 2.0.0 (YYYY-MM-DD)
869867
+
870-
+
871868
+ ### 🧱 Updated Dependencies
872869
+
873870
+ - Updated {project-name} to 2.0.0
@@ -879,7 +876,6 @@ describe('nx release circular dependencies', () => {
879876
880877
+ # 2.0.0 (YYYY-MM-DD)
881878
+
882-
+
883879
+ ### 🧱 Updated Dependencies
884880
+
885881
+ - Updated {project-name} to 2.0.0
@@ -1054,7 +1050,6 @@ describe('nx release circular dependencies', () => {
10541050
10551051
+ # 2.0.0 (YYYY-MM-DD)
10561052
+
1057-
+
10581053
+ ### 🧱 Updated Dependencies
10591054
+
10601055
+ - Updated {project-name} to 1.0.1
@@ -1066,7 +1061,6 @@ describe('nx release circular dependencies', () => {
10661061
10671062
+ ## 1.0.1 (YYYY-MM-DD)
10681063
+
1069-
+
10701064
+ ### 🧱 Updated Dependencies
10711065
+
10721066
+ - Updated {project-name} to 2.0.0

e2e/release/src/conventional-commits-config.test.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,10 @@ describe('nx release conventional commits config', () => {
364364
expect(pkg1Changelog).toMatchInlineSnapshot(`
365365
# 1.0.0 (YYYY-MM-DD)
366366
367-
368367
### Custom Type
369368
370369
- ⚠️ **{project-name}:** this is a breaking change
371370
372-
373371
### ⚠️ Breaking Changes
374372
375373
- ⚠️ **{project-name}:** this is a breaking change
@@ -379,7 +377,6 @@ describe('nx release conventional commits config', () => {
379377
expect(pkg2Changelog).toMatchInlineSnapshot(`
380378
# 1.0.0 (YYYY-MM-DD)
381379
382-
383380
### Custom Type
384381
385382
- **{project-name}:** this is a custom type
@@ -389,7 +386,6 @@ describe('nx release conventional commits config', () => {
389386
expect(pkg3Changelog).toMatchInlineSnapshot(`
390387
# 1.0.0 (YYYY-MM-DD)
391388
392-
393389
### Custom Docs Header
394390
395391
- this is a doc
@@ -408,7 +404,6 @@ describe('nx release conventional commits config', () => {
408404
expect(pkg5Changelog).toMatchInlineSnapshot(`
409405
# 1.0.0 (YYYY-MM-DD)
410406
411-
412407
### 🔥 Performance
413408
414409
- this is a performance improvement
@@ -418,12 +413,10 @@ describe('nx release conventional commits config', () => {
418413
expect(pkg6Changelog).toMatchInlineSnapshot(`
419414
# 1.0.0 (YYYY-MM-DD)
420415
421-
422416
### 💅 Refactors
423417
424418
- this is refactor
425419
426-
427420
### 📦 Build
428421
429422
- this is a build

e2e/release/src/release.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ describe('nx release', () => {
129129
130130
+ ## 999.9.9 (YYYY-MM-DD)
131131
+
132-
+
133132
+ ### 🚀 Features
134133
+
135134
+ - an awesome new feature ([{COMMIT_SHA}](https://github.com/nrwl/fake-repo/commit/{COMMIT_SHA}))
@@ -150,7 +149,6 @@ describe('nx release', () => {
150149
expect(readFile('CHANGELOG.md')).toMatchInlineSnapshot(`
151150
## 999.9.9 (YYYY-MM-DD)
152151
153-
154152
### 🚀 Features
155153
156154
- an awesome new feature ([{COMMIT_SHA}](https://github.com/nrwl/fake-repo/commit/{COMMIT_SHA}))
@@ -666,7 +664,7 @@ describe('nx release', () => {
666664
+
667665
## 999.9.9 (YYYY-MM-DD)
668666
669-
667+
### 🚀 Features
670668
671669
672670
NX Previewing an entry in {project-name}/CHANGELOG.md for v1000.0.0-next.0

0 commit comments

Comments
 (0)