mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fix RN version string in builds (#29787)
The version was set for React but not the renderers
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user