diff --git a/node_modules/@npmcli/arborist/lib/shrinkwrap.js b/node_modules/@npmcli/arborist/lib/shrinkwrap.js index 93e1cb1a45ca2..e7dd435ca34fe 100644 --- a/node_modules/@npmcli/arborist/lib/shrinkwrap.js +++ b/node_modules/@npmcli/arborist/lib/shrinkwrap.js @@ -238,21 +238,31 @@ class Shrinkwrap { return swKeyOrder } - static reset (options) { + static async reset (options) { // still need to know if it was loaded from the disk, but don't // bother reading it if we're gonna just throw it away. const s = new Shrinkwrap(options) s.reset() - return s[_maybeStat]().then(([sw, lock]) => { - s.filename = resolve(s.path, - (s.hiddenLockfile ? 'node_modules/.package-lock' - : s.shrinkwrapOnly || sw ? 'npm-shrinkwrap' - : 'package-lock') + '.json') - s.loadedFromDisk = !!(sw || lock) - s.type = basename(s.filename) - return s - }) + const [sw, lock] = await s[_maybeStat]() + + s.filename = resolve(s.path, + (s.hiddenLockfile ? 'node_modules/.package-lock' + : s.shrinkwrapOnly || sw ? 'npm-shrinkwrap' + : 'package-lock') + '.json') + s.loadedFromDisk = !!(sw || lock) + s.type = basename(s.filename) + + try { + if (s.loadedFromDisk && !s.lockfileVersion) { + const json = parseJSON(await maybeReadFile(s.filename)) + if (json.lockfileVersion > defaultLockfileVersion) { + s.lockfileVersion = json.lockfileVersion + } + } + } catch (e) {} + + return s } static metaFromNode (node, path) { @@ -380,9 +390,10 @@ class Shrinkwrap { reset () { this.tree = null this[_awaitingUpdate] = new Map() - this.originalLockfileVersion = this.lockfileVersion + const lockfileVersion = this.lockfileVersion || defaultLockfileVersion + this.originalLockfileVersion = lockfileVersion this.data = { - lockfileVersion: this.lockfileVersion || defaultLockfileVersion, + lockfileVersion, requires: true, packages: {}, dependencies: {}, diff --git a/node_modules/@npmcli/arborist/package.json b/node_modules/@npmcli/arborist/package.json index 1954be5b3d7ca..cfa74a805b116 100644 --- a/node_modules/@npmcli/arborist/package.json +++ b/node_modules/@npmcli/arborist/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/arborist", - "version": "4.0.2", + "version": "4.0.3", "description": "Manage node_modules trees", "dependencies": { "@isaacs/string-locale-compare": "^1.0.1", @@ -45,11 +45,10 @@ "tcompare": "^5.0.6" }, "scripts": { - "test": "npm run test-only --", - "test-only": "tap", - "posttest": "npm run lint --", + "test": "tap", + "posttest": "npm run lint", "snap": "tap", - "postsnap": "npm run lintfix --", + "postsnap": "npm run lintfix", "test-proxy": "ARBORIST_TEST_PROXY=1 tap --snapshot", "preversion": "npm test", "postversion": "npm publish", @@ -88,7 +87,7 @@ "--no-warnings", "--no-deprecation" ], - "timeout": "240" + "timeout": "360" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" diff --git a/package-lock.json b/package-lock.json index 3fe8a086c70db..5f45cca04730d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -86,7 +86,7 @@ ], "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", - "@npmcli/arborist": "^4.0.2", + "@npmcli/arborist": "^4.0.3", "@npmcli/ci-detect": "^1.4.0", "@npmcli/config": "^2.3.0", "@npmcli/map-workspaces": "^2.0.0", @@ -772,9 +772,9 @@ } }, "node_modules/@npmcli/arborist": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-4.0.2.tgz", - "integrity": "sha512-tmuUNr66acGh8oOo6rKLNOaleeUDSymxTBQJFzDpRET8kG1nzLwIRMpV+CZkzmQ0tbCQ1NMyDvBeyu+kaJ+Dtw==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-4.0.3.tgz", + "integrity": "sha512-gFz/dNJtpv2bYXlupcUpEaWlFDRUNmvVnQNbE6dY4ild6beZ2SkG4R5/CM4GZZwj9HD2TyfGjO350Ja+xlLzuA==", "inBundle": true, "dependencies": { "@isaacs/string-locale-compare": "^1.0.1", @@ -11082,9 +11082,9 @@ "dev": true }, "@npmcli/arborist": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-4.0.2.tgz", - "integrity": "sha512-tmuUNr66acGh8oOo6rKLNOaleeUDSymxTBQJFzDpRET8kG1nzLwIRMpV+CZkzmQ0tbCQ1NMyDvBeyu+kaJ+Dtw==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-4.0.3.tgz", + "integrity": "sha512-gFz/dNJtpv2bYXlupcUpEaWlFDRUNmvVnQNbE6dY4ild6beZ2SkG4R5/CM4GZZwj9HD2TyfGjO350Ja+xlLzuA==", "requires": { "@isaacs/string-locale-compare": "^1.0.1", "@npmcli/installed-package-contents": "^1.0.7", diff --git a/package.json b/package.json index b92ca93f613c5..7856494e717b1 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ }, "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", - "@npmcli/arborist": "^4.0.2", + "@npmcli/arborist": "^4.0.3", "@npmcli/ci-detect": "^1.4.0", "@npmcli/config": "^2.3.0", "@npmcli/map-workspaces": "^2.0.0",