Skip to content

Commit

Permalink
Merge pull request #26363 from storybookjs/fix/doctor-compat-check
Browse files Browse the repository at this point in the history
CLI: Fix doctor compatibility check
  • Loading branch information
ndelangen authored Mar 7, 2024
2 parents b400750 + 83303b1 commit 247015e
Showing 1 changed file with 4 additions and 10 deletions.
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

0 comments on commit 247015e

Please sign in to comment.