-
-
Notifications
You must be signed in to change notification settings - Fork 811
Fix peer dep changelogs #747
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
Changes from all commits
f25f866
a9d5ee4
db6a2a2
7687aa6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@changesets/cli": minor | ||
| "@changesets/types": minor | ||
| --- | ||
|
|
||
| Adds an additional `dependencyType` argument to the `getDependencyReleaseLine` changelog function to distinguish peer dependency upgrades from normal dependency upgrades |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@changesets/apply-release-plan": patch | ||
| "@changesets/cli": patch | ||
| --- | ||
|
|
||
| Fix peer dependency changelog lines being added under 'patch' instead of 'major' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1931,6 +1931,82 @@ describe("apply release plan", () => { | |
|
|
||
| - Hey, let's have fun with testing!`); | ||
| }); | ||
|
|
||
| it("should add peer dependency changelog line under major", async () => { | ||
| let { changedFiles } = await testSetup( | ||
| "simple-caret-peer-dep", | ||
| { | ||
| changesets: [ | ||
| { | ||
| id: "quick-lions-devour", | ||
| summary: "Hey, let's have fun with testing!", | ||
| releases: [{ name: "depended-upon", type: "minor" }] | ||
| } | ||
| ], | ||
| releases: [ | ||
| { | ||
| name: "depended-upon", | ||
| type: "patch", | ||
| oldVersion: "1.0.0", | ||
| newVersion: "1.1.0", | ||
| changesets: ["quick-lions-devour"] | ||
| }, | ||
| { | ||
| name: "has-peer-dep", | ||
| type: "patch", | ||
| oldVersion: "1.0.0", | ||
| newVersion: "2.0.0", | ||
| changesets: [] | ||
| } | ||
| ], | ||
| preState: undefined | ||
| }, | ||
| { | ||
| changelog: [ | ||
| path.resolve(__dirname, "test-utils/simple-get-changelog-entry"), | ||
| null | ||
| ], | ||
| commit: false, | ||
| linked: [], | ||
| access: "restricted", | ||
| baseBranch: "main", | ||
| updateInternalDependencies: "patch", | ||
| ignore: [], | ||
| ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { | ||
| onlyUpdatePeerDependentsWhenOutOfRange: false, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity - so I assume that you are still using this default setting, doesn't it create major releases for you way too often?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah we are. It does for packages that have peer dependencies that upgrade frequently yes. The alternative though is that the minimum versions of peer dependency version ranges become stale which can break things, especially with aggressive de-duplication. It probably is worth re-exploring though. |
||
| updateInternalDependents: "out-of-range", | ||
| useCalculatedVersionForSnapshots: false | ||
| } | ||
| } | ||
| ); | ||
|
|
||
| let readmePath = changedFiles.find(a => | ||
| a.endsWith(`depended-upon${path.sep}CHANGELOG.md`) | ||
| ); | ||
| let readmePathB = changedFiles.find(a => | ||
| a.endsWith(`has-peer-dep${path.sep}CHANGELOG.md`) | ||
| ); | ||
|
|
||
| if (!readmePath || !readmePathB) | ||
| throw new Error(`could not find an updated changelog`); | ||
| let readme = await fs.readFile(readmePath, "utf-8"); | ||
| let readmeB = await fs.readFile(readmePathB, "utf-8"); | ||
|
|
||
| expect(readme.trim()).toEqual(outdent`# depended-upon | ||
|
|
||
| ## 1.1.0 | ||
| ### Minor Changes | ||
|
|
||
| - Hey, let's have fun with testing!`); | ||
|
|
||
| expect(readmeB.trim()).toEqual(outdent`# has-peer-dep | ||
|
|
||
| ## 2.0.0 | ||
| ### Major Changes | ||
|
|
||
| - Updated dependencies | ||
| - depended-upon@1.1.0`); | ||
| }); | ||
| }); | ||
| describe("should error and not write if", () => { | ||
| // This is skipped as *for now* we are assuming we have been passed | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I read the code correctly this could actually be also caused by an optional dependency.
q: do you plan to utilize this new argument in your code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Releases only contain packages specified in the
dependenciesandpeerDependenciesfields of package.json so I don't think optional dependencies would be included here unless they were also specified independencieswhich isn't recommended behaviour.We're planning to use it to distinguish peer dep upgrade lines from non-peer dep ones so that we output a more detailed message for major peer upgrades.
This distinction could also be made using a
bumpTypeorisPeerargument instead.