fix(cli): 'autopg uninstall --help' prints usage; uninstall confirms before pm2 teardown - #148
Merged
Merged
Conversation
…before pm2 teardown
`dispatch()` in `src/cli-install.cjs` called `mod.runUninstall()` without
forwarding `args`, so `autopg uninstall --help` (or any flag) silently ran
the real uninstall and stopped a live postmaster.
- `cli-install.cjs`: forward `{ argv: args }` to `runUninstall`.
- `src/commands/uninstall.js`: parse argv first. `--help`/`-h` prints
usage and returns 0 before any pm2 call (same shape as `install
--help`); an unknown flag prints usage on stderr and returns 2.
- Confirmation gate: on a TTY prompt `This stops autopg-server/autopg-ui
under pm2 (data dir preserved). Continue? [y/N]`; `--yes`/`-y` skips
it; a non-interactive terminal without `--yes` returns 2 with a hint
instead of tearing anything down. `runUninstall` is now async (the
wrapper already resolves Promise exit codes).
- Existing non-interactive callers updated to pass `--yes`
(tests/cli/uninstall.test.js, tests/cli-install.test.js,
tests/e2e/settings-flow.test.js). No script or install.sh path invokes
`autopg uninstall`.
- README: mention the prompt and `--yes`.
Closes #146
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014DFsrEGgS79a6ELNUE38Dh
|
Warning Review limit reachedNext included review available in 56 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (6)
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
dispatch()insrc/cli-install.cjs(case 'uninstall') calledmod.runUninstall()and droppedargson the floor, soautopg uninstall --help— or any flag — ran the real uninstall:pm2 delete autopg-server autopg-ui+ supervisor record cleared. There was also no confirmation step in front of stopping the postmaster.Fix
src/cli-install.cjs: forward{ argv: args }torunUninstall.src/commands/uninstall.js:parseUninstallArgs(argv)(pure, exported) runs first.--help/-hprints usage to stdout and returns 0 before any pm2 or admin.json access — same short-circuit shape as the v2.6.1install --helpfix. An unknown flag prints usage on stderr and returns 2.stdin.isTTY && stdout.isTTY) promptsThis stops autopg-server/autopg-ui under pm2 (data dir preserved). Continue? [y/N];--yes/-y(or programmaticopts.yes) skips it; a non-interactive terminal without--yesreturns 2 with aRe-run with --yeshint and touches nothing.runUninstallis nowasync(the wrapper already resolves Promise exit codes).opts.silent/opts.configDirbehave as before.scripts/,Makefile,install.shor workflow invokesautopg uninstall. The three test call sites (tests/cli/uninstall.test.js,tests/cli-install.test.js,tests/e2e/settings-flow.test.js) now pass--yes.install --redeploydoes its own pm2 delete and is unaffected.--yes.Tests
New in
tests/cli/uninstall.test.js(9 tests, real wrapper against the stubpm2):--help→ exit 0, prints usage, pm2 call log stays empty, seededadmin.jsonuntouched;-halias;--helpwins over--yes.unknown flag (
--nuke) → exit 2, usage on stderr, no pm2 call.non-TTY without
--yes→ exit 2 with--yeshint, nopm2 delete, sentinel +admin.jsonintact.--yesruns the existing teardown;-yalias.parseUninstallArgsunit cases.bun run test: 704 pass, 3 skip, 0 fail (707 tests across 49 files) — baseline onmainwas 695 pass / 3 skip / 0 failbun run lint: cleanbun run deadcode: cleanCloses #146
🤖 Generated with Claude Code
https://claude.ai/code/session_014DFsrEGgS79a6ELNUE38Dh