| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
📝 Walkthrough
WalkthroughThe sg launchers now emit deprecation warnings before delegating to ast-grep. npm platform packages publish both binaries, postinstall installs both, and CLI tests verify the warning. Changessg deprecation and distribution
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: copilot Poem 🚥 Pre-merge checks | ✅ 4 | ❌ 1 ❌ Failed checks (1 warning)
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. ❤️ ShareComment @coderabbitai help to get the list of available commands. |
Sorry, something went wrong.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #2843 +/- ##
==========================================
+ Coverage 86.39% 86.43% +0.04%
==========================================
Files 126 126
Lines 22832 22836 +4
==========================================
+ Hits 19726 19739 +13
+ Misses 3106 3097 -9 ☔ View full report in Codecov by Harness.
|
Sorry, something went wrong.
There was a problem hiding this comment.
This PR deprecates the sg command by emitting a prominent warning on every invocation and directing users to ast-grep, across Rust binaries and npm-distributed shims/binaries.
Changes:
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file| File | Description |
|---|---|
| npm/sg | Prints a deprecation warning to stderr before delegating to ast-grep. |
| npm/postinstall.js | Installs both ast-grep and sg binaries into the npm package during postinstall. |
| npm/platforms/win32-x64-msvc/package.json | Ships sg.exe alongside ast-grep.exe for this platform package. |
| npm/platforms/win32-ia32-msvc/package.json | Ships sg.exe alongside ast-grep.exe for this platform package. |
| npm/platforms/win32-arm64-msvc/package.json | Ships sg.exe alongside ast-grep.exe for this platform package. |
| npm/platforms/linux-x64-gnu/package.json | Ships sg alongside ast-grep for this platform package. |
| npm/platforms/linux-arm64-gnu/package.json | Ships sg alongside ast-grep for this platform package. |
| npm/platforms/darwin-x64/package.json | Ships sg alongside ast-grep for this platform package. |
| npm/platforms/darwin-arm64/package.json | Ships sg alongside ast-grep for this platform package. |
| crates/cli/tests/help_test.rs | Adds an integration test asserting sg prints the deprecation warning to stderr. |
| crates/cli/src/bin/alias.rs | Prints a deprecation warning when sg is invoked (Windows runs full CLI; Unix forwards). |
crates/cli/src/bin/alias.rs:28
Prefer resolving a sibling ast-grep next to the current sg executable (and fall back to PATH search if it’s not found).
print_deprecation_warning();
let mut child = Command::new("ast-grep")
.args(args().skip(1))
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
Sorry, something went wrong.
There was a problem hiding this comment.
npm/postinstall.js (1)🤖 Prompt for all review comments with AI agents54-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Swallowed errors hinder install failure diagnosis.
Both installBinary's fallback and main's catch discard the underlying error (catch (_)), so if both linkSync and copyFileSync fail, users only see a generic message with no indication of which binary failed or why (permissions, missing source, disk full, etc.).
♻️ Proposed fix to surface the underlying errorfunction installBinary(src, dest) { try { fs.linkSync(src, dest); - } catch (_) { - fs.copyFileSync(src, dest); + } catch (_) { + fs.copyFileSync(src, dest); } } ... try { installBinary(src, destBin); installBinary(srcAlt, destAlt); - } catch (_) { - console.error("Failed to move `@ast-grep/cli` binaries into place."); + } catch (err) { + console.error("Failed to move `@ast-grep/cli` binaries into place.", err); process.exit(1); }Also applies to: 74-80
🤖 Prompt for AI AgentsVerify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@npm/postinstall.js` around lines 54 - 61, Update installBinary and main error handling to preserve and surface the original errors instead of discarding them with catch (_). When linkSync fails, retain its error and include it alongside any copyFileSync failure; ensure main’s failure message identifies the affected binary and includes the underlying error details.
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Nitpick comments: In `@npm/postinstall.js`: - Around line 54-61: Update installBinary and main error handling to preserve and surface the original errors instead of discarding them with catch (_). When linkSync fails, retain its error and include it alongside any copyFileSync failure; ensure main’s failure message identifies the affected binary and includes the underlying error details.
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d9b0283e-b308-4b75-ad2e-dbd74724a322
📥 CommitsReviewing files that changed from the base of the PR and between 64d2a26 and c889def.
📒 Files selected for processing (11)
Sorry, something went wrong.
ast-grep 0.45.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>- feat: deprecate the sg command [`#2843`](ast-grep/ast-grep#2843) - fix: avoid Defender false positive for Windows sg [`#2842`](ast-grep/ast-grep#2842) - chore(deps): update dependency @napi-rs/cli to v3.7.4 [`#2834`](ast-grep/ast-grep#2834) - chore(deps): update dependency oxlint to v1.75.0 [`#2838`](ast-grep/ast-grep#2838) - chore(deps): update actions/setup-node action to v7 [`#2810`](ast-grep/ast-grep#2810) - chore(deps): update actions/setup-python action to v7 [`#2829`](ast-grep/ast-grep#2829) - fix: specify correct MSRV in Cargo.toml [`#2837`](ast-grep/ast-grep#2837) - Revert "chore(deps): update dependency typescript to v7 (#2795)" [`#2831`](ast-grep/ast-grep#2831) - chore(deps): update astral-sh/setup-uv action to v8.3.2 [`#2790`](ast-grep/ast-grep#2790) - chore(deps): update dependency typescript to v7 [`#2795`](ast-grep/ast-grep#2795) - chore(deps): update rust crate thiserror to v2.0.19 [`#2819`](ast-grep/ast-grep#2819) - chore(deps): update dependency @napi-rs/cli to v3.7.3 [`#2801`](ast-grep/ast-grep#2801) - chore(deps): update dependency web-tree-sitter to v0.26.11 [`#2802`](ast-grep/ast-grep#2802) - chore(deps): update rust crate target-triple to v1.0.1 [`#2817`](ast-grep/ast-grep#2817) - chore(deps): update dependency oxlint to v1.74.0 [`#2809`](ast-grep/ast-grep#2809) - chore(deps): update dependency dprint to v0.55.2 [`#2808`](ast-grep/ast-grep#2808) - chore(deps): update dependency @ast-grep/napi to v0.44.1 [`#2789`](ast-grep/ast-grep#2789) - chore(deps): update dependency oxlint to v1.73.0 [`#2793`](ast-grep/ast-grep#2793) - chore(deps): update dependency @types/node to v24.13.3 [`#2794`](ast-grep/ast-grep#2794) - chore(deps): update rust crate bit-set to 0.11.0 [`#2791`](ast-grep/ast-grep#2791) - fix: use is_extra instead of comment heuristic [`#2821`](ast-grep/ast-grep#2821) - fix: stop using ignore files outside rule_dirs [`#2803`](ast-grep/ast-grep#2803) - chore: update dependencies [`b24ca85`](ast-grep/ast-grep@b24ca85) - feat(outline): support ambient TypeScript modules [`4f75c21`](ast-grep/ast-grep@4f75c21) - chore: bump versions [`82eb291`](https://github.com/ast-grep/ast-grep/commit/82eb2916782ae5ed572813272f5845214b5aa321)</pre> <p>View the full release notes at <a href="https://github.com/ast-grep/ast-grep/releases/tag/0.45.0">https://github.com/ast-grep/ast-grep/releases/tag/0.45.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!14931
| Back | FazBrowse Home | New Git URL |
Print a prominent deprecation warning to stderr whenever sg is invoked and direct users to ast-grep. Package the real sg binary in every native npm platform package so npm installations receive the warning too, while preserving the same warning in the JavaScript fallback when lifecycle scripts do not run. Includes an integration test for the stderr warning. Checks: cargo fmt, targeted Rust integration tests, cargo check, clippy, JavaScript syntax checks, and package JSON validation.
Related to #56
Summary by CodeRabbit
New Features
Bug Fixes
Tests