Skip to content

Commit b41dab8

Browse files
committed
[do not merge] run stats for #69484
1 parent 2195a10 commit b41dab8

File tree

2 files changed

+42
-12
lines changed

2 files changed

+42
-12
lines changed

.github/actions/next-stats-action/src/run/index.js

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ async function runConfigs(
2222
let diffRepoStats
2323
let diffs
2424

25+
let i = 0
2526
for (const pkgPaths of [mainRepoPkgPaths, diffRepoPkgPaths]) {
2627
let curStats = {
2728
General: {
@@ -48,7 +49,42 @@ async function runConfigs(
4849
}
4950

5051
// links local builds of the packages and installs dependencies
51-
await linkPkgs(statsAppDir, pkgPaths)
52+
const pkgJsonPath = path.join(statsAppDir, 'package.json')
53+
const isMainRepo = i === 0
54+
if (isMainRepo) {
55+
// TODO: Remove me before merging
56+
const original = await fs.readFile(
57+
path.join(statsAppDir, 'package.json'),
58+
'utf8'
59+
)
60+
await fs.writeFile(
61+
path.join(statsAppDir, 'package.json'),
62+
original.replaceAll('^18.2.0', '19.0.0-rc-7771d3a7-20240827'),
63+
'utf8'
64+
)
65+
} else {
66+
// TODO: Remove me before merging
67+
const original = await fs.readFile(
68+
path.join(statsAppDir, 'package.json'),
69+
'utf8'
70+
)
71+
await fs.writeFile(
72+
path.join(statsAppDir, 'package.json'),
73+
original.replaceAll('19.0.0-rc-7771d3a7-20240827', '^18.2.0'),
74+
'utf8'
75+
)
76+
}
77+
78+
const initialPkg = JSON.parse(
79+
await fs.readFile(path.join(statsAppDir, 'package.json'), 'utf8')
80+
)
81+
82+
const pkgData = await linkPkgs(statsAppDir, initialPkg, pkgPaths)
83+
await fs.writeFile(pkgJsonPath, JSON.stringify(pkgData, null, 2), 'utf8')
84+
await exec(
85+
`cd ${statsAppDir} && pnpm install --strict-peer-dependencies=false`,
86+
false
87+
)
5288

5389
if (!diffing) {
5490
curStats.General.nodeModulesSize = await getDirSize(
@@ -156,6 +192,7 @@ async function runConfigs(
156192
await exec(`cd ${statsAppDir} && ${statsConfig.appBuildCommand}`, false)
157193
)
158194
curStats.General.buildDurationCached = Date.now() - secondBuildStart
195+
i++
159196
}
160197

161198
logger(`Finished running: ${config.title}`)
@@ -171,15 +208,12 @@ async function runConfigs(
171208
return results
172209
}
173210

174-
async function linkPkgs(pkgDir = '', pkgPaths) {
211+
async function linkPkgs(pkgDir = '', pkgData, pkgPaths) {
175212
await fs.rm(path.join(pkgDir, 'node_modules'), {
176213
recursive: true,
177214
force: true,
178215
})
179216

180-
const pkgJsonPath = path.join(pkgDir, 'package.json')
181-
const pkgData = require(pkgJsonPath)
182-
183217
if (!pkgData.dependencies && !pkgData.devDependencies) return
184218

185219
for (const pkg of pkgPaths.keys()) {
@@ -191,12 +225,8 @@ async function linkPkgs(pkgDir = '', pkgPaths) {
191225
pkgData.devDependencies[pkg] = pkgPath
192226
}
193227
}
194-
await fs.writeFile(pkgJsonPath, JSON.stringify(pkgData, null, 2), 'utf8')
195228

196-
await exec(
197-
`cd ${pkgDir} && pnpm install --strict-peer-dependencies=false`,
198-
false
199-
)
229+
return pkgData
200230
}
201231

202232
module.exports = runConfigs

test/.stats-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"license": "MIT",
55
"dependencies": {
66
"next": "latest",
7-
"react": "^18.2.0",
8-
"react-dom": "^18.2.0"
7+
"react": "19.0.0-rc-7771d3a7-20240827",
8+
"react-dom": "19.0.0-rc-7771d3a7-20240827"
99
},
1010
"engines": {
1111
"node": ">=18.18.0"

0 commit comments

Comments
 (0)