Skip to content

Commit

Permalink
refactor: Adding .template extension to template files (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
notdanilo authored Dec 2, 2024
1 parent d597787 commit 8e015c5
Show file tree
Hide file tree
Showing 27 changed files with 23 additions and 23 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion cli/src/templates/component/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions cli/src/templates/program/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
Expand All @@ -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(),
),
]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cli/src/templates/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 14 additions & 14 deletions cli/src/templates/workspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,44 @@ 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
)
}

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
Expand All @@ -52,29 +52,29 @@ 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
)
}

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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8e015c5

Please sign in to comment.