fix(cli): restore auto-open in sh1pt login — --no-browser default disables it permanently - #972
Merged
ralyodio merged 1 commit intoAug 19, 2026
Conversation
…fault on --no-browser
`.option('--no-browser', ..., false)` overrides the default Commander assigns to a
negated boolean flag. `opts.browser` therefore resolved to `false` even when the flag
was absent, so `opts.browser !== false` never held and the verification URL was never
opened. That silently disabled auto-open for every user and made `--no-browser` a no-op.
Removing the explicit default restores Commander's intended semantics:
no flag -> opts.browser === true (browser opens, as documented)
--no-browser -> opts.browser === false (browser stays closed)
Adds packages/cli/src/commands/login.test.ts covering both directions plus a guard
against the explicit default returning.
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.
Problem
sh1pt loginnever opens the verification URL, and--no-browserdoes nothing.packages/cli/src/commands/login.tsdeclares the flag like this:Commander derives a boolean option named
browserfrom--no-browserand defaults it totrue.Supplying an explicit third argument overrides that default, so
opts.browserresolves tofalseeven when the user never passed the flag. The action guard is:
With the default forced to
false, that condition never holds. Auto-open is therefore disabled forevery user, and
--no-browseris a no-op because the value was alreadyfalse.The comment above the command documents the intended behaviour ("attempts to open the URL in the
user's browser"), so this is a defect rather than a deliberate default.
Verification
Reproduced against
commander@12with the exact option declarations:opts.browser.option('--no-browser', ..., false)(current)false.option('--no-browser', ..., false)(current)--no-browserfalse.option('--no-browser', ...)(fixed)true.option('--no-browser', ...)(fixed)--no-browserfalseFix
Remove the explicit
falsedefault so Commander's negated-boolean semantics apply:The action guard is left untouched, so behaviour is unchanged for anyone who does pass
--no-browser.Test
Adds
packages/cli/src/commands/login.test.ts(vitest, matches the existingpackages/**/src/**/*.test.tspattern). It asserts both directions and guards against the explicitdefault being reintroduced.
parseOptionsis used so the command's action never runs — the testtouches no network, consistent with the 5s contract-test timeout in
vitest.config.ts.Scope
One-line source change plus a focused test. No dependency, build, or public API changes.
Separate issue noticed while verifying (happy to send a follow-up PR)
The three published packages —
@profullstack/sh1pt,-core,-policy— declare noenginesfield, but the CLI relies on global
fetch(login.ts,build.ts,cloud-vault.ts,core/setup-helpers.ts), which requires Node >= 18.mise.tomlpins Node 22 and the workflows run22 (threatcrush uses 20). A user on Node 16 installs successfully and then hits
ReferenceError: fetch is not definedat runtime instead of an install-time engine warning.Adding
"engines": { "node": ">=20" }(or>=22to match mise/CI exactly) would surface that atinstall time. Say the word and I will open it as its own PR.