-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
base: next
Are you sure you want to change the base?
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 c458370.
☁️ Nx Cloud last updated this comment at |
@@ -57,10 +57,10 @@ export const computeStorybookMetadata = async ({ | |||
mainConfig?: StorybookConfig & Record<string, any>; | |||
configDir: string; | |||
}): Promise<StorybookMetadata> => { | |||
const settings = await globalSettings(); | |||
const settings = process.env.CI === 'true' ? undefined : await globalSettings(); |
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.
Seeing several different usages of process.env.CI
in the codebase. This one seems like the safest to me:
inCI: Boolean(process.env.CI), |
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.
Boolean('false')
returns true
, seems pretty bad to me.
Ie. CI=false storybook dev
would make that thing become true
.
Although process.env.CI === 'true'
wouldn't support CI=1
, but I'm not sure how many use that.
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.
Should we use this
storybook/code/core/src/core-server/presets/common-preset.ts
Lines 173 to 188 in c2d246c
const optionalEnvToBoolean = (input: string | undefined): boolean | undefined => { | |
if (input === undefined) { | |
return undefined; | |
} | |
if (input.toUpperCase() === 'FALSE') { | |
return false; | |
} | |
if (input.toUpperCase() === 'TRUE') { | |
return true; | |
} | |
if (typeof input === 'string') { | |
return true; | |
} | |
return undefined; | |
}; | |
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.
Slight detour but can we also fix that across the codebase? If Boolean('false')
returns true
that's a bug. And there's a ton of other places that just refer to process.env.CI
directly.
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.
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 | 49 | 49 | 0 |
Self size | 31.87 MB | 31.90 MB | 🚨 +30 KB 🚨 |
Dependency size | 17.41 MB | 17.41 MB | 0 B |
Bundle Size Analyzer | Link | Link |
@storybook/nextjs
Before | After | Difference | |
---|---|---|---|
Dependency count | 531 | 531 | 0 |
Self size | 902 KB | 217 KB | 🎉 -686 KB 🎉 |
Dependency size | 58.92 MB | 58.92 MB | 🎉 -172 B 🎉 |
Bundle Size Analyzer | Link | Link |
@storybook/nextjs-vite
Before | After | Difference | |
---|---|---|---|
Dependency count | 131 | 131 | 0 |
Self size | 3.07 MB | 2.39 MB | 🎉 -685 KB 🎉 |
Dependency size | 22.30 MB | 22.30 MB | 🎉 -500 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 | 49.27 MB | 49.30 MB | 🚨 +30 KB 🚨 |
Bundle Size Analyzer | Link | Link |
@storybook/cli
Before | After | Difference | |
---|---|---|---|
Dependency count | 216 | 216 | 0 |
Self size | 582 KB | 582 KB | 🎉 -39 B 🎉 |
Dependency size | 94.59 MB | 94.64 MB | 🚨 +47 KB 🚨 |
Bundle Size Analyzer | Link | Link |
@storybook/codemod
Before | After | Difference | |
---|---|---|---|
Dependency count | 185 | 185 | 0 |
Self size | 31 KB | 31 KB | 0 B |
Dependency size | 78.72 MB | 78.75 MB | 🚨 +30 KB 🚨 |
Bundle Size Analyzer | Link | Link |
create-storybook
Before | After | Difference | |
---|---|---|---|
Dependency count | 1 | 1 | 0 |
Self size | 12.47 MB | 12.49 MB | 🚨 +16 KB 🚨 |
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.
I have a couple questions but looks good otherwise, good improvement.
if (input.toUpperCase() === 'TRUE' || input === '1') { | ||
return true; | ||
} |
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.
This is redundant right.. do we think it's better for brevity? Should this function be unit tested?
* Doing Boolean(process.env.CI) or !process.env.CI is not enough, because users might set CI=false | ||
* or CI=0, which would be truthy, and thus return true in those cases. | ||
*/ | ||
export const isCI = optionalEnvToBoolean(process.env.CI); |
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.
Is it OK for this file to read process.env
? It's never used in a scenario where one of those might be undefined?
Closes #31709
What I did
isCI
that 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: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
Modified global settings handling to prevent failures in read-only environments like CI systems by replacing error throwing with warning logs.
SavingGlobalSettingsFileError
fromcode/core/src/server-errors.ts
code/core/src/telemetry/storybook-metadata.ts
code/core/src/cli/globalSettings.ts
to log warnings instead of throwing errors on save failurescode/core/src/cli/globalSettings.test.ts
to verify new warning behavior