#[derive(Debug, Clone, Copy)]
#[allow(dead_code)] pub struct SettingMeta {
pub name: &'static str,
pub description: &'static str,
pub type_: &'static str,
pub default: &'static str,
pub docs: &'static str,
pub cli_flags: &'static [&'static str],
pub env_vars: &'static [&'static str],
pub npmrc_keys: &'static [&'static str],
pub workspace_yaml_keys: &'static [&'static str],
pub examples: &'static [&'static str],
pub typed_accessor_unused: bool,
}
include!(concat!(env!("OUT_DIR"), "/settings_meta_data.rs"));
pub fn all() -> &'static [SettingMeta] {
SETTINGS
}
pub fn find(name: &str) -> Option<&'static SettingMeta> {
SETTINGS.iter().find(|s| s.name == name)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn settings_metadata_has_expected_count() {
assert!(
SETTINGS.len() >= 100,
"expected ≥100 settings, got {}",
SETTINGS.len()
);
}
#[test]
fn every_setting_has_required_fields() {
for s in SETTINGS {
assert!(!s.name.is_empty(), "empty name in entry");
assert!(!s.description.is_empty(), "{}: empty description", s.name);
assert!(!s.type_.is_empty(), "{}: empty type", s.name);
}
}
#[test]
fn known_settings_resolve() {
assert!(find("registries").is_some());
assert!(find("preferFrozenLockfile").is_some());
assert!(find("aubeNoLock").is_some());
assert!(find("totally-fake-setting").is_none());
}
#[test]
fn find_matches_all() {
for s in all() {
assert_eq!(find(s.name).map(|x| x.name), Some(s.name));
}
}
#[test]
fn workspace_yaml_keys_deserialize_onto_workspace_config() {
let shapes = ["null", "true", "\"x\"", "0", "{}", "[]"];
for s in SETTINGS {
for key in s.workspace_yaml_keys {
let mut recognized = false;
let top_level_key = key.split('.').next().unwrap_or(key);
for shape in shapes {
let yaml = format!("{top_level_key}: {shape}\n");
if let Ok(cfg) = yaml_serde::from_str::<aube_manifest::WorkspaceConfig>(&yaml)
&& !cfg.extra.contains_key(top_level_key)
{
recognized = true;
break;
}
}
assert!(
recognized,
"{}: workspaceYaml key `{key}` is not a real field on WorkspaceConfig \
— it fell through to `extra` (or failed to deserialize entirely). \
Either add the field or remove the metadata.",
s.name
);
}
}
}
}