Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 25 additions & 34 deletions scripts/rollup/build-all-release-channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ function processStable(buildDir) {
);
}

const rnVersionString =
ReactVersion + '-native-fb-' + sha + '-' + dateString;
const rnVersionString = ReactVersion + '-native-fb-' + sha + '-' + dateString;
if (fs.existsSync(buildDir + '/facebook-react-native')) {
updatePlaceholderReactVersionInCompiledArtifacts(
buildDir + '/facebook-react-native',
Expand All @@ -231,9 +230,16 @@ function processStable(buildDir) {
}

if (fs.existsSync(buildDir + '/react-native')) {
updatePlaceholderReactVersionInCompiledArtifactsFb(
updatePlaceholderReactVersionInCompiledArtifacts(
buildDir + '/react-native',
rnVersionString
rnVersionString,
(filename) => filename.endsWith('.fb.js')
);

updatePlaceholderReactVersionInCompiledArtifacts(
buildDir + '/react-native',
ReactVersion,
(filename) => !filename.endsWith('.fb.js') && filename.endsWith('.js')
);
}

Expand Down Expand Up @@ -340,9 +346,16 @@ function processExperimental(buildDir, version) {
}

if (fs.existsSync(buildDir + '/react-native')) {
updatePlaceholderReactVersionInCompiledArtifactsFb(
updatePlaceholderReactVersionInCompiledArtifacts(
buildDir + '/react-native',
rnVersionString
rnVersionString,
(filename) => filename.endsWith('.fb.js')
);

updatePlaceholderReactVersionInCompiledArtifacts(
buildDir + '/react-native',
ReactVersion,
(filename) => !filename.endsWith('.fb.js') && filename.endsWith('.js')
);
}

Expand Down Expand Up @@ -437,38 +450,15 @@ function updatePackageVersions(

function updatePlaceholderReactVersionInCompiledArtifacts(
artifactsDirectory,
newVersion
newVersion,
filteringClosure
) {
// 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('.js'));

for (const artifactFilename of artifactFilenames) {
const originalText = fs.readFileSync(artifactFilename, 'utf8');
const replacedText = originalText.replaceAll(
PLACEHOLDER_REACT_VERSION,
newVersion
);
fs.writeFileSync(artifactFilename, replacedText);
if (filteringClosure == null) {
filteringClosure = filename => filename.endsWith('.js')
}
}

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',
Expand All @@ -479,7 +469,7 @@ function updatePlaceholderReactVersionInCompiledArtifactsFb(
)
.trim()
.split('\n')
.filter(filename => filename.endsWith('.fb.js'));
.filter(filteringClosure);

for (const artifactFilename of artifactFilenames) {
const originalText = fs.readFileSync(artifactFilename, 'utf8');
Expand All @@ -491,6 +481,7 @@ function updatePlaceholderReactVersionInCompiledArtifactsFb(
}
}


/**
* cross-platform alternative to `rsync -ar`
* @param {string} source
Expand Down
Loading