From 281a7f39ac314bd7657ce2bcd7918b21eee99210 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 2 Oct 2020 11:21:32 -0700 Subject: [PATCH] @npmcli/arborist@0.0.31 --- .../arborist/lib/arborist/build-ideal-tree.js | 2 +- .../@npmcli/arborist/lib/arborist/rebuild.js | 38 +++++++++++-------- node_modules/@npmcli/arborist/package.json | 2 +- package-lock.json | 14 +++---- package.json | 2 +- 5 files changed, 32 insertions(+), 26 deletions(-) diff --git a/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js b/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js index 4b8376c931a73..2fce837a58ce9 100644 --- a/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js +++ b/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js @@ -545,7 +545,7 @@ module.exports = cls => class IdealTreeBuilder extends cls { [_shouldUpdateNode] (node) { return this[_updateNames].includes(node.name) && !node.isTop && - !node.inBundle && + !node.inDepBundle && !node.inShrinkwrap } diff --git a/node_modules/@npmcli/arborist/lib/arborist/rebuild.js b/node_modules/@npmcli/arborist/lib/arborist/rebuild.js index fd7be340bb719..b610045c0655e 100644 --- a/node_modules/@npmcli/arborist/lib/arborist/rebuild.js +++ b/node_modules/@npmcli/arborist/lib/arborist/rebuild.js @@ -8,7 +8,10 @@ const binLinks = require('bin-links') const runScript = require('@npmcli/run-script') const promiseCallLimit = require('promise-call-limit') const {resolve} = require('path') -const { isNodeGypPackage } = require('@npmcli/node-gyp') +const { + isNodeGypPackage, + defaultGypInstallScript, +} = require('@npmcli/node-gyp') const boolEnv = b => b ? '1' : '' const sortNodes = (a, b) => (a.depth - b.depth) || a.path.localeCompare(b.path) @@ -140,7 +143,7 @@ module.exports = cls => class Builder extends cls { await binLinks.checkBins({ pkg, path, top: true, global: true }) } - async [_addToBuildSet] (node, set) { + async [_addToBuildSet] (node, set, refreshed = false) { if (set.has(node)) return @@ -151,12 +154,11 @@ module.exports = cls => class Builder extends cls { } const { package: pkg, hasInstallScript } = node - const { bin, scripts = {} } = pkg + const { gypfile, bin, scripts = {} } = pkg const { preinstall, install, postinstall } = scripts const anyScript = preinstall || install || postinstall - - if (!anyScript && (hasInstallScript || this[_oldMeta])) { + if (!refreshed && !anyScript && (hasInstallScript || this[_oldMeta])) { // we either have an old metadata (and thus might have scripts) // or we have an indication that there's install scripts (but // don't yet know what they are) so we have to load the package.json @@ -169,21 +171,25 @@ module.exports = cls => class Builder extends cls { set.delete(node) const {scripts = {}} = pkg - if (scripts.preinstall || scripts.install || scripts.postinstall) { - node.package.scripts = pkg.scripts - return this[_addToBuildSet](node, set) - } + node.package.scripts = scripts + return this[_addToBuildSet](node, set, true) } - if (bin || preinstall || install || postinstall) { + // Rebuild node-gyp dependencies lacking an install or preinstall script + // note that 'scripts' might be missing entirely, and the package may + // set gypfile:false to avoid this automatic detection. + const isGyp = gypfile !== false && + !install && + !preinstall && + await isNodeGypPackage(node.path) + + if (bin || preinstall || install || postinstall || isGyp) { if (bin) await this[_checkBins](node) - set.add(node) - } else if (!install && !preinstall && await isNodeGypPackage(node.path)) { - // Rebuild node-gyp dependencies lacking an install or preinstall script - // note that 'scripts' might be missing entirely. - scripts.install = 'node-gyp rebuild' - node.package.scripts = scripts + if (isGyp) { + scripts.install = defaultGypInstallScript + node.package.scripts = scripts + } set.add(node) } } diff --git a/node_modules/@npmcli/arborist/package.json b/node_modules/@npmcli/arborist/package.json index 055e9620695e8..e9ff371f65b03 100644 --- a/node_modules/@npmcli/arborist/package.json +++ b/node_modules/@npmcli/arborist/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/arborist", - "version": "0.0.30", + "version": "0.0.31", "description": "Manage node_modules trees", "dependencies": { "@npmcli/installed-package-contents": "^1.0.5", diff --git a/package-lock.json b/package-lock.json index 61bd3adec4114..5d31555ecd7e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -76,7 +76,7 @@ ], "license": "Artistic-2.0", "dependencies": { - "@npmcli/arborist": "^0.0.30", + "@npmcli/arborist": "^0.0.31", "@npmcli/ci-detect": "^1.2.0", "@npmcli/config": "^1.1.8", "@npmcli/run-script": "^1.7.0", @@ -379,9 +379,9 @@ } }, "node_modules/@npmcli/arborist": { - "version": "0.0.30", - "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-0.0.30.tgz", - "integrity": "sha512-L2xeTh6ca0RU/J57YZb/etKDsaRdUl+O7NrObIhgg5KaqF+IxOc6+QcDznnmN6swdZcxR0wX7o/VJqEyTv657w==", + "version": "0.0.31", + "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-0.0.31.tgz", + "integrity": "sha512-BO5mCagGFv2szVhdAoZj2RcyjgOFxf1B+KpBTJvJYnYWwj/v4dDpzh5BixNrvDRcrCVZUq+kOOL/l53d5MHPjA==", "inBundle": true, "dependencies": { "@npmcli/installed-package-contents": "^1.0.5", @@ -8511,9 +8511,9 @@ } }, "@npmcli/arborist": { - "version": "0.0.30", - "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-0.0.30.tgz", - "integrity": "sha512-L2xeTh6ca0RU/J57YZb/etKDsaRdUl+O7NrObIhgg5KaqF+IxOc6+QcDznnmN6swdZcxR0wX7o/VJqEyTv657w==", + "version": "0.0.31", + "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-0.0.31.tgz", + "integrity": "sha512-BO5mCagGFv2szVhdAoZj2RcyjgOFxf1B+KpBTJvJYnYWwj/v4dDpzh5BixNrvDRcrCVZUq+kOOL/l53d5MHPjA==", "requires": { "@npmcli/installed-package-contents": "^1.0.5", "@npmcli/map-workspaces": "^1.0.1", diff --git a/package.json b/package.json index 28b0f65cad7ee..f346c44a05053 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "./package.json": "./package.json" }, "dependencies": { - "@npmcli/arborist": "^0.0.30", + "@npmcli/arborist": "^0.0.31", "@npmcli/ci-detect": "^1.2.0", "@npmcli/config": "^1.1.8", "@npmcli/run-script": "^1.7.0",