substrate_manager/templates/
mod.rs

1use std::path::PathBuf;
2
3use serde_derive::Deserialize;
4
5use crate::{core::manifest::Manifest, util::SubstrateResult};
6
7#[derive(Debug, Deserialize, PartialEq, Eq)]
8pub struct TemplateConfig {
9    pub remote: String,
10    pub branch: String,
11    pub template_path: String,
12}
13
14// TODO: Add support for custom templates
15pub fn load_template_config(template_name: &str) -> SubstrateResult<TemplateConfig> {
16     // Construct the path to the embedded config file
17    let template_config_str = match template_name.to_lowercase().as_str() {
18        "substrate" => include_str!("chain/substrate.toml"),
19        "cumulus" => include_str!("chain/cumulus.toml"),
20        "frontier" => include_str!("chain/frontier.toml"),
21        "canvas" => include_str!("chain/canvas.toml"),
22        // Add more cases for each config file
23        _ => anyhow::bail!("Invalid template name".to_string()),
24    };
25
26    let template_config = toml_edit::de::from_str::<TemplateConfig>(template_config_str)?;
27
28    Ok(template_config)
29}