-
Notifications
You must be signed in to change notification settings - Fork 3
fix(cli): runner-aware help banners + wizard reference #384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --- | ||
| '@cipherstash/cli': patch | ||
| --- | ||
|
|
||
| Make `--help` banners and the post-install "Next steps" panel show commands using the package manager the user actually invoked the CLI with, instead of always emitting `npx`. | ||
|
|
||
| A user who runs `bunx @cipherstash/cli --help` now sees: | ||
|
|
||
| ``` | ||
| Usage: bunx @cipherstash/cli <command> [options] | ||
| … | ||
| Examples: | ||
| bunx @cipherstash/cli init | ||
| bunx @cipherstash/cli auth login | ||
| bunx @cipherstash/cli db install | ||
| ``` | ||
|
|
||
| instead of `npx @cipherstash/cli …` regardless of how they invoked it. Same for `pnpm dlx`, `yarn dlx`, and the default `npx` path. | ||
|
|
||
| Concretely: | ||
|
|
||
| - `--help` (top-level) — usage line and all six examples in `bin/stash.ts`. | ||
| - `--help` (auth) — usage line and the two `auth login` examples in `commands/auth/index.ts`. | ||
| - `db install`'s "Next steps" note — the `wizard` invocation now matches the user's runner. | ||
| - The `@cipherstash/stack is required for this command` hint shown by `requireStack` (when `db push`/`validate`/`schema build` are run before the runtime SDK is installed) now suggests the package manager's install command and the user's runner for the follow-up `init` invocation. | ||
|
|
||
| No public-API change. Detection sources unchanged from #379: `npm_config_user_agent` first, then lockfile, then `npx` fallback. | ||
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { render } from '../helpers/pty.js' | ||
|
|
||
| /** | ||
| * E2E coverage for the runner-aware help rendering. The smoke suite | ||
| * already verifies the help is rendered; this file specifically asserts | ||
| * that the correct package-manager runner (`npx` / `bunx` / `pnpm dlx` / | ||
| * `yarn dlx`) flows from `npm_config_user_agent` through | ||
| * `detectPackageManager` → `runnerCommand` into the Usage line and | ||
| * Examples. | ||
| * | ||
| * Detection itself is unit-tested in | ||
| * `src/commands/init/__tests__/utils.test.ts`. These E2E tests close the | ||
| * gap between "the helper works in isolation" and "the rendered HELP | ||
| * actually surfaces what the helper produces". | ||
| */ | ||
|
|
||
| const cases = [ | ||
| { ua: '', label: 'npx' }, // empty UA — falls back to lockfile/npm | ||
| { ua: 'bun/1.0.0', label: 'bunx' }, | ||
|
coderdan marked this conversation as resolved.
|
||
| { ua: 'pnpm/9.0.0', label: 'pnpm dlx' }, | ||
| { ua: 'yarn/4.0.0', label: 'yarn dlx' }, | ||
| ] as const | ||
|
|
||
| describe('--help — runner-aware Usage + Examples', () => { | ||
| it.each(cases)( | ||
| 'with npm_config_user_agent=$ua, renders "$label stash"', | ||
| async ({ ua, label }) => { | ||
| const r = render(['--help'], { env: { npm_config_user_agent: ua } }) | ||
| const { exitCode } = await r.exit | ||
| expect(exitCode).toBe(0) | ||
| // Usage line must use the right runner. The leader is stable | ||
| // (`messages.cli.usagePrefix === 'Usage: '`) so we assert on the | ||
| // suffix the renderer composes at runtime. | ||
| expect(r.output).toContain(`Usage: ${label} stash`) | ||
| // At least one of the Examples lines must surface the same runner. | ||
| expect(r.output).toContain(`${label} stash init`) | ||
| expect(r.output).toContain(`${label} stash db install`) | ||
| }, | ||
| ) | ||
| }) | ||
|
|
||
| describe('auth — runner-aware Usage + Examples', () => { | ||
| it.each(cases)( | ||
| 'with npm_config_user_agent=$ua, renders "$label stash auth"', | ||
| async ({ ua, label }) => { | ||
| // `auth` with no subcommand prints the auth HELP and exits 0. | ||
| const r = render(['auth'], { env: { npm_config_user_agent: ua } }) | ||
| const { exitCode } = await r.exit | ||
| expect(exitCode).toBe(0) | ||
| expect(r.output).toContain(`Usage: ${label} stash auth`) | ||
| expect(r.output).toContain(`${label} stash auth login`) | ||
| }, | ||
| ) | ||
| }) | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.