@samitouri / QOS-React / commits / 90499a730e

Fix RN version string in builds (#29787)

The version was set for React but not the renderers

Ricky committed Jun 6, 2024 at 14:07 UTC 90499a730ed53c29c2321faaf19e77b4ebeeada4
1 file changed +48 -6
scripts/rollup/build-all-release-channels.js
+48 -6
@@ -168,12 +168,19 @@ function processStable(buildDir) {
168 );
169 }
170
171 + const rnVersionString =
172 + ReactVersion + '-native-fb-' + sha + '-' + dateString;
173 if (fs.existsSync(buildDir + '/facebook-react-native')) {
172 - const versionString =
173 - ReactVersion + '-native-fb-' + sha + '-' + dateString;
174 updatePlaceholderReactVersionInCompiledArtifacts(
175 buildDir + '/facebook-react-native',
176 - versionString
176 + rnVersionString
177 + );
178 + }
179 +
180 + if (fs.existsSync(buildDir + '/react-native')) {
181 + updatePlaceholderReactVersionInCompiledArtifactsFb(
182 + buildDir + '/react-native',
183 + rnVersionString
184 );
185 }
186
@@ -265,17 +272,24 @@ function processExperimental(buildDir, version) {
272 fs.writeFileSync(buildDir + '/facebook-www/VERSION_MODERN', versionString);
273 }
274
275 + const rnVersionString = ReactVersion + '-native-fb-' + sha + '-' + dateString;
276 if (fs.existsSync(buildDir + '/facebook-react-native')) {
269 - const versionString = ReactVersion + '-native-fb-' + sha + '-' + dateString;
277 updatePlaceholderReactVersionInCompiledArtifacts(
278 buildDir + '/facebook-react-native',
272 - versionString
279 + rnVersionString
280 );
281
282 // Also save a file with the version number
283 fs.writeFileSync(
284 buildDir + '/facebook-react-native/VERSION_NATIVE_FB',
278 - versionString
285 + rnVersionString
286 + );
287 + }
288 +
289 + if (fs.existsSync(buildDir + '/react-native')) {
290 + updatePlaceholderReactVersionInCompiledArtifactsFb(
291 + buildDir + '/react-native',
292 + rnVersionString
293 );
294 }
295
@@ -396,6 +410,34 @@ function updatePlaceholderReactVersionInCompiledArtifacts(
410 }
411 }
412
413 +function updatePlaceholderReactVersionInCompiledArtifactsFb(
414 + artifactsDirectory,
415 + newVersion
416 +) {
417 + // Update the version of React in the compiled artifacts by searching for
418 + // the placeholder string and replacing it with a new one.
419 + const artifactFilenames = String(
420 + spawnSync('grep', [
421 + '-lr',
422 + PLACEHOLDER_REACT_VERSION,
423 + '--',
424 + artifactsDirectory,
425 + ]).stdout
426 + )
427 + .trim()
428 + .split('\n')
429 + .filter(filename => filename.endsWith('.fb.js'));
430 +
431 + for (const artifactFilename of artifactFilenames) {
432 + const originalText = fs.readFileSync(artifactFilename, 'utf8');
433 + const replacedText = originalText.replaceAll(
434 + PLACEHOLDER_REACT_VERSION,
435 + newVersion
436 + );
437 + fs.writeFileSync(artifactFilename, replacedText);
438 + }
439 +}
440 +
441 /**
442 * cross-platform alternative to `rsync -ar`
443 * @param {string} source