From d7088577800510be73d1ffb088302bde3e490e73 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 15 Mar 2024 13:52:14 +0100 Subject: [PATCH 1/4] fix https://github.com/storybookjs/storybook/issues/26478 --- .../cli/src/automigrate/helpers/getMigrationSummary.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts b/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts index 12c8ac07bfa7..c191b757316c 100644 --- a/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts +++ b/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts @@ -1,9 +1,10 @@ import chalk from 'chalk'; import boxen from 'boxen'; import dedent from 'ts-dedent'; -import type { InstallationMetadata } from '@storybook/core-common'; +import { versions, type InstallationMetadata } from '@storybook/core-common'; import type { FixSummary } from '../types'; import { FixStatus } from '../types'; +import { isPrerelease } from '../../doctor/utils'; export const messageDivider = '\n\n'; const segmentDivider = '\n\n─────────────────────────────────────────────────\n\n'; @@ -59,11 +60,15 @@ export function getMigrationSummary({ installationMetadata?: InstallationMetadata | null; logFile: string; }) { + const automigrateCommand = isPrerelease(versions.storybook) + ? 'npx storybook@next automigrate' + : 'npx storybook@latest automigrate'; + const messages = []; messages.push(getGlossaryMessages(fixSummary, fixResults, logFile).join(messageDivider)); messages.push(dedent`If you'd like to run the migrations again, you can do so by running '${chalk.cyan( - 'npx storybook@next automigrate' + automigrateCommand )}' The automigrations try to migrate common patterns in your project, but might not contain everything needed to migrate to the latest version of Storybook. From ac7943390f17fd2425f48e3d69826f52b749fc9d Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Wed, 20 Mar 2024 10:29:01 +0100 Subject: [PATCH 2/4] update npx storybook command references --- .../automigrate/helpers/getMigrationSummary.test.ts | 6 +++--- .../cli/src/automigrate/helpers/getMigrationSummary.ts | 6 +----- code/lib/cli/src/doctor/index.ts | 6 +----- code/lib/core-events/src/errors/server-errors.ts | 10 +++++----- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/code/lib/cli/src/automigrate/helpers/getMigrationSummary.test.ts b/code/lib/cli/src/automigrate/helpers/getMigrationSummary.test.ts index eb49848ab2c0..92c9c91c9f04 100644 --- a/code/lib/cli/src/automigrate/helpers/getMigrationSummary.test.ts +++ b/code/lib/cli/src/automigrate/helpers/getMigrationSummary.test.ts @@ -104,7 +104,7 @@ describe('getMigrationSummary', () => { ───────────────────────────────────────────────── - If you'd like to run the migrations again, you can do so by running 'npx storybook@next automigrate' + If you'd like to run the migrations again, you can do so by running 'npx storybook automigrate' The automigrations try to migrate common patterns in your project, but might not contain everything needed to migrate to the latest version of Storybook. @@ -124,7 +124,7 @@ describe('getMigrationSummary', () => { expect(summary).toMatchInlineSnapshot(` "No migrations were applicable to your project - If you'd like to run the migrations again, you can do so by running 'npx storybook@next automigrate' + If you'd like to run the migrations again, you can do so by running 'npx storybook automigrate' The automigrations try to migrate common patterns in your project, but might not contain everything needed to migrate to the latest version of Storybook. @@ -144,7 +144,7 @@ describe('getMigrationSummary', () => { expect(summary).toMatchInlineSnapshot(` "No migrations were applicable to your project - If you'd like to run the migrations again, you can do so by running 'npx storybook@next automigrate' + If you'd like to run the migrations again, you can do so by running 'npx storybook automigrate' The automigrations try to migrate common patterns in your project, but might not contain everything needed to migrate to the latest version of Storybook. diff --git a/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts b/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts index c191b757316c..35d135bcd4c2 100644 --- a/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts +++ b/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts @@ -60,15 +60,11 @@ export function getMigrationSummary({ installationMetadata?: InstallationMetadata | null; logFile: string; }) { - const automigrateCommand = isPrerelease(versions.storybook) - ? 'npx storybook@next automigrate' - : 'npx storybook@latest automigrate'; - const messages = []; messages.push(getGlossaryMessages(fixSummary, fixResults, logFile).join(messageDivider)); messages.push(dedent`If you'd like to run the migrations again, you can do so by running '${chalk.cyan( - automigrateCommand + 'npx storybook automigrate' )}' The automigrations try to migrate common patterns in your project, but might not contain everything needed to migrate to the latest version of Storybook. diff --git a/code/lib/cli/src/doctor/index.ts b/code/lib/cli/src/doctor/index.ts index 69884c2f6755..ff9da7118f34 100644 --- a/code/lib/cli/src/doctor/index.ts +++ b/code/lib/cli/src/doctor/index.ts @@ -141,12 +141,8 @@ export const doctor = async ({ } } - const doctorCommand = isPrerelease(storybookVersion) - ? 'npx storybook@next doctor' - : 'npx storybook@latest doctor'; - const commandMessage = `You can always recheck the health of your project by running:\n${chalk.cyan( - doctorCommand + 'npx storybook doctor' )}`; logger.info(); diff --git a/code/lib/core-events/src/errors/server-errors.ts b/code/lib/core-events/src/errors/server-errors.ts index c8eccef6eb2a..85bf7cda02c4 100644 --- a/code/lib/core-events/src/errors/server-errors.ts +++ b/code/lib/core-events/src/errors/server-errors.ts @@ -77,7 +77,7 @@ export class MissingFrameworkFieldError extends StorybookError { return dedent` Could not find a 'framework' field in Storybook config. - Please run 'npx storybook@next automigrate' to automatically fix your config. + Please run 'npx storybook automigrate' to automatically fix your config. `; } } @@ -98,7 +98,7 @@ export class InvalidFrameworkNameError extends StorybookError { return dedent` Invalid value of '${this.data.frameworkName}' in the 'framework' field of Storybook config. - Please run 'npx storybook@next automigrate' to automatically fix your config. + Please run 'npx storybook automigrate' to automatically fix your config. `; } } @@ -276,7 +276,7 @@ export class AngularLegacyBuildOptionsError extends StorybookError { Your Storybook startup script uses a solution that is not supported anymore. You must use Angular builder to have an explicit configuration on the project used in angular.json. - Please run 'npx storybook@next automigrate' to automatically fix your config. + Please run 'npx storybook automigrate' to automatically fix your config. `; } } @@ -390,7 +390,7 @@ export class NoMatchingExportError extends StorybookError { Correct example: { "@storybook/react": "7.5.3", "@storybook/react-vite": "7.5.3", "storybook": "7.5.3" } - Please run \`npx storybook@latest doctor\` for guidance on how to fix this issue. + Please run \`npx storybook doctor\` for guidance on how to fix this issue. `; } } @@ -557,7 +557,7 @@ export class UpgradeStorybookToSameVersionError extends StorybookError { If you intended to re-run automigrations, you should run the "automigrate" command directly instead: - "npx storybook@${this.data.beforeVersion} automigrate" + "npx storybook automigrate" `; } } From 7116c0581763dc32a816ce55c3a0b540a044df27 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 20 Mar 2024 13:08:08 +0100 Subject: [PATCH 3/4] fix --- code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts b/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts index 35d135bcd4c2..e0f708543bef 100644 --- a/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts +++ b/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts @@ -1,10 +1,9 @@ import chalk from 'chalk'; import boxen from 'boxen'; import dedent from 'ts-dedent'; -import { versions, type InstallationMetadata } from '@storybook/core-common'; +import { type InstallationMetadata } from '@storybook/core-common'; import type { FixSummary } from '../types'; import { FixStatus } from '../types'; -import { isPrerelease } from '../../doctor/utils'; export const messageDivider = '\n\n'; const segmentDivider = '\n\n─────────────────────────────────────────────────\n\n'; From a2582badd909125b6448c3dc9aea3e6e0fb14cf2 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 20 Mar 2024 15:19:47 +0100 Subject: [PATCH 4/4] Remove unused import in doctor/index.ts --- code/lib/cli/src/doctor/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/code/lib/cli/src/doctor/index.ts b/code/lib/cli/src/doctor/index.ts index ff9da7118f34..2dfecaa96d17 100644 --- a/code/lib/cli/src/doctor/index.ts +++ b/code/lib/cli/src/doctor/index.ts @@ -15,7 +15,6 @@ import { getIncompatibleStorybookPackages, } from './getIncompatibleStorybookPackages'; import { getDuplicatedDepsWarnings } from './getDuplicatedDepsWarnings'; -import { isPrerelease } from './utils'; const logger = console; const LOG_FILE_NAME = 'doctor-storybook.log';