Fix RN version string in builds (#29787)

The version was set for React but not the renderers
This commit is contained in:
Ricky
2024-06-06 14:07:16 -04:00
committed by GitHub
parent 29b1278790
commit 90499a730e
+48 -6
View File
@@ -168,12 +168,19 @@ function processStable(buildDir) {
);
}
const rnVersionString =
ReactVersion + '-native-fb-' + sha + '-' + dateString;
if (fs.existsSync(buildDir + '/facebook-react-native')) {
const versionString =
ReactVersion + '-native-fb-' + sha + '-' + dateString;
updatePlaceholderReactVersionInCompiledArtifacts(
buildDir + '/facebook-react-native',
versionString
rnVersionString
);
}
if (fs.existsSync(buildDir + '/react-native')) {
updatePlaceholderReactVersionInCompiledArtifactsFb(
buildDir + '/react-native',
rnVersionString
);
}
@@ -265,17 +272,24 @@ function processExperimental(buildDir, version) {
fs.writeFileSync(buildDir + '/facebook-www/VERSION_MODERN', versionString);
}
const rnVersionString = ReactVersion + '-native-fb-' + sha + '-' + dateString;
if (fs.existsSync(buildDir + '/facebook-react-native')) {
const versionString = ReactVersion + '-native-fb-' + sha + '-' + dateString;
updatePlaceholderReactVersionInCompiledArtifacts(
buildDir + '/facebook-react-native',
versionString
rnVersionString
);
// Also save a file with the version number
fs.writeFileSync(
buildDir + '/facebook-react-native/VERSION_NATIVE_FB',
versionString
rnVersionString
);
}
if (fs.existsSync(buildDir + '/react-native')) {
updatePlaceholderReactVersionInCompiledArtifactsFb(
buildDir + '/react-native',
rnVersionString
);
}
@@ -396,6 +410,34 @@ function updatePlaceholderReactVersionInCompiledArtifacts(
}
}
function updatePlaceholderReactVersionInCompiledArtifactsFb(
artifactsDirectory,
newVersion
) {
// Update the version of React in the compiled artifacts by searching for
// the placeholder string and replacing it with a new one.
const artifactFilenames = String(
spawnSync('grep', [
'-lr',
PLACEHOLDER_REACT_VERSION,
'--',
artifactsDirectory,
]).stdout
)
.trim()
.split('\n')
.filter(filename => filename.endsWith('.fb.js'));
for (const artifactFilename of artifactFilenames) {
const originalText = fs.readFileSync(artifactFilename, 'utf8');
const replacedText = originalText.replaceAll(
PLACEHOLDER_REACT_VERSION,
newVersion
);
fs.writeFileSync(artifactFilename, replacedText);
}
}
/**
* cross-platform alternative to `rsync -ar`
* @param {string} source