mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-30 10:38:13 -05:00
fix: write allow-build value to pnpm-workspace.yaml (#9404)
This commit is contained in:
6
.changeset/tidy-memes-dig.md
Normal file
6
.changeset/tidy-memes-dig.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-installation": patch
|
||||
pnpm: patch
|
||||
---
|
||||
|
||||
If there is no pnpm related configuration in `package.json`, `onlyBuiltDependencies` will be written to `pnpm-workspace.yaml` file [#9404](https://github.com/pnpm/pnpm/pull/9404).
|
||||
@@ -7,9 +7,9 @@ import { prepareExecutionEnv } from '@pnpm/plugin-commands-env'
|
||||
import { createOrConnectStoreController } from '@pnpm/store-connection-manager'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
import { createProjectManifestWriter } from './createProjectManifestWriter'
|
||||
import { type InstallCommandOptions } from './install'
|
||||
import { installDeps } from './installDeps'
|
||||
import { writeSettings } from '@pnpm/config.config-writer'
|
||||
|
||||
export function rcOptionsTypes (): Record<string, unknown> {
|
||||
return pick([
|
||||
@@ -250,10 +250,13 @@ export async function handler (
|
||||
])).sort((a, b) => a.localeCompare(b))
|
||||
if (opts.rootProjectManifestDir) {
|
||||
opts.rootProjectManifest = opts.rootProjectManifest ?? {}
|
||||
opts.rootProjectManifest.pnpm = opts.rootProjectManifest.pnpm ?? {}
|
||||
opts.rootProjectManifest.pnpm.onlyBuiltDependencies = opts.onlyBuiltDependencies
|
||||
const writeProjectManifest = await createProjectManifestWriter(opts.rootProjectManifestDir)
|
||||
await writeProjectManifest(opts.rootProjectManifest)
|
||||
await writeSettings({
|
||||
...opts,
|
||||
workspaceDir: opts.workspaceDir ?? opts.rootProjectManifestDir,
|
||||
updatedSettings: {
|
||||
onlyBuiltDependencies: opts.onlyBuiltDependencies,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
return installDeps({
|
||||
|
||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -6201,6 +6201,9 @@ importers:
|
||||
'@pnpm/workspace.pkgs-graph':
|
||||
specifier: workspace:*
|
||||
version: link:../workspace/pkgs-graph
|
||||
'@pnpm/workspace.read-manifest':
|
||||
specifier: workspace:*
|
||||
version: link:../workspace/read-manifest
|
||||
'@pnpm/workspace.state':
|
||||
specifier: workspace:*
|
||||
version: link:../workspace/state
|
||||
|
||||
@@ -133,6 +133,7 @@
|
||||
"@pnpm/worker": "workspace:*",
|
||||
"@pnpm/workspace.find-packages": "workspace:*",
|
||||
"@pnpm/workspace.pkgs-graph": "workspace:*",
|
||||
"@pnpm/workspace.read-manifest": "workspace:*",
|
||||
"@pnpm/workspace.state": "workspace:*",
|
||||
"@pnpm/write-project-manifest": "workspace:*",
|
||||
"@types/cross-spawn": "catalog:",
|
||||
|
||||
@@ -8,6 +8,7 @@ import loadJsonFile from 'load-json-file'
|
||||
import writeYamlFile from 'write-yaml-file'
|
||||
import { execPnpm, execPnpmSync, pnpmBinLocation } from '../utils'
|
||||
import { getIntegrity } from '@pnpm/registry-mock'
|
||||
import { readWorkspaceManifest } from '@pnpm/workspace.read-manifest'
|
||||
|
||||
const pkgRoot = path.join(__dirname, '..', '..')
|
||||
const pnpmPkg = loadJsonFile.sync<PackageManifest>(path.join(pkgRoot, 'package.json'))
|
||||
@@ -175,7 +176,7 @@ test('selectively allow scripts in some dependencies by onlyBuiltDependenciesFil
|
||||
})
|
||||
|
||||
test('selectively allow scripts in some dependencies by --allow-build flag', async () => {
|
||||
prepare({})
|
||||
const project = prepare({})
|
||||
execPnpmSync(['add', '--allow-build=@pnpm.e2e/install-script-example', '@pnpm.e2e/pre-and-postinstall-scripts-example@1.0.0', '@pnpm.e2e/install-script-example'])
|
||||
|
||||
expect(fs.existsSync('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
|
||||
@@ -183,7 +184,9 @@ test('selectively allow scripts in some dependencies by --allow-build flag', asy
|
||||
expect(fs.existsSync('node_modules/@pnpm.e2e/install-script-example/generated-by-install.js')).toBeTruthy()
|
||||
|
||||
const manifest = loadJsonFile.sync<ProjectManifest>('package.json')
|
||||
expect(manifest.pnpm?.onlyBuiltDependencies).toStrictEqual(['@pnpm.e2e/install-script-example'])
|
||||
expect(manifest.pnpm?.onlyBuiltDependencies).toStrictEqual(undefined)
|
||||
const modulesManifest = await readWorkspaceManifest(project.dir())
|
||||
expect(modulesManifest?.onlyBuiltDependencies).toStrictEqual(['@pnpm.e2e/install-script-example'])
|
||||
})
|
||||
|
||||
test('selectively allow scripts in some dependencies by --allow-build flag overlap ignoredBuiltDependencies', async () => {
|
||||
|
||||
@@ -177,6 +177,9 @@
|
||||
{
|
||||
"path": "../workspace/pkgs-graph"
|
||||
},
|
||||
{
|
||||
"path": "../workspace/read-manifest"
|
||||
},
|
||||
{
|
||||
"path": "../workspace/state"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user