feat: update to template_metadata 0.5 with supersedes and commit_hash#122
feat: update to template_metadata 0.5 with supersedes and commit_hash#122
Conversation
… support - Bump tari_ootle_template_metadata to 0.5 - Add --supersedes CLI arg to `tari template init` with interactive prompt - Display commit_hash and supersedes in `tari template inspect` and `tari template publish` - Add [patch.crates-io] for local Ootle path deps until next release
There was a problem hiding this comment.
Code Review
This pull request bumps the tari_ootle_template_metadata version to 0.5 and introduces a supersedes field to template metadata, allowing users to link a new template to a previous version. Changes include CLI updates for metadata initialization, inspection, and publishing, along with various dependency updates in Cargo.lock. Review feedback highlights a portability issue caused by relative path overrides in Cargo.toml and suggests implementing input validation and trimming for the new supersedes field.
| [patch.crates-io] | ||
| tari_ootle_template_metadata = { path = "../dan/crates/template_metadata" } | ||
| tari_ootle_template_build = { path = "../dan/crates/template_build" } | ||
| tari_engine = { path = "../dan/crates/engine" } | ||
| tari_engine_types = { path = "../dan/crates/engine_types" } | ||
| tari_ootle_common_types = { path = "../dan/crates/common_types" } | ||
| tari_ootle_transaction = { path = "../dan/crates/transaction" } | ||
| tari_template_lib_types = { path = "../dan/crates/template_lib_types" } | ||
| tari_ootle_walletd_client = { path = "../dan/clients/wallet_daemon_client" } | ||
| tari_ootle_wallet_sdk = { path = "../dan/crates/wallet/sdk" } | ||
| tari_bor = { path = "../dan/crates/tari_bor" } |
There was a problem hiding this comment.
The [patch.crates-io] section uses relative paths to a sibling directory (../dan/...). This makes the repository non-portable and will cause build failures for any developer or CI environment that does not have the dan repository checked out at that specific relative location. While the description notes this is temporary, it should be replaced with git dependencies (pointing to specific tags or commits) or removed before merging to the main branch to ensure the project remains buildable for all contributors.
| documentation: args.documentation.clone(), | ||
| homepage: args.homepage.clone(), | ||
| logo_url: args.logo_url.clone(), | ||
| supersedes: args.supersedes.clone(), |
There was a problem hiding this comment.
| let supersedes: String = Input::new() | ||
| .with_prompt("Supersedes template address (64-char hex, leave empty to skip)") | ||
| .default(args.supersedes.clone().unwrap_or_default()) | ||
| .allow_empty(true) | ||
| .interact_text()?; | ||
| let supersedes = if supersedes.is_empty() { None } else { Some(supersedes) }; |
There was a problem hiding this comment.
The supersedes input should be validated to ensure it matches the expected 64-character hex format mentioned in the prompt. Additionally, the input should be trimmed to handle accidental whitespace.
| let supersedes: String = Input::new() | |
| .with_prompt("Supersedes template address (64-char hex, leave empty to skip)") | |
| .default(args.supersedes.clone().unwrap_or_default()) | |
| .allow_empty(true) | |
| .interact_text()?; | |
| let supersedes = if supersedes.is_empty() { None } else { Some(supersedes) }; | |
| let supersedes: String = Input::new() | |
| .with_prompt("Supersedes template address (64-char hex, leave empty to skip)") | |
| .default(args.supersedes.as_ref().map(|s| s.trim()).unwrap_or_default().to_string()) | |
| .allow_empty(true) | |
| .validate_with(|input: &String| -> Result<(), &str> { | |
| let trimmed = input.trim(); | |
| if trimmed.is_empty() { | |
| return Ok(()); | |
| } | |
| if trimmed.len() != 64 { | |
| return Err("Template address must be 64 characters long"); | |
| } | |
| if !trimmed.chars().all(|c| c.is_ascii_hexdigit()) { | |
| return Err("Template address must be a hex string"); | |
| } | |
| Ok(()) | |
| }) | |
| .interact_text()?; | |
| let supersedes = supersedes.trim(); | |
| let supersedes = if supersedes.is_empty() { None } else { Some(supersedes.to_string()) }; |
Summary
tari_ootle_template_metadatato 0.5 andtari_ootle_template_buildto 0.5--supersedesCLI arg totari template init(interactive prompt + Cargo.toml writer)commit_hashandsupersedesfields intari template inspectandtari template publish[patch.crates-io]section for local Ootle path deps until next coordinated releaseTest plan
cargo test— all 7 tests passtari template init --supersedes <addr>writes to Cargo.tomltari template inspectdisplays new fields