Skip to content
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

fix(arborist): save workspace version #4578

Conversation

ruyadorno
Copy link
Contributor

When declaring dependencies to workspaces the common practice is to
refer to their version numbers, currently the cli adds a link reference
instead of the proper semver range when trying to install/declare as a
direct direct dependency one of its own workspaces.

This change fixes it by adding a new condition for handling workspace
edges when saving the current ideal tree.


This also makes it so that it's now possible to update workspace
dependencies in the cli using reify commands, e.g:

Before:

Correct, manually declared, semver range gets replaced with file:<workspace_path>.

$ node . version -w libnpmdiff patch --ignore-scripts
$ node . install libnpmdiff
$ git diff
diff --git a/package-lock.json b/package-lock.json
index b0d9ef371..862374f50 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -112,7 +112,7 @@
         "is-cidr": "^4.0.2",
         "json-parse-even-better-errors": "^2.3.1",
         "libnpmaccess": "^6.0.1",
-        "libnpmdiff": "^4.0.1",
+        "libnpmdiff": "file:workspaces/libnpmdiff",
         "libnpmexec": "^4.0.1",
         "libnpmfund": "^3.0.1",
         "libnpmhook": "^8.0.1",
@@ -10334,7 +10334,7 @@
       }
     },
     "workspaces/libnpmdiff": {
-      "version": "4.0.1",
+      "version": "4.0.2",
       "license": "ISC",
       "dependencies": {
         "@npmcli/disparity-colors": "^1.0.1",
diff --git a/package.json b/package.json
index faf59dc5d..abee5169b 100644
--- a/package.json
+++ b/package.json
@@ -80,7 +80,7 @@
     "is-cidr": "^4.0.2",
     "json-parse-even-better-errors": "^2.3.1",
     "libnpmaccess": "^6.0.1",
-    "libnpmdiff": "^4.0.1",
+    "libnpmdiff": "file:workspaces/libnpmdiff",
     "libnpmexec": "^4.0.1",
     "libnpmfund": "^3.0.1",
     "libnpmhook": "^8.0.1",
diff --git a/workspaces/libnpmdiff/package.json b/workspaces/libnpmdiff/package.json
index 8bf47df12..11d0f5887 100644
--- a/workspaces/libnpmdiff/package.json
+++ b/workspaces/libnpmdiff/package.json
@@ -1,6 +1,6 @@
 {
   "name": "libnpmdiff",
-  "version": "4.0.1",
+  "version": "4.0.2",
   "description": "The registry diff",
   "repository": {
     "type": "git",

After:

Reify uses semver ranges for workspace dependencies.

$ node . version -w libnpmdiff patch --ignore-scripts
$ node . install libnpmdiff
$ git diff
diff --git a/package-lock.json b/package-lock.json
index b0d9ef371..759e118d3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -112,7 +112,7 @@
         "is-cidr": "^4.0.2",
         "json-parse-even-better-errors": "^2.3.1",
         "libnpmaccess": "^6.0.1",
-        "libnpmdiff": "^4.0.1",
+        "libnpmdiff": "^4.0.2",
         "libnpmexec": "^4.0.1",
         "libnpmfund": "^3.0.1",
         "libnpmhook": "^8.0.1",
@@ -10334,7 +10334,7 @@
       }
     },
     "workspaces/libnpmdiff": {
-      "version": "4.0.1",
+      "version": "4.0.2",
       "license": "ISC",
       "dependencies": {
         "@npmcli/disparity-colors": "^1.0.1",
diff --git a/package.json b/package.json
index faf59dc5d..3ddaa1ad3 100644
--- a/package.json
+++ b/package.json
@@ -80,7 +80,7 @@
     "is-cidr": "^4.0.2",
     "json-parse-even-better-errors": "^2.3.1",
     "libnpmaccess": "^6.0.1",
-    "libnpmdiff": "^4.0.1",
+    "libnpmdiff": "^4.0.2",
     "libnpmexec": "^4.0.1",
     "libnpmfund": "^3.0.1",
     "libnpmhook": "^8.0.1",
diff --git a/workspaces/libnpmdiff/package.json b/workspaces/libnpmdiff/package.json
index 8bf47df12..11d0f5887 100644
--- a/workspaces/libnpmdiff/package.json
+++ b/workspaces/libnpmdiff/package.json
@@ -1,6 +1,6 @@
 {
   "name": "libnpmdiff",
-  "version": "4.0.1",
+  "version": "4.0.2",
   "description": "The registry diff",
   "repository": {
     "type": "git",

References

Relates to: #3403

@ruyadorno ruyadorno requested a review from a team as a code owner March 17, 2022 03:23
@ruyadorno ruyadorno added semver:patch semver patch level for changes Release 8.x work is associated with a specific npm 8 release release: next These items should be addressed in the next release labels Mar 17, 2022
When declaring dependencies to workspaces the common practice is to
refer to their version numbers, currently the cli adds a link reference
instead of the proper semver range when trying to install/declare as a
direct direct dependency one of its own workspaces.

This change fixes it by adding a new condition for handling workspace
edges when saving the current ideal tree.

Relates to: npm#3403
@ruyadorno ruyadorno force-pushed the fix-saving-workspace-semver-range-to-root-package-json branch from 509d4b6 to 55a6759 Compare March 17, 2022 03:26
@nlf nlf merged commit e9a2981 into npm:latest Mar 17, 2022
@nlf nlf mentioned this pull request Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: next These items should be addressed in the next release Release 8.x work is associated with a specific npm 8 release semver:patch semver patch level for changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants