diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..22c6871 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[registries.sunbeam] +index = "sparse+https://src.sunbeam.pt/api/packages/studio/cargo/" diff --git a/.gitignore b/.gitignore index ce58724..e25d35d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ build/ # Rust /target/ + +# Environment +.envrc diff --git a/src/update.rs b/src/update.rs index 554d12e..4daebbe 100644 --- a/src/update.rs +++ b/src/update.rs @@ -29,20 +29,22 @@ fn forge_url() -> String { return url.trim_end_matches('/').to_string(); } - // Derive from production_host domain in config + // Derive from active context domain or production_host + let domain = crate::config::domain(); + if !domain.is_empty() { + return format!("https://src.{domain}"); + } + let config = crate::config::load_config(); if !config.production_host.is_empty() { - // production_host is like "user@server.example.com" — extract domain let host = config .production_host .split('@') .last() .unwrap_or(&config.production_host); - // Strip any leading subdomain segments that look like a hostname to get the base domain. - // For a host like "admin.sunbeam.pt", the forge is "src.sunbeam.pt". - // Heuristic: use the last two segments as the domain. + // For "admin.sunbeam.pt" → "sunbeam.pt". Skip bare IPs. let parts: Vec<&str> = host.split('.').collect(); - if parts.len() >= 2 { + if parts.len() >= 2 && parts.iter().any(|p| p.parse::().is_err()) { let domain = format!("{}.{}", parts[parts.len() - 2], parts[parts.len() - 1]); return format!("https://src.{domain}"); } diff --git a/sunbeam-sdk/Cargo.toml b/sunbeam-sdk/Cargo.toml index 9c99747..721550e 100644 --- a/sunbeam-sdk/Cargo.toml +++ b/sunbeam-sdk/Cargo.toml @@ -3,6 +3,9 @@ name = "sunbeam-sdk" version = "0.1.0" edition = "2024" description = "Sunbeam SDK — reusable library for cluster management" +repository = "https://src.sunbeam.pt/studio/cli" +license = "MIT" +publish = ["sunbeam"] [features] default = [] diff --git a/sunbeam-sdk/src/update/mod.rs b/sunbeam-sdk/src/update/mod.rs index 554d12e..4daebbe 100644 --- a/sunbeam-sdk/src/update/mod.rs +++ b/sunbeam-sdk/src/update/mod.rs @@ -29,20 +29,22 @@ fn forge_url() -> String { return url.trim_end_matches('/').to_string(); } - // Derive from production_host domain in config + // Derive from active context domain or production_host + let domain = crate::config::domain(); + if !domain.is_empty() { + return format!("https://src.{domain}"); + } + let config = crate::config::load_config(); if !config.production_host.is_empty() { - // production_host is like "user@server.example.com" — extract domain let host = config .production_host .split('@') .last() .unwrap_or(&config.production_host); - // Strip any leading subdomain segments that look like a hostname to get the base domain. - // For a host like "admin.sunbeam.pt", the forge is "src.sunbeam.pt". - // Heuristic: use the last two segments as the domain. + // For "admin.sunbeam.pt" → "sunbeam.pt". Skip bare IPs. let parts: Vec<&str> = host.split('.').collect(); - if parts.len() >= 2 { + if parts.len() >= 2 && parts.iter().any(|p| p.parse::().is_err()) { let domain = format!("{}.{}", parts[parts.len() - 2], parts[parts.len() - 1]); return format!("https://src.{domain}"); }