Skip to content

Commit

Permalink
Merge pull request #25642 from storybookjs/jeppe/fix-version-detection
Browse files Browse the repository at this point in the history
CLI: Fix existing version detection in `upgrade`
  • Loading branch information
JReinhold authored Jan 18, 2024
2 parents b03191d + 688bed9 commit 81db91d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion code/lib/cli/src/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ export const doUpgrade = async ({
}: UpgradeOptions) => {
const packageManager = JsPackageManagerFactory.getPackageManager({ force: pkgMgr });

const beforeVersion = await getStorybookCoreVersion();
// If we can't determine the existing version (Yarn PnP), fallback to v0.0.0 to not block the upgrade
const beforeVersion = (await getStorybookCoreVersion()) ?? '0.0.0';
const currentVersion = versions['@storybook/cli'];
const isCanary = currentVersion.startsWith('0.0.0');

Expand Down
8 changes: 3 additions & 5 deletions code/lib/telemetry/src/package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ export const getActualPackageJson = async (packageName: string) => {
return packageJson;
};

// Note that this probably doesn't work in PNPM mode
// Note that this probably doesn't work in Yarn PNP mode because @storybook/telemetry doesn't depend on @storybook/cli
export const getStorybookCoreVersion = async () => {
const coreVersions = await Promise.all(
['@storybook/core-common', '@storybook/core-server'].map(getActualPackageVersion)
);
return coreVersions.find((v) => v.version)?.version;
const { version } = await getActualPackageVersion('@storybook/cli');
return version;
};

0 comments on commit 81db91d

Please sign in to comment.