TheBevyFlock / bevy_new_minimal

"Hello, world!" for Bevy
MIT License
3 stars 1 forks source link

Liquid placeholders make `cargo` and `rust-analyzer` fail #10

Closed benfrankel closed 1 month ago

benfrankel commented 1 month ago

For example, "{{project-name}}" in Cargo.toml is not a valid crate name, so the template itself cannot be compiled. This makes it harder for maintainers of the template to make changes.

Generated repos are not affected by this issue, only the template itself.

benfrankel commented 1 month ago

Okay I found an approach that works:

  1. Split Cargo.toml into a Cargo.toml.template (or w/e) with Liquid placeholders, and a Cargo.toml with valid syntax.
  2. Add "Cargo.toml.template" to the include list in cargo-generate.toml (this can be "*.template" so it only has to be added once).
  3. Add file::rename("Cargo.toml.template", "Cargo.toml"); to the post-generate hook.
richchurcher commented 1 month ago

Oh, funny I was just strongly considering using sed in a pre-commit lol... nice one.

benfrankel commented 1 month ago

This does mean that there will be 2 copies of each templated file that should be kept in sync, but that's a sacrifice I was prepared to make for a working solution anyways. Better than 2 branches of the entire repo :P

janhohenheim commented 1 month ago

@BD103 if you feel like doing some CI magic at some point, we could issue a warning if a PR touches only one file when there exist both foo.rs and foo.rs.template 👀