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

CLI: Fix doctor compatibility check #26363

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions code/lib/cli/src/doctor/getIncompatibleStorybookPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ type Context = {
skipErrors?: boolean;
};

const isPackageIncompatible = (installedVersion: string, currentStorybookVersion: string) => {
const storybookVersion = semver.coerce(currentStorybookVersion);
const packageVersion = semver.coerce(installedVersion);
return storybookVersion?.major !== packageVersion?.major;
};

export const checkPackageCompatibility = async (dependency: string, context: Context) => {
const { currentStorybookVersion, skipErrors, packageManager } = context;
try {
Expand All @@ -46,12 +40,12 @@ export const checkPackageCompatibility = async (dependency: string, context: Con
...peerDependencies,
})
.filter(([dep]) => storybookCorePackages[dep as keyof typeof storybookCorePackages])
.find(([, version]) => {
.find(([_, versionRange]) => {
// prevent issues with "tag" based versions e.g. "latest" or "next" instead of actual numbers
return (
version &&
semver.validRange(version) &&
isPackageIncompatible(version, currentStorybookVersion)
versionRange &&
semver.validRange(versionRange) &&
!semver.satisfies(currentStorybookVersion, versionRange)
);
});

Expand Down
Loading