Skip to main content

actr_cli/templates/typescript/
echo.rs

1use crate::error::Result;
2use crate::templates::ProjectTemplate;
3use std::collections::HashMap;
4use std::path::Path;
5
6pub fn load(files: &mut HashMap<String, String>, is_service: bool) -> Result<()> {
7    let fixtures_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures");
8    let ts_fixtures = fixtures_root.join("typescript/echo");
9
10    ProjectTemplate::load_file(&ts_fixtures.join("package.json.hbs"), files, "package.json")?;
11    ProjectTemplate::load_file(
12        &ts_fixtures.join("tsconfig.json.hbs"),
13        files,
14        "tsconfig.json",
15    )?;
16    ProjectTemplate::load_file(&ts_fixtures.join("gitignore.hbs"), files, ".gitignore")?;
17    ProjectTemplate::load_file(&ts_fixtures.join("README.md.hbs"), files, "README.md")?;
18
19    if is_service {
20        ProjectTemplate::load_file(
21            &ts_fixtures.join("manifest.toml.service.hbs"),
22            files,
23            "manifest.toml",
24        )?;
25        ProjectTemplate::load_file(
26            &ts_fixtures.join("index.service.ts.hbs"),
27            files,
28            "src/actr_service.ts",
29        )?;
30    } else {
31        ProjectTemplate::load_file(
32            &ts_fixtures.join("manifest.toml.hbs"),
33            files,
34            "manifest.toml",
35        )?;
36        ProjectTemplate::load_file(
37            &ts_fixtures.join("index.ts.hbs"),
38            files,
39            "src/actr_service.ts",
40        )?;
41    }
42
43    Ok(())
44}