-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Enable yarn 3 for Redwood projects #4444
Changes from 45 commits
d14490d
8b54fe7
7b11c48
a5b89f2
714e294
1c6045a
7fa682d
d700136
1d93acb
03a4beb
5ee4f29
9bae87e
8bf0a2b
f7a7738
c5f4439
66e18d6
ac50664
5def5a0
411a384
f5ea110
076a112
5da7111
5d8d1a9
45105f2
31358db
12d72f9
ac62acd
9ea6015
c36a87d
6009ab1
3abc9af
f4bce34
de6bc2f
656932e
790d008
f9803f6
4f91533
50503d9
00a41c8
bd10f97
ebb021f
44d1d9f
cb97ddd
900de0c
a14c7c0
51e03ba
8e4c774
653df96
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 |
---|---|---|
|
@@ -20,6 +20,5 @@ | |
}, | ||
"prisma": { | ||
"seed": "yarn rw exec seed" | ||
}, | ||
"packageManager": "[email protected]" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env node | ||
import { createRequire } from 'module' | ||
|
||
const requireFromCli = createRequire( | ||
require.resolve('@redwoodjs/cli/package.json') | ||
) | ||
|
||
const bins = requireFromCli('./package.json')['bin'] | ||
|
||
process.chdir('../') | ||
requireFromCli(bins['redwood']) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env node | ||
import { createRequire } from 'module' | ||
|
||
const requireFromCli = createRequire( | ||
require.resolve('@redwoodjs/cli/package.json') | ||
) | ||
|
||
const bins = requireFromCli('./package.json')['bin'] | ||
|
||
process.chdir('../') | ||
requireFromCli(bins['rwfw']) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env node | ||
import { createRequire } from 'module' | ||
|
||
const requireFromTypeScript = createRequire( | ||
require.resolve('typescript/package.json') | ||
) | ||
|
||
const bins = requireFromTypeScript('./package.json')['bin'] | ||
|
||
requireFromTypeScript(bins['tsc']) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,7 +122,9 @@ export const handler = async ({ force, install }) => { | |
} | ||
} | ||
|
||
await execa('yarn', ['tailwindcss', 'init', tailwindConfigPath]) | ||
await execa('yarn', ['tailwindcss', 'init', tailwindConfigPath], { | ||
cwd: rwPaths.web.base, | ||
}) | ||
Comment on lines
+127
to
+129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jtoar curious if you tried setup ui chakra-ui? |
||
|
||
// Replace `content`. | ||
const tailwindConfig = fs.readFileSync(tailwindConfigPath, 'utf-8') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import terminalLink from 'terminal-link' | |
import { getProject } from '@redwoodjs/structure' | ||
import { errorTelemetry } from '@redwoodjs/telemetry' | ||
|
||
import { getCmdMajorVersion } from '../commands/upgrade' | ||
import { getPaths } from '../lib' | ||
import c from '../lib/colors' | ||
import { generatePrismaClient } from '../lib/generatePrismaClient' | ||
|
@@ -55,13 +56,17 @@ export const handler = async ({ sides, verbose, prisma, generate }) => { | |
const typeCheck = async () => { | ||
let conclusiveExitCode = 0 | ||
|
||
const yarnVersion = await getCmdMajorVersion('yarn') | ||
|
||
const tscForAllSides = sides.map((side) => { | ||
const projectDir = path.join(getPaths().base, side) | ||
// -s flag to suppress error output from yarn. For example yarn doc link on non-zero status. | ||
// Since it'll be printed anyways after the whole execution. | ||
return { | ||
cwd: projectDir, | ||
command: `yarn -s tsc --noEmit --skipLibCheck`, | ||
command: `yarn ${ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jtoar what if we created a helper for running yarn commands so all the logic is in one place? Something like |
||
yarnVersion > 1 ? '' : '-s' | ||
} tsc --noEmit --skipLibCheck`, | ||
} | ||
}) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Upgrade Yarn | ||
|
||
This codemod upgrades Redwood projects from yarn 1 to yarn 3. | ||
|
||
The first thing it does is enable corepack: | ||
|
||
``` | ||
corepack enable | ||
``` | ||
|
||
Corepack is a new thing in the Node.js core—it essentially packages yarn with node so that it doesn't have to be installed separately. | ||
Its only available on node >= `v14.9.0`, so we check for that first. | ||
|
||
After enabling corepack, we set the yarn version: | ||
|
||
``` | ||
yarn set version stable | ||
``` | ||
|
||
Finally, before installing, we have to update `.yarnrc.yml` and `.gitignore`. | ||
We have to update the `.yarnc.yml` because we only support the `node_modules` install strategy. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.idea | ||
.DS_Store | ||
.env | ||
.netlify | ||
.redwood | ||
dev.db* | ||
dist | ||
dist-babel | ||
node_modules | ||
yarn-error.log | ||
web/public/mockServiceWorker.js | ||
web/types/graphql.d.ts | ||
api/types/graphql.d.ts |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"private": true, | ||
"workspaces": { | ||
"packages": [ | ||
"api", | ||
"web", | ||
"packages/*" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@redwoodjs/core": "0.47.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@redwoodjs/eslint-config", | ||
"root": true | ||
}, | ||
"engines": { | ||
"node": ">=14.17 <=16.x", | ||
"yarn": ">=1.15 <2" | ||
}, | ||
"prisma": { | ||
"seed": "yarn rw exec seed" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.idea | ||
.DS_Store | ||
.env | ||
.netlify | ||
.redwood | ||
dev.db* | ||
dist | ||
dist-babel | ||
node_modules | ||
yarn-error.log | ||
web/public/mockServiceWorker.js | ||
web/types/graphql.d.ts | ||
api/types/graphql.d.ts | ||
.pnp.* | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
compressionLevel: 0 | ||
|
||
enableGlobalCache: true | ||
|
||
nmMode: hardlinks-local | ||
|
||
nodeLinker: node-modules | ||
|
||
yarnPath: .yarn/releases/yarn-3.2.0.cjs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"private": true, | ||
"workspaces": { | ||
"packages": [ | ||
"api", | ||
"web", | ||
"packages/*" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@redwoodjs/core": "0.47.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@redwoodjs/eslint-config", | ||
"root": true | ||
}, | ||
"engines": { | ||
"node": ">=14.17 <=16.x", | ||
"yarn": ">=1.15 <2" | ||
}, | ||
"prisma": { | ||
"seed": "yarn rw exec seed" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
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.
This may have been accidentally committed? it contradicts the value in
.yarnrc.yml
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.
@dom I noticed that over here and believe it's an artifact that results during the initial create-redwood-app (done with Yarn 3), which isn't changed when
yarn set version classic
is run.https://github.com/redwoodjs/redwood/pull/4566/files#r815032225