Skip to content

Commit

Permalink
CLI: Handle Yarn PnP wrapper scenario when adding an addon
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Sep 2, 2024
1 parent 56b28c0 commit a476108
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion code/lib/cli-storybook/src/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import { readConfig, writeConfig } from 'storybook/internal/csf-tools';
import SemVer from 'semver';
import { dedent } from 'ts-dedent';

import {
getRequireWrapperName,
isRequireWrapperNecessary,
wrapValueWithRequireWrapper,
} from './automigrate/fixes/wrap-require-utils';
import { postinstallAddon } from './postinstallAddon';

export interface PostinstallOptions {
Expand Down Expand Up @@ -136,7 +141,17 @@ export async function add(
await packageManager.addDependencies({ installAsDevDependencies: true }, [addonWithVersion]);

logger.log(`Adding '${addon}' to main.js addons field.`);
main.appendValueToArray(['addons'], addonName);

const mainConfigAddons = main.getFieldNode(['addons']);

Check failure on line 145 in code/lib/cli-storybook/src/add.ts

View workflow job for this annotation

GitHub Actions / Core Unit Tests, windows-latest

src/add.test.ts > add > 'aa'

TypeError: main.getFieldNode is not a function ❯ Module.add src/add.ts:145:33 ❯ src/add.test.ts:91:5

Check failure on line 145 in code/lib/cli-storybook/src/add.ts

View workflow job for this annotation

GitHub Actions / Core Unit Tests, windows-latest

src/add.test.ts > add > 'aa@4'

TypeError: main.getFieldNode is not a function ❯ Module.add src/add.ts:145:33 ❯ src/add.test.ts:91:5

Check failure on line 145 in code/lib/cli-storybook/src/add.ts

View workflow job for this annotation

GitHub Actions / Core Unit Tests, windows-latest

src/add.test.ts > add > '[email protected]'

TypeError: main.getFieldNode is not a function ❯ Module.add src/add.ts:145:33 ❯ src/add.test.ts:91:5

Check failure on line 145 in code/lib/cli-storybook/src/add.ts

View workflow job for this annotation

GitHub Actions / Core Unit Tests, windows-latest

src/add.test.ts > add > 'aa@^4'

TypeError: main.getFieldNode is not a function ❯ Module.add src/add.ts:145:33 ❯ src/add.test.ts:91:5

Check failure on line 145 in code/lib/cli-storybook/src/add.ts

View workflow job for this annotation

GitHub Actions / Core Unit Tests, windows-latest

src/add.test.ts > add > 'aa@~4'

TypeError: main.getFieldNode is not a function ❯ Module.add src/add.ts:145:33 ❯ src/add.test.ts:91:5

Check failure on line 145 in code/lib/cli-storybook/src/add.ts

View workflow job for this annotation

GitHub Actions / Core Unit Tests, windows-latest

src/add.test.ts > add > '[email protected]'

TypeError: main.getFieldNode is not a function ❯ Module.add src/add.ts:145:33 ❯ src/add.test.ts:91:5

Check failure on line 145 in code/lib/cli-storybook/src/add.ts

View workflow job for this annotation

GitHub Actions / Core Unit Tests, windows-latest

src/add.test.ts > add > 'aa@next'

TypeError: main.getFieldNode is not a function ❯ Module.add src/add.ts:145:33 ❯ src/add.test.ts:91:5

Check failure on line 145 in code/lib/cli-storybook/src/add.ts

View workflow job for this annotation

GitHub Actions / Core Unit Tests, windows-latest

src/add.test.ts > add > '@org/aa'

TypeError: main.getFieldNode is not a function ❯ Module.add src/add.ts:145:33 ❯ src/add.test.ts:91:5

Check failure on line 145 in code/lib/cli-storybook/src/add.ts

View workflow job for this annotation

GitHub Actions / Core Unit Tests, windows-latest

src/add.test.ts > add > '@org/aa@4'

TypeError: main.getFieldNode is not a function ❯ Module.add src/add.ts:145:33 ❯ src/add.test.ts:91:5

Check failure on line 145 in code/lib/cli-storybook/src/add.ts

View workflow job for this annotation

GitHub Actions / Core Unit Tests, windows-latest

src/add.test.ts > add > '@org/[email protected]'

TypeError: main.getFieldNode is not a function ❯ Module.add src/add.ts:145:33 ❯ src/add.test.ts:91:5

if (mainConfigAddons && getRequireWrapperName(main) !== null) {
const addonNode = main.valueToNode(addonName);
main.appendNodeToArray(['addons'], addonNode as any);
wrapValueWithRequireWrapper(main, addonNode as any);
} else {
main.appendValueToArray(['addons'], addonName);
}

await writeConfig(main);

if (!skipPostinstall && isCoreAddon(addonName)) {
Expand Down

0 comments on commit a476108

Please sign in to comment.