Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
21565ff6
Unverified
Commit
21565ff6
authored
Dec 18, 2024
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Dec 18, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync-react: Handle version bumps across SemVer minors and release channels (#74091)
parent
58d3982e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
40 deletions
+46
-40
sync-react.js
scripts/sync-react.js
+46
-40
No files found.
scripts/sync-react.js
View file @
21565ff6
...
@@ -21,6 +21,7 @@ const pullRequestReviewers = ['eps1lon']
...
@@ -21,6 +21,7 @@ const pullRequestReviewers = ['eps1lon']
*/
*/
const
pagesRouterReact
=
'^19.0.0'
const
pagesRouterReact
=
'^19.0.0'
const
defaultLatestChannel
=
'canary'
const
filesReferencingReactPeerDependencyVersion
=
[
const
filesReferencingReactPeerDependencyVersion
=
[
'run-tests.js'
,
'run-tests.js'
,
'packages/create-next-app/templates/index.ts'
,
'packages/create-next-app/templates/index.ts'
,
...
@@ -38,6 +39,24 @@ const appManifestsInstallingNextjsPeerDependencies = [
...
@@ -38,6 +39,24 @@ const appManifestsInstallingNextjsPeerDependencies = [
'test/e2e/next-test/first-time-setup-ts/package.json'
,
'test/e2e/next-test/first-time-setup-ts/package.json'
,
]
]
async
function
getSchedulerVersion
(
reactVersion
)
{
const
url
=
`https://registry.npmjs.org/react-dom/
${
reactVersion
}
`
const
response
=
await
fetch
(
url
,
{
headers
:
{
Accept
:
'application/json'
,
},
})
if
(
!
response
.
ok
)
{
throw
new
Error
(
`
${
url
}
:
${
response
.
status
}
${
response
.
statusText
}
\n
${
await
response
.
text
()}
`
)
}
const
manifest
=
await
response
.
json
()
return
manifest
.
dependencies
[
'scheduler'
]
}
// Use this script to update Next's vendored copy of React and related packages:
// Use this script to update Next's vendored copy of React and related packages:
//
//
// Basic usage (defaults to most recent React canary version):
// Basic usage (defaults to most recent React canary version):
...
@@ -46,13 +65,7 @@ const appManifestsInstallingNextjsPeerDependencies = [
...
@@ -46,13 +65,7 @@ const appManifestsInstallingNextjsPeerDependencies = [
// Update package.json but skip installing the dependencies automatically:
// Update package.json but skip installing the dependencies automatically:
// pnpm run sync-react --no-install
// pnpm run sync-react --no-install
async
function
sync
({
async
function
sync
({
channel
,
newVersionStr
,
noInstall
})
{
channel
,
newVersionStr
,
newSha
,
newDateString
,
noInstall
,
})
{
const
useExperimental
=
channel
===
'experimental'
const
useExperimental
=
channel
===
'experimental'
const
cwd
=
process
.
cwd
()
const
cwd
=
process
.
cwd
()
const
pkgJson
=
JSON
.
parse
(
const
pkgJson
=
JSON
.
parse
(
...
@@ -64,38 +77,35 @@ async function sync({
...
@@ -64,38 +77,35 @@ async function sync({
useExperimental
?
'react-experimental-builtin'
:
'react-builtin'
useExperimental
?
'react-experimental-builtin'
:
'react-builtin'
].
replace
(
/^npm:react@/
,
''
)
].
replace
(
/^npm:react@/
,
''
)
const
baseVersionInfo
=
extractInfoFromReactVersion
(
baseVersionStr
)
console
.
log
(
`Updating "react@
${
channel
}
" to
${
newVersionStr
}
...`
)
if
(
!
baseVersionInfo
)
{
if
(
newVersionStr
===
baseVersionStr
)
{
throw
new
Error
(
'Base react version does not match expected format: '
+
baseVersionStr
)
}
const
{
sha
:
baseSha
,
releaseLabel
:
baseReleaseLabel
,
dateString
:
baseDateString
,
}
=
baseVersionInfo
console
.
log
(
`Updating "react@
${
channel
}
" to
${
newSha
}
...\n`
)
if
(
newSha
===
baseSha
)
{
console
.
log
(
'Already up to date.'
)
console
.
log
(
'Already up to date.'
)
return
return
}
}
const
baseSchedulerVersionStr
=
devDependencies
[
useExperimental
?
'scheduler-experimental-builtin'
:
'scheduler-builtin'
].
replace
(
/^npm:scheduler@/
,
''
)
const
newSchedulerVersionStr
=
await
getSchedulerVersion
(
newVersionStr
)
console
.
log
(
`Updating "scheduler@
${
channel
}
" to
${
newSchedulerVersionStr
}
...`
)
for
(
const
[
dep
,
version
]
of
Object
.
entries
(
devDependencies
))
{
for
(
const
[
dep
,
version
]
of
Object
.
entries
(
devDependencies
))
{
if
(
version
.
endsWith
(
`
${
baseReleaseLabel
}
-
${
baseSha
}
-
${
baseDateString
}
`
))
{
if
(
version
.
endsWith
(
baseVersionStr
))
{
devDependencies
[
dep
]
=
version
.
replace
(
baseVersionStr
,
newVersionStr
)
}
else
if
(
version
.
endsWith
(
baseSchedulerVersionStr
))
{
devDependencies
[
dep
]
=
version
.
replace
(
devDependencies
[
dep
]
=
version
.
replace
(
`
${
baseReleaseLabel
}
-
${
baseSha
}
-
${
baseDateString
}
`
,
baseSchedulerVersionStr
,
`
${
channel
}
-
${
newSha
}
-
${
newDateString
}
`
newSchedulerVersionStr
)
)
}
}
}
}
for
(
const
[
dep
,
version
]
of
Object
.
entries
(
pnpmOverrides
))
{
for
(
const
[
dep
,
version
]
of
Object
.
entries
(
pnpmOverrides
))
{
if
(
version
.
endsWith
(
`
${
baseReleaseLabel
}
-
${
baseSha
}
-
${
baseDateString
}
`
))
{
if
(
version
.
endsWith
(
baseVersionStr
))
{
pnpmOverrides
[
dep
]
=
version
.
replace
(
baseVersionStr
,
newVersionStr
)
}
else
if
(
version
.
endsWith
(
baseSchedulerVersionStr
))
{
pnpmOverrides
[
dep
]
=
version
.
replace
(
pnpmOverrides
[
dep
]
=
version
.
replace
(
`
${
baseReleaseLabel
}
-
${
baseSha
}
-
${
baseDateString
}
`
,
baseSchedulerVersionStr
,
`
${
channel
}
-
${
newSha
}
-
${
newDateString
}
`
newSchedulerVersionStr
)
)
}
}
}
}
...
@@ -224,7 +234,7 @@ async function main() {
...
@@ -224,7 +234,7 @@ async function main() {
)
{
)
{
const
{
stdout
,
stderr
}
=
await
execa
(
const
{
stdout
,
stderr
}
=
await
execa
(
'npm'
,
'npm'
,
[
'--silent'
,
'view'
,
'react@canary'
,
'version'
],
[
'--silent'
,
'view'
,
`react@
${
defaultLatestChannel
}
`
,
'version'
],
{
{
// Avoid "Usage Error: This project is configured to use pnpm".
// Avoid "Usage Error: This project is configured to use pnpm".
cwd
:
'/tmp'
,
cwd
:
'/tmp'
,
...
@@ -236,7 +246,7 @@ async function main() {
...
@@ -236,7 +246,7 @@ async function main() {
}
}
newVersionStr
=
stdout
.
trim
()
newVersionStr
=
stdout
.
trim
()
console
.
log
(
console
.
log
(
`--version was not provided. Using react@
canary
:
${
newVersionStr
}
`
`--version was not provided. Using react@
${
defaultLatestChannel
}
:
${
newVersionStr
}
`
)
)
}
}
...
@@ -253,7 +263,7 @@ Or, run this command with no arguments to use the most recently published versio
...
@@ -253,7 +263,7 @@ Or, run this command with no arguments to use the most recently published versio
}
}
const
{
sha
:
newSha
,
dateString
:
newDateString
}
=
newVersionInfo
const
{
sha
:
newSha
,
dateString
:
newDateString
}
=
newVersionInfo
const
branchName
=
`update/react/
${
new
Sha
}
-
${
newDateString
}
`
const
branchName
=
`update/react/
${
new
VersionStr
}
`
if
(
createPull
)
{
if
(
createPull
)
{
const
{
exitCode
,
all
,
command
}
=
await
execa
(
const
{
exitCode
,
all
,
command
}
=
await
execa
(
'git'
,
'git'
,
...
@@ -292,9 +302,7 @@ Or, run this command with no arguments to use the most recently published versio
...
@@ -292,9 +302,7 @@ Or, run this command with no arguments to use the most recently published versio
)
)
await
sync
({
await
sync
({
newDateString
,
newVersionStr
:
`0.0.0-experimental-
${
newSha
}
-
${
newDateString
}
`
,
newSha
,
newVersionStr
,
noInstall
:
!
install
,
noInstall
:
!
install
,
channel
:
'experimental'
,
channel
:
'experimental'
,
})
})
...
@@ -302,14 +310,12 @@ Or, run this command with no arguments to use the most recently published versio
...
@@ -302,14 +310,12 @@ Or, run this command with no arguments to use the most recently published versio
await
commitEverything
(
'Update `react@experimental`'
)
await
commitEverything
(
'Update `react@experimental`'
)
}
}
await
sync
({
await
sync
({
newDateString
,
newSha
,
newVersionStr
,
newVersionStr
,
noInstall
:
!
install
,
noInstall
:
!
install
,
channel
:
'
rc
'
,
channel
:
'
<framework-stable>
'
,
})
})
if
(
commit
)
{
if
(
commit
)
{
await
commitEverything
(
'Update `react
@rc
`'
)
await
commitEverything
(
'Update `react`'
)
}
}
const
baseVersionInfo
=
extractInfoFromReactVersion
(
baseVersionStr
)
const
baseVersionInfo
=
extractInfoFromReactVersion
(
baseVersionStr
)
...
@@ -394,9 +400,9 @@ Or, run this command with no arguments to use the most recently published versio
...
@@ -394,9 +400,9 @@ Or, run this command with no arguments to use the most recently published versio
// Install the updated dependencies and build the vendored React files.
// Install the updated dependencies and build the vendored React files.
if
(
!
install
)
{
if
(
!
install
)
{
console
.
log
(
'Skipping install step because --no-install flag was passed.
\
n
'
)
console
.
log
(
'Skipping install step because --no-install flag was passed.'
)
}
else
{
}
else
{
console
.
log
(
'Installing dependencies...
\
n
'
)
console
.
log
(
'Installing dependencies...'
)
const
installSubprocess
=
execa
(
'pnpm'
,
[
const
installSubprocess
=
execa
(
'pnpm'
,
[
'install'
,
'install'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment