Skip to content

Commit

Permalink
Fix a bug with the dev and peer dep check (#30)
Browse files Browse the repository at this point in the history
* Stuff

* A better name for the test
  • Loading branch information
emmatown authored Nov 7, 2019
1 parent a2f0214 commit 528bb72
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-fans-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@manypkg/cli": minor
---

Changed peer and dev dependency relationship check to only require that the upper bound of the dev dep range is within the peer dep range so that cases where the dev dep range allows versions lower than the lower bound of such as a peer dep with `^1.0.0` and dev dep with `*` are allowed and this fixes the regression in 0.8.1 where cases that should have been fine weren't like a peer dep with `^1.0.0` and a dev dep with `^1.1.0`
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"get-workspaces": "^0.5.0",
"meow": "^5.0.0",
"p-limit": "^2.2.1",
"sembear": "^0.4.1",
"sembear": "^0.5.0",
"semver": "^6.3.0",
"spawndamnit": "^2.0.0",
"validate-npm-package-name": "^3.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeCheck, Workspace, getHighestExternalRanges } from "./utils";
import { contains } from "sembear";
import { upperBoundOfRangeAWithinBoundsOfB } from "sembear";

type ErrorType = {
type: "INVALID_DEV_AND_PEER_DEPENDENCY_RELATIONSHIP";
Expand Down Expand Up @@ -36,7 +36,12 @@ export default makeCheck<ErrorType>({
devVersion: null,
idealDevVersion
});
} else if (!contains(devDeps[depName], peerDeps[depName])) {
} else if (
!upperBoundOfRangeAWithinBoundsOfB(
devDeps[depName],
peerDeps[depName]
)
) {
let highestRanges = getHighestExternalRanges(allWorkspaces);
let idealDevVersion = highestRanges.get(depName);
if (idealDevVersion === undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,17 @@ describe("invalid dev and peer dependency", () => {
"external-dep": "^1.0.0"
});
});
it("should work when the lower bound of the devDep range is above the lower bound of the peer dep range", () => {
let ws = getWS();
let pkg1 = ws.get("pkg-1")!;

pkg1.config.peerDependencies = {
"external-dep": "^1.0.0"
};
pkg1.config.devDependencies = {
"external-dep": "^1.1.0"
};
let errors = makeCheck.validate(pkg1, ws);
expect(errors).toHaveLength(0);
});
});
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11893,10 +11893,10 @@ selfsigned@^1.10.7:
dependencies:
node-forge "0.9.0"

sembear@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/sembear/-/sembear-0.4.1.tgz#c1599bba0fd29cce68a25382576891e5fae84990"
integrity sha512-q3LJepi7qgDbkR9eDe1OVYfbD8A14vuC8TtETtEvpAQ4GxynA9B0fhG6ts8scBMDe/GwLlVUeU+Icnl1oidH7g==
sembear@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/sembear/-/sembear-0.5.0.tgz#c2816702770022c94f5e7a0fc92a20103ff98b33"
integrity sha512-TIKNdyDMViRifHrQC1OLM/o75ApE6dTISmsoCJrkgZmzKLpwgAgsq5gYvv0e7BZpuA0fT4N+Ya5ZxeH6hQv1Tw==
dependencies:
"@types/semver" "^6.0.1"
semver "^6.3.0"
Expand Down

0 comments on commit 528bb72

Please sign in to comment.