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): load actual tree on named updates #4306

Merged
merged 1 commit into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion workspaces/arborist/lib/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
// Load on a new Arborist object, so the Nodes aren't the same,
// or else it'll get super confusing when we change them!
.then(async root => {
if (!this[_updateAll] && !this[_global] && !root.meta.loadedFromDisk) {
if ((!this[_updateAll] && !this[_global] && !root.meta.loadedFromDisk) || (this[_global] && this[_updateNames].length)) {
await new this.constructor(this.options).loadActual({ root })
const tree = root.target
// even though we didn't load it from a package-lock.json FILE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121522,6 +121522,66 @@ ArboristNode {
exports[`test/arborist/build-ideal-tree.js TAP update global > update a single dep 1`] = `
ArboristNode {
"children": Map {
"@isaacs/testing-dev-optional-flags" => ArboristNode {
"children": Map {
"own-or" => ArboristNode {
"edgesIn": Set {
EdgeIn {
"from": "node_modules/@isaacs/testing-dev-optional-flags",
"name": "own-or",
"spec": "^1.0.0",
"type": "prod",
},
},
"location": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/own-or",
"name": "own-or",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global/node_modules/@isaacs/testing-dev-optional-flags/node_modules/own-or",
"version": "1.0.0",
},
"wrappy" => ArboristNode {
"edgesIn": Set {
EdgeIn {
"error": "INVALID",
"from": "node_modules/@isaacs/testing-dev-optional-flags",
"name": "wrappy",
"spec": "^1.0.2",
"type": "prod",
},
},
"location": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/wrappy",
"name": "wrappy",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global/node_modules/@isaacs/testing-dev-optional-flags/node_modules/wrappy",
"version": "1.0.0",
},
},
"edgesIn": Set {
EdgeIn {
"from": "",
"name": "@isaacs/testing-dev-optional-flags",
"spec": "*",
"type": "prod",
},
},
"edgesOut": Map {
"own-or" => EdgeOut {
"name": "own-or",
"spec": "^1.0.0",
"to": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/own-or",
"type": "prod",
},
"wrappy" => EdgeOut {
"error": "INVALID",
"name": "wrappy",
"spec": "^1.0.2",
"to": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/wrappy",
"type": "prod",
},
},
"location": "node_modules/@isaacs/testing-dev-optional-flags",
"name": "@isaacs/testing-dev-optional-flags",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global/node_modules/@isaacs/testing-dev-optional-flags",
"version": "1.0.0",
},
"once" => ArboristNode {
"children": Map {
"wrappy" => ArboristNode {
Expand All @@ -121536,8 +121596,7 @@ ArboristNode {
"location": "node_modules/once/node_modules/wrappy",
"name": "wrappy",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global/node_modules/once/node_modules/wrappy",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"version": "1.0.2",
"version": "1.0.1",
},
},
"edgesIn": Set {
Expand All @@ -121564,6 +121623,12 @@ ArboristNode {
},
},
"edgesOut": Map {
"@isaacs/testing-dev-optional-flags" => EdgeOut {
"name": "@isaacs/testing-dev-optional-flags",
"spec": "*",
"to": "node_modules/@isaacs/testing-dev-optional-flags",
"type": "prod",
},
"once" => EdgeOut {
"name": "once",
"spec": "*",
Expand Down Expand Up @@ -121706,8 +121771,245 @@ ArboristNode {
}
`

exports[`test/arborist/build-ideal-tree.js TAP update global > updating missing dep should have no effect 1`] = `
ArboristNode {
"children": Map {
"@isaacs/testing-dev-optional-flags" => ArboristNode {
"children": Map {
"own-or" => ArboristNode {
"edgesIn": Set {
EdgeIn {
"from": "node_modules/@isaacs/testing-dev-optional-flags",
"name": "own-or",
"spec": "^1.0.0",
"type": "prod",
},
},
"location": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/own-or",
"name": "own-or",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global/node_modules/@isaacs/testing-dev-optional-flags/node_modules/own-or",
"version": "1.0.0",
},
"wrappy" => ArboristNode {
"edgesIn": Set {
EdgeIn {
"error": "INVALID",
"from": "node_modules/@isaacs/testing-dev-optional-flags",
"name": "wrappy",
"spec": "^1.0.2",
"type": "prod",
},
},
"location": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/wrappy",
"name": "wrappy",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global/node_modules/@isaacs/testing-dev-optional-flags/node_modules/wrappy",
"version": "1.0.0",
},
},
"edgesIn": Set {
EdgeIn {
"from": "",
"name": "@isaacs/testing-dev-optional-flags",
"spec": "*",
"type": "prod",
},
},
"edgesOut": Map {
"own-or" => EdgeOut {
"name": "own-or",
"spec": "^1.0.0",
"to": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/own-or",
"type": "prod",
},
"wrappy" => EdgeOut {
"error": "INVALID",
"name": "wrappy",
"spec": "^1.0.2",
"to": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/wrappy",
"type": "prod",
},
},
"location": "node_modules/@isaacs/testing-dev-optional-flags",
"name": "@isaacs/testing-dev-optional-flags",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global/node_modules/@isaacs/testing-dev-optional-flags",
"version": "1.0.0",
},
"once" => ArboristNode {
"children": Map {
"wrappy" => ArboristNode {
"edgesIn": Set {
EdgeIn {
"from": "node_modules/once",
"name": "wrappy",
"spec": "1",
"type": "prod",
},
},
"location": "node_modules/once/node_modules/wrappy",
"name": "wrappy",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global/node_modules/once/node_modules/wrappy",
"version": "1.0.1",
},
},
"edgesIn": Set {
EdgeIn {
"from": "",
"name": "once",
"spec": "*",
"type": "prod",
},
},
"edgesOut": Map {
"wrappy" => EdgeOut {
"name": "wrappy",
"spec": "1",
"to": "node_modules/once/node_modules/wrappy",
"type": "prod",
},
},
"location": "node_modules/once",
"name": "once",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global/node_modules/once",
"version": "1.3.1",
},
},
"edgesOut": Map {
"@isaacs/testing-dev-optional-flags" => EdgeOut {
"name": "@isaacs/testing-dev-optional-flags",
"spec": "*",
"to": "node_modules/@isaacs/testing-dev-optional-flags",
"type": "prod",
},
"once" => EdgeOut {
"name": "once",
"spec": "*",
"to": "node_modules/once",
"type": "prod",
},
},
"isProjectRoot": true,
"location": "",
"name": "tap-testdir-build-ideal-tree-update-global",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global",
}
`

exports[`test/arborist/build-ideal-tree.js TAP update global > updating sub-dep has no effect 1`] = `
ArboristNode {
"children": Map {
"@isaacs/testing-dev-optional-flags" => ArboristNode {
"children": Map {
"own-or" => ArboristNode {
"edgesIn": Set {
EdgeIn {
"from": "node_modules/@isaacs/testing-dev-optional-flags",
"name": "own-or",
"spec": "^1.0.0",
"type": "prod",
},
},
"location": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/own-or",
"name": "own-or",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global/node_modules/@isaacs/testing-dev-optional-flags/node_modules/own-or",
"version": "1.0.0",
},
"wrappy" => ArboristNode {
"edgesIn": Set {
EdgeIn {
"error": "INVALID",
"from": "node_modules/@isaacs/testing-dev-optional-flags",
"name": "wrappy",
"spec": "^1.0.2",
"type": "prod",
},
},
"location": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/wrappy",
"name": "wrappy",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global/node_modules/@isaacs/testing-dev-optional-flags/node_modules/wrappy",
"version": "1.0.0",
},
},
"edgesIn": Set {
EdgeIn {
"from": "",
"name": "@isaacs/testing-dev-optional-flags",
"spec": "*",
"type": "prod",
},
},
"edgesOut": Map {
"own-or" => EdgeOut {
"name": "own-or",
"spec": "^1.0.0",
"to": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/own-or",
"type": "prod",
},
"wrappy" => EdgeOut {
"error": "INVALID",
"name": "wrappy",
"spec": "^1.0.2",
"to": "node_modules/@isaacs/testing-dev-optional-flags/node_modules/wrappy",
"type": "prod",
},
},
"location": "node_modules/@isaacs/testing-dev-optional-flags",
"name": "@isaacs/testing-dev-optional-flags",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global/node_modules/@isaacs/testing-dev-optional-flags",
"version": "1.0.0",
},
"once" => ArboristNode {
"children": Map {
"wrappy" => ArboristNode {
"edgesIn": Set {
EdgeIn {
"from": "node_modules/once",
"name": "wrappy",
"spec": "1",
"type": "prod",
},
},
"location": "node_modules/once/node_modules/wrappy",
"name": "wrappy",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global/node_modules/once/node_modules/wrappy",
"version": "1.0.1",
},
},
"edgesIn": Set {
EdgeIn {
"from": "",
"name": "once",
"spec": "*",
"type": "prod",
},
},
"edgesOut": Map {
"wrappy" => EdgeOut {
"name": "wrappy",
"spec": "1",
"to": "node_modules/once/node_modules/wrappy",
"type": "prod",
},
},
"location": "node_modules/once",
"name": "once",
"path": "{CWD}/test/arborist/tap-testdir-build-ideal-tree-update-global/node_modules/once",
"version": "1.3.1",
},
},
"edgesOut": Map {
"@isaacs/testing-dev-optional-flags" => EdgeOut {
"name": "@isaacs/testing-dev-optional-flags",
"spec": "*",
"to": "node_modules/@isaacs/testing-dev-optional-flags",
"type": "prod",
},
"once" => EdgeOut {
"name": "once",
"spec": "*",
"to": "node_modules/once",
"type": "prod",
},
},
"isProjectRoot": true,
"location": "",
"name": "tap-testdir-build-ideal-tree-update-global",
Expand Down
4 changes: 4 additions & 0 deletions workspaces/arborist/test/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,10 @@ t.test('update global', async t => {
},
},
})

t.matchSnapshot(await printIdeal(path, { global: true, update: ['abbrev'] }),
'updating missing dep should have no effect')

t.matchSnapshot(await printIdeal(path, { global: true, update: ['wrappy'] }),
'updating sub-dep has no effect')
t.matchSnapshot(await printIdeal(path, { global: true, update: ['once'] }),
Expand Down