fix: reading settings from package.json when shared-workspace-lockfile is false (#7202)

close #7184
This commit is contained in:
Zoltan Kochan
2023-10-15 12:46:56 +03:00
committed by GitHub
parent ac5abd3ff7
commit 46dc34dcc8
4 changed files with 39 additions and 5 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-installation": patch
"pnpm": patch
---
When `shared-workspace-lockfile` is set to `false`, read the pnpm settings from `package.json` files that are nested. This was broken in pnpm v8.9.0 [#7184](https://github.com/pnpm/pnpm/issues/7184).

View File

@@ -219,10 +219,9 @@ when running add/update with the --workspace option')
}
const store = await createOrConnectStoreController(opts)
const manifestOpts = opts.rootProjectManifest ? getOptionsFromRootManifest(opts.rootProjectManifestDir!, opts.rootProjectManifest) : {}
const installOpts: Omit<MutateModulesOptions, 'allProjects'> = {
...opts,
...manifestOpts,
...getOptionsFromRootManifest(opts.dir, manifest),
forceHoistPattern,
forcePublicHoistPattern,
// In case installation is done in a multi-package repository

View File

@@ -360,13 +360,12 @@ export async function recursive (
}
const localConfig = await memReadLocalConfig(rootDir)
const optionsFromManifest = opts.rootProjectManifest ? getOptionsFromRootManifest(opts.rootProjectManifestDir!, opts.rootProjectManifest) : {}
const newManifest = await action(
manifest,
{
...installOpts,
...localConfig,
...optionsFromManifest,
...getOptionsFromRootManifest(rootDir, manifest),
bin: path.join(rootDir, 'node_modules', '.bin'),
dir: rootDir,
hooks,
@@ -415,7 +414,6 @@ export async function recursive (
) {
await rebuild.handler({
...opts,
...getOptionsFromRootManifest(opts.rootProjectManifestDir!, opts.rootProjectManifest ?? {}),
pending: opts.pending === true,
skipIfHasSideEffectsCache: true,
}, [])

View File

@@ -1853,3 +1853,34 @@ test('peer dependencies are resolved from the root of the workspace when a new d
const lockfile = await projects['project-1'].readLockfile()
expect(lockfile.packages).toHaveProperty(['/ajv-keywords@1.5.0(ajv@4.10.4)'])
})
test('overrides in workspace project should be taken into account when shared-workspace-lockfiles is false', async () => {
const projects = preparePackages([
{
name: 'project-1',
version: '1.0.0',
pnpm: {
overrides: {
'is-odd': '1.0.0',
},
},
},
{
name: 'project-2',
version: '2.0.0',
},
])
await fs.writeFile('.npmrc', `
shared-workspace-lockfile=false
`, 'utf8')
await writeYamlFile('pnpm-workspace.yaml', { packages: ['**', '!store/**'] })
await execPnpm(['install'])
const lockfile = await projects['project-1'].readLockfile()
expect(lockfile.overrides).toStrictEqual({
'is-odd': '1.0.0',
})
})