use std::collections::BTreeMap;
use std::path::PathBuf;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum NpmrcSource {
User,
PnpmAuth,
Project,
NpmrcAuthFile,
Env,
}
impl NpmrcSource {
pub(super) fn is_trusted_for_subprocess_settings(self) -> bool {
matches!(self, Self::User | Self::PnpmAuth | Self::Env)
}
}
#[derive(Debug, Clone)]
pub struct NpmConfig {
pub registry: String,
pub scoped_registries: BTreeMap<String, String>,
pub auth_by_uri: BTreeMap<String, AuthConfig>,
pub https_proxy: Option<String>,
pub http_proxy: Option<String>,
pub no_proxy: Option<String>,
pub strict_ssl: bool,
pub local_address: Option<std::net::IpAddr>,
pub max_sockets: Option<usize>,
pub cafile: Option<PathBuf>,
pub ca: Vec<String>,
pub npmrc_proxy: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct AuthConfig {
pub auth_token: Option<String>,
pub auth: Option<String>,
pub username: Option<String>,
pub password: Option<String>,
pub token_helper: Option<String>,
pub tls: TlsConfig,
}
#[derive(Debug, Clone, Default)]
pub struct TlsConfig {
pub ca: Vec<String>,
pub cafile: Option<PathBuf>,
pub cert: Option<String>,
pub key: Option<String>,
}
impl Default for NpmConfig {
fn default() -> Self {
Self {
registry: String::new(),
scoped_registries: BTreeMap::new(),
auth_by_uri: BTreeMap::new(),
https_proxy: None,
http_proxy: None,
no_proxy: None,
strict_ssl: true,
local_address: None,
max_sockets: None,
cafile: None,
ca: Vec::new(),
npmrc_proxy: None,
}
}
}