Skip to content

feat: pin new templates to the latest tari_ootle_template_build - #192

Merged
sdbondi merged 2 commits into
mainfrom
feat/fetch-latest-build-dep-version
Aug 21, 2026
Merged

feat: pin new templates to the latest tari_ootle_template_build#192
sdbondi merged 2 commits into
mainfrom
feat/fetch-latest-build-dep-version

Conversation

@sdbondi

@sdbondi sdbondi commented Aug 21, 2026

Copy link
Copy Markdown
Member

tari init / tari template init wrote a hardcoded tari_ootle_template_build = "0.7" into every scaffolded template. crates.io is on 0.11, so new templates were pinned four minor versions behind on day one, and nothing about the release process would ever catch it.

Approach

Look the version up on the crates.io sparse index rather than the API — no auth, no User-Agent policy, one compact JSON line per published release. Take the highest non-yanked, non-prerelease version and write it as a major.minor requirement.

New module crates/cli/src/cli/crates_io.rs, ~150 lines including tests. reqwest was already a dependency (rustls + json), so no new deps.

Behaviour

  • Already declared? No lookup at all — a version the user chose deliberately is never re-pinned.
  • Offline / firewalled / slow? 3s timeout, then a message saying why, then the previously hardcoded 0.7 as a fallback. tari init keeps working without network access.
  • Index sharding (1/, 2/, 3/{c}/, {ab}/{cd}/) and name lowercasing are handled per the registry spec.
$ tari template init -y
✅ Added tari_ootle_template_build = "0.11" to [build-dependencies]

$ tari template init -y          # second run
ℹ️  tari_ootle_template_build already in [build-dependencies], skipping

$ HTTPS_PROXY=http://127.0.0.1:9 tari template init -y      # no network
ℹ️  Could not check crates.io for the latest tari_ootle_template_build (…Connection refused…), using 0.7
✅ Added tari_ootle_template_build = "0.7" to [build-dependencies]

Note on the other hardcoded 0.7

publish.rs:239 also mentions ^0.7, but that one is a compatibility floor — pre-0.7 emitted map-encoded CBOR — not a "latest", so it is deliberately left alone.

The fallback constant does not disappear; it just stops being the source of truth, so letting it age is no longer silently harmful.

Testing

10 new unit tests covering index sharding, lowercasing, picking the highest version rather than the last line published, and skipping yanked/prerelease/malformed entries — all pure, no network. add_build_dependency is now a pure function taking the version, so the existing tests stay offline too. cargo test -p tari-ootle-cli: 54 passed. Clippy and fmt clean. Manually exercised the online, already-declared, and offline paths shown above.

Version bumped to 0.24.0.

`tari init` / `tari template init` wrote a hardcoded `tari_ootle_template_build
= "0.7"` into every scaffolded template. crates.io is on 0.11, so new templates
were being pinned four minor versions behind on day one.

Look the version up on the crates.io sparse index instead — no auth, no
User-Agent policy, one JSON line per release — taking the highest non-yanked,
non-prerelease version and writing it as a `major.minor` requirement.

The lookup is skipped entirely when the dependency is already declared, so a
version the user chose deliberately is never re-pinned. On any failure (offline,
firewalled, 3s timeout) the CLI prints why and falls back to the previously
hardcoded version, so init still works without network access.

Also bumps the workspace version to 0.24.0.
An offline `tari init` should still scaffold a current template. 0.7 was the
value being replaced precisely because it was stale, so keeping it as the
fallback reproduced the original problem whenever crates.io was unreachable.
@sdbondi
sdbondi changed the base branch from feat/lint-command to main August 21, 2026 07:02
@sdbondi
sdbondi merged commit 5bf155b into main Aug 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant