feat: pin new templates to the latest tari_ootle_template_build - #192
Merged
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tari init/tari template initwrote a hardcodedtari_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.minorrequirement.New module
crates/cli/src/cli/crates_io.rs, ~150 lines including tests.reqwestwas already a dependency (rustls + json), so no new deps.Behaviour
0.7as a fallback.tari initkeeps working without network access.1/,2/,3/{c}/,{ab}/{cd}/) and name lowercasing are handled per the registry spec.Note on the other hardcoded 0.7
publish.rs:239also 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_dependencyis 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.