Skip to content

Commit d33737a

Browse files
authored
bugfix: add support for underscore in project name for generated files (#296)
* bugfix: add support for underscore in project name for generated files * bugfix: update CHANGELOG.md to reflect recent changes
1 parent 910f256 commit d33737a

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Updated CLI template `increment_rs`: Changed authority validation to use `Authority` type wrapper instead of raw `Pubkey` in `IncrementAccounts` (#297)
1313
- Updated CLI template `states_rs`: Changed `AccountValidate` implementation for `CounterAccount` to use `Authority` type parameter instead of `&Pubkey`, and updated reference type from `Self::Ref<'_>` to `Self::Ptr` (#297)
1414
- Updated CLI template `initialize_rs`: Changed `Seeds` argument in `idl` macro to use `FindCounterAccountSeeds` instead of `FindCounterSeeds` (#297)
15+
- CLI template: ensure crate name uses underscores in `cargo_toml`. Added `{name_lowercase_underscore}` placeholder and generator replacement to convert hyphens to underscores in generated project names. (#296)
1516

1617
## [0.27.0] - 2025-11-07
1718

star_frame_cli/src/new_project.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ pub fn new_project(args: NewArgs) -> eyre::Result<()> {
7171
fn stub_file(template: &str, path: &PathBuf, project_name: &String) -> io::Result<()> {
7272
let content = template
7373
.replace("{name_lowercase}", &project_name.to_ascii_lowercase())
74+
.replace(
75+
"{name_lowercase_underscore}",
76+
&project_name.to_ascii_lowercase().replace('-', "_"),
77+
)
7478
.replace("{name_uppercase}", &project_name.to_ascii_uppercase())
7579
.replace("{name_pascalcase}", &project_name.to_case(Case::Pascal))
7680
.replace("{pubkey}", &Pubkey::new_unique().to_string());

star_frame_cli/src/template/cargo_toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ release.release = false
1212
# Using only `cdylib` enables the compiler to optimize with LTO. If you need to use the library, make a separate lib crate
1313
# or add `rlib` here if the performance impact is acceptable.
1414
crate-type = ["cdylib"]
15-
name = "{name_lowercase}"
15+
name = "{name_lowercase_underscore}"
1616

1717
[features]
1818
no_entrypoint = []

0 commit comments

Comments
 (0)