Skip to content

feat: remove login dependency on help command [XTNSNS-2080]#1270

Open
silvadenisaraujo wants to merge 3 commits into
mainfrom
feat/help-without-login
Open

feat: remove login dependency on help command [XTNSNS-2080]#1270
silvadenisaraujo wants to merge 3 commits into
mainfrom
feat/help-without-login

Conversation

@silvadenisaraujo

@silvadenisaraujo silvadenisaraujo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What

Renders help without requiring login, so agents (and users) can discover commands without credentials. Includes the spec (specs/help-without-login.md) and its implementation.

Why

src/oclif/hooks/init.ts forces an interactive login for any command not in an allowedList. Running vtex <command> --help (e.g. vtex deploy --help) triggers a login prompt even though only static help text is requested, blocking command discovery on logged-out machines.

How

  • isHelpInvocation(commandId, argv) pure helper in src/oclif/hooks/utils.ts: detects every help form — vtex help, vtex help <command>, vtex <command> --help/-h, and bare vtex --help/-h (oclif passes the bare flag as the command id itself). Args after the -- separator are ignored (documented in code), so vtex cmd -- --help is not treated as help.
  • checkLogin(command, argv) now receives argv explicitly (from options.argv in the init hook) and early-returns for help invocations. Exported for testability.
  • Defensive feature-flag fallback in showHelp: when COMMANDS_GROUP/COMMANDS_GROUP_ID are missing (fresh install — the cache is populated by a non-blocking child process), all commands render under a single default group instead of crashing on Object.keys(undefined).

Testing

  • Table-driven unit tests for isHelpInvocation (src/oclif/hooks/utils.test.ts)
  • Unit tests asserting checkLogin never calls authLogin for help argv, and still does for non-help/non-allowed commands (src/oclif/hooks/init.test.ts)
  • Shell smoke test (scripts/smoke-help.sh): runs every help form via node bin/run in an isolated HOME with no credentials and an empty feature-flag cache, asserting exit 0, help output, and no interactive login prompt — also exercising the feature-flag fallback

All help forms verified locally:

PASS [vtex help]
PASS [vtex help <command>]
PASS [vtex <command> --help]
PASS [vtex <command> -h]
PASS [vtex --help]
All help smoke tests passed

@silvadenisaraujo silvadenisaraujo added ai-assisted PR created or modified with AI assistance ai:anthropic/claude-opus-4-8 AI model: anthropic/claude-opus-4-8 labels Jun 24, 2026
@wisneycardeal wisneycardeal changed the title docs: spec for removing login dependency on help command docs: spec for removing login dependency on help command [XTNSNS-2080] Jun 25, 2026
Comment thread specs/help-without-login.md
- Wire checkLogin via explicit argv parameter for testability
- Pull the showHelp feature-flag fallback into scope (same PR)
- Add checkLogin early-return unit test and no-credentials smoke test
- Document the -- separator handling in utils.ts
Implements specs/help-without-login.md:

- Add isHelpInvocation(commandId, argv) helper in oclif/hooks/utils.ts,
  respecting the -- separator and handling bare --help/-h passed as the
  command id by oclif
- checkLogin now takes argv explicitly and early-returns for any help
  invocation (exported for testability)
- Defensive fallback in showHelp when COMMANDS_GROUP/COMMANDS_GROUP_ID
  feature flags are missing (fresh install), rendering all commands
  under a single default group instead of crashing
- Unit tests for isHelpInvocation and checkLogin early return
- Shell smoke test (scripts/smoke-help.sh) running every help form in an
  isolated HOME with no credentials and empty feature-flag cache
@silvadenisaraujo silvadenisaraujo changed the title docs: spec for removing login dependency on help command [XTNSNS-2080] feat: remove login dependency on help command [XTNSNS-2080] Jul 9, 2026

@juliobguedes juliobguedes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Test case suggestions are to check the edges of the implementation.

['deploy', ['--', '--help'], false],
['deploy', ['--', '-h'], false],
[undefined, [], false],
['link', ['--verbose'], false],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
['link', ['--verbose'], false],
['link', ['--verbose'], false],
['login', '-h'],
['login', '--help']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:anthropic/claude-opus-4-8 AI model: anthropic/claude-opus-4-8 ai-assisted PR created or modified with AI assistance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants