feat(wasm): add pre-flight check for wasm-bindgen-cli version#3094
feat(wasm): add pre-flight check for wasm-bindgen-cli version#3094QuantumExplorer merged 1 commit intov3.1-devfrom
Conversation
📝 WalkthroughWalkthroughThe build script now includes a pre-flight version verification check that compares the installed wasm-bindgen-cli version with the required version specified in Cargo.lock, erroring if the tool is missing or a mismatch is detected. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/scripts/build-wasm.sh (1)
103-103: Consider anchoring theawkmatch to avoid edge-case false matches.The current
awkpattern relies on$to anchor the end of the line, which is correct. However, thegetline; printwill print whatever line follows — if the lockfile format ever changes (e.g., a comment or blank line between fields), this would silently extract the wrong value. A slightly more defensive approach:♻️ Optional: more robust version extraction
-REQUIRED_WB_VERSION=$(awk '/^name = "wasm-bindgen"$/{getline; print}' "$REPO_ROOT/Cargo.lock" | head -1 | sed 's/version = "//;s/"//') +REQUIRED_WB_VERSION=$(awk '/^name = "wasm-bindgen"$/{found=1; next} found && /^version = /{print; exit}' "$REPO_ROOT/Cargo.lock" | sed 's/version = "//;s/"//')This validates that the next relevant line actually starts with
version =before extracting it.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/scripts/build-wasm.sh` at line 103, The current extraction assigned to REQUIRED_WB_VERSION uses awk with '/^name = "wasm-bindgen"$/{getline; print}' which can pick up the wrong following line if the lockfile format changes; modify the awk logic used in REQUIRED_WB_VERSION so that after matching the 'name = "wasm-bindgen"' line it scans subsequent lines until it finds one that explicitly begins with 'version = ' and then extracts that value (i.e., only print when the next relevant line matches /^version = /), ensuring more robust and defensively anchored version extraction.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/scripts/build-wasm.sh`:
- Line 103: The current extraction assigned to REQUIRED_WB_VERSION uses awk with
'/^name = "wasm-bindgen"$/{getline; print}' which can pick up the wrong
following line if the lockfile format changes; modify the awk logic used in
REQUIRED_WB_VERSION so that after matching the 'name = "wasm-bindgen"' line it
scans subsequent lines until it finds one that explicitly begins with 'version =
' and then extracts that value (i.e., only print when the next relevant line
matches /^version = /), ensuring more robust and defensively anchored version
extraction.
QuantumExplorer
left a comment
There was a problem hiding this comment.
Self verified.
Issue being fixed or feature implemented
This update introduces a pre-flight check to ensure that the installed version of
wasm-bindgen-climatches the version specified in theCargo.lockfile.What was done?
build-wasm.shthat checks the installed version ofwasm-bindgen-cliagainst the required version fromCargo.lock.wasm-bindgen-cliis not installed, an error message prompts the user to install it with the correct version.How Has This Been Tested?
The script was tested by running it in an environment with both matching and mismatched versions of
wasm-bindgen-cli, as well as in an environment wherewasm-bindgen-cliis not installed.Breaking Changes
None
Checklist
For repository code-owners and collaborators only
Summary by CodeRabbit