mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-26 18:09:06 -04:00
refactor(config): remove dead RAW_POLICY_CFG_KEYS handling
Policy keys (minimum-release-age*, trust-policy*) are filtered out of .npmrc by isNpmrcReadableKey, so they can never appear in authConfig. The RAW_POLICY_CFG_KEYS / isRawPolicyCfgKey / pickRawDlxConfig branch for those keys was unreachable in production. inheritDlxConfig now uses pickRawAuthConfig directly for the raw config pick. The test assertion that placed minimum-release-age in authConfig (an impossible state) is also dropped. https://claude.ai/code/session_01NumMLsTvswMVJpbWp3YJrH
This commit is contained in:
@@ -68,7 +68,6 @@ test('inheritDlxConfig copies auth and security policy keys from source to targe
|
||||
authConfig: {
|
||||
registry: 'https://example.com/local-registry/',
|
||||
'//example.com/local-registry/:_authToken': 'SECRET_TOKEN',
|
||||
'minimum-release-age': '1440',
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -89,7 +88,6 @@ test('inheritDlxConfig copies auth and security policy keys from source to targe
|
||||
authConfig: {
|
||||
registry: 'https://example.com/local-registry/',
|
||||
'//example.com/local-registry/:_authToken': 'SECRET_TOKEN',
|
||||
'minimum-release-age': '1440',
|
||||
},
|
||||
})
|
||||
// storeDir exists only on the source, must not be inherited.
|
||||
|
||||
@@ -82,19 +82,6 @@ const POLICY_CFG_KEYS = [
|
||||
'trustPolicyIgnoreAfter',
|
||||
] satisfies Array<keyof Config>
|
||||
|
||||
/**
|
||||
* Raw (kebab-case) config keys for security and trust policy settings.
|
||||
* These are the keys as they appear in .npmrc or pnpm-workspace.yaml.
|
||||
*/
|
||||
const RAW_POLICY_CFG_KEYS = [
|
||||
'minimum-release-age',
|
||||
'minimum-release-age-exclude',
|
||||
'minimum-release-age-strict',
|
||||
'trust-policy',
|
||||
'trust-policy-exclude',
|
||||
'trust-policy-ignore-after',
|
||||
]
|
||||
|
||||
const NPM_AUTH_SETTINGS = [
|
||||
...RAW_AUTH_CFG_KEYS,
|
||||
'_auth',
|
||||
@@ -119,10 +106,6 @@ function isPolicyCfgKey (cfgKey: keyof Config): cfgKey is typeof POLICY_CFG_KEYS
|
||||
return (POLICY_CFG_KEYS as Array<keyof Config>).includes(cfgKey)
|
||||
}
|
||||
|
||||
function isRawPolicyCfgKey (rawCfgKey: string): boolean {
|
||||
return (RAW_POLICY_CFG_KEYS as string[]).includes(rawCfgKey)
|
||||
}
|
||||
|
||||
function pickRawAuthConfig<RawLocalCfg extends Record<string, unknown>> (rawLocalCfg: RawLocalCfg): Partial<RawLocalCfg> {
|
||||
const result: Partial<RawLocalCfg> = {}
|
||||
for (const key in rawLocalCfg) {
|
||||
@@ -143,16 +126,6 @@ function pickAuthConfig (localCfg: Partial<Config>): Partial<Config> {
|
||||
return result as Partial<Config>
|
||||
}
|
||||
|
||||
function pickRawDlxConfig<RawLocalCfg extends Record<string, unknown>> (rawLocalCfg: RawLocalCfg): Partial<RawLocalCfg> {
|
||||
const result: Partial<RawLocalCfg> = {}
|
||||
for (const key in rawLocalCfg) {
|
||||
if (isRawAuthCfgKey(key) || isRawPolicyCfgKey(key)) {
|
||||
result[key] = rawLocalCfg[key]
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function pickDlxConfig (localCfg: Partial<Config>): Partial<Config> {
|
||||
const result: Record<string, unknown> = {}
|
||||
for (const key in localCfg) {
|
||||
@@ -176,7 +149,7 @@ export function inheritAuthConfig (target: InheritableConfigPair, src: Inheritab
|
||||
* while ignoring project-structural settings.
|
||||
*/
|
||||
export function inheritDlxConfig (target: InheritableConfigPair, src: InheritableConfigPair): void {
|
||||
inheritPickedConfig(target, src, pickDlxConfig, pickRawDlxConfig)
|
||||
inheritPickedConfig(target, src, pickDlxConfig, pickRawAuthConfig)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user