feat: remove login dependency on help command [XTNSNS-2080]#1270
Open
silvadenisaraujo wants to merge 3 commits into
Open
feat: remove login dependency on help command [XTNSNS-2080]#1270silvadenisaraujo wants to merge 3 commits into
silvadenisaraujo wants to merge 3 commits into
Conversation
- 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
juliobguedes
approved these changes
Jul 10, 2026
juliobguedes
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Test case suggestions are to check the edges of the implementation.
| ['deploy', ['--', '--help'], false], | ||
| ['deploy', ['--', '-h'], false], | ||
| [undefined, [], false], | ||
| ['link', ['--verbose'], false], |
Contributor
There was a problem hiding this comment.
Suggested change
| ['link', ['--verbose'], false], | |
| ['link', ['--verbose'], false], | |
| ['login', '-h'], | |
| ['login', '--help'] |
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.
What
Renders
helpwithout 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.tsforces an interactive login for any command not in anallowedList. Runningvtex <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 insrc/oclif/hooks/utils.ts: detects every help form —vtex help,vtex help <command>,vtex <command> --help/-h, and barevtex --help/-h(oclif passes the bare flag as the command id itself). Args after the--separator are ignored (documented in code), sovtex cmd -- --helpis not treated as help.checkLogin(command, argv)now receives argv explicitly (fromoptions.argvin the init hook) and early-returns for help invocations. Exported for testability.showHelp: whenCOMMANDS_GROUP/COMMANDS_GROUP_IDare missing (fresh install — the cache is populated by a non-blocking child process), all commands render under a single default group instead of crashing onObject.keys(undefined).Testing
isHelpInvocation(src/oclif/hooks/utils.test.ts)checkLoginnever callsauthLoginfor help argv, and still does for non-help/non-allowed commands (src/oclif/hooks/init.test.ts)scripts/smoke-help.sh): runs every help form vianode bin/runin an isolatedHOMEwith no credentials and an empty feature-flag cache, asserting exit 0, help output, and no interactive login prompt — also exercising the feature-flag fallbackAll help forms verified locally: