-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Automigration: Refactor automigration command handling and add tests #31302
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
base: next
Are you sure you want to change the base?
Conversation
- Introduced `getAutomigrateCommand` function to standardize the command generation for automigrating addons. - Updated `postinstall.ts` files for `addonA11y` and `vitest` to utilize the new command function. - Added unit tests for `getAutomigrateCommand` to ensure correct command generation. - Updated various fix definitions to include a generic key type for better type safety.
64d41c0
to
89531e8
Compare
View your CI Pipeline Execution ↗ for commit 40a56bc.
☁️ Nx Cloud last updated this comment at |
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.
22 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
export type CommandFix<ResultType = any, Key extends string = string> = { | ||
promptType: PromptType<ResultType, 'command'>; | ||
run: (options: RunOptions<ResultType>) => Promise<void>; | ||
} & Omit<BaseFix<ResultType>, 'versionRange' | 'check' | 'prompt'>; | ||
} & Omit<BaseFix<ResultType, Key>, 'versionRange' | 'check' | 'prompt'>; |
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 making Key parameter required instead of defaulting to string to enforce strict typing
code/core/src/cli/automigrate.ts
Outdated
* // ['storybook', 'automigrate', 'addon-a11y-parameters', '--yes', '--config-dir', 'config', '--package-manager', 'npm'] | ||
* ``` | ||
*/ | ||
export const getAutomigrateCommand = ( |
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.
wouldn't it be better to have an abstraction to run Storybook CLI commands instead? And force the configDir to be passed? The problem we face happens on all Storybook CLI commands essentially, including the Storybook doctor command.
I guess it begs the question too, do we need to spawn npm commands in all places that currently do that? Or can we just call the function if the import is available? I understand it might not work in a few places like when executing something from @storybook/cli as part of create-storybook, but in other places it might work?
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.
Let's give it a try!
Closes #31300
getAutomigrateCommand
function to standardize the command generation for automigrating addons.postinstall.ts
files foraddonA11y
andvitest
to utilize the new command function.getAutomigrateCommand
to ensure correct command generation.Closes #
What I did
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-storybook/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 PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>
Greptile Summary
This PR refactors automigration command handling by introducing a standardized
getAutomigrateCommand
function and updates various fix definitions with improved type safety across the Storybook codebase.code/core/src/cli/automigrate.ts
withgetAutomigrateCommand
function for standardized command generationcode/addons/a11y
andcode/addons/vitest
to use the new command functioncode/lib/cli-storybook/src/automigrate/types.ts
for better type safetycode/core/src/cli/automigrate.test.ts
for command generation