diff --git a/tap-snapshots/test/lib/commands/shrinkwrap.js.test.cjs b/tap-snapshots/test/lib/commands/shrinkwrap.js.test.cjs index 96b41b117d19b..8414685ac1ab3 100644 --- a/tap-snapshots/test/lib/commands/shrinkwrap.js.test.cjs +++ b/tap-snapshots/test/lib/commands/shrinkwrap.js.test.cjs @@ -16,7 +16,6 @@ exports[`test/lib/commands/shrinkwrap.js TAP with hidden lockfile ancient > must }, "config": {}, "shrinkwrap": { - "name": "prefix", "lockfileVersion": 1, "requires": true }, @@ -40,7 +39,6 @@ exports[`test/lib/commands/shrinkwrap.js TAP with hidden lockfile ancient upgrad "lockfile-version": 3 }, "shrinkwrap": { - "name": "prefix", "lockfileVersion": 3, "requires": true, "packages": {} @@ -65,7 +63,6 @@ exports[`test/lib/commands/shrinkwrap.js TAP with hidden lockfile existing > mus }, "config": {}, "shrinkwrap": { - "name": "prefix", "lockfileVersion": 2, "requires": true, "packages": {} @@ -90,7 +87,6 @@ exports[`test/lib/commands/shrinkwrap.js TAP with hidden lockfile existing downg "lockfile-version": 1 }, "shrinkwrap": { - "name": "prefix", "lockfileVersion": 1, "requires": true }, @@ -116,7 +112,6 @@ exports[`test/lib/commands/shrinkwrap.js TAP with hidden lockfile existing upgra "lockfile-version": 3 }, "shrinkwrap": { - "name": "prefix", "lockfileVersion": 3, "requires": true, "packages": {} @@ -135,7 +130,6 @@ exports[`test/lib/commands/shrinkwrap.js TAP with nothing ancient > must match s "localPrefix": {}, "config": {}, "shrinkwrap": { - "name": "prefix", "lockfileVersion": 3, "requires": true, "packages": {} @@ -154,7 +148,6 @@ exports[`test/lib/commands/shrinkwrap.js TAP with nothing ancient upgrade > must "lockfile-version": 3 }, "shrinkwrap": { - "name": "prefix", "lockfileVersion": 3, "requires": true, "packages": {} diff --git a/workspaces/arborist/lib/shrinkwrap.js b/workspaces/arborist/lib/shrinkwrap.js index e4b159c568250..76291ffaf733e 100644 --- a/workspaces/arborist/lib/shrinkwrap.js +++ b/workspaces/arborist/lib/shrinkwrap.js @@ -985,7 +985,9 @@ class Shrinkwrap { #buildLegacyLockfile (node, lock, path = []) { if (node === this.tree) { // the root node - lock.name = node.packageName || node.name + if (node.packageName) { + lock.name = node.packageName + } if (node.version) { lock.version = node.version } diff --git a/workspaces/arborist/tap-snapshots/test/arborist/reify.js.test.cjs b/workspaces/arborist/tap-snapshots/test/arborist/reify.js.test.cjs index b94ccc76df7f5..a0c65f0c50916 100644 --- a/workspaces/arborist/tap-snapshots/test/arborist/reify.js.test.cjs +++ b/workspaces/arborist/tap-snapshots/test/arborist/reify.js.test.cjs @@ -205,7 +205,6 @@ ArboristNode { exports[`test/arborist/reify.js TAP add a new pkg to a prefix that needs to be mkdirpd not dry run > should place expected lockfile file into place 1`] = ` { - "name": "root", "lockfileVersion": 3, "requires": true, "packages": { @@ -237,7 +236,6 @@ exports[`test/arborist/reify.js TAP add a new pkg to a prefix that needs to be m exports[`test/arborist/reify.js TAP add deps to workspaces add a to root > lockfile added workspace as dep 1`] = ` Object { "lockfileVersion": 3, - "name": "tap-testdir-reify-add-deps-to-workspaces-add-a-to-root", "packages": Object { "": Object { "dependencies": Object { @@ -469,7 +467,6 @@ ArboristNode { exports[`test/arborist/reify.js TAP add deps to workspaces add mkdirp 0.5.0 to b > lockfile 1`] = ` Object { "lockfileVersion": 3, - "name": "tap-testdir-reify-add-deps-to-workspaces-add-mkdirp-0.5.0-to-b", "packages": Object { "": Object { "dependencies": Object { @@ -768,7 +765,6 @@ ArboristNode { exports[`test/arborist/reify.js TAP add deps to workspaces add mkdirp 0.5.0 to b, empty start > lockfile 1`] = ` Object { "lockfileVersion": 3, - "name": "tap-testdir-reify-add-deps-to-workspaces-add-mkdirp-0.5.0-to-b-empty-start", "packages": Object { "": Object { "dependencies": Object { @@ -979,7 +975,6 @@ ArboristNode { exports[`test/arborist/reify.js TAP add deps to workspaces no args > lockfile 1`] = ` Object { "lockfileVersion": 3, - "name": "tap-testdir-reify-add-deps-to-workspaces-no-args", "packages": Object { "": Object { "dependencies": Object { @@ -1198,7 +1193,6 @@ ArboristNode { exports[`test/arborist/reify.js TAP add deps to workspaces remove mkdirp from a > lockfile 1`] = ` Object { "lockfileVersion": 3, - "name": "tap-testdir-reify-add-deps-to-workspaces-remove-mkdirp-from-a", "packages": Object { "": Object { "dependencies": Object { @@ -1355,7 +1349,6 @@ ArboristNode { exports[`test/arborist/reify.js TAP add deps to workspaces remove mkdirp from a, empty start > lockfile 1`] = ` Object { "lockfileVersion": 3, - "name": "tap-testdir-reify-add-deps-to-workspaces-remove-mkdirp-from-a-empty-start", "packages": Object { "": Object { "dependencies": Object { @@ -1472,7 +1465,6 @@ ArboristNode { exports[`test/arborist/reify.js TAP add deps to workspaces upgrade mkdirp in a, dedupe on root > lockfile 1`] = ` Object { "lockfileVersion": 3, - "name": "tap-testdir-reify-add-deps-to-workspaces-upgrade-mkdirp-in-a-dedupe-on-root", "packages": Object { "": Object { "dependencies": Object { @@ -1649,7 +1641,6 @@ ArboristNode { exports[`test/arborist/reify.js TAP add deps to workspaces upgrade mkdirp in a, dedupe on root, empty start > lockfile 1`] = ` Object { "lockfileVersion": 3, - "name": "tap-testdir-reify-add-deps-to-workspaces-upgrade-mkdirp-in-a-dedupe-on-root-empty-start", "packages": Object { "": Object { "dependencies": Object { @@ -3677,7 +3668,6 @@ ArboristNode { exports[`test/arborist/reify.js TAP filtered reification in workspaces > hidden lockfile - c 1`] = ` { - "name": "tap-testdir-reify-filtered-reification-in-workspaces", "lockfileVersion": 3, "requires": true, "packages": { @@ -3704,7 +3694,6 @@ exports[`test/arborist/reify.js TAP filtered reification in workspaces > hidden exports[`test/arborist/reify.js TAP filtered reification in workspaces > hidden lockfile - c, old x, removed a 1`] = ` { - "name": "tap-testdir-reify-filtered-reification-in-workspaces", "lockfileVersion": 3, "requires": true, "packages": { @@ -3738,7 +3727,6 @@ exports[`test/arborist/reify.js TAP filtered reification in workspaces > hidden exports[`test/arborist/reify.js TAP filtered reification in workspaces > hidden lockfile - c, x 1`] = ` { - "name": "tap-testdir-reify-filtered-reification-in-workspaces", "lockfileVersion": 3, "requires": true, "packages": { @@ -3772,7 +3760,6 @@ exports[`test/arborist/reify.js TAP filtered reification in workspaces > hidden exports[`test/arborist/reify.js TAP filtered reification in workspaces > hidden lockfile - c, x, a 1`] = ` { - "name": "tap-testdir-reify-filtered-reification-in-workspaces", "lockfileVersion": 3, "requires": true, "packages": { @@ -3832,7 +3819,6 @@ exports[`test/arborist/reify.js TAP filtered reification in workspaces > hidden exports[`test/arborist/reify.js TAP filtered reification in workspaces > hidden lockfile - foo/x linked, c, old x, removed a 1`] = ` { - "name": "tap-testdir-reify-filtered-reification-in-workspaces", "lockfileVersion": 3, "requires": true, "packages": { @@ -4725,7 +4711,6 @@ exports[`test/arborist/reify.js TAP just the shrinkwrap cli-750-fresh > must mat exports[`test/arborist/reify.js TAP just the shrinkwrap yarn-lock-mkdirp > must match snapshot 1`] = ` { - "name": "tap-testdir-reify-just-the-shrinkwrap-yarn-lock-mkdirp", "lockfileVersion": 3, "requires": true, "packages": { @@ -18433,7 +18418,6 @@ exports[`test/arborist/reify.js TAP packageLockOnly can add deps > must match sn exports[`test/arborist/reify.js TAP packageLockOnly can add deps > must match snapshot 2`] = ` { - "name": "tap-testdir-reify-packageLockOnly-can-add-deps", "lockfileVersion": 3, "requires": true, "packages": { @@ -33452,7 +33436,6 @@ exports[`test/arborist/reify.js TAP save package.json on update should not save exports[`test/arborist/reify.js TAP save package.json on update should not save many deps in multiple package.json when using save=false > should update lockfile with many deps updated package.json save=false 1`] = ` { - "name": "tap-testdir-reify-save-package.json-on-update-should-not-save-many-deps-in-multiple-package.json-when-using-save-false", "lockfileVersion": 3, "requires": true, "packages": { @@ -33512,7 +33495,6 @@ exports[`test/arborist/reify.js TAP save package.json on update should not save exports[`test/arborist/reify.js TAP save package.json on update should save many deps in multiple package.json when using save=true > should update lockfile with many deps updated package.json save=true 1`] = ` { - "name": "tap-testdir-reify-save-package.json-on-update-should-save-many-deps-in-multiple-package.json-when-using-save-true", "lockfileVersion": 3, "requires": true, "packages": { @@ -33572,7 +33554,7 @@ exports[`test/arborist/reify.js TAP save package.json on update should save many exports[`test/arborist/reify.js TAP save package.json on update should update named dep across multiple package.json using save=true > should update lockfile with many deps updated package.json save=true 1`] = ` { - "name": "tap-testdir-reify-save-package.json-on-update-should-update-named-dep-across-multiple-package.json-using-save-true", + "name": "workspaces-need-update", "lockfileVersion": 2, "requires": true, "packages": { @@ -33663,7 +33645,7 @@ exports[`test/arborist/reify.js TAP save package.json on update should update na exports[`test/arborist/reify.js TAP save package.json on update should update single named dep across multiple package.json using save=true > should update lockfile with single dep updated package.json save=true 1`] = ` { - "name": "tap-testdir-reify-save-package.json-on-update-should-update-single-named-dep-across-multiple-package.json-using-save-true", + "name": "workspaces-need-update", "lockfileVersion": 2, "requires": true, "packages": { @@ -33754,7 +33736,6 @@ exports[`test/arborist/reify.js TAP save package.json on update should update si exports[`test/arborist/reify.js TAP save proper lockfile with bins when upgrading lockfile complete=false > should upgrade, with bins in place 1`] = ` { - "name": "tap-testdir-reify-save-proper-lockfile-with-bins-when-upgrading-lockfile-complete-false", "lockfileVersion": 3, "requires": true, "packages": { @@ -33782,7 +33763,6 @@ exports[`test/arborist/reify.js TAP save proper lockfile with bins when upgradin exports[`test/arborist/reify.js TAP save proper lockfile with bins when upgrading lockfile complete=true > should upgrade, with bins in place 1`] = ` { - "name": "tap-testdir-reify-save-proper-lockfile-with-bins-when-upgrading-lockfile-complete-true", "lockfileVersion": 3, "requires": true, "packages": { @@ -33819,7 +33799,6 @@ exports[`test/arborist/reify.js TAP saveBundle > must match snapshot 1`] = ` exports[`test/arborist/reify.js TAP saving the ideal tree save some stuff > lock after save 1`] = ` Object { "lockfileVersion": 3, - "name": "tap-testdir-reify-saving-the-ideal-tree-save-some-stuff", "packages": Object { "": Object { "bundleDependencies": Array [ @@ -47645,7 +47624,7 @@ mkdirp@^1.0.2: exports[`test/arborist/reify.js TAP warn and correct if damaged data in lockfile first pass logs > "fixed" lockfile 1`] = ` { - "name": "tap-testdir-reify-warn-and-correct-if-damaged-data-in-lockfile", + "name": "garbage-in-reify-tree", "lockfileVersion": 2, "requires": true, "packages": { @@ -47661,7 +47640,7 @@ exports[`test/arborist/reify.js TAP warn and correct if damaged data in lockfile exports[`test/arborist/reify.js TAP warn and correct if damaged data in lockfile second pass just does the right thing > actually fixed lockfile 1`] = ` { - "name": "tap-testdir-reify-warn-and-correct-if-damaged-data-in-lockfile", + "name": "garbage-in-reify-tree", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/workspaces/arborist/tap-snapshots/test/shrinkwrap.js.test.cjs b/workspaces/arborist/tap-snapshots/test/shrinkwrap.js.test.cjs index a061ef5fbe493..c1ecd23c78601 100644 --- a/workspaces/arborist/tap-snapshots/test/shrinkwrap.js.test.cjs +++ b/workspaces/arborist/tap-snapshots/test/shrinkwrap.js.test.cjs @@ -1865,7 +1865,6 @@ Object { exports[`test/shrinkwrap.js TAP loadActual tests link-dep-cycle > shrinkwrap data 1`] = ` Object { "lockfileVersion": 3, - "name": "link-dep-cycle", "packages": Object { "": Object { "dependencies": Object { @@ -2319,7 +2318,6 @@ Object { exports[`test/shrinkwrap.js TAP loadActual tests noname > shrinkwrap data 1`] = ` Object { "lockfileVersion": 3, - "name": "noname", "packages": Object { "node_modules/foo": Object { "extraneous": true, @@ -2422,7 +2420,6 @@ Object { exports[`test/shrinkwrap.js TAP loadActual tests other > shrinkwrap data 1`] = ` Object { "lockfileVersion": 3, - "name": "other", "packages": Object { "../root/node_modules/@scope/x/node_modules/glob": Object { "dependencies": Object { @@ -9958,7 +9955,6 @@ Object { exports[`test/shrinkwrap.js TAP loadActual tests yarn-lock-mkdirp-file-dep > shrinkwrap data 1`] = ` Object { "lockfileVersion": 3, - "name": "yarn-lock-mkdirp-file-dep", "packages": Object { "": Object { "dependencies": Object { diff --git a/workspaces/arborist/test/shrinkwrap.js b/workspaces/arborist/test/shrinkwrap.js index bc0e56cf3928d..55f33244f7102 100644 --- a/workspaces/arborist/test/shrinkwrap.js +++ b/workspaces/arborist/test/shrinkwrap.js @@ -152,7 +152,6 @@ t.test('loading in empty dir gets empty lockfile', async t => { root.extraneous = false sw.add(root) t.strictSame(sw.commit(), { - name: 'empty', lockfileVersion: 3, requires: true, packages: {},