Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ Rust project template for [Copier](https://copier.readthedocs.io/).
## Usage

- Create a new project - `copier copy gh:<owner>/rust-template path/to/new-project`
- Pull in template updates from inside a generated project - `copier update`
- Pull in template updates from inside a generated project - `just update-template` (runs `copier update`)

## Development

- Install `just` - `brew install just`
- Install Copier, rustup, tombi, actionlint, zizmor, prek and gitleaks with Homebrew, then cargo-binstall and the pinned Rust tools (cargo-deny, cargo-nextest, cargo-shear, cargo-llvm-cov, typos) with cargo - `just setup`
- Change tool versions in `cargo_tools` at the top of the `justfile`; reinstall with `just install-tools`
- Bump them all to the latest releases and install them - `just update`
- Bump them all to the latest releases and install them - `just update-cargo-tools`
- Enable the Git hooks in `prek.toml` - `prek install`
- Before each commit they run `just lint` and scan the staged changes for secrets with gitleaks

Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ install-tools:
cargo binstall --no-confirm {{cargo_tools}}

# Bump `binstall_version` and the `cargo_tools` versions in this justfile to their latest releases, then install them
update:
update-cargo-tools:
#!/usr/bin/env bash
set -euo pipefail
latest() {
Expand Down
4 changes: 2 additions & 2 deletions template/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

// Install the toolchain pinned in rust-toolchain.toml, the `just` command runner, the zizmor workflow linter, the Rust tools in the justfile's
// `cargo_tools` (cargo-deny, cargo-nextest, cargo-shear, cargo-llvm-cov, typos) with cargo-binstall via `just install-tools`,
// uv, actionlint and the tombi TOML formatter (from PyPI, since Debian doesn't package them), the prek Git hook manager and the gitleaks secret scanner (a checksum-verified GitHub
// uv, then actionlint, the tombi TOML formatter and Copier from PyPI with uv, the prek Git hook manager and the gitleaks secret scanner (a checksum-verified GitHub
// release, since Debian's package is too old), then install the hooks if the workspace is a Git repository
"postCreateCommand": "rustup toolchain install && sudo apt-get update && sudo apt-get install -y --no-install-recommends just && cargo install --locked zizmor prek uv && just install-tools && uv tool install actionlint-py==1.7.12.25 && uv tool install tombi && uv tool update-shell && v=8.30.1 && a=$(dpkg --print-architecture | sed s/amd64/x64/) && cd /tmp && curl -fsSLO https://github.com/gitleaks/gitleaks/releases/download/v$v/gitleaks_${v}_linux_$a.tar.gz && curl -fsSL https://github.com/gitleaks/gitleaks/releases/download/v$v/gitleaks_${v}_checksums.txt | sha256sum --check --ignore-missing && sudo tar -xzf gitleaks_${v}_linux_$a.tar.gz -C /usr/local/bin gitleaks && rm gitleaks_${v}_linux_$a.tar.gz && cd - && if [ -e .git ]; then prek install; fi",
"postCreateCommand": "rustup toolchain install && sudo apt-get update && sudo apt-get install -y --no-install-recommends just && cargo install --locked zizmor prek uv && just install-tools && uv tool install actionlint-py==1.7.12.25 && uv tool install tombi && uv tool install copier && uv tool update-shell && v=8.30.1 && a=$(dpkg --print-architecture | sed s/amd64/x64/) && cd /tmp && curl -fsSLO https://github.com/gitleaks/gitleaks/releases/download/v$v/gitleaks_${v}_linux_$a.tar.gz && curl -fsSL https://github.com/gitleaks/gitleaks/releases/download/v$v/gitleaks_${v}_checksums.txt | sha256sum --check --ignore-missing && sudo tar -xzf gitleaks_${v}_linux_$a.tar.gz -C /usr/local/bin gitleaks && rm gitleaks_${v}_linux_$a.tar.gz && cd - && if [ -e .git ]; then prek install; fi",

"customizations": {
"vscode": {
Expand Down
4 changes: 2 additions & 2 deletions template/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Run project tasks through `just` (see `justfile`) rather than calling `cargo` di

- `just setup` - install Homebrew dependencies, the pinned toolchain, the Rust tools (via `just install-tools`) and the prek Git hooks (`prek.toml`), which run `just lint` before each commit
- `just install-tools` - install the Rust tools pinned in `cargo_tools` at the top of the `justfile` with cargo-binstall; bump versions there
- `just update` - bump `binstall_version` and `cargo_tools` in the `justfile` to the latest releases, then install them
- `just update-cargo-tools` - bump `binstall_version` and `cargo_tools` in the `justfile` to the latest releases, then install them
- `just build` - build (pass extra flags, e.g. `just build --release`)
- `just test` - run tests with cargo-nextest, then doc tests with `cargo test --doc` (pass a filter, e.g. `just test greeting`)
- `just coverage` - run tests with coverage; fails below `coverage_threshold`% line coverage (set at the top of the `justfile`; `src/main.rs` excluded)
Expand Down Expand Up @@ -47,4 +47,4 @@ prek (`prek.toml`) runs `just lint` and a gitleaks scan of the staged changes be

## Template

This project was generated from a Copier template. `.copier-answers.yml` is managed by Copier; don't edit it by hand. Template updates are pulled in with `copier update`.
This project was generated from a Copier template. `.copier-answers.yml` is managed by Copier; don't edit it by hand. Template updates are pulled in with `just update-template` (runs `copier update`; needs a clean Git working tree).
8 changes: 5 additions & 3 deletions template/README.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export PATH="$HOME/.cargo/bin:$(brew --prefix rustup)/bin:$PATH"
### Dev Container

- Open the repo in VS Code and run **Dev Containers: Reopen in Container**
- Rust, `just`, cargo-deny, cargo-nextest, cargo-shear, cargo-llvm-cov, typos, tombi, actionlint, zizmor, prek, gitleaks and the recommended extensions are installed automatically
- Rust, `just`, cargo-deny, cargo-nextest, cargo-shear, cargo-llvm-cov, typos, tombi, actionlint, zizmor, prek, gitleaks, Copier and the recommended extensions are installed automatically
- The Git hooks are installed if the workspace is a Git repository

## Project Commands
Expand All @@ -35,7 +35,7 @@ Commands are defined in the `justfile` and run with [just](https://github.com/ca
- List available commands - `just`
- Install Homebrew dependencies, the pinned toolchain, the Rust tools and the Git hooks - `just setup`
- Install or update the pinned Rust tools (`cargo_tools` in the `justfile`) - `just install-tools`
- Bump the pinned Rust tools to their latest releases in the `justfile`, then install them - `just update`
- Bump the pinned Rust tools to their latest releases in the `justfile`, then install them - `just update-cargo-tools`
- Build the project - `just build`
- Pass extra flags - `just build --release`
- Run tests with [nextest](https://nexte.st), then doc tests - `just test`
Expand Down Expand Up @@ -80,5 +80,7 @@ Optional: re-run the tests each time you save with [bacon](https://dystroy.org/b

This project was generated from a [Copier](https://copier.readthedocs.io/) template.

- Pull in template updates - `copier update`
- Pull in template updates - `just update-template`
- Runs `copier update`; commit or stash your changes first, since Copier needs a clean Git working tree
- Pass extra flags, e.g. only ask new questions - `just update-template --skip-answered`
- Don't edit `.copier-answers.yml` by hand; Copier uses it to apply updates
6 changes: 5 additions & 1 deletion template/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ install-tools:
cargo binstall --no-confirm {{cargo_tools}}

# Bump `binstall_version` and the `cargo_tools` versions in this justfile to their latest releases, then install them
update:
update-cargo-tools:
#!/usr/bin/env bash
set -euo pipefail
latest() {
Expand All @@ -54,6 +54,10 @@ update:
echo "cargo_tools := \"$tools\""
just install-tools

# Pull in template updates with Copier; needs a clean Git working tree (pass extra flags, e.g. `just update-template --skip-answered`)
update-template *args:
copier update {{args}}

# Build the project (pass extra flags, e.g. `just build --release`)
build *args:
cargo build {{args}}
Expand Down
Loading