Skip to content

Commit c754755

Browse files
blakeffacebook-github-bot
authored andcommitted
CLI supports ordering of tasks
Summary: This gives Frameworks more control in selecting specific tasks and integrating the return types data in their UI. For example piping `stdout` to the user or using packages like [Listr2](https://www.npmjs.com/package/listr2) to run tasks in parallel and show progress. The ordering is suggestive (but also enforced by some assertions). Frameworks are free to do what they want. The order was implicit in the previous data structure with lists of Tasks, but made it difficult to tap into each async task. I've also had to rework how we transpile the code if directly executed from the monorepo. This keeps our: - flow types valid, - allows the core-cli-utils package to be built (to generate TypeScript types and a valid npm module), and - allows direct transpiled execution as a yarn script. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D56242487 fbshipit-source-id: a1a18f14a4aef53a98770462c8ebdef4111f0ab4
1 parent 2168e3f commit c754755

File tree

26 files changed

+314
-173
lines changed

26 files changed

+314
-173
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = {
2424
// overriding the JS config from @react-native/eslint-config to ensure
2525
// that we use hermes-eslint for all js files
2626
{
27-
files: ['*.js', '*.js.flow'],
27+
files: ['*.js', '*.js.flow', '*.jsx'],
2828
parser: 'hermes-eslint',
2929
rules: {
3030
// These rules are not required with hermes-eslint

packages/community-cli-plugin/src/commands/start/runServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export type StartCommandArgs = {
3838
https?: boolean,
3939
maxWorkers?: number,
4040
key?: string,
41-
platforms?: string[],
41+
platforms: string[],
4242
port?: number,
4343
resetCache?: boolean,
4444
sourceExts?: string[],

packages/core-cli-utils/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
"name": "@react-native/core-cli-utils",
33
"version": "0.75.0-main",
44
"description": "React Native CLI library for Frameworks to build on",
5-
"main": "./src/index.js",
5+
"main": "./src/index.flow.js",
66
"license": "MIT",
77
"repository": {
88
"type": "git",
99
"url": "git+https://github.com/facebook/react-native.git",
1010
"directory": "packages/core-cli-utils"
1111
},
1212
"exports": {
13-
".": "./src/index.js",
13+
".": "./src/index.flow.js",
1414
"./package.json": "./package.json",
1515
"./version.js": "./src/public/version.js"
1616
},
17-
"types": "./dist/index.d.ts",
17+
"types": "./dist/index.flow.d.ts",
1818
"homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/core-cli-utils#readme",
1919
"keywords": [
2020
"cli-utils",
@@ -25,8 +25,8 @@
2525
"node": ">=18"
2626
},
2727
"files": [
28-
"dist"
28+
"src"
2929
],
3030
"dependencies": {},
3131
"devDependencies": {}
32-
}
32+
}

packages/core-cli-utils/src/index.js

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
* @oncall react_native
9+
*/
10+
11+
// Should only used when called in the monorepo when we don't want to use the `yarn run build`
12+
// step to transpile to project. When used as a vanilla npm package, it should be built and
13+
// exported with `dist/index.flow.js` as main.
14+
//
15+
// The reason for this workaround is that flow-api-translator can't understand ESM and CJS style
16+
// exports in the same file. Throw in a bit of Flow in the mix and it all goes to hell.
17+
//
18+
// See packages/helloworld/cli.js for an example of how to swap this out in the monorepo.
19+
if (process.env.BUILD_EXCLUDE_BABEL_REGISTER == null) {
20+
require('../../../scripts/build/babel-register').registerForMonorepo();
21+
}
22+
23+
module.exports = require('./index.flow.js');

packages/core-cli-utils/src/private/android.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,8 @@ type AndroidBuild = {
2424
gradleArgs?: Array<string>,
2525
};
2626

27-
async function gradle(
28-
cwd: string,
29-
...args: string[]
30-
): ReturnType<typeof execa> {
27+
function gradle(cwd: string, ...args: string[]): ExecaPromise {
3128
const gradlew = isWindows ? 'gradlew.bat' : './gradlew';
32-
// $FlowFixMe[incompatible-return] Mismatch between flow and TypeScript types
3329
return execa(gradlew, args, {
3430
cwd,
3531
stdio: 'inherit',

packages/core-cli-utils/src/private/apple.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type AppleInstallApp = {
3939
// `xcrun simctl list devices`
4040
device: string,
4141
appPath: string,
42+
bundleId: string,
4243
...AppleOptions,
4344
};
4445

packages/core-cli-utils/src/private/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type PathCheckResult = {
4141
export function isOnPath(dep: string, description: string): PathCheckResult {
4242
const cmd = isWindows ? ['where', [dep]] : ['command', ['-v', dep]];
4343
try {
44+
const args = isWindows ? ['where', [dep]] : ['command', ['-v', dep]];
4445
return {
4546
dep,
4647
description,

packages/helloworld/.gitignore

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# OSX
2-
#
32
.DS_Store
43

54
# Xcode
6-
#
75
build/
86
*.pbxuser
97
!default.pbxuser
@@ -23,7 +21,6 @@ DerivedData
2321
**/.xcode.env.local
2422

2523
# Android/IntelliJ
26-
#
2724
build/
2825
.idea
2926
.gradle
@@ -35,36 +32,20 @@ local.properties
3532
!debug.keystore
3633

3734
# node.js
38-
#
3935
node_modules/
4036
npm-debug.log
4137
yarn-error.log
4238

43-
# fastlane
44-
#
45-
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
46-
# screenshots whenever they are needed.
47-
# For more information about the recommended setup visit:
48-
# https://docs.fastlane.tools/best-practices/source-control/
49-
50-
**/fastlane/report.xml
51-
**/fastlane/Preview.html
52-
**/fastlane/screenshots
53-
**/fastlane/test_output
54-
5539
# Bundle artifact
5640
*.jsbundle
5741

5842
# Ruby / CocoaPods
59-
**/Pods/
60-
/vendor/bundle/
43+
ios/Pods/
44+
vendor/bundle/
6145

6246
# Temporary files created by Metro to check the health of the file watcher
6347
.metro-health-check*
6448

65-
# testing
66-
/coverage
67-
6849
# Yarn
6950
.yarn/*
7051
!.yarn/patches
File renamed without changes.

0 commit comments

Comments
 (0)