fix(new): address remaining Copilot review comments

- Install hint in find_spel_on_path error now uses DEFAULT_SPEL.tag
  instead of a hard-coded version string that would drift on bumps.
- check_spel_version() warns when the installed spel version does not
  match DEFAULT_SPEL.tag, so mismatches surface before `lgs setup`.
- available_templates() now includes "spel" explicitly; after removing
  the lez-framework template directory it was no longer discoverable
  from disk, so --template help advertised only "default".
- Renamed is_lez_framework -> requires_idl in run_state.rs; the old
  name implied the flag only covered lez-framework, but it also matches
  spel. Updated the inline comment at the use site to match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Václav Pavlín
2026-06-02 10:18:32 +02:00
co-authored by Claude Sonnet 4.6
parent 4a426ae239
commit 47ddccfbb7
3 changed files with 42 additions and 8 deletions
+34 -5
View File
@@ -103,11 +103,15 @@ fn cmd_new_spel(
target: &Path,
bootstrap_cache: &std::path::Path,
) -> DynResult<()> {
let spel_bin = find_spel_on_path().context(
"spel binary not found on PATH.\n\
Install it first:\n \
cargo install --git https://github.com/logos-co/spel.git --tag v0.5.0 spel",
)?;
let spel_bin = find_spel_on_path().with_context(|| {
format!(
"spel binary not found on PATH.\n\
Install it first:\n \
cargo install --git https://github.com/logos-co/spel.git --tag {} spel",
DEFAULT_SPEL.tag
)
})?;
check_spel_version(&spel_bin);
if cmd.lez_path.is_some() {
anyhow::bail!(
@@ -313,6 +317,31 @@ fn build_scaffold_config(
}
}
/// Warn if the installed `spel` version does not match `DEFAULT_SPEL.tag`.
/// A mismatch is non-fatal — the user may have a newer version — but silently
/// using the wrong version produces hard-to-diagnose mismatches at first
/// `lgs build idl` or `lgs setup`.
fn check_spel_version(spel_bin: &std::path::Path) {
let output = match std::process::Command::new(spel_bin)
.arg("--version")
.output()
{
Ok(o) => o,
Err(_) => return,
};
let stdout = String::from_utf8_lossy(&output.stdout);
if !stdout.contains(DEFAULT_SPEL.tag) {
eprintln!(
"warning: installed spel version ({}) does not match the expected {} pinned by scaffold.\n\
This may cause unexpected behaviour. Install the pinned version with:\n \
cargo install --git https://github.com/logos-co/spel.git --tag {} spel",
stdout.trim(),
DEFAULT_SPEL.tag,
DEFAULT_SPEL.tag,
);
}
}
/// Locate the `spel` binary by walking PATH entries.
fn find_spel_on_path() -> anyhow::Result<std::path::PathBuf> {
let path_var = std::env::var_os("PATH").unwrap_or_default();
+3 -3
View File
@@ -86,7 +86,7 @@ pub(crate) fn compute_program_hashes(project: &Project) -> DynResult<BTreeMap<St
let idl_dir = project.root.join(&project.config.framework.idl.path);
let cfg_digest = config_digest(project);
// Both lez-framework and spel projects require an IDL file at deploy time.
let is_lez_framework = matches!(
let requires_idl = matches!(
project.config.framework.kind.as_str(),
FRAMEWORK_KIND_LEZ_FRAMEWORK | FRAMEWORK_KIND_SPEL
);
@@ -116,8 +116,8 @@ pub(crate) fn compute_program_hashes(project: &Project) -> DynResult<BTreeMap<St
.with_context(|| format!("read {} for hashing", idl_path.display()))?;
hasher.update(b"\x00idl\x00");
hasher.update(&idl_bytes);
} else if is_lez_framework {
// For lez-framework projects, the IDL file is a documented
} else if requires_idl {
// For spel and lez-framework projects, the IDL file is a documented
// build artifact (`<stem>.json` produced by `build idl`).
// Missing it would mean we cache a partial digest and silently
// skip deploys after later ABI-only edits. Bail loudly.
+5
View File
@@ -137,6 +137,11 @@ pub(crate) fn available_templates() -> Vec<String> {
})
.filter(|s| !s.is_empty())
.collect();
// `spel` is handled by delegating to `spel init` rather than an embedded
// template directory, so it does not appear in TEMPLATES_DIR.
if !names.contains(&"spel".to_string()) {
names.push("spel".to_string());
}
names.sort();
names
}