From 8f3b3b84eef04798c043eadb7cfe9b299740177d Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Thu, 7 Mar 2024 11:30:41 +0100 Subject: [PATCH] CLI: Fix doctor compatibility check --- .../src/doctor/getIncompatibleStorybookPackages.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/code/lib/cli/src/doctor/getIncompatibleStorybookPackages.ts b/code/lib/cli/src/doctor/getIncompatibleStorybookPackages.ts index d27694136074..09f0c40d5bb9 100644 --- a/code/lib/cli/src/doctor/getIncompatibleStorybookPackages.ts +++ b/code/lib/cli/src/doctor/getIncompatibleStorybookPackages.ts @@ -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 { @@ -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) ); });