From 5ee72dcd821e1706a26a24d27feb9bbb9bde3b90 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Wed, 30 Aug 2017 09:38:14 -0700 Subject: [PATCH] Add --sync-www flag to build script (#10571) --- scripts/rollup/build.js | 4 ++++ scripts/rollup/sync.js | 41 ++++++++++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index a4d3151fea..decdd5db2a 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -18,6 +18,7 @@ const Bundles = require('./bundles'); const propertyMangleWhitelist = require('./mangle').propertyMangleWhitelist; const sizes = require('./plugins/sizes-plugin'); const Stats = require('./stats'); +const syncReactDom = require('./sync').syncReactDom; const syncReactNative = require('./sync').syncReactNative; const Packaging = require('./packaging'); const Header = require('./header'); @@ -40,6 +41,7 @@ const requestedBundleNames = (argv._[0] || '') .split(',') .map(type => type.toLowerCase()); const syncFbsource = argv['sync-fbsource']; +const syncWww = argv['sync-www']; // used for when we property mangle with uglify/gcc const mangleRegex = new RegExp( @@ -514,6 +516,8 @@ rimraf('build', () => { tasks.push(() => syncReactNative(join('build', 'react-native'), syncFbsource) ); + } else if (syncWww) { + tasks.push(() => syncReactDom(join('build', 'facebook-www'), syncWww)); } // rather than run concurently, opt to run them serially // this helps improve console/warning/error output diff --git a/scripts/rollup/sync.js b/scripts/rollup/sync.js index d5563c8249..0e44ad3ea9 100644 --- a/scripts/rollup/sync.js +++ b/scripts/rollup/sync.js @@ -5,7 +5,32 @@ const chalk = require('chalk'); const resolvePath = require('./utils').resolvePath; const DEFAULT_FB_SOURCE_PATH = '~/fbsource/'; +const DEFAULT_WWW_PATH = '~/www/'; const RELATIVE_RN_PATH = 'xplat/js/react-native-github/Libraries/Renderer/'; +const RELATIVE_WWW_PATH = 'html/shared/react/'; + +function doSync(buildPath, destPath) { + console.log(`${chalk.bgYellow.black(' SYNCING ')} React to ${destPath}`); + + const promise = asyncCopyTo(buildPath, destPath); + promise.then(() => { + console.log(`${chalk.bgGreen.black(' SYNCED ')} React to ${destPath}`); + }); + + return promise; +} + +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); + + return doSync(buildPath, destPath); +} function syncReactNative(buildPath, fbSourcePath) { fbSourcePath = typeof fbSourcePath === 'string' @@ -18,20 +43,10 @@ function syncReactNative(buildPath, fbSourcePath) { const destPath = resolvePath(fbSourcePath + RELATIVE_RN_PATH); - console.log( - `${chalk.bgYellow.black(' SYNCING ')} ReactNative to ${destPath}` - ); - - const promise = asyncCopyTo(buildPath, destPath); - promise.then(() => { - console.log( - `${chalk.bgGreen.black(' SYNCED ')} ReactNative to ${destPath}` - ); - }); - - return promise; + return doSync(buildPath, destPath); } module.exports = { - syncReactNative: syncReactNative, + syncReactDom, + syncReactNative, };