Skip to content

fix(cli): 'autopg uninstall --help' prints usage; uninstall confirms before pm2 teardown - #148

Merged
namastex888 merged 1 commit into
mainfrom
fix/uninstall-help-confirm
Sep 2, 2026
Merged

fix(cli): 'autopg uninstall --help' prints usage; uninstall confirms before pm2 teardown#148
namastex888 merged 1 commit into
mainfrom
fix/uninstall-help-confirm

Conversation

@automagik-genie

Copy link
Copy Markdown
Contributor

Root cause

dispatch() in src/cli-install.cjs (case 'uninstall') called mod.runUninstall() and dropped args on the floor, so autopg 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 } to runUninstall.
  • src/commands/uninstall.js:
    • parseUninstallArgs(argv) (pure, exported) runs first. --help / -h prints usage to stdout and returns 0 before any pm2 or admin.json access — same short-circuit shape as the v2.6.1 install --help fix. An unknown flag prints usage on stderr and returns 2.
    • Confirmation gate: on a TTY (stdin.isTTY && stdout.isTTY) prompts This stops autopg-server/autopg-ui under pm2 (data dir preserved). Continue? [y/N]; --yes / -y (or programmatic opts.yes) skips it; a non-interactive terminal without --yes returns 2 with a Re-run with --yes hint and touches nothing.
    • runUninstall is now async (the wrapper already resolves Promise exit codes). opts.silent / opts.configDir behave as before.
  • Callers audited: no scripts/, Makefile, install.sh or workflow invokes autopg 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 --redeploy does its own pm2 delete and is unaffected.
  • README: notes the prompt and --yes.

Tests

New in tests/cli/uninstall.test.js (9 tests, real wrapper against the stub pm2):

  • --help → exit 0, prints usage, pm2 call log stays empty, seeded admin.json untouched; -h alias; --help wins over --yes.

  • unknown flag (--nuke) → exit 2, usage on stderr, no pm2 call.

  • non-TTY without --yes → exit 2 with --yes hint, no pm2 delete, sentinel + admin.json intact.

  • --yes runs the existing teardown; -y alias.

  • parseUninstallArgs unit cases.

  • bun run test: 704 pass, 3 skip, 0 fail (707 tests across 49 files) — baseline on main was 695 pass / 3 skip / 0 fail

  • bun run lint: clean

  • bun run deadcode: clean

Closes #146

🤖 Generated with Claude Code

https://claude.ai/code/session_014DFsrEGgS79a6ELNUE38Dh

…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
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 56 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: b8bff16b-e0f5-4efc-888c-450b206dda9e

📥 Commits

Reviewing files that changed from the base of the PR and between 7e8d508 and 5d9dd4d.

📒 Files selected for processing (6)
  • README.md
  • src/cli-install.cjs
  • src/commands/uninstall.js
  • tests/cli-install.test.js
  • tests/cli/uninstall.test.js
  • tests/e2e/settings-flow.test.js

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@namastex888
namastex888 merged commit acc6d82 into main Sep 2, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'autopg uninstall --help' executes the uninstall instead of printing help

2 participants