Skip to content

Commit

Permalink
Merge pull request #24087 from storybookjs/kasper/fix-ci
Browse files Browse the repository at this point in the history
CI: Inform the user how to dedupe and strip color from info command
  • Loading branch information
kasperpeulen authored Sep 7, 2023
2 parents d627022 + d98ff76 commit 08e371c
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('getMigrationSummary', () => {
},
dependencies: {},
infoCommand: 'yarn why',
dedupeCommand: 'yarn dedupe',
};

const logFile = '/path/to/log/file';
Expand Down Expand Up @@ -146,7 +147,9 @@ describe('getMigrationSummary', () => {
@storybook/addon-essentials:
7.0.0, 7.1.0
You can find more information for a given dependency by running yarn why <package-name>"
You can find more information for a given dependency by running yarn why <package-name>
Please try de-duplicating these dependencies by running yarn dedupe"
`);
});

Expand Down
5 changes: 5 additions & 0 deletions code/lib/cli/src/automigrate/helpers/getMigrationSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ function getWarnings(installationMetadata: InstallationMetadata) {
`${installationMetadata.infoCommand} <package-name>`
)}`
);
messages.push(
`Please try de-duplicating these dependencies by running ${chalk.cyan(
`${installationMetadata.dedupeCommand}`
)}`
);

return messages;
}
1 change: 1 addition & 0 deletions code/lib/cli/src/js-package-manager/NPMProxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ describe('NPM Proxy', () => {

expect(installations).toMatchInlineSnapshot(`
Object {
"dedupeCommand": "npm dedupe",
"dependencies": Object {
"@storybook/addon-interactions": Array [
Object {
Expand Down
4 changes: 4 additions & 0 deletions code/lib/cli/src/js-package-manager/NPMProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ export class NPMProxy extends JsPackageManager {
args: ['ls', '--json', '--depth=99', pipeToNull],
// ignore errors, because npm ls will exit with code 1 if there are e.g. unmet peer dependencies
ignoreError: true,
env: {
FORCE_COLOR: 'false',
},
});

try {
Expand Down Expand Up @@ -272,6 +275,7 @@ export class NPMProxy extends JsPackageManager {
dependencies: acc,
duplicatedDependencies,
infoCommand: 'npm ls --depth=1',
dedupeCommand: 'npm dedupe',
};
}

Expand Down
1 change: 1 addition & 0 deletions code/lib/cli/src/js-package-manager/PNPMProxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ describe('PNPM Proxy', () => {

expect(installations).toMatchInlineSnapshot(`
Object {
"dedupeCommand": "pnpm dedupe",
"dependencies": Object {
"@storybook/addon-interactions": Array [
Object {
Expand Down
4 changes: 4 additions & 0 deletions code/lib/cli/src/js-package-manager/PNPMProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ export class PNPMProxy extends JsPackageManager {
const commandResult = await this.executeCommand({
command: 'pnpm',
args: ['list', pattern.map((p) => `"${p}"`).join(' '), '--json', '--depth=99'],
env: {
FORCE_COLOR: 'false',
},
});

try {
Expand Down Expand Up @@ -287,6 +290,7 @@ export class PNPMProxy extends JsPackageManager {
dependencies: acc,
duplicatedDependencies,
infoCommand: 'pnpm list --depth=1',
dedupeCommand: 'pnpm dedupe',
};
}

Expand Down
1 change: 1 addition & 0 deletions code/lib/cli/src/js-package-manager/Yarn1Proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ describe('Yarn 1 Proxy', () => {

expect(installations).toMatchInlineSnapshot(`
Object {
"dedupeCommand": "yarn dedupe",
"dependencies": Object {
"@storybook/addon-interactions": Array [
Object {
Expand Down
4 changes: 4 additions & 0 deletions code/lib/cli/src/js-package-manager/Yarn1Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export class Yarn1Proxy extends JsPackageManager {
const commandResult = await this.executeCommand({
command: 'yarn',
args: ['list', '--pattern', pattern.map((p) => `"${p}"`).join(' '), '--recursive', '--json'],
env: {
FORCE_COLOR: 'false',
},
});

try {
Expand Down Expand Up @@ -215,6 +218,7 @@ export class Yarn1Proxy extends JsPackageManager {
dependencies: acc,
duplicatedDependencies,
infoCommand: 'yarn why',
dedupeCommand: 'yarn dedupe',
};
}

Expand Down
1 change: 1 addition & 0 deletions code/lib/cli/src/js-package-manager/Yarn2Proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ describe('Yarn 2 Proxy', () => {

expect(installations).toMatchInlineSnapshot(`
Object {
"dedupeCommand": "yarn dedupe",
"dependencies": Object {
"@storybook/global": Array [
Object {
Expand Down
4 changes: 4 additions & 0 deletions code/lib/cli/src/js-package-manager/Yarn2Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ export class Yarn2Proxy extends JsPackageManager {
pattern.map((p) => `"${p}"`).join(' '),
`"${pattern}"`,
],
env: {
FORCE_COLOR: 'false',
},
});

try {
Expand Down Expand Up @@ -286,6 +289,7 @@ export class Yarn2Proxy extends JsPackageManager {
dependencies: acc,
duplicatedDependencies,
infoCommand: 'yarn why',
dedupeCommand: 'yarn dedupe',
};
}

Expand Down
1 change: 1 addition & 0 deletions code/lib/cli/src/js-package-manager/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export type InstallationMetadata = {
dependencies: Record<string, PackageMetadata[]>;
duplicatedDependencies: Record<string, string[]>;
infoCommand: string;
dedupeCommand: string;
};

0 comments on commit 08e371c

Please sign in to comment.