-
Notifications
You must be signed in to change notification settings - Fork 161
feat: add customizable spinner cancel and error messages #278
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 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2dc2d06
feat: add customizable spinner cancel and error messages
dreyfus92 24c4e34
fix: linting issues
dreyfus92 42428f0
apply suggestions from @43081j's review
dreyfus92 b38af30
test: use snapshots for spinner cancel message tests
dreyfus92 659a09f
Apply suggestion's from @natemoo-re's review
dreyfus92 893f34f
update: changeset's description
dreyfus92 5b7128a
refactor: replace manual process event handling with spies in spinner…
dreyfus92 10441df
chore: run format
43081j 37f6046
test: mock process events
43081j 84d0257
refactor: use core settings directly in spinner implementation for co…
dreyfus92 3ee19fa
refactor: improve updateSettings type safety and undefined handling
dreyfus92 1841107
Update packages/prompts/src/index.ts
natemoo-re 5b2b75b
Merge branch 'main' into feat/improve-cancel-msgs
dreyfus92 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,32 @@ | ||
| --- | ||
| "@clack/prompts": minor | ||
| "@clack/core": minor | ||
| --- | ||
|
|
||
| Add support for customizable spinner cancel and error messages. Users can now customize these messages either per spinner instance or globally via the `updateSettings` function to support multilingual CLIs. | ||
|
|
||
| This update also improves the architecture by exposing the core settings to the prompts package, enabling more consistent default message handling across the codebase. | ||
|
|
||
| ```ts | ||
| // Per-instance customization | ||
| const spinner = prompts.spinner({ | ||
| cancelMessage: 'Operación cancelada', // "Operation cancelled" in Spanish | ||
| errorMessage: 'Se produjo un error' // "An error occurred" in Spanish | ||
| }); | ||
|
|
||
| // Global customization via updateSettings | ||
| prompts.updateSettings({ | ||
| messages: { | ||
| cancel: 'Operación cancelada', // "Operation cancelled" in Spanish | ||
| error: 'Se produjo un error' // "An error occurred" in Spanish | ||
| } | ||
| }); | ||
|
|
||
| // Settings can now be accessed directly | ||
| console.log(prompts.settings.messages.cancel); // "Operación cancelada" | ||
|
|
||
| // Direct options take priority over global settings | ||
| const spinner = prompts.spinner({ | ||
| cancelMessage: 'Cancelled', // This will be used instead of the global setting | ||
| }); | ||
| ``` | ||
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
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.