Repository: atlassian/changesets
Pull request #205 (2019-10-26 08:40:42)

Don't update ranges set to */x/X when versioning
This means we won't break Manypkg's new "make internal dev deps '*'" rule.

changeset-bot[bot]: ###  🦋  Changeset is good to go

Latest commit: 45f81845fca3520429c5b0bb877a3cca14d6f9c0

**We got this.**

Not sure what this means? [Click here  to learn what changesets are](https://github.com/Noviny/changesets/blob/master/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add another changeset to this PR](https://github.com/atlassian/changesets/new/do-not-update-ranges-set-to-match-all-versions?filename=.changeset/wet-melons-study.md)


codecov[bot]: # [Codecov](https://codecov.io/gh/atlassian/changesets/pull/205?src=pr&el=h1) Report
> Merging [#205](https://codecov.io/gh/atlassian/changesets/pull/205?src=pr&el=desc) into [master](https://codecov.io/gh/atlassian/changesets/commit/003db6b1b1e15c82864df419029d4930a0859ab1?src=pr&el=desc) will **increase** coverage by `0.04%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/atlassian/changesets/pull/205/graphs/tree.svg?width=650&token=j0W25zrXm2&height=150&src=pr)](https://codecov.io/gh/atlassian/changesets/pull/205?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##           master    #205      +/-   ##
=========================================
+ Coverage   76.35%   76.4%   +0.04%     
=========================================
  Files          41      41              
  Lines        1049    1051       +2     
  Branches      228     229       +1     
=========================================
+ Hits          801     803       +2     
  Misses        244     244              
  Partials        4       4
```


| [Impacted Files](https://codecov.io/gh/atlassian/changesets/pull/205?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [packages/apply-release-plan/src/version-package.ts](https://codecov.io/gh/atlassian/changesets/pull/205/diff?src=pr&el=tree#diff-cGFja2FnZXMvYXBwbHktcmVsZWFzZS1wbGFuL3NyYy92ZXJzaW9uLXBhY2thZ2UudHM=) | `100% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/atlassian/changesets/pull/205?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/atlassian/changesets/pull/205?src=pr&el=footer). Last update [003db6b...ea53029](https://codecov.io/gh/atlassian/changesets/pull/205?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/.changeset/rich-rules-live.md b/.changeset/rich-rules-live.md
new file mode 100644
index 0000000..06181ca
--- /dev/null
+++ b/.changeset/rich-rules-live.md
@@ -0,0 +1,6 @@
+---
+"@changesets/apply-release-plan": patch
+"@changesets/cli": patch
+---
+
+Don't update ranges set to \*/x/X when versioning
diff --git a/__fixtures__/simple-star-dep/.changeset/README.md b/__fixtures__/simple-star-dep/.changeset/README.md
new file mode 100644
index 0000000..fd188f5
--- /dev/null
+++ b/__fixtures__/simple-star-dep/.changeset/README.md
@@ -0,0 +1,3 @@
+# We just want a file in here so git collects it
+
+For this we have deliberately not included a config file, as we want to test the defaults
\ No newline at end of file
diff --git a/__fixtures__/simple-star-dep/.changeset/config.json b/__fixtures__/simple-star-dep/.changeset/config.json
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/__fixtures__/simple-star-dep/.changeset/config.json
@@ -0,0 +1,1 @@
+{}
diff --git a/__fixtures__/simple-star-dep/package.json b/__fixtures__/simple-star-dep/package.json
new file mode 100644
index 0000000..2e742d8
--- /dev/null
+++ b/__fixtures__/simple-star-dep/package.json
@@ -0,0 +1,11 @@
+{
+  "private": true,
+  "name": "simple-project",
+  "description": "three projects, each depending on one other",
+  "version": "1.0.0",
+  "bolt": {
+    "workspaces": [
+      "packages/*"
+    ]
+  }
+}
diff --git a/__fixtures__/simple-star-dep/packages/pkg-a/package.json b/__fixtures__/simple-star-dep/packages/pkg-a/package.json
new file mode 100644
index 0000000..1b5eaff
--- /dev/null
+++ b/__fixtures__/simple-star-dep/packages/pkg-a/package.json
@@ -0,0 +1,7 @@
+{
+  "name": "pkg-a",
+  "version": "1.0.0",
+  "dependencies": {
+    "pkg-b": "*"
+  }
+}
diff --git a/__fixtures__/simple-star-dep/packages/pkg-b/package.json b/__fixtures__/simple-star-dep/packages/pkg-b/package.json
new file mode 100644
index 0000000..be4760e
--- /dev/null
+++ b/__fixtures__/simple-star-dep/packages/pkg-b/package.json
@@ -0,0 +1,4 @@
+{
+  "name": "pkg-b",
+  "version": "1.0.0"
+}
diff --git a/packages/apply-release-plan/package.json b/packages/apply-release-plan/package.json
index 4a35ce3..d92ee8c 100644
--- a/packages/apply-release-plan/package.json
+++ b/packages/apply-release-plan/package.json
@@ -17,7 +17,8 @@
     "lodash.startcase": "^4.4.0",
     "outdent": "^0.5.0",
     "prettier": "^1.14.3",
-    "resolve-from": "^5.0.0"
+    "resolve-from": "^5.0.0",
+    "semver": "^5.4.1"
   },
   "devDependencies": {
     "jest-fixtures": "^0.5.0",
diff --git a/packages/apply-release-plan/src/index.ts b/packages/apply-release-plan/src/index.ts
index 2962646..84b023d 100644
--- a/packages/apply-release-plan/src/index.ts
+++ b/packages/apply-release-plan/src/index.ts
@@ -77,11 +77,9 @@ export default async function applyReleasePlan(
   );
 
   // iterate over releases updating packages
-  let finalisedRelease = await Promise.all(
-    releaseWithChangelogs.map(release => {
-      return versionPackage(release, versionsToUpdate);
-    })
-  );
+  let finalisedRelease = releaseWithChangelogs.map(release => {
+    return versionPackage(release, versionsToUpdate);
+  });
 
   let prettierConfig = await prettier.resolveConfig(cwd);
 
diff --git a/packages/apply-release-plan/src/version-package.ts b/packages/apply-release-plan/src/version-package.ts
index a677b60..ff48c3f 100644
--- a/packages/apply-release-plan/src/version-package.ts
+++ b/packages/apply-release-plan/src/version-package.ts
@@ -1,5 +1,6 @@
 import { ComprehensiveRelease, PackageJSON } from "@changesets/types";
 import getVersionRangeType from "@changesets/get-version-range-type";
+import { Range } from "semver";
 
 const DEPENDENCY_TYPES = [
   "dependencies",
@@ -8,7 +9,7 @@ const DEPENDENCY_TYPES = [
   "optionalDependencies"
 ] as const;
 
-export default async function versionPackage(
+export default function versionPackage(
   release: ComprehensiveRelease & {
     changelog: string | null;
     config: PackageJSON;
@@ -21,17 +22,23 @@ export default async function versionPackage(
   config.version = newVersion;
 
   for (let type of DEPENDENCY_TYPES) {
-    if (config[type]) {
-      versionsToUpdate.forEach(({ name, version }) => {
-        // @ts-ignore I shan't be having with this config[type] might be undefined nonsense
-        let depCurrentVersion = config[type][name];
-        if (depCurrentVersion) {
+    let deps = config[type];
+    if (deps) {
+      for (let { name, version } of versionsToUpdate) {
+        let depCurrentVersion = deps[name];
+        if (
+          depCurrentVersion &&
+          // an empty string is the normalised version of x/X/*
+          // we don't want to change these versions because they will match
+          // any version and if someone makes the range that
+          // they probably want it to stay like that
+          new Range(depCurrentVersion).range !== ""
+        ) {
           let rangeType = getVersionRangeType(depCurrentVersion);
           let newNewRange = `${rangeType}${version}`;
-          // @ts-ignore I shan't be having with this config[type] might be undefined nonsense
-          config[type][name] = newNewRange;
+          deps[name] = newNewRange;
         }
-      });
+      }
     }
   }
 


Test patch:
diff --git a/packages/apply-release-plan/src/index.test.ts b/packages/apply-release-plan/src/index.test.ts
index 33c06a7..62289ab 100644
--- a/packages/apply-release-plan/src/index.test.ts
+++ b/packages/apply-release-plan/src/index.test.ts
@@ -105,6 +105,43 @@ describe("apply release plan", () => {
         version: "1.1.0"
       });
     });
+    it("should not update ranges set to *", async () => {
+      const releasePlan = new FakeReleasePlan(
+        [
+          {
+            id: "some-id",
+            releases: [{ name: "pkg-b", type: "minor" }],
+            summary: "a very useful summary"
+          }
+        ],
+        [
+          {
+            changesets: ["some-id"],
+            name: "pkg-b",
+            newVersion: "1.1.0",
+            oldVersion: "1.0.0",
+            type: "minor"
+          }
+        ]
+      );
+      let { changedFiles } = await testSetup(
+        "simple-star-dep",
+        releasePlan.getReleasePlan(),
+        releasePlan.config
+      );
+      let pkgPath = changedFiles.find(a => a.endsWith("pkg-a/package.json"));
+
+      if (!pkgPath) throw new Error(`could not find an updated package json`);
+      let pkgJSON = await fs.readJSON(pkgPath);
+
+      expect(pkgJSON).toEqual({
+        name: "pkg-a",
+        version: "1.1.0",
+        dependencies: {
+          "pkg-b": "*"
+        }
+      });
+    });
     it("should update a version for two packages with different new versions", async () => {
       const releasePlan = new FakeReleasePlan();
       releasePlan.releases = [