From bb79636fa2168c474d1af7b1b3105ae858c17c45 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Thu, 18 Jan 2024 09:30:01 +0100 Subject: [PATCH 1/2] use @storybook/cli to detect existing version --- code/lib/telemetry/src/package-json.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/code/lib/telemetry/src/package-json.ts b/code/lib/telemetry/src/package-json.ts index 8163cc2fa167..56e6823b5920 100644 --- a/code/lib/telemetry/src/package-json.ts +++ b/code/lib/telemetry/src/package-json.ts @@ -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; }; From 688bed95863398580ec85ac4e1999c534425b2b5 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Thu, 18 Jan 2024 10:35:31 +0100 Subject: [PATCH 2/2] fallback existing version to v0.0.0 --- code/lib/cli/src/upgrade.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/lib/cli/src/upgrade.ts b/code/lib/cli/src/upgrade.ts index 29115c4244cf..e3a62bbdcd1d 100644 --- a/code/lib/cli/src/upgrade.ts +++ b/code/lib/cli/src/upgrade.ts @@ -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');