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

fix(storybook): update version check #27278

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

abcdmku
Copy link
Contributor

@abcdmku abcdmku commented Aug 2, 2024

Previously the check would see if the version of storybook is less than 7 and would throw an error. This causes an issue when testing canary releases of storybook since they are labeled 0.0.0-[pr-info...]

Update pleaseUpgrade text

One of the checks is to see if storybook is less than 7. The text is updated so it matches for the very unlikely scenario that someone with version 5 or lower runs this plugin.

Current Behavior

The storybook plugin throws and error if the storybook version is less than 7.

const storybook7 = storybookMajorVersion() >= 7;
if (!storybook7) {
  throw pleaseUpgrade();
}

When testing a canary release for storybook the version is 0.0.0-[pr info] so when spinning up storybook it will display:

> nx run component-lib:storybook

 NX   

    Storybook 6 is no longer maintained, and not supported in Nx. 
    Please upgrade to Storybook 7.

    Here is a guide on how to upgrade:
    https://nx.dev/nx-api/storybook/generators/migrate-7

Expected Behavior

Storybook spins up when running a canary release. Modifying the version check to not include v0 solves the problem:

const sbVersion = storybookMajorVersion();
const sbLessThan7 = sbVersion < 7 && sbVersion > 0;

if (sbLessThan7) {
  throw pleaseUpgrade();
}

then running Storybook with that modification:

╭──────────────────────────────────────────────────────────────────────╮
│                                                                      │
│   Storybook 0.0.0-pr-28752-sha-a65743e5 for react-webpack5 started   │
│   307 ms for manager and 7.73 s for preview                          │
│                                                                      │
│    Local:            http://localhost:4402/                          │
│    On your network:  http://192.168.4.41:4402/                       │
│                                                                      │
╰──────────────────────────────────────────────────────────────────────╯

Related Issue(s)

Fixes #27277

@abcdmku abcdmku requested a review from a team as a code owner August 2, 2024 16:32
@abcdmku abcdmku requested a review from Coly010 August 2, 2024 16:32
Copy link

vercel bot commented Aug 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Aug 2, 2024 4:42pm

Previously the check would see if the version of storybook is less than 7 and would throw an error. This causes an issue when testing canary releases of storybook since they are labeled 0.0.0-[pr-info...]

Update pleaseUpgrade text

One of the checks is to see if storybook is less than 7. The text is updated so it matches for the very unlikely scenario that someone with version 5 and lower runs this plugin.
@Coly010 Coly010 merged commit 3c2c462 into nrwl:master Aug 12, 2024
6 checks passed
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nx Storybook plugin falsely throws upgrade error when testing canary release
2 participants