-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
CLI: Fix throwing in readonly environments #31785
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
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
4 files reviewed, no comments
Edit PR Review Bot Settings | Greptile
|
View your CI Pipeline Execution ↗ for commit 0510d85
☁️ Nx Cloud last updated this comment at |
shilman
left a comment
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.
Looks good with one minor nit
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 51 | 51 | 0 |
| Self size | 41.75 MB | 41.36 MB | 🎉 -384 KB 🎉 |
| Dependency size | 18.13 MB | 18.13 MB | 🎉 -2 B 🎉 |
| Bundle Size Analyzer | Link | Link |
sb
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 52 | 52 | 0 |
| Self size | 1 KB | 1 KB | 🎉 -2 B 🎉 |
| Dependency size | 59.88 MB | 59.50 MB | 🎉 -384 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 220 | 220 | 0 |
| Self size | 585 KB | 585 KB | 🚨 +145 B 🚨 |
| Dependency size | 104.34 MB | 103.96 MB | 🎉 -378 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 189 | 189 | 0 |
| Self size | 31 KB | 31 KB | 🎉 -2 B 🎉 |
| Dependency size | 88.43 MB | 88.05 MB | 🎉 -384 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
tmeasday
left a comment
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.
I have a couple questions but looks good otherwise, good improvement.
|
👋 Just wanna bring this back since it was automatically closed. We do need this fix for our CI use case same as #31709 and it would be nice to have this also released to v8 as well since |
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.
19 files reviewed, 5 comments
Edit PR Review Bot Settings | Greptile
| const { hasEslint, isStorybookPluginInstalled, isFlatConfig, eslintConfigFile } = | ||
| // TODO: Investigate why packageManager type does not match on CI | ||
| await extractEslintInfo(packageManager as any); |
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: Type casting can hide potential issues. Consider fixing the packageManager type mismatch instead
| if (input.toUpperCase() === 'FALSE' || input === '0') { | ||
| return false; | ||
| } |
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.
logic: Potential issue with case sensitivity - 'FALSE' check is inconsistent (uses toUpperCase) while '0' check is case-sensitive. Consider normalizing both checks.
| if (input.toUpperCase() === 'FALSE' || input === '0') { | |
| return false; | |
| } | |
| if (input.toUpperCase() === 'FALSE' || input.toUpperCase() === '0') { | |
| return false; | |
| } |
| .action(async (options) => { | ||
| options.debug = options.debug ?? false; | ||
| options.dev = options.dev ?? (IS_NON_CI && IS_NON_STORYBOOK_SANDBOX); | ||
| options.dev = options.dev ?? (isCI && !optionalEnvToBoolean(process.env.IN_STORYBOOK_SANDBOX)); |
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.
logic: Logic error: isCI && !optionalEnvToBoolean(process.env.IN_STORYBOOK_SANDBOX) will enable dev mode in CI, which is opposite of the previous behavior (IS_NON_CI). Should be !isCI && !optionalEnvToBoolean(process.env.IN_STORYBOOK_SANDBOX)
| options.dev = options.dev ?? (isCI && !optionalEnvToBoolean(process.env.IN_STORYBOOK_SANDBOX)); | |
| options.dev = options.dev ?? (!isCI && !optionalEnvToBoolean(process.env.IN_STORYBOOK_SANDBOX)); |
| const { initiate } = await import('create-storybook'); | ||
| await initiate({ | ||
| dev: process.env.CI !== 'true' && process.env.IN_STORYBOOK_SANDBOX !== 'true', | ||
| dev: isCI && !optionalEnvToBoolean(process.env.IN_STORYBOOK_SANDBOX), |
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.
logic: The condition needs to be inverted - currently isCI && !optionalEnvToBoolean() enables dev mode when in CI, which is opposite of the intended behavior. Should be !isCI && !optionalEnvToBoolean()
| dev: isCI && !optionalEnvToBoolean(process.env.IN_STORYBOOK_SANDBOX), | |
| dev: !isCI && !optionalEnvToBoolean(process.env.IN_STORYBOOK_SANDBOX), |
| let currentPromptLibrary: PromptLibrary = optionalEnvToBoolean(process.env.USE_CLACK) | ||
| ? 'clack' | ||
| : 'prompts'; |
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: Could the default value be extracted into a constant? This would make it easier to change the default prompt library in the future if needed.
|
@JReinhold Can you take another look and maybe resolve the conflicts? |
- Changed instances of `isCI` to `isCI()` in various files to ensure consistent function usage. - Updated related logic in `postinstall-logger.ts`, `postinstall.ts`, `withTelemetry.ts`, and others to reflect this change. - Enhanced test coverage for `isCI` behavior in `storybook-metadata.test.ts`.
- Replaced direct imports of `isCI` and `logger` from internal paths with imports from centralized utility modules. - This change enhances maintainability and consistency across the codebase.
…readonly CLI: Fix throwing in readonly environments (cherry picked from commit d87db5c)
Closes #31709
What I did
isCIthat uses that.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: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 PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/coreteam 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
Improves error handling in read-only environments by replacing error throwing with warning logs and adding robust environment variable handling utilities.
isCIandoptionalEnvToBooleanincode/core/src/common/utils/envs.tsfor consistent environment detectioncode/core/src/telemetry/storybook-metadata.tsto skip global settings in CI environmentscode/lib/cli-storybook/src/bin/index.tsto use warning logs instead of throwing errors when saving fails