MCPcopy Index your code
hub / github.com/adobe/react-spectrum / enforceConsistentDependenciesAcrossTheProject

Function enforceConsistentDependenciesAcrossTheProject

yarn.config.cjs:17–74  ·  view source on GitHub ↗

* This rule will enforce that a workspace MUST depend on the same version of * a dependency as the one used by the other workspaces. * * @param {Context} context

({Yarn})

Source from the content-addressed store, hash-verified

15 * @param {Context} context
16 */
17function enforceConsistentDependenciesAcrossTheProject({Yarn}) {
18 // enforce react/react-dom version
19 for (const dependency of Yarn.dependencies()) {
20 if (dependency.type === 'peerDependencies') {
21 if (dependency.ident === 'react' || dependency.ident === 'react-dom') {
22 if (dependency.workspace.ident === 'storybook-react-parcel') {
23 continue;
24 }
25 if (dependency.workspace.ident === 'storybook-builder-parcel') {
26 dependency.update('*');
27 } else if (
28 dependency.workspace.ident === '@react-spectrum/s2' ||
29 dependency.workspace.ident === '@react-spectrum/s2-icon-builder' ||
30 dependency.workspace.ident === '@react-spectrum/ai'
31 ) {
32 dependency.update('^19.0.0-rc.1');
33 } else if (dependency.workspace.ident === '@react-spectrum/codemods') {
34 dependency.update('^18.0.0 || ^19.0.0-rc.1');
35 } else {
36 dependency.update('^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1');
37 }
38 }
39 }
40
41 // for (const otherDependency of Yarn.dependencies({ident: dependency.ident})) {
42 // if (otherDependency.type === `peerDependencies`)
43 // continue;
44 //
45 // // useful, however, i haven't quite made it relaxed enough
46 // // dependency.update(otherDependency.range);
47 // }
48 }
49
50 // enforce swc helpers version, spectrum-css-temp, and where they are placed in the package.json
51 for (const workspace of Yarn.workspaces()) {
52 if (
53 isPublishing(workspace) &&
54 // should these be included in the requirement?
55 workspace.ident !== '@adobe/react-spectrum' &&
56 workspace.ident !== 'react-aria' &&
57 workspace.ident !== 'react-stately' &&
58 workspace.ident !== '@internationalized/string-compiler' &&
59 workspace.ident !== 'tailwindcss-react-aria-components' &&
60 workspace.ident !== '@react-spectrum/s2' &&
61 workspace.ident !== '@react-spectrum/ai' &&
62 workspace.manifest.rsp?.type !== 'cli'
63 ) {
64 workspace.set('dependencies.@swc/helpers', '^0.5.0');
65 // these should not be in dependencies, but should be in dev or peer
66 // can't change the error message, but the package knows if it even needs it
67 if (!workspace.ident.startsWith('@react-spectrum/test-utils-internal')) {
68 workspace.set('dependencies.@react-spectrum/test-utils');
69 workspace.set('dependencies.react');
70 workspace.set('dependencies.react-dom');
71 }
72 }
73 }
74}

Callers 1

yarn.config.cjsFile · 0.85

Calls 3

isPublishingFunction · 0.85
updateMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected