From 8c420efbf94de026c81163215cf354f62119cf9e Mon Sep 17 00:00:00 2001 From: PrathamLalwani Date: Sat, 11 Nov 2023 10:47:00 -0800 Subject: [PATCH 1/4] Added windows powershell syntax to build scripts --- package.json | 1 + packages/react-devtools-extensions/deploy.js | 18 +++++++++---- .../build-artifacts.js | 8 ++++-- scripts/rollup/build-all-release-channels.js | 27 ++++++++++++++----- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 488ce8a70136..91808a332c98 100644 --- a/package.json +++ b/package.json @@ -109,6 +109,7 @@ "build": "node ./scripts/rollup/build-all-release-channels.js", "build-combined": "echo 'build-combined is deprecated. yarn build instead.'", "build-for-devtools": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react/jsx,react-dom/index,react-dom/unstable_testing,react-dom/test-utils,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh,react-art --type=NODE && cp -r ./build/node_modules build/oss-experimental/", + "build-for-devtools-windows": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react/jsx,react-dom/index,react-dom/unstable_testing,react-dom/test-utils,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh,react-art --type=NODE -and xcopy /s /i build\\node_modules build\\oss-experimental/", "build-for-devtools-dev": "yarn build-for-devtools --type=NODE_DEV", "build-for-devtools-prod": "yarn build-for-devtools --type=NODE_PROD", "linc": "node ./scripts/tasks/linc.js", diff --git a/packages/react-devtools-extensions/deploy.js b/packages/react-devtools-extensions/deploy.js index 37d06e481789..642248698db9 100644 --- a/packages/react-devtools-extensions/deploy.js +++ b/packages/react-devtools-extensions/deploy.js @@ -5,7 +5,7 @@ const {exec, execSync} = require('child_process'); const {readFileSync, writeFileSync} = require('fs'); const {join} = require('path'); - +const isWindows = require('is-windows'); const main = async buildId => { const root = join(__dirname, buildId); const buildPath = join(root, 'build'); @@ -19,10 +19,18 @@ const main = async buildId => { stdio: 'inherit', }); - await exec(`cp ${join(root, 'now.json')} ${join(buildPath, 'now.json')}`, { - cwd: root, - }); - + if (isWindows()) { + await exec( + `copy ${join(root, 'now.json')} ${join(buildPath, 'now.json')}`, + { + cwd: root, + }, + ); + } else { + await exec(`cp ${join(root, 'now.json')} ${join(buildPath, 'now.json')}`, { + cwd: root, + }); + } const file = readFileSync(join(root, 'now.json')); const json = JSON.parse(file); const alias = json.alias[0]; diff --git a/scripts/release/build-release-locally-commands/build-artifacts.js b/scripts/release/build-release-locally-commands/build-artifacts.js index 65867052a04b..2a59b458fe5b 100644 --- a/scripts/release/build-release-locally-commands/build-artifacts.js +++ b/scripts/release/build-release-locally-commands/build-artifacts.js @@ -5,7 +5,7 @@ const {exec} = require('child-process-promise'); const {join} = require('path'); const {logPromise} = require('../utils'); - +const isWindows = require('is-windows'); const run = async ({cwd, dry, tempDirectory}) => { const defaultOptions = { cwd: tempDirectory, @@ -17,7 +17,11 @@ const run = async ({cwd, dry, tempDirectory}) => { const tempNodeModulesPath = join(tempDirectory, 'build', 'node_modules'); const buildPath = join(cwd, 'build'); - await exec(`cp -r ${tempNodeModulesPath} ${buildPath}`); + if (isWindows()) { + await exec(`xcopy /s /i ${tempNodeModulesPath} ${buildPath}`); + } else { + await exec(`cp -r ${tempNodeModulesPath} ${buildPath}`); + } }; module.exports = async params => { diff --git a/scripts/rollup/build-all-release-channels.js b/scripts/rollup/build-all-release-channels.js index 25f2652ecf56..68032c0d4145 100644 --- a/scripts/rollup/build-all-release-channels.js +++ b/scripts/rollup/build-all-release-channels.js @@ -8,7 +8,7 @@ const fse = require('fs-extra'); const {spawnSync} = require('child_process'); const path = require('path'); const tmp = require('tmp'); - +const isWindows = require('is-windows'); const { ReactVersion, stablePackages, @@ -74,7 +74,11 @@ if (process.env.CIRCLE_NODE_TOTAL) { buildForChannel('stable', '', ''); const stableDir = tmp.dirSync().name; crossDeviceRenameSync('./build', stableDir); - processStable(stableDir); + try { + processStable(stableDir); + } catch (err) { + console.log(err); + } buildForChannel('experimental', '', ''); const experimentalDir = tmp.dirSync().name; crossDeviceRenameSync('./build', experimentalDir); @@ -115,11 +119,20 @@ function processStable(buildDir) { if (fs.existsSync(buildDir + '/node_modules')) { // Identical to `oss-stable` but with real, semver versions. This is what // will get published to @latest. - spawnSync('cp', [ - '-r', - buildDir + '/node_modules', - buildDir + '/oss-stable-semver', - ]); + if (isWindows()) { + spawnSync('xcopy', [ + '/s', + '/i', + buildDir + '/node_modules', + buildDir + '/oss-stable-semver', + ]); + } else { + spawnSync('cp', [ + '-r', + buildDir + '/node_modules', + buildDir + '/oss-stable-semver', + ]); + } const defaultVersionIfNotFound = '0.0.0' + '-' + sha + '-' + dateString; const versionsMap = new Map(); From 5cc12e36b2bf78c76c097a344e53339226425d3f Mon Sep 17 00:00:00 2001 From: PrathamLalwani Date: Mon, 13 Nov 2023 13:35:17 -0800 Subject: [PATCH 2/4] added shelljs dependency and updated commands --- package.json | 4 ++-- packages/react-devtools-extensions/deploy.js | 18 ++++-------------- .../build-artifacts.js | 9 +++------ scripts/rollup/build-all-release-channels.js | 17 ++--------------- yarn.lock | 9 +++++++++ 5 files changed, 20 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index 91808a332c98..dcd766720639 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "jest-environment-jsdom": "^29.4.2", "jest-snapshot-serializer-raw": "^1.2.0", "minimatch": "^3.0.4", + "shelljs":"^0.8.5", "minimist": "^1.2.3", "mkdirp": "^0.5.1", "ncp": "^2.0.0", @@ -108,8 +109,7 @@ "scripts": { "build": "node ./scripts/rollup/build-all-release-channels.js", "build-combined": "echo 'build-combined is deprecated. yarn build instead.'", - "build-for-devtools": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react/jsx,react-dom/index,react-dom/unstable_testing,react-dom/test-utils,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh,react-art --type=NODE && cp -r ./build/node_modules build/oss-experimental/", - "build-for-devtools-windows": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react/jsx,react-dom/index,react-dom/unstable_testing,react-dom/test-utils,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh,react-art --type=NODE -and xcopy /s /i build\\node_modules build\\oss-experimental/", + "build-for-devtools": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react/jsx,react-dom/index,react-dom/unstable_testing,react-dom/test-utils,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh,react-art --type=NODE", "build-for-devtools-dev": "yarn build-for-devtools --type=NODE_DEV", "build-for-devtools-prod": "yarn build-for-devtools --type=NODE_PROD", "linc": "node ./scripts/tasks/linc.js", diff --git a/packages/react-devtools-extensions/deploy.js b/packages/react-devtools-extensions/deploy.js index 642248698db9..7f77b73a483e 100644 --- a/packages/react-devtools-extensions/deploy.js +++ b/packages/react-devtools-extensions/deploy.js @@ -5,7 +5,7 @@ const {exec, execSync} = require('child_process'); const {readFileSync, writeFileSync} = require('fs'); const {join} = require('path'); -const isWindows = require('is-windows'); +const shell = require('shelljs'); const main = async buildId => { const root = join(__dirname, buildId); const buildPath = join(root, 'build'); @@ -18,19 +18,9 @@ const main = async buildId => { }, stdio: 'inherit', }); - - if (isWindows()) { - await exec( - `copy ${join(root, 'now.json')} ${join(buildPath, 'now.json')}`, - { - cwd: root, - }, - ); - } else { - await exec(`cp ${join(root, 'now.json')} ${join(buildPath, 'now.json')}`, { - cwd: root, - }); - } + shell.pushd(root); + shell.cp(join(root, 'now.json'), join(buildPath, 'now.json')); + shell.popd(); const file = readFileSync(join(root, 'now.json')); const json = JSON.parse(file); const alias = json.alias[0]; diff --git a/scripts/release/build-release-locally-commands/build-artifacts.js b/scripts/release/build-release-locally-commands/build-artifacts.js index 2a59b458fe5b..0b4580482207 100644 --- a/scripts/release/build-release-locally-commands/build-artifacts.js +++ b/scripts/release/build-release-locally-commands/build-artifacts.js @@ -5,7 +5,8 @@ const {exec} = require('child-process-promise'); const {join} = require('path'); const {logPromise} = require('../utils'); -const isWindows = require('is-windows'); +const shell = require('shelljs'); + const run = async ({cwd, dry, tempDirectory}) => { const defaultOptions = { cwd: tempDirectory, @@ -17,11 +18,7 @@ const run = async ({cwd, dry, tempDirectory}) => { const tempNodeModulesPath = join(tempDirectory, 'build', 'node_modules'); const buildPath = join(cwd, 'build'); - if (isWindows()) { - await exec(`xcopy /s /i ${tempNodeModulesPath} ${buildPath}`); - } else { - await exec(`cp -r ${tempNodeModulesPath} ${buildPath}`); - } + shell.cp('-r', tempNodeModulesPath, buildPath); }; module.exports = async params => { diff --git a/scripts/rollup/build-all-release-channels.js b/scripts/rollup/build-all-release-channels.js index 68032c0d4145..0c976113e23e 100644 --- a/scripts/rollup/build-all-release-channels.js +++ b/scripts/rollup/build-all-release-channels.js @@ -8,7 +8,7 @@ const fse = require('fs-extra'); const {spawnSync} = require('child_process'); const path = require('path'); const tmp = require('tmp'); -const isWindows = require('is-windows'); +const shell = require('shelljs'); const { ReactVersion, stablePackages, @@ -119,20 +119,7 @@ function processStable(buildDir) { if (fs.existsSync(buildDir + '/node_modules')) { // Identical to `oss-stable` but with real, semver versions. This is what // will get published to @latest. - if (isWindows()) { - spawnSync('xcopy', [ - '/s', - '/i', - buildDir + '/node_modules', - buildDir + '/oss-stable-semver', - ]); - } else { - spawnSync('cp', [ - '-r', - buildDir + '/node_modules', - buildDir + '/oss-stable-semver', - ]); - } + shell.cp('-r', buildDir + '/node_modules', buildDir + '/oss-stable-semver'); const defaultVersionIfNotFound = '0.0.0' + '-' + sha + '-' + dateString; const versionsMap = new Map(); diff --git a/yarn.lock b/yarn.lock index 00876fed7cc7..d12f18713b20 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13871,6 +13871,15 @@ shelljs@0.7.7: interpret "^1.0.0" rechoir "^0.6.2" +shelljs@^0.8.5: + version "0.8.5" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.5.tgz#de055408d8361bed66c669d2f000538ced8ee20c" + integrity sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow== + dependencies: + glob "^7.0.0" + interpret "^1.0.0" + rechoir "^0.6.2" + shellwords@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" From 137b27b3e5efd507ac83c5ad7401a6a660ef7974 Mon Sep 17 00:00:00 2001 From: PrathamLalwani Date: Tue, 14 Nov 2023 04:44:26 -0800 Subject: [PATCH 3/4] removed try/catch and unnecessary commands --- packages/react-devtools-extensions/deploy.js | 2 -- scripts/rollup/build-all-release-channels.js | 6 +----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/react-devtools-extensions/deploy.js b/packages/react-devtools-extensions/deploy.js index 7f77b73a483e..046a1b4696c2 100644 --- a/packages/react-devtools-extensions/deploy.js +++ b/packages/react-devtools-extensions/deploy.js @@ -18,9 +18,7 @@ const main = async buildId => { }, stdio: 'inherit', }); - shell.pushd(root); shell.cp(join(root, 'now.json'), join(buildPath, 'now.json')); - shell.popd(); const file = readFileSync(join(root, 'now.json')); const json = JSON.parse(file); const alias = json.alias[0]; diff --git a/scripts/rollup/build-all-release-channels.js b/scripts/rollup/build-all-release-channels.js index 0c976113e23e..b7427d135bcc 100644 --- a/scripts/rollup/build-all-release-channels.js +++ b/scripts/rollup/build-all-release-channels.js @@ -74,11 +74,7 @@ if (process.env.CIRCLE_NODE_TOTAL) { buildForChannel('stable', '', ''); const stableDir = tmp.dirSync().name; crossDeviceRenameSync('./build', stableDir); - try { - processStable(stableDir); - } catch (err) { - console.log(err); - } + processStable(stableDir); buildForChannel('experimental', '', ''); const experimentalDir = tmp.dirSync().name; crossDeviceRenameSync('./build', experimentalDir); From 7e5577c1d07fd58956fbee2d04028f8ceee5318d Mon Sep 17 00:00:00 2001 From: PrathamLalwani Date: Wed, 15 Nov 2023 11:33:59 -0800 Subject: [PATCH 4/4] rearranged shelljs in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dcd766720639..375c74794067 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,6 @@ "jest-environment-jsdom": "^29.4.2", "jest-snapshot-serializer-raw": "^1.2.0", "minimatch": "^3.0.4", - "shelljs":"^0.8.5", "minimist": "^1.2.3", "mkdirp": "^0.5.1", "ncp": "^2.0.0", @@ -92,6 +91,7 @@ "rollup-plugin-prettier": "^4.1.1", "rollup-plugin-strip-banner": "^3.0.0", "semver": "^7.1.1", + "shelljs":"^0.8.5", "signedsource": "^2.0.0", "targz": "^1.0.1", "through2": "^3.0.1",