use crate::config::SastriConfig;
pub fn print_checklist(cfg: &SastriConfig) {
println!("Secrets & external setup for {}\n", cfg.github_slug());
println!("(Sastri never writes secret values into Sastri.toml.)\n");
if cfg.release.publish_crates_io {
println!("• CRATES_IO_TOKEN — GitHub Actions secret for cargo publish");
}
if cfg.mechanism_enabled("npm") {
println!(
"• NPM_TOKEN — npm granular Automation token (bypass 2FA) for @{}/…",
cfg.org
.npm_org
.as_deref()
.unwrap_or(&cfg.project.github_owner)
);
println!(" gh secret set NPM_TOKEN --repo {}", cfg.github_slug());
}
if cfg.mechanism_enabled("hex") {
println!("• HEX_API_KEY — Hex.pm API key for mix hex.publish");
}
if cfg.mechanism_enabled("pypi") {
println!("• PyPI Trusted Publishing (OIDC) — no long-lived token:");
println!(" GitHub Environment: pypi");
println!(
" Pending publisher: owner={} repo={} workflow=publish-pypi.yml env=pypi",
cfg.project.github_owner, cfg.project.github_repo
);
}
if cfg.mechanism_enabled("homebrew") {
if let Some(tap) = &cfg.org.homebrew_tap {
println!("• Create/push tap repo {tap}; fill sha256 after first release");
}
}
if cfg.mechanism_enabled("scoop") {
if let Some(bucket) = &cfg.org.scoop_bucket {
println!("• Create/push scoop bucket {bucket}; fill hash after first release");
}
}
if cfg.mechanism_enabled("asdf") {
if let Some(r) = &cfg.org.asdf_plugin_repo {
println!("• Create/push asdf plugin repo {r}");
}
}
println!();
}
pub fn checklist_lines(cfg: &SastriConfig) -> Vec<String> {
let mut lines = Vec::new();
if cfg.release.publish_crates_io {
lines.push("CRATES_IO_TOKEN".into());
}
if cfg.mechanism_enabled("npm") {
lines.push("NPM_TOKEN".into());
}
if cfg.mechanism_enabled("hex") {
lines.push("HEX_API_KEY".into());
}
if cfg.mechanism_enabled("pypi") {
lines.push("PyPI Trusted Publishing".into());
}
if cfg.mechanism_enabled("homebrew") {
if let Some(tap) = &cfg.org.homebrew_tap {
lines.push(format!("homebrew:{tap}"));
}
}
if cfg.mechanism_enabled("scoop") {
if let Some(bucket) = &cfg.org.scoop_bucket {
lines.push(format!("scoop:{bucket}"));
}
}
if cfg.mechanism_enabled("asdf") {
if let Some(r) = &cfg.org.asdf_plugin_repo {
lines.push(format!("asdf:{r}"));
}
}
lines
}
#[cfg(test)]
mod tests {
use super::*;
use crate::config::{Org, Paths, Project, Release};
use indexmap::IndexMap;
fn cfg_with(mechs: &[(&str, bool)]) -> SastriConfig {
SastriConfig {
project: Project {
name: "greet".into(),
description: "x".into(),
github_owner: "latentmeta".into(),
github_repo: "greet".into(),
binary_name: "greet".into(),
license: "MIT".into(),
version: "0.1.0".into(),
cargo_manifest: "Cargo.toml".into(),
homepage: None,
},
org: Org {
homebrew_tap: Some("latentmeta/homebrew-tap".into()),
scoop_bucket: Some("latentmeta/scoop-bucket".into()),
npm_org: Some("latentmeta".into()),
npm_package: Some("@latentmeta/greet".into()),
hex_package: Some("greet".into()),
pypi_package: Some("greet".into()),
asdf_plugin_repo: Some("latentmeta/asdf-greet".into()),
},
mechanisms: mechs
.iter()
.map(|(k, v)| ((*k).into(), *v))
.collect::<IndexMap<_, _>>(),
release: Release::default(),
paths: Paths::default(),
}
}
#[test]
fn checklist_covers_enabled_channels() {
let cfg = cfg_with(&[
("npm", true),
("hex", true),
("pypi", true),
("homebrew", true),
("scoop", true),
("asdf", true),
]);
let lines = checklist_lines(&cfg);
assert!(lines.iter().any(|l| l.contains("CRATES_IO_TOKEN")));
assert!(lines.iter().any(|l| l.contains("NPM_TOKEN")));
assert!(lines.iter().any(|l| l.contains("HEX_API_KEY")));
assert!(lines.iter().any(|l| l.contains("PyPI")));
assert!(lines.iter().any(|l| l.contains("homebrew:")));
assert!(lines.iter().any(|l| l.contains("scoop:")));
assert!(lines.iter().any(|l| l.contains("asdf:")));
}
#[test]
fn checklist_skips_disabled() {
let cfg = cfg_with(&[("npm", false), ("homebrew", false)]);
let lines = checklist_lines(&cfg);
assert!(!lines.iter().any(|l| l.contains("NPM_TOKEN")));
assert!(!lines.iter().any(|l| l.contains("homebrew:")));
assert!(lines.iter().any(|l| l.contains("CRATES_IO_TOKEN")));
}
}