Allow running `download_devtools_regression_build.js` on a clean repo (#34456)
Sebastian "Sebbie" Silbermann committed
Sep 13, 2025 at 11:07 UTC
47664deb8e981ec0425731495be1c5826ce90956
1 file changed
+12
-9
scripts/ci/download_devtools_regression_build.js
+12
-9
@@ -9,7 +9,6 @@ const semver = require('semver');
9
const yargs = require('yargs');
10
const fs = require('fs');
11
12
-const INSTALL_PACKAGES = ['react-dom', 'react', 'react-test-renderer'];
12
const REGRESSION_FOLDER = 'build-regression';
13
14
const ROOT_PATH = join(__dirname, '..', '..');
@@ -23,6 +22,12 @@ const version = process.argv[2];
22
const shouldReplaceBuild = !!argv.replaceBuild;
23
24
async function downloadRegressionBuild() {
25
+ const reactVersion = semver.coerce(version).version;
26
+ const installPackages = ['react-dom', 'react', 'react-test-renderer'];
27
+ if (semver.gte(reactVersion, '16.3.0')) {
28
+ installPackages.push('react-is');
29
+ }
30
+
31
console.log(chalk.bold.white(`Downloading React v${version}\n`));
32
33
// Make build directory for temporary modules we're going to download
@@ -35,7 +40,7 @@ async function downloadRegressionBuild() {
40
await exec(`mkdir ${regressionBuildPath}`);
41
42
// Install all necessary React packages that have the same version
38
- const downloadPackagesStr = INSTALL_PACKAGES.reduce(
43
+ const downloadPackagesStr = installPackages.reduce(
44
(str, name) => `${str} ${name}@${version}`,
45
''
46
);
@@ -51,7 +56,7 @@ async function downloadRegressionBuild() {
56
57
// Remove all the packages that we downloaded in the original build folder
58
// so we can move the modules from the regression build over
54
- const removePackagesStr = INSTALL_PACKAGES.reduce(
59
+ const removePackagesStr = installPackages.reduce(
60
(str, name) => `${str} ${join(buildPath, name)}`,
61
''
62
);
@@ -63,12 +68,12 @@ async function downloadRegressionBuild() {
68
.join(' ')}\n`
69
)
70
);
66
- await exec(`rm -r ${removePackagesStr}`);
71
+ await exec(`rm -rf ${removePackagesStr}`);
72
73
// Move all packages that we downloaded to the original build folder
74
// We need to separately move the scheduler package because it might
75
// be called schedule
71
- const movePackageString = INSTALL_PACKAGES.reduce(
76
+ const movePackageString = installPackages.reduce(
77
(str, name) => `${str} ${join(regressionBuildPath, 'node_modules', name)}`,
78
''
79
);
@@ -80,9 +85,9 @@ async function downloadRegressionBuild() {
85
.join(' ')} to ${chalk.underline.blue(buildPath)}\n`
86
)
87
);
88
+ fs.mkdirSync(buildPath, {recursive: true});
89
await exec(`mv ${movePackageString} ${buildPath}`);
90
85
- const reactVersion = semver.coerce(version).version;
91
// For React versions earlier than 18.0.0, we explicitly scheduler v0.20.1, which
92
// is the first version that has unstable_mock, which DevTools tests need, but also
93
// has Scheduler.unstable_trace, which, although we don't use in DevTools tests
@@ -100,7 +105,7 @@ async function downloadRegressionBuild() {
105
);
106
} else {
107
console.log(chalk.white(`Downloading scheduler\n`));
103
- await exec(`rm -r ${join(buildPath, 'scheduler')}`);
108
+ await exec(`rm -rf ${join(buildPath, 'scheduler')}`);
109
await exec(
110
`mv ${join(
111
regressionBuildPath,
@@ -134,8 +139,6 @@ async function main() {
139
return;
140
}
141
await downloadRegressionBuild();
137
- } catch (e) {
138
- console.log(chalk.red(e));
142
} finally {
143
// We shouldn't remove the regression-build folder unless we're using
144
// it to replace the build folder