fix: setting requiredScripts in pnpm-workspace.yaml (#10404)

close #10261
This commit is contained in:
Zoltan Kochan
2026-01-04 16:43:08 +01:00
parent 6bdba72ad3
commit f022a1b29a
4 changed files with 12 additions and 4 deletions

View File

@@ -0,0 +1,7 @@
---
"@pnpm/plugin-commands-script-runners": patch
"@pnpm/config": patch
"pnpm": patch
---
It should be possible to declare the `requiredScripts` setting in `pnpm-workspace.yaml` [#10261](https://github.com/pnpm/pnpm/issues/10261).

View File

@@ -29,6 +29,7 @@ export type OptionsFromRootManifest = {
peerDependencyRules?: PeerDependencyRules
supportedArchitectures?: SupportedArchitectures
allowBuilds?: Record<string, boolean | string>
requiredScripts?: string[]
} & Pick<PnpmSettings, 'configDependencies' | 'auditConfig' | 'executionEnv' | 'updateConfig'>
export function getOptionsFromRootManifest (manifestDir: string, manifest: ProjectManifest): OptionsFromRootManifest {
@@ -54,6 +55,7 @@ export function getOptionsFromRootManifest (manifestDir: string, manifest: Proje
'packageExtensions',
'patchedDependencies',
'peerDependencyRules',
'requiredScripts',
'supportedArchitectures',
'updateConfig',
], manifest.pnpm ?? {}),

View File

@@ -26,6 +26,7 @@ export type RecursiveRunOpts = Pick<Config,
| 'unsafePerm'
| 'pnpmHomeDir'
| 'rawConfig'
| 'requiredScripts'
| 'rootProjectManifest'
| 'scriptsPrependNodePath'
| 'scriptShell'
@@ -74,7 +75,7 @@ export async function runRecursive (
const existsPnp = existsInDir.bind(null, '.pnp.cjs')
const workspacePnpPath = opts.workspaceDir && existsPnp(opts.workspaceDir)
const requiredScripts = opts.rootProjectManifest?.pnpm?.requiredScripts ?? []
const requiredScripts = opts.requiredScripts ?? []
if (requiredScripts.includes(scriptName)) {
const missingScriptPackages: string[] = packageChunks
.flat()

View File

@@ -783,12 +783,10 @@ test('`pnpm recursive run` should fail when no script in package with requiredSc
...await filterPackagesFromDir(process.cwd(), [{ namePattern: '*' }]),
dir: process.cwd(),
recursive: true,
requiredScripts: ['build'],
rootProjectManifest: {
name: 'test-workspaces',
private: true,
pnpm: {
requiredScripts: ['build'],
},
},
workspaceDir: process.cwd(),
}, ['build'])