-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Addon-vitest: Fix adding with --skip-install failing missing packageJson invariant
#31720
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
Conversation
|
View your CI Pipeline Execution ↗ for commit 24fbaa4.
☁️ Nx Cloud last updated this comment at |
--skip-install failing missing packageJson invariant
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.
Pull Request Overview
This PR addresses a bug where running packageManager.addDependencies() with --skip-install failed due to a missing packageJson parameter.
- Enforces that packageJson is passed when skipInstall is true via a union type in addDependencies.
- Updates the postinstall script for addon-vitest to supply the packageJson by invoking readPackageJson().
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| code/core/src/common/js-package-manager/JsPackageManager.ts | Refactored addDependencies signature to enforce packageJson with skipInstall. |
| code/addons/vitest/src/postinstall.ts | Updated addDependencies call to include packageJson read from the file system. |
Comments suppressed due to low confidence (1)
code/core/src/common/js-package-manager/JsPackageManager.ts:256
- [nitpick] Since the new union type in the method signature guarantees that packageJson is provided when skipInstall is true, consider removing the redundant runtime invariant check for packageJson or adding a comment explaining its necessity for extra safety.
invariant(packageJson, 'Missing packageJson.');
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.
LGTM
3 files reviewed, no comments
Edit PR Review Bot Settings | Greptile
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 49 | 49 | 0 |
| Self size | 31.22 MB | 31.40 MB | 🚨 +185 KB 🚨 |
| Dependency size | 17.41 MB | 17.41 MB | 0 B |
| Bundle Size Analyzer | Link | Link |
sb
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 50 | 50 | 0 |
| Self size | 1 KB | 1 KB | 0 B |
| Dependency size | 48.63 MB | 48.81 MB | 🚨 +185 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 324 | 324 | 0 |
| Self size | 244 KB | 244 KB | 🚨 +188 B 🚨 |
| Dependency size | 98.82 MB | 97.90 MB | 🎉 -921 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 267 | 267 | 0 |
| Self size | 31 KB | 31 KB | 0 B |
| Dependency size | 82.11 MB | 82.29 MB | 🚨 +185 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 1 | 1 | 0 |
| Self size | 12.13 MB | 11.02 MB | 🎉 -1.11 MB 🎉 |
| Dependency size | 98 KB | 98 KB | 0 B |
| Bundle Size Analyzer | Link | Link |
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.
LGTM
3 files reviewed, no comments
Edit PR Review Bot Settings | Greptile
…pinstall Addon-vitest: Fix adding with `--skip-install` failing missing packageJson invariant (cherry picked from commit 505b08f)
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.
LGTM
3 files reviewed, no comments
Edit PR Review Bot Settings | Greptile
What I did
Follow-up to #31605
This fixes a bug, that running
packageManager.addDependencies()withskipInstall: truerequired that you also passpackageJson, which the postinstall script from addon-vitest did not.An alternative solution would be that
JsPackageManageritself read the package.json (this.readPackageJson()) if it was not passed, but it was unclear to me whether that would work in all instances or not.This bug is currently blocking the installation of addon-vitest with the
sv(Svelte) CLI because that always runs with--skip-install.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
node_modules,package-lock.json, withoutvitestinstalled and without the addon installed, runnpx storybook@latest add @storybook/addon-vitest --skip-installnpx [email protected] add @storybook/addon-vitest --skip-installDocumentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH 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.tsMake 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-31720-sha-0f081578. Try it out in a new sandbox by runningnpx [email protected] sandboxor in an existing project withnpx [email protected] upgrade.More information
0.0.0-pr-31720-sha-0f081578jeppe/fix-addon-vitest-skipinstall0f0815781749545268)To request a new release of this pull request, mention the
@storybookjs/coreteam.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=31720Greptile Summary
Fixes a critical bug in
@storybook/addon-vitestwhere installation fails with--skip-installflag due to missingpackageJsonrequirement.code/addons/vitest/src/postinstall.tsto explicitly include requiredpackageJsonparameter inaddDependenciescallsJsPackageManager.tsto enforcepackageJsonparameter whenskipInstall: true--skip-install