From b421d9545d2073f0a2a8fadb12f4935afea714ea Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Thu, 30 Mar 2023 16:23:01 +0200 Subject: [PATCH] only provide critical duplicated dependency warning on major version difference --- .../src/automigrate/helpers/getMigrationSummary.test.ts | 8 ++++---- .../cli/src/automigrate/helpers/getMigrationSummary.ts | 2 +- code/lib/cli/src/automigrate/index.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/code/lib/cli/src/automigrate/helpers/getMigrationSummary.test.ts b/code/lib/cli/src/automigrate/helpers/getMigrationSummary.test.ts index d91fbe7ec1a9..79bcb7444ade 100644 --- a/code/lib/cli/src/automigrate/helpers/getMigrationSummary.test.ts +++ b/code/lib/cli/src/automigrate/helpers/getMigrationSummary.test.ts @@ -26,7 +26,7 @@ describe('getMigrationSummary', () => { const installationMetadata: InstallationMetadata = { duplicatedDependencies: { '@storybook/core-client': ['7.0.0', '7.1.0'], - '@storybook/instrumenter': ['7.0.0', '7.1.0'], + '@storybook/instrumenter': ['6.0.0', '7.1.0'], '@storybook/core-common': ['6.0.0', '7.1.0'], '@storybook/addon-essentials': ['7.0.0', '7.1.0'], }, @@ -136,13 +136,13 @@ describe('getMigrationSummary', () => { Critical: The following dependencies are duplicated and WILL cause unexpected behavior: @storybook/instrumenter: - 7.0.0, 7.1.0 - - @storybook/core-common: 6.0.0, 7.1.0 Attention: The following dependencies are duplicated which might cause unexpected behavior: + @storybook/core-common: + 6.0.0, 7.1.0 + @storybook/addon-essentials: 7.0.0, 7.1.0 diff --git a/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts b/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts index 9aa444e2a967..2a05084ad5e1 100644 --- a/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts +++ b/code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts @@ -147,7 +147,7 @@ function getWarnings(installationMetadata: InstallationMetadata) { const hasMultipleMajorVersions = hasMultipleVersions(versions); - if (hasMultipleMajorVersions || disallowList.includes(dep)) { + if (disallowList.includes(dep) && hasMultipleMajorVersions) { acc.critical.push(`${chalk.redBright(dep)}:\n${versions.join(', ')}`); } else { acc.trivial.push(`${chalk.hex('#ff9800')(dep)}:\n${versions.join(', ')}`); diff --git a/code/lib/cli/src/automigrate/index.ts b/code/lib/cli/src/automigrate/index.ts index d01975e81ebf..e412f483fcc8 100644 --- a/code/lib/cli/src/automigrate/index.ts +++ b/code/lib/cli/src/automigrate/index.ts @@ -153,7 +153,7 @@ export async function runFixes({ const sbVersionCoerced = storybookVersion && semver.coerce(storybookVersion)?.version; if (!sbVersionCoerced) { logger.info(dedent` - [Storybook automigrate] ❌ Unable to determine storybook version so the automigrations will be skipped. + [Storybook automigrate] ❌ Unable to determine storybook version so the automigrations will be skipped. 🤔 Are you running automigrate from your project directory? Please specify your Storybook config directory with the --config-dir flag. `); return {