forked from redwoodjs/redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RW projects: Add resolutions for @types/react 17 (redwoodjs#5112)
- Loading branch information
1 parent
dca8f8e
commit 032f4a9
Showing
10 changed files
with
176 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,8 @@ | |
"scripts": { | ||
"postinstall": "" | ||
}, | ||
"packageManager": "[email protected]" | ||
"packageManager": "[email protected]", | ||
"resolutions": { | ||
"@types/react": "17.0.40" | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/codemods/src/codemods/v1.1.x/addTypesReactResolution/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Update node engine | ||
|
||
Node 18 was recently released, but we're not ready to upgrade yet. So we need to pin the React types to v17 | ||
|
||
```diff | ||
diff --git a/package.json b/package.json | ||
index b22c4c0..bd018e5 100644 | ||
--- a/package.json | ||
+++ b/package.json | ||
@@ -21,5 +21,8 @@ | ||
"prisma": { | ||
"seed": "yarn rw exec seed" | ||
}, | ||
- "packageManager": "[email protected]" | ||
+ "packageManager": "[email protected]", | ||
+ "resolutions": { | ||
+ "@types/react": "17.0.40" | ||
+ } | ||
} | ||
``` |
25 changes: 25 additions & 0 deletions
25
...emods/src/codemods/v1.1.x/addTypesReactResolution/__testfixtures__/add/input/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"private": true, | ||
"workspaces": { | ||
"packages": [ | ||
"api", | ||
"web", | ||
"packages/*" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@redwoodjs/core": "1.0.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@redwoodjs/eslint-config", | ||
"root": true | ||
}, | ||
"engines": { | ||
"node": ">=14.19 <=16.x", | ||
"yarn": ">=1.15" | ||
}, | ||
"prisma": { | ||
"seed": "yarn rw exec seed" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
28 changes: 28 additions & 0 deletions
28
...mods/src/codemods/v1.1.x/addTypesReactResolution/__testfixtures__/add/output/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"private": true, | ||
"workspaces": { | ||
"packages": [ | ||
"api", | ||
"web", | ||
"packages/*" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@redwoodjs/core": "1.0.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@redwoodjs/eslint-config", | ||
"root": true | ||
}, | ||
"engines": { | ||
"node": ">=14.19 <=16.x", | ||
"yarn": ">=1.15" | ||
}, | ||
"prisma": { | ||
"seed": "yarn rw exec seed" | ||
}, | ||
"packageManager": "[email protected]", | ||
"resolutions": { | ||
"@types/react": "17.0.40" | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...ds/src/codemods/v1.1.x/addTypesReactResolution/__testfixtures__/append/input/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"private": true, | ||
"workspaces": { | ||
"packages": [ | ||
"api", | ||
"web", | ||
"packages/*" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@redwoodjs/core": "1.0.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@redwoodjs/eslint-config", | ||
"root": true | ||
}, | ||
"engines": { | ||
"node": ">=14.19 <=16.x", | ||
"yarn": ">=1.15" | ||
}, | ||
"prisma": { | ||
"seed": "yarn rw exec seed" | ||
}, | ||
"packageManager": "[email protected]", | ||
"resolutions": { | ||
"somePackage": "42.0.0" | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...s/src/codemods/v1.1.x/addTypesReactResolution/__testfixtures__/append/output/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"private": true, | ||
"workspaces": { | ||
"packages": [ | ||
"api", | ||
"web", | ||
"packages/*" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@redwoodjs/core": "1.0.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@redwoodjs/eslint-config", | ||
"root": true | ||
}, | ||
"engines": { | ||
"node": ">=14.19 <=16.x", | ||
"yarn": ">=1.15" | ||
}, | ||
"prisma": { | ||
"seed": "yarn rw exec seed" | ||
}, | ||
"packageManager": "[email protected]", | ||
"resolutions": { | ||
"somePackage": "42.0.0", | ||
"@types/react": "17.0.40" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...ods/src/codemods/v1.1.x/addTypesReactResolution/__tests__/addTypesReactResolution.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { addTypesReactResolution } from '../addTypesReactResolution' | ||
|
||
describe('addTypesReactResolution', () => { | ||
it('adds resolutions', async () => { | ||
await matchFolderTransform(addTypesReactResolution, 'add') | ||
}) | ||
it('appends to existing resolutions', async () => { | ||
await matchFolderTransform(addTypesReactResolution, 'append') | ||
}) | ||
}) |
15 changes: 15 additions & 0 deletions
15
packages/codemods/src/codemods/v1.1.x/addTypesReactResolution/addTypesReactResolution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import fs from 'fs' | ||
|
||
import getRootPackageJSON from '../../../lib/getRootPackageJSON' | ||
|
||
export const addTypesReactResolution = () => { | ||
const [rootPackageJSON, rootPackageJSONPath] = getRootPackageJSON() | ||
|
||
rootPackageJSON.resolutions = rootPackageJSON.resolutions || {} | ||
rootPackageJSON.resolutions['@types/react'] = '17.0.40' | ||
|
||
fs.writeFileSync( | ||
rootPackageJSONPath, | ||
JSON.stringify(rootPackageJSON, null, 2) + '\n' | ||
) | ||
} |
13 changes: 13 additions & 0 deletions
13
...ges/codemods/src/codemods/v1.1.x/addTypesReactResolution/addTypesReactResolution.yargs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import task from 'tasuku' | ||
|
||
import { addTypesReactResolution } from './addTypesReactResolution' | ||
|
||
export const command = 'types-react-resolution' | ||
export const description = | ||
'(v1.0->v1.1) Add @types/react resolution in the root package.json' | ||
|
||
export const handler = () => { | ||
task('Add @types/react resolution', async () => { | ||
addTypesReactResolution() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,8 @@ | |
"prisma": { | ||
"seed": "yarn rw exec seed" | ||
}, | ||
"packageManager": "[email protected]" | ||
"packageManager": "[email protected]", | ||
"resolutions": { | ||
"@types/react": "17.0.40" | ||
} | ||
} |