Skip to content

Commit

Permalink
bring duplicated deps logic back
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Feb 28, 2024
1 parent 99d04b2 commit 76c2388
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
30 changes: 29 additions & 1 deletion code/lib/cli/src/automigrate/helpers/getMigrationSummary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,35 @@ describe('getMigrationSummary', () => {
The automigrations try to migrate common patterns in your project, but might not contain everything needed to migrate to the latest version of Storybook.
Please check the changelog and migration guide for manual migrations and more information: https://storybook.js.org/docs/8.0/migration-guide
And reach out on Discord if you need help: https://discord.gg/storybook"
And reach out on Discord if you need help: https://discord.gg/storybook
─────────────────────────────────────────────────
Critical: The following dependencies are duplicated and WILL cause unexpected behavior:
@storybook/instrumenter:
6.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/addon-essentials:
7.0.0, 7.1.0
Please try de-duplicating these dependencies by running yarn dedupe
You can find more information for a given dependency by running yarn why <package-name>"
`);
});

Expand Down
10 changes: 10 additions & 0 deletions code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import dedent from 'ts-dedent';
import type { InstallationMetadata } from '@storybook/core-common';
import type { FixSummary } from '../types';
import { FixStatus } from '../types';
import { getDuplicatedDepsWarnings } from '../../doctor/getDuplicatedDepsWarnings';

export const messageDivider = '\n\n';
const segmentDivider = '\n\n─────────────────────────────────────────────────\n\n';
Expand Down Expand Up @@ -52,6 +53,7 @@ export function getMigrationSummary({
fixResults,
fixSummary,
logFile,
installationMetadata,
}: {
fixResults: Record<string, FixStatus>;
fixSummary: FixSummary;
Expand All @@ -73,6 +75,14 @@ export function getMigrationSummary({
And reach out on Discord if you need help: ${chalk.yellow('https://discord.gg/storybook')}
`);

const duplicatedDepsMessage = installationMetadata
? getDuplicatedDepsWarnings(installationMetadata)
: getDuplicatedDepsWarnings();

if (duplicatedDepsMessage) {
messages.push(duplicatedDepsMessage.join(messageDivider));
}

const hasNoFixes = Object.values(fixResults).every((r) => r === FixStatus.UNNECESSARY);
const hasFailures = Object.values(fixResults).some(
(r) => r === FixStatus.FAILED || r === FixStatus.CHECK_FAILED
Expand Down
8 changes: 4 additions & 4 deletions code/lib/cli/src/doctor/getDuplicatedDepsWarnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ export function getDuplicatedDepsWarnings(

messages.push(
'\n',
`You can find more information for a given dependency by running ${chalk.cyan(
`${installationMetadata.infoCommand} <package-name>`
`Please try de-duplicating these dependencies by running ${chalk.cyan(
`${installationMetadata.dedupeCommand}`
)}`
);

messages.push(
'\n',
`Please try de-duplicating these dependencies by running ${chalk.cyan(
`${installationMetadata.dedupeCommand}`
`You can find more information for a given dependency by running ${chalk.cyan(
`${installationMetadata.infoCommand} <package-name>`
)}`
);

Expand Down

0 comments on commit 76c2388

Please sign in to comment.