Skip to content
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

Migration: Add auto-automigration for merged packages #30753

Merged
merged 31 commits into from
Mar 10, 2025

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Mar 5, 2025

What I did

Added an automigration for CPC compliance.
No code should use the following packages anymore:

  • @storybook/channels
  • @storybook/client-logger
  • @storybook/core-common
  • @storybook/core-events
  • @storybook/csf-tools
  • @storybook/docs-tools
  • @storybook/node-logger
  • @storybook/preview-api
  • @storybook/router
  • @storybook/telemetry
  • @storybook/theming
  • @storybook/types
  • @storybook/manager-api
  • @storybook/manager
  • @storybook/preview
  • @storybook/core-server
  • @storybook/builder-manager
  • @storybook/components
  • @storybook/test

These have been merged into storybook-package, with these paths:

  • storybook/internal/channels
  • storybook/internal/client-logger
  • storybook/internal/common
  • storybook/internal/core-events
  • storybook/internal/csf-tools
  • storybook/internal/docs-tools
  • storybook/internal/node-logger
  • storybook/internal/preview-api
  • storybook/internal/router
  • storybook/internal/telemetry
  • storybook/internal/theming
  • storybook/internal/types
  • storybook/internal/manager-api
  • storybook/internal/manager
  • storybook/internal/preview
  • storybook/internal/core-server
  • storybook/internal/builder-manager
  • storybook/internal/components
  • storybook/test

This automigration will:

  • search for the user's files, and replace imports and require statements from old to new
  • uninstall old packages

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/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 pull request has been released as version 0.0.0-pr-30753-sha-0519e608. Try it out in a new sandbox by running npx storybook@0.0.0-pr-30753-sha-0519e608 sandbox or in an existing project with npx storybook@0.0.0-pr-30753-sha-0519e608 upgrade.

More information
Published version 0.0.0-pr-30753-sha-0519e608
Triggered by @valentinpalkovic
Repository storybookjs/storybook
Branch norbert/automigrate-cpc-complaince
Commit 0519e608
Datetime Sun Mar 9 19:10:52 UTC 2025 (1741547452)
Workflow run 13751647540

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=30753

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 79.9 MB 80 MB 59.2 kB 14.06 0.1%
initSize 79.9 MB 80 MB 59.2 kB 14.06 0.1%
diffSize 97 B 97 B 0 B - 0%
buildSize 7.47 MB 7.47 MB 0 B -0.6 0%
buildSbAddonsSize 1.98 MB 1.98 MB 0 B 0.9 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.88 MB 1.88 MB 0 B - 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.06 MB 4.06 MB 0 B 0.9 0%
buildPreviewSize 3.42 MB 3.42 MB 0 B -2.89 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 11.5s 25.4s 13.8s 1.14 54.6%
generateTime 20.2s 19.7s -502ms 0.15 -2.5%
initTime 4.9s 4.7s -249ms -0.02 -5.3%
buildTime 9.1s 9s -122ms -0.37 -1.3%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 4.6s 4.9s 294ms -0.33 6%
devManagerResponsive 4.4s 4.7s 282ms -0.31 6%
devManagerHeaderVisible 782ms 780ms -2ms -0.28 -0.3%
devManagerIndexVisible 793ms 794ms 1ms -0.41 0.1%
devStoryVisibleUncached 2.7s 2.3s -345ms -0.83 -14.5%
devStoryVisible 1.2s 1.2s 31ms -0.2 2.5%
devAutodocsVisible 1.1s 1.2s 108ms 0.48 8.8%
devMDXVisible 1.1s 1s -59ms -0.72 -5.5%
buildManagerHeaderVisible 880ms 919ms 39ms 0.46 4.2%
buildManagerIndexVisible 885ms 964ms 79ms 0.68 8.2%
buildStoryVisible 869ms 911ms 42ms 0.48 4.6%
buildAutodocsVisible 618ms 689ms 71ms -0.76 10.3%
buildMDXVisible 666ms 677ms 11ms -0.77 1.6%

Greptile Summary

Implements an automigration to consolidate multiple Storybook packages into the main storybook package, updating import paths and removing deprecated package dependencies for CPC compliance.

  • Added code/lib/cli-storybook/src/automigrate/fixes/consolidated-imports.ts to handle package.json updates and import path transformations
  • Added code/lib/cli-storybook/src/automigrate/helpers/consolidated-packages.ts defining mappings for 19 packages to their new internal paths
  • Added comprehensive test suite in consolidated-imports.test.ts covering package detection, transformation, and error handling
  • Modified code/lib/cli-storybook/src/automigrate/fixes/index.ts to include the new consolidatedImports fix

Copy link

nx-cloud bot commented Mar 5, 2025

View your CI Pipeline Execution ↗ for commit c657af9.

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 53s View ↗

☁️ Nx Cloud last updated this comment at 2025-03-10 06:59:06 UTC

Copy link

nx-cloud bot commented Mar 5, 2025

View your CI Pipeline Execution ↗ for commit 557c3f0.

Command Status Duration Result
nx run-many -t build -c production --parallel=3 ✅ Succeeded 12s View ↗

☁️ Nx Cloud last updated this comment at 2025-03-05 11:48:57 UTC

@storybook-pr-benchmarking
Copy link

storybook-pr-benchmarking bot commented Mar 5, 2025

Package Benchmarks

Commit: c657af9, ran on 10 March 2025 at 07:02:42 UTC

No significant changes detected, all good. 👏

This commit introduces a new automigration fix to handle consolidated Storybook packages in package.json files. The implementation includes:

- A check to identify package.json files with consolidated packages
- Transformation logic to remove consolidated packages
- Adding the main Storybook package to devDependencies
- Comprehensive test coverage for the new feature
This commit merges and refactors the consolidated imports and package.json migration fixes into a single, more comprehensive automigration solution. Key changes include:

- Combine separate import and package.json transformation logic
- Improve error handling and file processing
- Update type definitions and test coverage
- Simplify the overall migration approach for consolidated Storybook packages
Clean up automigrate fixes by removing the consolidated package.json migration, which appears to have been consolidated into another fix in a previous refactoring.
Enhance the consolidated imports fix by adding gitignore support to file globbing options, which helps exclude files specified in .gitignore during migration processing.
Remove automatic addition of Storybook version to package.json devDependencies in the consolidated imports migration fix. This change simplifies the package.json transformation logic and allows more flexibility in dependency management.
Streamline the import migration logic by replacing the AST-based transformation with a simpler regex-based approach. This change:
- Reduces complexity of import and require statement replacements
- Uses direct string replacement instead of abstract syntax tree manipulation
- Maintains the core functionality of package import consolidation
Enhance the consolidated imports migration by:
- Introducing an interactive prompt to allow custom file scanning patterns
- Dynamically importing globby to reduce initial import overhead
- Providing a default glob pattern with option for user customization
Enhance the consolidated imports migration by:
- Adding automatic dependency installation after file transformations
- Conditionally running package manager install only when not in dry run mode
- Suppressing an eslint rule for error handling to improve migration robustness
Add the '@storybook/test' package to the consolidated packages mapping, extending the import consolidation support for Storybook's test utilities.
Add a descriptive comment explaining the purpose of the consolidated packages object, which maps old Storybook package names to their new internal package names.
ndelangen and others added 3 commits March 6, 2025 14:00
Update the consolidated imports transformation to use dynamic import for p-limit, reducing initial import overhead and improving module loading flexibility.
Simplify the BaseFix type by removing the optional dependencies field, which appears to be no longer used in the automigrate system.
…rts.ts

Co-authored-by: Valentin Palkovic <valentin@chromatic.com>
@ndelangen ndelangen marked this pull request as ready for review March 6, 2025 13:37
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

ndelangen and others added 2 commits March 6, 2025 16:03
…9.0.0

Update MIGRATION.md to detail package consolidation and import changes for Storybook 9.0.0, including:
- List of packages moved to internal paths
- Instructions for package uninstallation and import updates
- Guidance for addon authors on internal package usage
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Comment on lines +6 to +24
'@storybook/channels': 'storybook/internal/channels',
'@storybook/client-logger': 'storybook/internal/client-logger',
'@storybook/core-common': 'storybook/internal/common',
'@storybook/core-events': 'storybook/internal/core-events',
'@storybook/csf-tools': 'storybook/internal/csf-tools',
'@storybook/docs-tools': 'storybook/internal/docs-tools',
'@storybook/node-logger': 'storybook/internal/node-logger',
'@storybook/preview-api': 'storybook/internal/preview-api',
'@storybook/router': 'storybook/internal/router',
'@storybook/telemetry': 'storybook/internal/telemetry',
'@storybook/theming': 'storybook/internal/theming',
'@storybook/types': 'storybook/internal/types',
'@storybook/manager-api': 'storybook/internal/manager-api',
'@storybook/manager': 'storybook/internal/manager',
'@storybook/preview': 'storybook/internal/preview',
'@storybook/core-server': 'storybook/internal/core-server',
'@storybook/builder-manager': 'storybook/internal/builder-manager',
'@storybook/components': 'storybook/internal/components',
'@storybook/test': 'storybook/test',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'@storybook/channels': 'storybook/internal/channels',
'@storybook/client-logger': 'storybook/internal/client-logger',
'@storybook/core-common': 'storybook/internal/common',
'@storybook/core-events': 'storybook/internal/core-events',
'@storybook/csf-tools': 'storybook/internal/csf-tools',
'@storybook/docs-tools': 'storybook/internal/docs-tools',
'@storybook/node-logger': 'storybook/internal/node-logger',
'@storybook/preview-api': 'storybook/internal/preview-api',
'@storybook/router': 'storybook/internal/router',
'@storybook/telemetry': 'storybook/internal/telemetry',
'@storybook/theming': 'storybook/internal/theming',
'@storybook/types': 'storybook/internal/types',
'@storybook/manager-api': 'storybook/internal/manager-api',
'@storybook/manager': 'storybook/internal/manager',
'@storybook/preview': 'storybook/internal/preview',
'@storybook/core-server': 'storybook/internal/core-server',
'@storybook/builder-manager': 'storybook/internal/builder-manager',
'@storybook/components': 'storybook/internal/components',
'@storybook/test': 'storybook/test',
'@storybook/channels': 'storybook/internal/channels',
'@storybook/client-logger': 'storybook/internal/client-logger',
'@storybook/core-common': 'storybook/internal/common',
'@storybook/core-events': 'storybook/internal/core-events',
'@storybook/csf-tools': 'storybook/internal/csf-tools',
'@storybook/docs-tools': 'storybook/internal/docs-tools',
'@storybook/node-logger': 'storybook/internal/node-logger',
'@storybook/preview-api': 'storybook/preview-api',
'@storybook/router': 'storybook/internal/router',
'@storybook/telemetry': 'storybook/internal/telemetry',
'@storybook/theming': 'storybook/theming',
'@storybook/types': 'storybook/internal/types',
'@storybook/manager-api': 'storybook/manager-api',
'@storybook/manager': 'storybook/internal/manager',
'@storybook/preview': 'storybook/internal/preview',
'@storybook/core-server': 'storybook/internal/core-server',
'@storybook/builder-manager': 'storybook/internal/builder-manager',
'@storybook/components': 'storybook/internal/components',
'@storybook/test': 'storybook/test',

valentinpalkovic and others added 2 commits March 9, 2025 20:11
Co-authored-by: Norbert de Langen <ndelangen@me.com>
Migration: Document dropped support legacy packages
@valentinpalkovic valentinpalkovic merged commit 24207c2 into next Mar 10, 2025
53 of 57 checks passed
@valentinpalkovic valentinpalkovic deleted the norbert/automigrate-cpc-complaince branch March 10, 2025 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants