feat: Remove fallback to Cookiecutters, use bundled template only

- Remove fallback to ~/Documents/Cookiecutters/snowflake from default_project_template()
- Panic with clear error if bundled template not found
- Update tests to use 05-First Draft instead of 06-First Draft
- Update comments to reflect merged structure (05-First Draft contains planning+draft)

The code now only uses the bundled template at templates/snowflake/ relative to the
executable, ensuring all new projects use the merged 05-First Draft structure.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-09-16 18:27:54 -05:00
parent aab943de6b
commit 2471312f05
2 changed files with 19 additions and 22 deletions
+8 -11
View File
@@ -185,9 +185,9 @@ pub fn default_show_toolbar() -> bool {
}
/// Default cookiecutter template for **File ▸ New project…**.
/// First tries the bundled template, then falls back to the user's Cookiecutters directory.
/// Uses the bundled template from the project's templates/snowflake directory.
pub fn default_project_template() -> PathBuf {
// Try the bundled template first (relative to the executable)
// Find the bundled template relative to the executable's location
if let Ok(exe_path) = std::env::current_exe() {
// The templates are at the project root level, same as Cargo.toml
// binary is typically at target/release/md-manuscript or target/debug/md-manuscript
@@ -209,17 +209,14 @@ pub fn default_project_template() -> PathBuf {
}
}
}
// Fallback to user's Cookiecutters directory
dirs::home_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join("Documents")
.join("Cookiecutters")
.join("snowflake")
// If we can't find the bundled template, panic with a clear error
// The bundled template should always be present in a properly built release
panic!("Bundled template not found. Please ensure templates/snowflake/ exists relative to the executable.");
}
/// Default subfolder opened after generating a project: the snowflake
/// template's drafting folder, where the chapter files live.
/// Supports both "05-First Draft" (merged planning+draft) and "06-First Draft" (legacy).
/// template's drafting folder (05-First Draft), where the chapter files live.
/// Contains merged planning and draft content in a single folder.
pub fn default_project_open_subdir() -> String {
"05-First Draft".to_string()
}
@@ -594,7 +591,7 @@ mod tests {
#[test]
fn bundled_template_is_found_via_exe_path() {
let path = default_project_template();
// The function should find either the bundled template or the fallback
// The function should find the bundled template
// Verify it returns a valid path that contains cookiecutter.json
assert!(path.join("cookiecutter.json").is_file(),
"Template path {} should contain cookiecutter.json", path.display());