Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Handle Yarn PnP wrapper scenario when adding an addon #29027

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 @@
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);
Comment on lines +147 to +148
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: type assertion to 'any' may hide potential type errors, consider using a more specific type

} else {
main.appendValueToArray(['addons'], addonName);
}

await writeConfig(main);

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