mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-24 07:38:12 -05:00
feat: dangerouslyAllowAllBuilds allows to enable the build of all dependencies (#9440)
close #9102
This commit is contained in:
22
.changeset/long-windows-lay.md
Normal file
22
.changeset/long-windows-lay.md
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
"@pnpm/config": minor
|
||||
"pnpm": minor
|
||||
---
|
||||
|
||||
Added a new setting, `dangerouslyAllowAllBuilds`, for automatically running any scripts of dependencies without the need to approve any builds. It was already possible to allow all builds by adding this to `pnpm-workspace.yaml`:
|
||||
|
||||
```yaml
|
||||
neverBuiltDependencies: []
|
||||
```
|
||||
|
||||
`dangerouslyAllowAllBuilds` has the same effect but also allows to be set globally via:
|
||||
|
||||
```
|
||||
pnpm config set dangerouslyAllowAllBuilds true
|
||||
```
|
||||
|
||||
It can also be set when running a command:
|
||||
|
||||
```
|
||||
pnpm install --dangerously-allow-all-builds
|
||||
```
|
||||
@@ -218,6 +218,7 @@ export interface Config extends OptionsFromRootManifest {
|
||||
strictDepBuilds: boolean
|
||||
syncInjectedDepsAfterScripts?: string[]
|
||||
initPackageManager: boolean
|
||||
dangerouslyAllowAllBuilds: boolean
|
||||
}
|
||||
|
||||
export interface ConfigWithDeprecatedSettings extends Config {
|
||||
|
||||
@@ -121,6 +121,7 @@ export async function getConfig (opts: {
|
||||
'auto-install-peers': true,
|
||||
bail: true,
|
||||
color: 'auto',
|
||||
'dangerously-allow-all-builds': false,
|
||||
'deploy-all-files': false,
|
||||
'dedupe-peer-dependents': true,
|
||||
'dedupe-direct-deps': false,
|
||||
@@ -519,6 +520,13 @@ export async function getConfig (opts: {
|
||||
pnpmConfig.dev = true
|
||||
}
|
||||
|
||||
if (pnpmConfig.dangerouslyAllowAllBuilds) {
|
||||
if (pnpmConfig.neverBuiltDependencies && pnpmConfig.neverBuiltDependencies.length > 0) {
|
||||
warnings.push('You have set dangerouslyAllowAllBuilds to true. The dependencies listed in neverBuiltDependencies will run their scripts.')
|
||||
}
|
||||
pnpmConfig.neverBuiltDependencies = []
|
||||
}
|
||||
|
||||
transformPathKeys(pnpmConfig, os.homedir())
|
||||
|
||||
return { config: pnpmConfig, warnings }
|
||||
|
||||
@@ -9,6 +9,7 @@ export const types = Object.assign({
|
||||
'merge-git-branch-lockfiles-branch-pattern': Array,
|
||||
color: ['always', 'auto', 'never'],
|
||||
'config-dir': String,
|
||||
'dangerously-allow-all-builds': Boolean,
|
||||
'deploy-all-files': Boolean,
|
||||
'dedupe-peer-dependents': Boolean,
|
||||
'dedupe-direct-deps': Boolean,
|
||||
|
||||
2
config/config/test/fixtures/never-built-dependencies/pnpm-workspace.yaml
vendored
Normal file
2
config/config/test/fixtures/never-built-dependencies/pnpm-workspace.yaml
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
neverBuiltDependencies:
|
||||
- foo
|
||||
@@ -1076,3 +1076,35 @@ test('settings shamefullyHoist in pnpm-workspace.yaml should take effect', async
|
||||
expect(config.publicHoistPattern).toStrictEqual(['*'])
|
||||
expect(config.rawConfig['shamefully-hoist']).toBe(true)
|
||||
})
|
||||
|
||||
test('when dangerouslyAllowAllBuilds is set to true neverBuiltDependencies is set to an empty array', async () => {
|
||||
const { config } = await getConfig({
|
||||
cliOptions: {
|
||||
'dangerously-allow-all-builds': true,
|
||||
},
|
||||
packageManager: {
|
||||
name: 'pnpm',
|
||||
version: '1.0.0',
|
||||
},
|
||||
})
|
||||
|
||||
expect(config.neverBuiltDependencies).toStrictEqual([])
|
||||
})
|
||||
|
||||
test('when dangerouslyAllowAllBuilds is set to true and neverBuiltDependencies not empty, a warning is returned', async () => {
|
||||
const workspaceDir = f.find('never-built-dependencies')
|
||||
process.chdir(workspaceDir)
|
||||
const { config, warnings } = await getConfig({
|
||||
cliOptions: {
|
||||
'dangerously-allow-all-builds': true,
|
||||
},
|
||||
packageManager: {
|
||||
name: 'pnpm',
|
||||
version: '1.0.0',
|
||||
},
|
||||
workspaceDir,
|
||||
})
|
||||
|
||||
expect(config.neverBuiltDependencies).toStrictEqual([])
|
||||
expect(warnings).toStrictEqual(['You have set dangerouslyAllowAllBuilds to true. The dependencies listed in neverBuiltDependencies will run their scripts.'])
|
||||
})
|
||||
|
||||
@@ -15,6 +15,7 @@ export function rcOptionsTypes (): Record<string, unknown> {
|
||||
return pick([
|
||||
'cache-dir',
|
||||
'child-concurrency',
|
||||
'dangerously-allow-all-builds',
|
||||
'engine-strict',
|
||||
'fetch-retries',
|
||||
'fetch-retry-factor',
|
||||
|
||||
@@ -13,6 +13,7 @@ export function rcOptionsTypes (): Record<string, unknown> {
|
||||
return pick([
|
||||
'cache-dir',
|
||||
'child-concurrency',
|
||||
'dangerously-allow-all-builds',
|
||||
'dev',
|
||||
'engine-strict',
|
||||
'fetch-retries',
|
||||
|
||||
@@ -25,6 +25,7 @@ import { parseUpdateParam } from '../recursive'
|
||||
export function rcOptionsTypes (): Record<string, unknown> {
|
||||
return pick([
|
||||
'cache-dir',
|
||||
'dangerously-allow-all-builds',
|
||||
'depth',
|
||||
'dev',
|
||||
'engine-strict',
|
||||
|
||||
Reference in New Issue
Block a user