-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -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 GitHub Actions / Core Unit Tests, windows-latestsrc/add.test.ts > add > 'aa'
Check failure on line 145 in code/lib/cli-storybook/src/add.ts GitHub Actions / Core Unit Tests, windows-latestsrc/add.test.ts > add > 'aa@4'
Check failure on line 145 in code/lib/cli-storybook/src/add.ts GitHub Actions / Core Unit Tests, windows-latestsrc/add.test.ts > add > '[email protected]'
Check failure on line 145 in code/lib/cli-storybook/src/add.ts GitHub Actions / Core Unit Tests, windows-latestsrc/add.test.ts > add > 'aa@^4'
Check failure on line 145 in code/lib/cli-storybook/src/add.ts GitHub Actions / Core Unit Tests, windows-latestsrc/add.test.ts > add > 'aa@~4'
Check failure on line 145 in code/lib/cli-storybook/src/add.ts GitHub Actions / Core Unit Tests, windows-latestsrc/add.test.ts > add > '[email protected]'
Check failure on line 145 in code/lib/cli-storybook/src/add.ts GitHub Actions / Core Unit Tests, windows-latestsrc/add.test.ts > add > 'aa@next'
Check failure on line 145 in code/lib/cli-storybook/src/add.ts GitHub Actions / Core Unit Tests, windows-latestsrc/add.test.ts > add > '@org/aa'
Check failure on line 145 in code/lib/cli-storybook/src/add.ts GitHub Actions / Core Unit Tests, windows-latestsrc/add.test.ts > add > '@org/aa@4'
Check failure on line 145 in code/lib/cli-storybook/src/add.ts GitHub Actions / Core Unit Tests, windows-latestsrc/add.test.ts > add > '@org/[email protected]'
|
||
|
||
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)) { | ||
|
There was a problem hiding this comment.
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