This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
fix(add): properly save new deps where they go #273
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wraithgar
force-pushed
the
gar/save-type-bugfixes
branch
5 times, most recently
from
May 5, 2021 15:59
70bb60a
to
29314bc
Compare
wraithgar
force-pushed
the
gar/save-type-bugfixes
branch
from
May 5, 2021 17:23
29314bc
to
70b6a05
Compare
Did you mean to include an empty |
wraithgar
force-pushed
the
gar/save-type-bugfixes
branch
from
May 5, 2021 20:03
70b6a05
to
f370563
Compare
isaacs
reviewed
May 6, 2021
isaacs
reviewed
May 6, 2021
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.
Everything here looks good, but I'd recommend adding this:
diff --git a/tap-snapshots/test/arborist/reify.js.test.cjs b/tap-snapshots/test/arborist/reify.js.test.cjs
index 513c7485..8a69c358 100644
--- a/tap-snapshots/test/arborist/reify.js.test.cjs
+++ b/tap-snapshots/test/arborist/reify.js.test.cjs
@@ -14982,6 +14982,10 @@ exports[`test/arborist/reify.js TAP no saveType: peer only > must match snapshot
{"peerDependencies":{"abbrev":"^1.1.1"}}
`
+exports[`test/arborist/reify.js TAP no saveType: prod w/ compatible peer, saves prod only > must match snapshot 1`] = `
+{"dependencies":{"abbrev":"^1.1.1"}}
+`
+
exports[`test/arborist/reify.js TAP omit peer deps > finished timers 1`] = `
Array [
"arborist:ctor",
diff --git a/test/arborist/reify.js b/test/arborist/reify.js
index b8323a8b..e1eb5361 100644
--- a/test/arborist/reify.js
+++ b/test/arborist/reify.js
@@ -1752,17 +1752,17 @@ t.test('no saveType: dev w/ incompatible optional', async t => {
t.matchSnapshot(fs.readFileSync(path + '/package.json', 'utf8'))
})
-// t.test('no saveType: prod w/ compatible peer', async t => {
-// const path = t.testdir({
-// 'package.json': JSON.stringify({
-// peerDependencies: { abbrev: '*' },
-// dependencies: { abbrev: '*' },
-// }),
-// })
-// const arb = newArb({ path })
-// await arb.reify({ add: ['abbrev'] })
-// t.matchSnapshot(fs.readFileSync(path + '/package.json', 'utf8'))
-// })
+t.test('no saveType: prod w/ compatible peer, saves prod only', async t => {
+ const path = t.testdir({
+ 'package.json': JSON.stringify({
+ peerDependencies: { abbrev: '*' },
+ dependencies: { abbrev: '*' },
+ }),
+ })
+ const arb = newArb({ path })
+ await arb.reify({ add: ['abbrev'] })
+ t.matchSnapshot(fs.readFileSync(path + '/package.json', 'utf8'))
+})
t.test('no saveType: peer only', async t => {
const path = t.testdir({
Ie, uncomment the test, and name it based on what is happening, so if it changes we notice. Or just delete the test if it's not necessary.
wraithgar
force-pushed
the
gar/save-type-bugfixes
branch
from
May 6, 2021 15:46
f370563
to
d289203
Compare
Right now where we end up saving a dep is not very well coupled to where the user requested it. We are inferring more than we are checking for intention. This moves us to more heavily lean on the `saveType` if given when adding a package into the dependencies. We also were not consistently inferring the saveType. There was code in two places trying to do this, and either place used slightly different logic. This moves the logic into one place. Finally, we are more consistently making certain dependency types mutually exclusive, for instance dependencies and devDependencies. PR-URL: #273 Credit: @wraithgar Close: #273 Reviewed-by: @nlf
nlf
force-pushed
the
gar/save-type-bugfixes
branch
from
May 6, 2021 17:01
d289203
to
cbcccc9
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This consolidates and standardizes the logic around where in the package.json we save added packages. We explicitly obey the
saveType
if it's given, properly infer it now if it isn't, and enforce exclusivity between things likedependencies
anddevDependencies
We also now log a warning when we've ignored one for the other.
References
Closes: npm/cli#2647
Related to: npm/cli#3096
Related to: npm/cli#2647