react/scripts/rollup/sync.js
Brian Vaughn 0887c7d56c
Fork React Native renderer into FB and OSS bundles (#12625)
* Added new "native-fb" and "native-fabric-fb" bundles.
* Split RN_DEV and RN_PROD bundle types into RN_OSS_DEV, RN_OSS_PROD, RN_FB_DEV, and RN_FB_PROD. (This is a bit redundant but it seemed the least intrusive way of supporting a forked feature flags file for these bundles.)
* Renamed FB_DEV and FB_PROD bundle types to be more explicitly for www (FB_WWW_DEV and FB_WWW_PROD)
* Removed Haste @providesModule headers from the RB-specific RN renderer bundles to avoid a duplicate name conflicts.
* Remove dynamic values from OSS RN feature flags. (Leave them in FB RN feature flags.)
* Updated the sync script(s) to account for new renderer type.
* Move ReactFeatureFlags.js shim to FB bundle only (since OSS bundle no longer needs dynamic values).
2018-04-18 13:16:50 -07:00

58 lines
1.5 KiB
JavaScript

'use strict';
const asyncCopyTo = require('./utils').asyncCopyTo;
const chalk = require('chalk');
const resolvePath = require('./utils').resolvePath;
const DEFAULT_FB_SOURCE_PATH = '~/fbsource/';
const DEFAULT_WWW_PATH = '~/www/';
const RELATIVE_RN_OSS_PATH = 'xplat/js/react-native-github/Libraries/Renderer/';
const RELATIVE_WWW_PATH = 'html/shared/react/';
async function doSync(buildPath, destPath) {
console.log(`${chalk.bgYellow.black(' SYNCING ')} React to ${destPath}`);
await asyncCopyTo(buildPath, destPath);
console.log(`${chalk.bgGreen.black(' SYNCED ')} React to ${destPath}`);
}
async function syncReactDom(buildPath, wwwPath) {
wwwPath = typeof wwwPath === 'string' ? wwwPath : DEFAULT_WWW_PATH;
if (wwwPath.charAt(wwwPath.length - 1) !== '/') {
wwwPath += '/';
}
const destPath = resolvePath(wwwPath + RELATIVE_WWW_PATH);
await doSync(buildPath, destPath);
}
async function syncReactNativeHelper(
buildPath,
fbSourcePath,
relativeDestPath
) {
fbSourcePath =
typeof fbSourcePath === 'string' ? fbSourcePath : DEFAULT_FB_SOURCE_PATH;
if (fbSourcePath.charAt(fbSourcePath.length - 1) !== '/') {
fbSourcePath += '/';
}
const destPath = resolvePath(fbSourcePath + relativeDestPath);
await doSync(buildPath, destPath);
}
async function syncReactNative(fbSourcePath) {
await syncReactNativeHelper(
'build/react-native',
fbSourcePath,
RELATIVE_RN_OSS_PATH
);
}
module.exports = {
syncReactDom,
syncReactNative,
};