From 24f72ed993a66f857ca0f2f568a50bffd61511bb Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Mon, 15 Jan 2024 12:56:09 +0100 Subject: [PATCH] fix the call to init in the cwd & ignore if next tag is missing --- code/lib/cli/src/sandbox.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/lib/cli/src/sandbox.ts b/code/lib/cli/src/sandbox.ts index 0d8003e07bac..2f0a8859a646 100644 --- a/code/lib/cli/src/sandbox.ts +++ b/code/lib/cli/src/sandbox.ts @@ -41,7 +41,10 @@ export const sandbox = async ( force: pkgMgr, }); const latestVersion = await packageManager.latestVersion('@storybook/cli'); - const nextVersion = await packageManager.latestVersion('@storybook/cli@next'); + // In verdaccio we often only have the latest tag, so this will fail. + const nextVersion = await packageManager + .latestVersion('@storybook/cli@next') + .catch((e) => '0.0.0'); const currentVersion = versions['@storybook/cli']; const isPrerelease = prerelease(currentVersion); const isOutdated = lt(currentVersion, isPrerelease ? nextVersion : latestVersion); @@ -215,12 +218,15 @@ export const sandbox = async ( // we warned the user the sandbox step would take longer if ((isOutdated || isPrerelease) && init) { // we run doInitiate, instead of initiate, to avoid sending this init event to telemetry, because it's not a real world project + const before = process.cwd(); + process.chdir(templateDestination); await doInitiate( { ...options, }, pkg ); + process.chdir(before); } } catch (err) { logger.error(`🚨 Failed to download sandbox template: ${err.message}`);