From ee55ee4cc1fe9b8e6a78bb12dccb2256a7893100 Mon Sep 17 00:00:00 2001 From: Danilo Guanabara Date: Sun, 1 Dec 2024 23:49:58 -0300 Subject: [PATCH] refactor: Adding .template extension to template files --- .../component/{lib.rs => lib.rs.template} | 0 cli/src/templates/component/mod.rs | 2 +- .../{constants.rs => constants.rs.template} | 0 .../program/{error.rs => error.rs.template} | 0 .../{initialize.rs => initialize.rs.template} | 0 .../instructions/{mod.rs => mod.rs.template} | 0 cli/src/templates/program/mod.rs | 14 +++++----- ...ltiple.lib.rs => multiple.lib.rs.template} | 0 .../{single.lib.rs => single.lib.rs.template} | 0 .../program/state/{mod.rs => mod.rs.template} | 0 .../system/{lib.rs => lib.rs.template} | 0 cli/src/templates/system/mod.rs | 2 +- .../{gitignore => .gitignore.template} | 0 ...rettierignore => .prettierignore.template} | 0 ...o.serde.toml => Cargo.serde.toml.template} | 0 .../{Cargo.toml => Cargo.toml.template} | 0 .../{Xargo.toml => Xargo.toml.template} | 0 .../workspace/{jest.js => jest.js.template} | 0 ...ackage.json => jest.package.json.template} | 0 ...age.json => jest.ts.package.json.template} | 0 .../workspace/{mocha.js => mocha.js.template} | 0 .../workspace/{mocha.ts => mocha.ts.template} | 0 cli/src/templates/workspace/mod.rs | 28 +++++++++---------- .../{package.json => package.json.template} | 0 ....package.json => ts.package.json.template} | 0 ...s.Cargo.toml => types.Cargo.toml.template} | 0 ...workspace.toml => workspace.toml.template} | 0 27 files changed, 23 insertions(+), 23 deletions(-) rename cli/src/templates/component/{lib.rs => lib.rs.template} (100%) rename cli/src/templates/program/{constants.rs => constants.rs.template} (100%) rename cli/src/templates/program/{error.rs => error.rs.template} (100%) rename cli/src/templates/program/instructions/{initialize.rs => initialize.rs.template} (100%) rename cli/src/templates/program/instructions/{mod.rs => mod.rs.template} (100%) rename cli/src/templates/program/{multiple.lib.rs => multiple.lib.rs.template} (100%) rename cli/src/templates/program/{single.lib.rs => single.lib.rs.template} (100%) rename cli/src/templates/program/state/{mod.rs => mod.rs.template} (100%) rename cli/src/templates/system/{lib.rs => lib.rs.template} (100%) rename cli/src/templates/workspace/{gitignore => .gitignore.template} (100%) rename cli/src/templates/workspace/{prettierignore => .prettierignore.template} (100%) rename cli/src/templates/workspace/{Cargo.serde.toml => Cargo.serde.toml.template} (100%) rename cli/src/templates/workspace/{Cargo.toml => Cargo.toml.template} (100%) rename cli/src/templates/workspace/{Xargo.toml => Xargo.toml.template} (100%) rename cli/src/templates/workspace/{jest.js => jest.js.template} (100%) rename cli/src/templates/workspace/{jest.package.json => jest.package.json.template} (100%) rename cli/src/templates/workspace/{jest.ts.package.json => jest.ts.package.json.template} (100%) rename cli/src/templates/workspace/{mocha.js => mocha.js.template} (100%) rename cli/src/templates/workspace/{mocha.ts => mocha.ts.template} (100%) rename cli/src/templates/workspace/{package.json => package.json.template} (100%) rename cli/src/templates/workspace/{ts.package.json => ts.package.json.template} (100%) rename cli/src/templates/workspace/{types.Cargo.toml => types.Cargo.toml.template} (100%) rename cli/src/templates/workspace/{workspace.toml => workspace.toml.template} (100%) diff --git a/cli/src/templates/component/lib.rs b/cli/src/templates/component/lib.rs.template similarity index 100% rename from cli/src/templates/component/lib.rs rename to cli/src/templates/component/lib.rs.template diff --git a/cli/src/templates/component/mod.rs b/cli/src/templates/component/mod.rs index 3de9b63..718ba04 100644 --- a/cli/src/templates/component/mod.rs +++ b/cli/src/templates/component/mod.rs @@ -13,7 +13,7 @@ pub fn create_component_template_simple(name: &str, program_path: &Path) -> File vec![( program_path.join("src").join("lib.rs"), format!( - include_str!("lib.rs"), + include_str!("lib.rs.template"), program_id = program_id, program_name = program_name ), diff --git a/cli/src/templates/program/constants.rs b/cli/src/templates/program/constants.rs.template similarity index 100% rename from cli/src/templates/program/constants.rs rename to cli/src/templates/program/constants.rs.template diff --git a/cli/src/templates/program/error.rs b/cli/src/templates/program/error.rs.template similarity index 100% rename from cli/src/templates/program/error.rs rename to cli/src/templates/program/error.rs.template diff --git a/cli/src/templates/program/instructions/initialize.rs b/cli/src/templates/program/instructions/initialize.rs.template similarity index 100% rename from cli/src/templates/program/instructions/initialize.rs rename to cli/src/templates/program/instructions/initialize.rs.template diff --git a/cli/src/templates/program/instructions/mod.rs b/cli/src/templates/program/instructions/mod.rs.template similarity index 100% rename from cli/src/templates/program/instructions/mod.rs rename to cli/src/templates/program/instructions/mod.rs.template diff --git a/cli/src/templates/program/mod.rs b/cli/src/templates/program/mod.rs index fb18071..8770505 100644 --- a/cli/src/templates/program/mod.rs +++ b/cli/src/templates/program/mod.rs @@ -8,7 +8,7 @@ pub fn create_program_template_single(name: &str, program_path: &Path) -> Files vec![( program_path.join("src").join("lib.rs"), format!( - include_str!("single.lib.rs"), + include_str!("single.lib.rs.template"), program_id = program_id, program_name = program_name ), @@ -24,27 +24,27 @@ pub fn create_program_template_multiple(name: &str, program_path: &Path) -> File ( src_path.join("lib.rs"), format!( - include_str!("multiple.lib.rs"), + include_str!("multiple.lib.rs.template"), program_id = program_id, program_name = program_name ), ), ( src_path.join("constants.rs"), - include_str!("constants.rs").into(), + include_str!("constants.rs.template").into(), ), - (src_path.join("error.rs"), include_str!("error.rs").into()), + (src_path.join("error.rs"), include_str!("error.rs.template").into()), ( src_path.join("instructions").join("mod.rs"), - include_str!("instructions/mod.rs").into(), + include_str!("instructions/mod.rs.template").into(), ), ( src_path.join("instructions").join("initialize.rs"), - include_str!("instructions/initialize.rs").into(), + include_str!("instructions/initialize.rs.template").into(), ), ( src_path.join("state").join("mod.rs"), - include_str!("state/mod.rs").into(), + include_str!("state/mod.rs.template").into(), ), ] } diff --git a/cli/src/templates/program/multiple.lib.rs b/cli/src/templates/program/multiple.lib.rs.template similarity index 100% rename from cli/src/templates/program/multiple.lib.rs rename to cli/src/templates/program/multiple.lib.rs.template diff --git a/cli/src/templates/program/single.lib.rs b/cli/src/templates/program/single.lib.rs.template similarity index 100% rename from cli/src/templates/program/single.lib.rs rename to cli/src/templates/program/single.lib.rs.template diff --git a/cli/src/templates/program/state/mod.rs b/cli/src/templates/program/state/mod.rs.template similarity index 100% rename from cli/src/templates/program/state/mod.rs rename to cli/src/templates/program/state/mod.rs.template diff --git a/cli/src/templates/system/lib.rs b/cli/src/templates/system/lib.rs.template similarity index 100% rename from cli/src/templates/system/lib.rs rename to cli/src/templates/system/lib.rs.template diff --git a/cli/src/templates/system/mod.rs b/cli/src/templates/system/mod.rs index bdd60ca..a723d2b 100644 --- a/cli/src/templates/system/mod.rs +++ b/cli/src/templates/system/mod.rs @@ -9,7 +9,7 @@ pub fn create_system_template_simple(name: &str, program_path: &Path) -> Files { vec![( program_path.join("src").join("lib.rs"), format!( - include_str!("lib.rs"), + include_str!("lib.rs.template"), program_id = program_id, program_name = program_name ), diff --git a/cli/src/templates/workspace/gitignore b/cli/src/templates/workspace/.gitignore.template similarity index 100% rename from cli/src/templates/workspace/gitignore rename to cli/src/templates/workspace/.gitignore.template diff --git a/cli/src/templates/workspace/prettierignore b/cli/src/templates/workspace/.prettierignore.template similarity index 100% rename from cli/src/templates/workspace/prettierignore rename to cli/src/templates/workspace/.prettierignore.template diff --git a/cli/src/templates/workspace/Cargo.serde.toml b/cli/src/templates/workspace/Cargo.serde.toml.template similarity index 100% rename from cli/src/templates/workspace/Cargo.serde.toml rename to cli/src/templates/workspace/Cargo.serde.toml.template diff --git a/cli/src/templates/workspace/Cargo.toml b/cli/src/templates/workspace/Cargo.toml.template similarity index 100% rename from cli/src/templates/workspace/Cargo.toml rename to cli/src/templates/workspace/Cargo.toml.template diff --git a/cli/src/templates/workspace/Xargo.toml b/cli/src/templates/workspace/Xargo.toml.template similarity index 100% rename from cli/src/templates/workspace/Xargo.toml rename to cli/src/templates/workspace/Xargo.toml.template diff --git a/cli/src/templates/workspace/jest.js b/cli/src/templates/workspace/jest.js.template similarity index 100% rename from cli/src/templates/workspace/jest.js rename to cli/src/templates/workspace/jest.js.template diff --git a/cli/src/templates/workspace/jest.package.json b/cli/src/templates/workspace/jest.package.json.template similarity index 100% rename from cli/src/templates/workspace/jest.package.json rename to cli/src/templates/workspace/jest.package.json.template diff --git a/cli/src/templates/workspace/jest.ts.package.json b/cli/src/templates/workspace/jest.ts.package.json.template similarity index 100% rename from cli/src/templates/workspace/jest.ts.package.json rename to cli/src/templates/workspace/jest.ts.package.json.template diff --git a/cli/src/templates/workspace/mocha.js b/cli/src/templates/workspace/mocha.js.template similarity index 100% rename from cli/src/templates/workspace/mocha.js rename to cli/src/templates/workspace/mocha.js.template diff --git a/cli/src/templates/workspace/mocha.ts b/cli/src/templates/workspace/mocha.ts.template similarity index 100% rename from cli/src/templates/workspace/mocha.ts rename to cli/src/templates/workspace/mocha.ts.template diff --git a/cli/src/templates/workspace/mod.rs b/cli/src/templates/workspace/mod.rs index c49e2ec..43368cb 100644 --- a/cli/src/templates/workspace/mod.rs +++ b/cli/src/templates/workspace/mod.rs @@ -4,7 +4,7 @@ pub const ANCHOR_VERSION: &str = anchor_cli::VERSION; pub fn workspace_manifest() -> String { format!( - include_str!("workspace.toml"), + include_str!("workspace.toml.template"), VERSION = VERSION, ANCHOR_VERSION = ANCHOR_VERSION ) @@ -12,36 +12,36 @@ pub fn workspace_manifest() -> String { pub fn package_json(jest: bool) -> String { if jest { - include_str!("jest.package.json").to_string() + include_str!("jest.package.json.template").to_string() } else { - include_str!("package.json").to_string() + include_str!("package.json.template").to_string() } } pub fn ts_package_json(jest: bool) -> String { if jest { - include_str!("jest.ts.package.json").to_string() + include_str!("jest.ts.package.json.template").to_string() } else { - include_str!("ts.package.json").to_string() + include_str!("ts.package.json.template").to_string() } } pub fn mocha(name: &str) -> String { - format!(include_str!("mocha.js"), name) + format!(include_str!("mocha.js.template"), name) } pub fn jest(name: &str) -> String { - format!(include_str!("jest.js"), name) + format!(include_str!("jest.js.template"), name) } pub fn ts_mocha(name: &str) -> String { - format!(include_str!("mocha.ts"), name) + format!(include_str!("mocha.ts.template"), name) } pub fn cargo_toml(name: &str) -> String { let snake_case_name = name.to_snake_case(); format!( - include_str!("Cargo.toml"), + include_str!("Cargo.toml.template"), name = name, snake_case_name = snake_case_name, VERSION = VERSION @@ -52,7 +52,7 @@ pub fn cargo_toml(name: &str) -> String { pub fn cargo_toml_with_serde(name: &str) -> String { let snake_case_name = name.to_snake_case(); format!( - include_str!("Cargo.serde.toml"), + include_str!("Cargo.serde.toml.template"), name = name, snake_case_name = snake_case_name, VERSION = VERSION @@ -60,21 +60,21 @@ pub fn cargo_toml_with_serde(name: &str) -> String { } pub fn xargo_toml() -> &'static str { - include_str!("Xargo.toml") + include_str!("Xargo.toml.template") } pub fn git_ignore() -> &'static str { - include_str!("gitignore") + include_str!(".gitignore.template") } pub fn prettier_ignore() -> &'static str { - include_str!("prettierignore") + include_str!(".prettierignore.template") } pub(crate) fn types_cargo_toml() -> String { let name = "bolt-types"; let snake_case_name = name.to_snake_case(); format!( - include_str!("types.Cargo.toml"), + include_str!("types.Cargo.toml.template"), name = name, snake_case_name = snake_case_name, VERSION = VERSION diff --git a/cli/src/templates/workspace/package.json b/cli/src/templates/workspace/package.json.template similarity index 100% rename from cli/src/templates/workspace/package.json rename to cli/src/templates/workspace/package.json.template diff --git a/cli/src/templates/workspace/ts.package.json b/cli/src/templates/workspace/ts.package.json.template similarity index 100% rename from cli/src/templates/workspace/ts.package.json rename to cli/src/templates/workspace/ts.package.json.template diff --git a/cli/src/templates/workspace/types.Cargo.toml b/cli/src/templates/workspace/types.Cargo.toml.template similarity index 100% rename from cli/src/templates/workspace/types.Cargo.toml rename to cli/src/templates/workspace/types.Cargo.toml.template diff --git a/cli/src/templates/workspace/workspace.toml b/cli/src/templates/workspace/workspace.toml.template similarity index 100% rename from cli/src/templates/workspace/workspace.toml rename to cli/src/templates/workspace/workspace.toml.template