From 74ce0015a2e23cac8bbbdf88dd7af5e93a09a7af Mon Sep 17 00:00:00 2001 From: Alex Schwartz Date: Tue, 20 May 2025 10:51:16 -0400 Subject: [PATCH 1/6] fix(arborist): fix file dep making wrong link --- workspaces/arborist/lib/arborist/reify.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js index e6d719b6b3468..7ce22ff86b721 100644 --- a/workspaces/arborist/lib/arborist/reify.js +++ b/workspaces/arborist/lib/arborist/reify.js @@ -871,13 +871,9 @@ module.exports = cls => class Reifier extends cls { return relative(dir, resolve(rootDir, overridePath)) } - // Fallback: derive the package name from node.resolved in a platform-agnostic way + // Fallback: derive the file path from node.resolved in a platform-agnostic way const filePath = node.resolved.replace(/^file:/, '') - // A node.package.name could be different than the folder name - const pathParts = filePath.split(/[\\/]/) - const packageName = pathParts[pathParts.length - 1] - - return join('..', packageName) + return join(filePath) } #registryResolved (resolved) { From 992144d6357ac6a5a129812fb24298d9004e63bc Mon Sep 17 00:00:00 2001 From: Alex Schwartz Date: Tue, 20 May 2025 12:03:00 -0400 Subject: [PATCH 2/6] update test --- workspaces/arborist/test/arborist/reify.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index 29b0bc9e103c9..d198bb390fd53 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -3224,6 +3224,17 @@ t.test('root overrides with file: paths are visible to workspaces', async t => { }, }), }, + nested: { + goodbye: { + 'package.json': JSON.stringify({ + name: 'second', + version: '1.0.0', + dependencies: { + print: '../print', + }, + }), + }, + }, print: { 'package.json': JSON.stringify({ name: 'print', @@ -3237,6 +3248,7 @@ t.test('root overrides with file: paths are visible to workspaces', async t => { await reify(path) const printSymlink = fs.readlinkSync(resolve(path, 'node_modules/print')) + const secondSymlink = fs.readlinkSync(resolve(path, 'node_modules/second')) // Create a platform-agnostic way to compare symlink targets const normalizeLinkTarget = target => { @@ -3254,6 +3266,12 @@ t.test('root overrides with file: paths are visible to workspaces', async t => { '../print', 'print symlink points to ../print (normalized for platform)' ) + + t.equal( + normalizeLinkTarget(secondSymlink), + '../second', + 'print symlink points to ../second (normalized for platform)' + ) }) t.test('should preserve exact ranges, missing actual tree', async (t) => { From 4ebdc51a4b0574fac90a3a9f2a385d2f97e660ee Mon Sep 17 00:00:00 2001 From: Alex Schwartz Date: Tue, 20 May 2025 12:05:22 -0400 Subject: [PATCH 3/6] Update reify.js --- workspaces/arborist/test/arborist/reify.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index d198bb390fd53..a28e38cdea97d 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -221,7 +221,7 @@ t.test('malformed package.json should not be overwitten', async t => { }) t.test('packageLockOnly does not work on globals', t => { - const path = t.testdir({ 'package.json': '{}' }) + const path = t.testdir({ '': '{}' }) createRegistry(t, false) return t.rejects(() => reify(path, { global: true, packageLockOnly: true })) }) @@ -455,7 +455,7 @@ t.test('do not update shrinkwrapped deps', async t => { }) t.test('tracks changes of shrinkwrapped dep correctly', async t => { - const path = t.testdir({ 'package.json': '{}' }) + const path = t.testdir({ '': '{}' }) createRegistry(t, true) const install1 = await printReified(path, { add: ['@nlf/shrinkwrapped-dep-updates-a@1.0.0'] }) @@ -556,7 +556,7 @@ t.test('reifying with shronk warp dep', t => { }) t.matchSnapshot(tree) const dep = `${path}/node_modules/@isaacs/shrinkwrapped-dependency` - t.equal(fs.statSync(`${dep}/package.json`).isFile(), true, 'has package.json') + t.equal(fs.statSync(`${dep}/`).isFile(), true, 'has ') }) } }) @@ -1038,9 +1038,9 @@ t.test('saving the ideal tree', t => { const npa = require('npm-package-arg') const kResolvedAdd = Symbol.for('resolvedAdd') const path = t.testdir({ - 'package.json': JSON.stringify(pkg), + '': JSON.stringify(pkg), e: { - 'package.json': JSON.stringify({ name: 'e' }), + '': JSON.stringify({ name: 'e' }), }, node_modules: { e: t.fixture('symlink', '../e'), @@ -1150,7 +1150,7 @@ t.test('saving the ideal tree', t => { }).then(saved => { t.ok(saved, 'true, because it was saved') t.matchSnapshot(require(path + '/package-lock.json'), 'lock after save') - t.strictSame(require(path + '/package.json'), { + t.strictSame(require(path + '/'), { bundleDependencies: ['a', 'b', 'c'], dependencies: { a: 'github:foo/bar#baz', @@ -1220,7 +1220,7 @@ t.test('scoped registries', async t => { t.test('bin links adding and removing', t => { const path = t.testdir({ - 'package.json': JSON.stringify({}), + '': JSON.stringify({}), }) const rbin = resolve(path, 'node_modules/.bin/rimraf') return reify(path, { add: ['rimraf@2.7.1'] }) @@ -3209,7 +3209,7 @@ t.test('root overrides with file: paths are visible to workspaces', async t => { const path = t.testdir({ 'package.json': JSON.stringify({ name: 'root', - workspaces: ['hello'], + workspaces: ['hello', 'nested/goodbye'], dependencies: {}, overrides: { print: 'file:./print', From 45ffe30cea8b4307f3b4e2e7377268a2db611c39 Mon Sep 17 00:00:00 2001 From: Alex Schwartz Date: Tue, 20 May 2025 12:06:17 -0400 Subject: [PATCH 4/6] revert previous commit --- workspaces/arborist/test/arborist/reify.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index a28e38cdea97d..d198bb390fd53 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -221,7 +221,7 @@ t.test('malformed package.json should not be overwitten', async t => { }) t.test('packageLockOnly does not work on globals', t => { - const path = t.testdir({ '': '{}' }) + const path = t.testdir({ 'package.json': '{}' }) createRegistry(t, false) return t.rejects(() => reify(path, { global: true, packageLockOnly: true })) }) @@ -455,7 +455,7 @@ t.test('do not update shrinkwrapped deps', async t => { }) t.test('tracks changes of shrinkwrapped dep correctly', async t => { - const path = t.testdir({ '': '{}' }) + const path = t.testdir({ 'package.json': '{}' }) createRegistry(t, true) const install1 = await printReified(path, { add: ['@nlf/shrinkwrapped-dep-updates-a@1.0.0'] }) @@ -556,7 +556,7 @@ t.test('reifying with shronk warp dep', t => { }) t.matchSnapshot(tree) const dep = `${path}/node_modules/@isaacs/shrinkwrapped-dependency` - t.equal(fs.statSync(`${dep}/`).isFile(), true, 'has ') + t.equal(fs.statSync(`${dep}/package.json`).isFile(), true, 'has package.json') }) } }) @@ -1038,9 +1038,9 @@ t.test('saving the ideal tree', t => { const npa = require('npm-package-arg') const kResolvedAdd = Symbol.for('resolvedAdd') const path = t.testdir({ - '': JSON.stringify(pkg), + 'package.json': JSON.stringify(pkg), e: { - '': JSON.stringify({ name: 'e' }), + 'package.json': JSON.stringify({ name: 'e' }), }, node_modules: { e: t.fixture('symlink', '../e'), @@ -1150,7 +1150,7 @@ t.test('saving the ideal tree', t => { }).then(saved => { t.ok(saved, 'true, because it was saved') t.matchSnapshot(require(path + '/package-lock.json'), 'lock after save') - t.strictSame(require(path + '/'), { + t.strictSame(require(path + '/package.json'), { bundleDependencies: ['a', 'b', 'c'], dependencies: { a: 'github:foo/bar#baz', @@ -1220,7 +1220,7 @@ t.test('scoped registries', async t => { t.test('bin links adding and removing', t => { const path = t.testdir({ - '': JSON.stringify({}), + 'package.json': JSON.stringify({}), }) const rbin = resolve(path, 'node_modules/.bin/rimraf') return reify(path, { add: ['rimraf@2.7.1'] }) @@ -3209,7 +3209,7 @@ t.test('root overrides with file: paths are visible to workspaces', async t => { const path = t.testdir({ 'package.json': JSON.stringify({ name: 'root', - workspaces: ['hello', 'nested/goodbye'], + workspaces: ['hello'], dependencies: {}, overrides: { print: 'file:./print', From 2aced89524f0f6389f905f2a39d0b01e62f14799 Mon Sep 17 00:00:00 2001 From: Alex Schwartz Date: Tue, 20 May 2025 12:06:56 -0400 Subject: [PATCH 5/6] Update reify.js --- workspaces/arborist/test/arborist/reify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index d198bb390fd53..6e10c78659db7 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -3209,7 +3209,7 @@ t.test('root overrides with file: paths are visible to workspaces', async t => { const path = t.testdir({ 'package.json': JSON.stringify({ name: 'root', - workspaces: ['hello'], + workspaces: ['hello', 'nested/goodbye'], dependencies: {}, overrides: { print: 'file:./print', From 948d18e2979956a07bac159e5286663136268191 Mon Sep 17 00:00:00 2001 From: Alex Schwartz Date: Tue, 20 May 2025 12:13:52 -0400 Subject: [PATCH 6/6] fix test --- workspaces/arborist/test/arborist/reify.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index 6e10c78659db7..4f565ffc80860 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -3269,8 +3269,8 @@ t.test('root overrides with file: paths are visible to workspaces', async t => { t.equal( normalizeLinkTarget(secondSymlink), - '../second', - 'print symlink points to ../second (normalized for platform)' + '../nested/goodbye', + 'print symlink points to ../nested/goodbye (normalized for platform)' ) }) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy