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
ca99500d
Unverified
Commit
ca99500d
authored
Dec 05, 2024
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Dec 05, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync-react: Add affordance to stop syncing Pages Router (#73533)
parent
6b393477
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
20 deletions
+45
-20
sync-react.js
scripts/sync-react.js
+45
-20
No files found.
scripts/sync-react.js
View file @
ca99500d
...
@@ -14,6 +14,12 @@ const repoOwner = 'vercel'
...
@@ -14,6 +14,12 @@ const repoOwner = 'vercel'
const
repoName
=
'next.js'
const
repoName
=
'next.js'
const
pullRequestLabels
=
[
'type: react-sync'
]
const
pullRequestLabels
=
[
'type: react-sync'
]
const
pullRequestReviewers
=
[
'eps1lon'
]
const
pullRequestReviewers
=
[
'eps1lon'
]
/**
* Set to `null` to automatically sync the React version of Pages Router with App Router React version.
* Set to a specific version to override the Pages Router React version e.g. `^19.0.0`.
* @type {string | null}
*/
const
pagesRouterReact
=
null
const
filesReferencingReactPeerDependencyVersion
=
[
const
filesReferencingReactPeerDependencyVersion
=
[
'run-tests.js'
,
'run-tests.js'
,
...
@@ -187,7 +193,14 @@ async function main() {
...
@@ -187,7 +193,14 @@ async function main() {
async
function
commitEverything
(
message
)
{
async
function
commitEverything
(
message
)
{
await
execa
(
'git'
,
[
'add'
,
'-A'
])
await
execa
(
'git'
,
[
'add'
,
'-A'
])
await
execa
(
'git'
,
[
'commit'
,
'--message'
,
message
,
'--no-verify'
])
await
execa
(
'git'
,
[
'commit'
,
'--message'
,
message
,
'--no-verify'
,
// Some steps can be empty, e.g. when we don't sync Pages router
'--allow-empty'
,
])
}
}
if
(
createPull
&&
!
actor
)
{
if
(
createPull
&&
!
actor
)
{
...
@@ -306,34 +319,41 @@ Or, run this command with no arguments to use the most recently published versio
...
@@ -306,34 +319,41 @@ Or, run this command with no arguments to use the most recently published versio
)
)
}
}
const
syncPagesRouterReact
=
pagesRouterReact
===
null
const
pagesRouterReactVersion
=
syncPagesRouterReact
?
newVersionStr
:
pagesRouterReact
const
{
sha
:
baseSha
,
dateString
:
baseDateString
}
=
baseVersionInfo
const
{
sha
:
baseSha
,
dateString
:
baseDateString
}
=
baseVersionInfo
if
(
syncPagesRouterReact
)
{
for
(
const
fileName
of
filesReferencingReactPeerDependencyVersion
)
{
for
(
const
fileName
of
filesReferencingReactPeerDependencyVersion
)
{
const
filePath
=
path
.
join
(
cwd
,
fileName
)
const
filePath
=
path
.
join
(
cwd
,
fileName
)
const
previousSource
=
await
fsp
.
readFile
(
filePath
,
'utf-8'
)
const
previousSource
=
await
fsp
.
readFile
(
filePath
,
'utf-8'
)
const
updatedSource
=
previousSource
.
replace
(
const
updatedSource
=
previousSource
.
replace
(
`const nextjsReactPeerVersion = "
${
baseVersionStr
}
";`
,
`const nextjsReactPeerVersion = "
${
baseVersionStr
}
";`
,
`const nextjsReactPeerVersion = "
${
newVersionStr
}
";`
`const nextjsReactPeerVersion = "
${
pagesRouterReactVersion
}
";`
)
)
if
(
updatedSource
===
previousSource
)
{
if
(
pagesRouterReact
===
null
&&
updatedSource
===
previousSource
)
{
errors
.
push
(
errors
.
push
(
new
Error
(
new
Error
(
`
${
fileName
}
: Failed to update
${
baseVersionStr
}
to
${
newVersionStr
}
. Is this file still referencing the React peer dependency version?`
`
${
fileName
}
: Failed to update
${
baseVersionStr
}
to
${
pagesRouterReactVersion
}
. Is this file still referencing the React peer dependency version?`
)
)
)
)
}
else
{
}
else
{
await
fsp
.
writeFile
(
filePath
,
updatedSource
)
await
fsp
.
writeFile
(
filePath
,
updatedSource
)
}
}
}
}
}
for
(
const
fileName
of
appManifestsInstallingNextjsPeerDependencies
)
{
for
(
const
fileName
of
appManifestsInstallingNextjsPeerDependencies
)
{
const
packageJsonPath
=
path
.
join
(
cwd
,
fileName
)
const
packageJsonPath
=
path
.
join
(
cwd
,
fileName
)
const
packageJson
=
await
fsp
.
readFile
(
packageJsonPath
,
'utf-8'
)
const
packageJson
=
await
fsp
.
readFile
(
packageJsonPath
,
'utf-8'
)
const
manifest
=
JSON
.
parse
(
packageJson
)
const
manifest
=
JSON
.
parse
(
packageJson
)
if
(
manifest
.
dependencies
[
'react'
])
{
if
(
manifest
.
dependencies
[
'react'
])
{
manifest
.
dependencies
[
'react'
]
=
newVersionStr
manifest
.
dependencies
[
'react'
]
=
pagesRouterReactVersion
}
}
if
(
manifest
.
dependencies
[
'react-dom'
])
{
if
(
manifest
.
dependencies
[
'react-dom'
])
{
manifest
.
dependencies
[
'react-dom'
]
=
newVersionStr
manifest
.
dependencies
[
'react-dom'
]
=
pagesRouterReactVersion
}
}
await
fsp
.
writeFile
(
await
fsp
.
writeFile
(
packageJsonPath
,
packageJsonPath
,
...
@@ -352,10 +372,12 @@ Or, run this command with no arguments to use the most recently published versio
...
@@ -352,10 +372,12 @@ Or, run this command with no arguments to use the most recently published versio
const
packageJson
=
await
fsp
.
readFile
(
packageJsonPath
,
'utf-8'
)
const
packageJson
=
await
fsp
.
readFile
(
packageJsonPath
,
'utf-8'
)
const
manifest
=
JSON
.
parse
(
packageJson
)
const
manifest
=
JSON
.
parse
(
packageJson
)
if
(
manifest
.
peerDependencies
[
'react'
])
{
if
(
manifest
.
peerDependencies
[
'react'
])
{
manifest
.
peerDependencies
[
'react'
]
=
`^18.2.0 ||
${
newVersionStr
}
`
manifest
.
peerDependencies
[
'react'
]
=
`^18.2.0 ||
${
pagesRouterReactVersion
}
`
}
}
if
(
manifest
.
peerDependencies
[
'react-dom'
])
{
if
(
manifest
.
peerDependencies
[
'react-dom'
])
{
manifest
.
peerDependencies
[
'react-dom'
]
=
`^18.2.0 ||
${
newVersionStr
}
`
manifest
.
peerDependencies
[
'react-dom'
]
=
`^18.2.0 ||
${
pagesRouterReactVersion
}
`
}
}
await
fsp
.
writeFile
(
await
fsp
.
writeFile
(
packageJsonPath
,
packageJsonPath
,
...
@@ -417,7 +439,10 @@ Or, run this command with no arguments to use the most recently published versio
...
@@ -417,7 +439,10 @@ Or, run this command with no arguments to use the most recently published versio
console
.
log
()
console
.
log
()
}
}
let
prDescription
=
`**breaking change for canary users: Bumps peer dependency of React from \`
${
baseVersionStr
}
\` to \`
${
newVersionStr
}
\`**\n\n`
let
prDescription
=
''
if
(
syncPagesRouterReact
)
{
prDescription
+=
`**breaking change for canary users: Bumps peer dependency of React from \`
${
baseVersionStr
}
\` to \`
${
pagesRouterReactVersion
}
\`**\n\n`
}
// Fetch the changelog from GitHub and print it to the console.
// Fetch the changelog from GitHub and print it to the console.
prDescription
+=
`[diff facebook/react@
${
baseSha
}
...
${
newSha
}
](https://github.com/facebook/react/compare/
${
baseSha
}
...
${
newSha
}
)\n\n`
prDescription
+=
`[diff facebook/react@
${
baseSha
}
...
${
newSha
}
](https://github.com/facebook/react/compare/
${
baseSha
}
...
${
newSha
}
)\n\n`
...
...
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