use include_dir::{Dir, include_dir};
pub static SAAS: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/src/starters/saas");
pub static CMS: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/src/starters/cms");
#[derive(Debug)]
pub struct Builtin {
pub name: &'static str,
pub description: &'static str,
pub dir: &'static Dir<'static>,
}
pub static BUILTINS: &[Builtin] = &[
Builtin {
name: "saas",
description: "Multi-tenant SaaS: session auth + row-level tenancy + tenant-scoped dashboard",
dir: &SAAS,
},
Builtin {
name: "cms",
description: "WordPress-parity CMS: posts/pages, taxonomies, media, moderated comments, roles, themes, plugins",
dir: &CMS,
},
];
#[must_use]
pub fn find(name: &str) -> Option<&'static Builtin> {
BUILTINS.iter().find(|b| b.name == name)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn saas_is_registered() {
let b = find("saas").expect("saas built-in should be registered");
assert_eq!(b.name, "saas");
assert!(!b.description.is_empty());
}
#[test]
fn unknown_builtin_is_none() {
assert!(find("does-not-exist").is_none());
}
#[test]
fn saas_tree_contains_manifest() {
assert!(
SAAS.get_file(super::super::manifest::MANIFEST_FILE)
.is_some(),
"embedded saas starter must ship an autumn-starter.toml manifest"
);
}
#[test]
fn cms_is_registered() {
let b = find("cms").expect("cms built-in should be registered");
assert_eq!(b.name, "cms");
assert!(!b.description.is_empty());
}
#[test]
fn cms_tree_contains_manifest() {
assert!(
CMS.get_file(super::super::manifest::MANIFEST_FILE)
.is_some(),
"embedded cms starter must ship an autumn-starter.toml manifest"
);
}
#[test]
fn builtin_names_are_unique() {
let mut names: Vec<&str> = BUILTINS.iter().map(|b| b.name).collect();
names.sort_unstable();
let count = names.len();
names.dedup();
assert_eq!(names.len(), count, "duplicate built-in starter name");
}
}