-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Addon Test: Improve messages and post install script handling #29036
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 8170e25. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings
const fancy = | ||
process.platform !== 'win32' || process.env.CI || process.env.TERM === 'xterm-256color'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using a more descriptive variable name than 'fancy', such as 'useFancyCharacters' or 'useUnicodeSymbols'
export const printInfo = (title: string, message: string, options?: Options) => | ||
print(message, { borderColor: 'blue', title, ...options }); | ||
|
||
export const printWarning = (title: string, message: string, options?: Options) => | ||
print(message, { borderColor: 'yellow', title, ...options }); | ||
|
||
export const printError = (title: string, message: string, options?: Options) => | ||
print(message, { borderColor: 'red', title, ...options }); | ||
|
||
export const printSuccess = (title: string, message: string, options?: Options) => | ||
print(message, { borderColor: 'green', title, ...options }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: These functions are very similar. Consider using a single function with an enum parameter for the message type to reduce code duplication
code/addons/test/src/postinstall.ts
Outdated
const addonName = '@storybook/experimental-addon-vitest'; | ||
const dependencies = ['vitest', '@vitest/browser', 'playwright']; | ||
const optionalDependencies = ['@vitest/coverage-istanbul', '@vitest/coverage-v8']; | ||
const extensions = ['.js', '.jsx', '.ts', '.tsx', '.cts', '.mts', '.cjs', '.mjs']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using a constant for the addon name and dependencies to improve maintainability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the focus on UX here!
Added some suggestions to make it easier for users to follow along, feel free to ignore any of them.
…fig file exists with a 'test' property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great improvements.
One meta comment is that there are inconsistent references to the addon, as either the "the Test Addon", "the Vitest Addon", or "the Storybook Addon @storybook/experimental-addon-test".
I propose we refer to the product as "Storybook Test" which reads better. We also do this for "Storybook Docs", although that one was unfortunate because it can also refer to the project documentation.
Closes #
What I did
This PR does revamps the postinstall script from addon test, improving its messages as well as error handling.
Before:
After:
1 - Successful scenario:
2 - Failure scenario with early bail (slightly outdated):
3 - Partial failure scenario (slightly outdated):
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This pull request has been released as version
0.0.0-pr-29036-sha-b6b6c248
. Try it out in a new sandbox by runningnpx [email protected] sandbox
or in an existing project withnpx [email protected] upgrade
.More information
0.0.0-pr-29036-sha-b6b6c248
cli/improve-sb-add-messages
b6b6c248
1725442762
)To request a new release of this pull request, mention the
@storybookjs/core
team.core team members can create a new canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=29036
Greptile Summary
This PR enhances the postinstall script for the Storybook Vitest addon, improving user experience with better messaging and error handling.
code/addons/test/src/postinstall-logger.ts
for improved console output with boxed messages and color-codingcode/addons/test/src/postinstall.ts
with more thorough compatibility checks and informative error messagescode/lib/cli-storybook/src/add.ts
to provide clearer instructions and better handling of already installed addonscode/addons/test/package.json
to support enhanced functionality