Skip to content

fix: omit name from package-lock.json in case of package.json don't have name #8193

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

Draft
wants to merge 2 commits into
base: latest
Choose a base branch
from
Draft
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
7 changes: 0 additions & 7 deletions tap-snapshots/test/lib/commands/shrinkwrap.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ exports[`test/lib/commands/shrinkwrap.js TAP with hidden lockfile ancient > must
},
"config": {},
"shrinkwrap": {
"name": "prefix",
"lockfileVersion": 1,
"requires": true
},
Expand All @@ -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": {}
Expand All @@ -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": {}
Expand All @@ -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
},
Expand All @@ -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": {}
Expand All @@ -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": {}
Expand All @@ -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": {}
Expand Down
4 changes: 3 additions & 1 deletion workspaces/arborist/lib/shrinkwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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": {
Expand All @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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 [
Expand Down Expand Up @@ -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": {
Expand All @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion workspaces/arborist/test/shrinkwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down
Loading