Fix CLI completion install errors and Homebrew tap detection#1487
Fix CLI completion install errors and Homebrew tap detection#1487ChiragAgg5k merged 1 commit intomasterfrom
Conversation
* Wrap the `completion install` action in a try/catch so filesystem errors (e.g. EACCES on `~/.zfunc`) print a friendly message and set a non-zero exit code instead of crashing with a raw stack trace. * Broaden `getInstalledHomebrewFormula` to match any installed formula whose tail segment is the executable name. Without this, users who installed via a non-official tap (e.g. `homebrew/core/appwrite`) fell back to the official tap formula and `brew upgrade` failed with "formula not installed".
Greptile SummaryThis PR applies two targeted fixes to the CLI SDK templates: a try/catch around Confidence Score: 5/5Safe to merge — both changes are narrow bug fixes with no regressions introduced. No P0 or P1 issues found. The try/catch in completions.ts correctly uses No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "Fix CLI completion install errors and Ho..." | Re-trigger Greptile |
Addresses two findings from the Greptile review on appwrite/sdk-for-cli#304.
What's Changed
templates/cli/lib/completions.ts: Wrap thecompletion installaction handler in a try/catch.installCompletioncallsfs.mkdirSyncandfs.writeFileSyncsynchronously, so anEACCESon~/.zfunc(or any other filesystem error) used to crash the process with a raw stack trace. We now printFailed to install <shell> completion: <message>to stderr and exit with a non-zero code.templates/cli/lib/utils.ts: BroadengetInstalledHomebrewFormulaso users who installed via a non-official tap (e.g.homebrew/core/appwrite, or a personal tap whose formula tail isappwrite) are detected correctly. Previously the lookup only matchedappwrite/appwrite/appwriteand the bare nameappwrite; anything else fell through to the official tap formula, and the subsequentbrew upgrade appwrite/appwrite/appwritewould fail with "formula not installed". The official tap is still preferred when it's installed; the recommendation hint to switch to the official tap continues to fire as before.Verification
examples/cli/viaphp example.php cli— both fixes are reflected in the regeneratedexamples/cli/lib/completions.tsandexamples/cli/lib/utils.ts.getFiles()changes required.Follow-up
After merge, cut a new sdk-generator release and regenerate
appwrite/sdk-for-cliso 19.2.0 ships with these fixes.