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`
(cherry picked from commit 81db91d)
  • Loading branch information
JReinhold authored and storybook-bot committed Jan 18, 2024
1 parent ed9f791 commit 04cd1a5
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 @@ -292,7 +292,8 @@ export const doUpgrade = async ({

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 04cd1a5

Please sign in to comment.