feat(napi): report explicitly set settings from readConfig (#13518)

Every projected numeric network value carries the engine default when
unset, and Bit merges the projection over its own global network
config - without knowing which values are explicit it either forwards
defaults as overrides or forwards nothing.
This commit is contained in:
Zoltan Kochan authored and GitHub committed 2026-08-01 13:15:34 +02:00
1 parent e706bbf43b
commit 12db10e4e7
4 files changed
+37

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@pnpm/napi": minor
---
`readConfig` now returns `explicitSettings` — the camelCase names of settings the config cascade set explicitly — so hosts that layer the resolved config over their own defaults can forward only the values the user actually configured.
+7
View File
@@ -81,6 +81,12 @@ pub struct ResolvedConfig {
/// default) — not a per-project setting. `None` when no home
/// directory is resolvable.
pub pnpm_home_dir: Option<String>,
/// The camelCase names of settings the cascade set explicitly
/// (`pnpm-workspace.yaml`, the global config, `pnpm_config_*` env
/// vars). Every other projected value is an engine default; an
/// embedder that layers this config over its own must forward only
/// the explicit ones.
pub explicit_settings: Vec<String>,
}
#[napi(js_name = "readConfig")]
@@ -161,6 +167,7 @@ fn project_config(config: &pacquet_config::Config) -> ResolvedConfig {
shamefully_hoist: config.shamefully_hoist,
pnpm_home_dir: pacquet_config::default_pnpm_home_dir::<pacquet_config::Host>()
.map(|dir| dir.display().to_string()),
explicit_settings: config.explicit_settings.keys().cloned().collect(),
}
}
+18
View File
@@ -170,3 +170,21 @@ fn read_config_resolves_the_project_npmrc_cascade() {
assert!(!resolved.store_dir.is_empty());
assert!(!resolved.cache_dir.is_empty());
}
/// A `pnpm-workspace.yaml` setting must surface both as its resolved
/// value and as an entry in `explicit_settings`, while an unset sibling
/// (whose projected value is an engine default) stays off that list.
#[test]
fn read_config_reports_explicitly_set_workspace_settings() {
let dir = tempfile::tempdir().expect("tempdir");
std::fs::write(dir.path().join("pnpm-workspace.yaml"), "fetchRetries: 7\n")
.expect("write pnpm-workspace.yaml");
let resolved =
super::read_config(super::ReadConfigOptions { dir: dir.path().display().to_string() })
.expect("read config");
assert_eq!(resolved.fetch_retries, 7);
assert!(resolved.explicit_settings.contains(&"fetchRetries".to_string()));
assert!(!resolved.explicit_settings.contains(&"fetchTimeout".to_string()));
}
+7
View File
@@ -415,6 +415,13 @@ export interface ResolvedConfig {
* not a per-project setting. Absent when no home directory is resolvable.
*/
pnpmHomeDir?: string
/**
* The camelCase names of settings the cascade set explicitly
* (`pnpm-workspace.yaml`, the global config, `pnpm_config_*` env vars).
* Every other projected value is an engine default; an embedder that
* layers this config over its own must forward only the explicit ones.
*/
explicitSettings: string[]
}
/**