Repository: atlassian/changesets
Pull request #482 (2020-11-06 01:10:22)

None bumping peerdeps should not cause major bumps

changeset-bot[bot]: ###  ⚠️  No Changeset found

Latest commit: d1f3469810f23bbcc951be58307146065533206e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**

<details><summary>This PR includes no changesets</summary>

  When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

</details>

[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/master/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/jonathanmorley/changesets/new/none-major-peerdeps?filename=.changeset/blue-yaks-joke.md&value=---%0A%22%40changesets%2Fassemble-release-plan%22%3A%20patch%0A---%0A%0ANone%20bumping%20peerdeps%20should%20not%20cause%20major%20bumps%0A)



Patch:
diff --git a/.changeset/blue-yaks-joke.md b/.changeset/blue-yaks-joke.md
new file mode 100644
index 0000000..be3a0dd
--- /dev/null
+++ b/.changeset/blue-yaks-joke.md
@@ -0,0 +1,5 @@
+---
+"@changesets/assemble-release-plan": patch
+---
+
+Fixed an issue with bumping a peer dependency using a `"none"` changeset type resulting in the dependant package being major bumped.
diff --git a/packages/assemble-release-plan/src/determine-dependents.ts b/packages/assemble-release-plan/src/determine-dependents.ts
index 4dd4648..ca4d4b7 100644
--- a/packages/assemble-release-plan/src/determine-dependents.ts
+++ b/packages/assemble-release-plan/src/determine-dependents.ts
@@ -210,6 +210,7 @@ function shouldBumpMajor({
   // we check if it is a peerDependency because if it is, our dependent bump type might need to be major.
   return (
     depType === "peerDependencies" &&
+    nextRelease.type !== "none" &&
     nextRelease.type !== "patch" &&
     // 1. If onlyUpdatePeerDependentsWhenOutOfRange set to true, bump major if the version is leaving the range.
     // 2. If onlyUpdatePeerDependentsWhenOutOfRange set to false, bump major regardless whether or not the version is leaving the range.


Test patch:
diff --git a/packages/assemble-release-plan/src/index.test.ts b/packages/assemble-release-plan/src/index.test.ts
index a06a2c4..3372d12 100644
--- a/packages/assemble-release-plan/src/index.test.ts
+++ b/packages/assemble-release-plan/src/index.test.ts
@@ -669,6 +669,25 @@ describe("bumping peerDeps", () => {
     expect(releases[1].name).toEqual("pkg-b");
     expect(releases[1].newVersion).toEqual("1.0.1");
   });
+  it("should not bump the dependent when bumping a tilde peerDep by none", () => {
+    setup.updatePeerDep("pkg-b", "pkg-a", "~1.0.0");
+    setup.changesets = [];
+    setup.addChangeset({
+      id: "anyway-the-windblows",
+      releases: [{ name: "pkg-a", type: "none" }]
+    });
+
+    let { releases } = assembleReleasePlan(
+      setup.changesets,
+      setup.packages,
+      defaultConfig,
+      undefined
+    );
+
+    expect(releases.length).toBe(1);
+    expect(releases[0].name).toEqual("pkg-a");
+    expect(releases[0].newVersion).toEqual("1.0.0");
+  });
   it("should not bump the dependent when bumping a tilde peerDep by a patch", () => {
     setup.updatePeerDep("pkg-b", "pkg-a", "~1.0.0");
 
@@ -723,6 +742,25 @@ describe("bumping peerDeps", () => {
     expect(releases[1].name).toEqual("pkg-b");
     expect(releases[1].newVersion).toEqual("2.0.0");
   });
+  it("should not bump dependent when bumping caret peerDep by none", () => {
+    setup.updatePeerDep("pkg-b", "pkg-a", "^1.0.0");
+    setup.changesets = [];
+    setup.addChangeset({
+      id: "anyway-the-windblows",
+      releases: [{ name: "pkg-a", type: "none" }]
+    });
+
+    let { releases } = assembleReleasePlan(
+      setup.changesets,
+      setup.packages,
+      defaultConfig,
+      undefined
+    );
+
+    expect(releases.length).toBe(1);
+    expect(releases[0].name).toEqual("pkg-a");
+    expect(releases[0].newVersion).toEqual("1.0.0");
+  });
   it("should not bump dependent when bumping caret peerDep by patch", () => {
     setup.updatePeerDep("pkg-b", "pkg-a", "^1.0.0");