summaryrefslogtreecommitdiff
path: root/gen/src/gen_iscc_script.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-03-17 14:47:25 +0800
committer魏曹先生 <1992414357@qq.com>2026-03-17 14:47:25 +0800
commit92670ec92b555383fc31cf42b15d4ea38f8e9c8f (patch)
treeb2f1479247411027fb41b346d2195e79e38729a1 /gen/src/gen_iscc_script.rs
parent7fcc38d0e76fc4088269cd3ea22c56a60e5db109 (diff)
Extract build-time generation code into separate crate
Diffstat (limited to 'gen/src/gen_iscc_script.rs')
-rw-r--r--gen/src/gen_iscc_script.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/gen/src/gen_iscc_script.rs b/gen/src/gen_iscc_script.rs
new file mode 100644
index 0000000..eabaab3
--- /dev/null
+++ b/gen/src/gen_iscc_script.rs
@@ -0,0 +1,36 @@
+use std::path::PathBuf;
+
+use just_template::{Template, tmpl_param};
+
+use crate::{
+ constants::{SETUP_JV_CLI_ISS, SETUP_JV_CLI_ISS_TEMPLATE},
+ env::{get_author, get_site, get_version},
+};
+
+/// Generate Inno Setup installer script (Windows only) using just_template
+pub async fn generate_installer_script(repo_root: &PathBuf) {
+ let template_path = repo_root.join(SETUP_JV_CLI_ISS_TEMPLATE);
+ let output_path = repo_root.join(SETUP_JV_CLI_ISS);
+
+ // Read the template
+ let template_content = tokio::fs::read_to_string(&template_path).await.unwrap();
+
+ // Get values for the template
+ let author = get_author().unwrap();
+ let version = get_version();
+ let site = get_site().unwrap();
+
+ // Create template
+ let mut template = Template::from(template_content);
+
+ // Set all parameters
+ tmpl_param!(template, version = version, author = author, site = site);
+
+ // Expand the template
+ let generated = template.expand().unwrap();
+
+ // Write the generated script
+ tokio::fs::write(output_path, generated).await.unwrap();
+
+ println!("Generated Inno Setup script using just_template");
+}