@samitouri / QOS-React / commits / e4b4aac2a0

Fix existing usage of names/type in build command (#30450)

https://github.com/facebook/react/pull/30422 broke existing build shortcuts. Revert the usage of `names` (`_`) and `type` args. `yarn build-for-devtools` / `yarn build-for-devtools-dev` / `yarn build-for-devtools-prod` should all work again. Moved the bundleType documentation into description so they can be fuzzy matched. But a build like `yarn build --type FB_WWW_PROD` still works when matched exactly. There's probably a better way to document the positional `names` arg in the `--help` command, but didn't see it when browsing the yargs docs so let's just fix the existing builds for now. Now: ``` % yarn build --help yarn run v1.22.19 $ node ./scripts/rollup/build-all-release-channels.js --help Options: --help Show help [boolean] --version Show version number [boolean] --releaseChannel, -r Build the given release channel. [string] [choices: "experimental", "stable"] --index, -i Worker id. [number] --total, -t Total number of workers. [number] --ci Run tests in CI [choices: "circleci", "github"] --type Build the given bundle type. (NODE_ES2015,ESM_DEV,ESM_PROD,NODE_DEV,NODE_PROD,NODE_PROFILING,BUN_DEV,BUN_PROD,FB_WWW_DEV,FB_WWW_PROD,FB_WWW_PROFILING,RN_OSS_DE V,RN_OSS_PROD,RN_OSS_PROFILING,RN_FB_DEV,RN_FB_PROD,RN_FB_PROFILING,BROWSER_SCRIPT) [string] --pretty Force pretty output. [boolean] --sync-fbsource Include to sync build to fbsource. [string] --sync-www Include to sync build to www. [string] --unsafe-partial Do not clean ./build first. ```

Jack Pope committed Jul 25, 2024 at 07:44 UTC e4b4aac2a01b53f8151ca85148873096368a7de2
2 files changed +12 -12
scripts/rollup/build-all-release-channels.js
+5 -9
@@ -80,16 +80,12 @@ const argv = yargs.wrap(yargs.terminalWidth()).options({
80 type: 'choices',
81 choices: ['circleci', 'github'],
82 },
83 - bundle: {
84 - describe: 'Build the given bundle type.',
83 + type: {
84 + describe: `Build the given bundle type. (${Object.values(
85 + Bundles.bundleTypes
86 + )})`,
87 requiresArg: false,
86 - type: 'choices',
87 - choices: [...Object.values(Bundles.bundleTypes)],
88 - },
89 - names: {
90 - describe: 'Build for matched bundle names. Example: "react-test,index.js".',
91 - requiresArg: false,
92 - type: 'array',
88 + type: 'string',
89 },
90 pretty: {
91 describe: 'Force pretty output.',
scripts/rollup/build.js
+7 -3
@@ -84,11 +84,15 @@ function parseRequestedNames(names, toCase) {
84 }
85 return result;
86 }
87 -const argvType = Array.isArray(argv.bundle) ? argv.bundle : [argv.bundle];
88 -const requestedBundleTypes = argv.bundle ? argvType : [];
87 +const argvType = Array.isArray(argv.type) ? argv.type : [argv.type];
88 +const requestedBundleTypes = parseRequestedNames(
89 + argv.type ? argvType : [],
90 + 'uppercase'
91 +);
92
93 +const names = argv._;
94 const requestedBundleNames = parseRequestedNames(
91 - argv.names ? argv.names : [],
95 + names ? names : [],
96 'lowercase'
97 );
98 const forcePrettyOutput = argv.pretty;