Skip to content

Commit

Permalink
Merge branch 'react-native-community:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
arushikesarwani94 committed Aug 22, 2023
2 parents 14df175 + 2204d35 commit 3b472af
Show file tree
Hide file tree
Showing 91 changed files with 3,043 additions and 3,170 deletions.
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ labels: 'bug report'

## Environment

<!-- Run `react-native info` in your terminal and paste its contents here. -->
<!-- Run `npx react-native info` in your terminal and paste its contents here. -->

## Description

<!--
Describe your issue in detail. Include screenshots if needed. If this is a regression, let us know.
-->


## Reproducible Demo

<!--
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: "master"
ref: "main"
persist-credentials: false

- name: "Setup Node v16"
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
Expand All @@ -29,9 +29,9 @@ jobs:
matrix:
node-version: [18, 20]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
Expand All @@ -48,7 +48,7 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-2019]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
Expand All @@ -70,7 +70,7 @@ jobs:
uses: microsoft/setup-msbuild@v1.3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ All work on React Native CLI happens directly on GitHub. Contributors send pull
> Please make sure the version of React Native matches the one present in devDependencies of the CLI. Otherwise, you may get unexpected errors.
_Note: you must use the `--watchFolders` flag with the `start` command when testing the CLI with `yarn link` like this. Otherwise Metro can't find the symlinked folder and this may result in errors such as `ReferenceError: SHA-1 for file ... is not computed`. If you are experiencing this error while using Release configuration, please add `watchFolders: ["path/to/cloned/cli/"]` to your `metro.config.js` file._

### Setup

Because of a modular design of the CLI, we recommend developing using symbolic links to its packages. This way you can use it seamlessly in the tested project, as you'd use the locally installed CLI. Here's what you need to run in the terminal:
Expand All @@ -31,7 +32,7 @@ And then:

```sh
cd /my/new/react-native/project/
yarn link "@react-native-community/cli-platform-ios" "@react-native-community/cli-platform-android" "@react-native-community/cli" "@react-native-community/cli-server-api" "@react-native-community/cli-types" "@react-native-community/cli-tools" "@react-native-community/cli-debugger-ui" "@react-native-community/cli-hermes" "@react-native-community/cli-plugin-metro" "@react-native-community/cli-clean" "@react-native-community/cli-doctor" "react-native-community/cli-config"
yarn link "@react-native-community/cli-platform-ios" "@react-native-community/cli-platform-android" "@react-native-community/cli" "@react-native-community/cli-server-api" "@react-native-community/cli-types" "@react-native-community/cli-tools" "@react-native-community/cli-debugger-ui" "@react-native-community/cli-hermes" "@react-native-community/cli-plugin-metro" "@react-native-community/cli-clean" "@react-native-community/cli-doctor" "@react-native-community/cli-config"
```

Once you're done with testing and you'd like to get back to regular setup, run `yarn unlink` instead of `yarn link` from above command. Then `yarn install --force`.
Expand Down Expand Up @@ -66,7 +67,7 @@ First make sure you have RN repo checked out and CLI repo checked out and built.

1. Check out `react-native` repo. Then update template in local `react-native/template/package.json`, replacing dependency version of `react-native` with the absolute path of the react native repo, for example: "react-native": "file:///Users/username/react-native" (you can find the absolute path using `pwd` command)

1. Go back up and create a new RN project: `node ./cli/packages/cli/build/bin.js init --template=file:///path/to/local/react-native RNTestProject`
1. Go back up and create a new RN project: `node ./cli/packages/cli/build/bin.js init --template=file:///path/to/local/react-native/RNTestProject`

1. To work with android, update gradle config in the newly created project following the second part of [Christoph's instructions](https://gist.github.com/cpojer/38a91f90614f35769e88410e3a387b48)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ This monorepository contains tools and helpers for React Native projects in form
Run the following command in your terminal prompt:

```sh
npx react-native init MyApp
npx react-native@latest init MyApp
```

## Usage in an existing React Native project
Expand Down
4 changes: 3 additions & 1 deletion __e2e__/__snapshots__/config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ exports[`shows up current config without unnecessary output 1`] = `
"android": {
"sourceDir": "<<REPLACED_ROOT>>/TestProject/android",
"appName": "app",
"packageName": "com.testproject"
"packageName": "com.testproject",
"applicationId": "com.testproject",
"mainActivity": ".MainActivity"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
[
require.resolve('@babel/preset-env'),
{
targets: {node: '16'},
targets: {node: '18'},
useBuiltIns: 'entry',
corejs: '2.x',
},
Expand Down
14 changes: 7 additions & 7 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ React Native CLI comes with following commands:
- [`build-ios`](/packages/cli-platform-ios/README.md#build-ios)
- [`start`](/packages/cli-plugin-metro/README.md#start)
- [`upgrade`](#upgrade)
- [`profile-hermes`](/packages/cli-platform-android/README.md#profile-hermes)
- [`profile-hermes`](/packages/cli-hermes/README.md#profile-hermes)

### `init`

Expand All @@ -28,7 +28,7 @@ React Native CLI comes with following commands:
Usage (with `npx`):

```sh
npx react-native init <projectName> [options]
npx react-native@latest init <projectName> [options]
```

Initialize a new React Native project named <projectName> in a directory of the same name. You can find out more use cases in [init docs](./init.md).
Expand Down Expand Up @@ -59,10 +59,10 @@ Uses a custom template. Accepts following template sources:
Example:

```sh
npx react-native init MyApp --template react-native-custom-template
npx react-native init MyApp --template file:///Users/name/template-path
npx react-native init MyApp --template file:///Users/name/template-name-1.0.0.tgz
npx react-native init MyApp --template Esemesek/react-native-new-template
npx react-native@latest init MyApp --template react-native-custom-template
npx react-native@latest init MyApp --template file:///Users/name/template-path
npx react-native@latest init MyApp --template file:///Users/name/template-name-1.0.0.tgz
npx react-native@latest init MyApp --template Esemesek/react-native-new-template
```

A template is any directory or npm package that contains a `template.config.js` file in the root with the following type:
Expand Down Expand Up @@ -112,7 +112,7 @@ Create project with custom package name for Android and bundle identifier for iO
Usage:

```sh
react-native upgrade
npx react-native upgrade
```

This command generates a relevant link to the [Upgrade Helper](https://react-native-community.github.io/upgrade-helper/) to help you upgrade manually.
2 changes: 1 addition & 1 deletion docs/healthChecks.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Health Check Plugins

Plugins can be used to extend the health checks that `react-native doctor` runs. This can be used to add additional checks for out of tree platforms, or other checks that are specific to a community module.
Plugins can be used to extend the health checks that `npx react-native doctor` runs. This can be used to add additional checks for out of tree platforms, or other checks that are specific to a community module.

See [`Plugins`](./plugins.md) for information about how plugins work.

Expand Down
16 changes: 8 additions & 8 deletions docs/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ There are couple of ways to initialize new React Native projects.

### For `react-native@0.60.0` or greater

#### Using `npx` utility:
#### Using `npx` utility

```sh
npx react-native init ProjectName
npx react-native@latest init ProjectName
```

> Note: If you have both `yarn` and `npm` installed on your machine, React Native CLI will always try to use `yarn`, so even if you use `npx` utility, only `react-native` executable will be installed using `npm` and the rest of the work will be delegated to `yarn`. You can force usage of `npm` adding `--npm` flag to the command.
> Note: for Yarn users, `yarn dlx` command similar to `npx` will be featured in Yarn 2.0: <https://github.com/yarnpkg/berry/pull/40> so we’ll be able to use it in a similar fashion.
#### Installing `react-native` and invoking `init` command:
#### Installing `react-native` and invoking `init` command

```sh
yarn init && yarn add react-native && yarn react-native init ProjectName
```

#### Initializing project with custom version of `react-native`:
#### Initializing project with custom version of `react-native`

```sh
# This will use the latest init command but will install react-native@VERSION and use its template
npx react-native init ProjectName --version ${VERSION}
npx react-native@latest init ProjectName --version ${VERSION}

# This will use init command from react-native@VERSION
npx react-native@${VERSION} init ProjectName
Expand All @@ -47,7 +47,7 @@ For all available options, please check [Yarn documentation](https://classic.yar

```sh
# This will initialize new project using template from `react-native-template-typescript` package
npx react-native init ProjectName --template ${TEMPLATE_NAME}
npx react-native@latest init ProjectName --template ${TEMPLATE_NAME}

# This will initialize new project using init command from react-native@VERSION but will use a custom template
npx react-native@${VERSION} init ProjectName --template ${TEMPLATE_NAME}
Expand All @@ -56,7 +56,7 @@ npx react-native@${VERSION} init ProjectName --template ${TEMPLATE_NAME}
You can force usage of `npm` if you have both `yarn` and `npm` installed on your machine:

```sh
npx react-native init ProjectName --npm
npx react-native@latest init ProjectName --npm
```

### For older `react-native` versions
Expand All @@ -65,7 +65,7 @@ Using legacy `react-native-cli` package:

```sh
yarn global add react-native-cli
react-native init ProjectName
npx react-native@latest init ProjectName
```

> Note: It is not recommended, but you can also use legacy `react-native-cli` package to initialize projects using latest `react-native` versions.
Expand Down
1 change: 1 addition & 0 deletions docs/platforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ type AndroidProjectConfig = {
sourceDir: string;
appName: string;
packageName: string;
mainActivity: string;
dependencyConfiguration?: string;
watchModeCommandParams: string;
};
Expand Down
6 changes: 3 additions & 3 deletions docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Plugin is a JavaScript package that extends built-in React Native CLI features. It can provide an array of additional commands to run or platforms to target.

For example, `react-native-windows` package is a plugin that provides `react-native run-windows` command and `windows` platform.
For example, `react-native-windows` package is a plugin that provides `run-windows` command and `windows` platform.

Details of this particular integration as well as how to provide an additional platform for React Native were described in a [`dedicated section`](./platforms.md) about platforms.

Expand All @@ -21,13 +21,13 @@ module.exports = {
};
```

> Above is an example of a plugin that exports a command named `foo-command` that can be executed with `react-native foo-command` and logs "It worked" and exits.
> Above is an example of a plugin that exports a command named `foo-command` that can be executed with `npx react-native foo-command` and logs "It worked" and exits.
At the startup, React Native CLI reads configuration from all dependencies listed in `package.json` and reduces them into a single configuration.

At the end, an array of commands concatenated from all plugins is passed on to the CLI to be loaded after built-in commands.

> See [`healthChecks`](./healthChecks.md) for information on how plugins can provide additional health checks for `react-native doctor`.
> See [`healthChecks`](./healthChecks.md) for information on how plugins can provide additional health checks for `npx react-native doctor`.
## Command interface

Expand Down
4 changes: 2 additions & 2 deletions docs/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ multiple `Podfile` files in your project.

#### project.ios.watchModeCommandParams

Array of strings that will be passed to the `react-native run-ios` command when running in watch mode.
Array of strings that will be passed to the `npx react-native run-ios` command when running in watch mode.

#### project.ios.unstable_reactLegacyComponentNames

Expand Down Expand Up @@ -122,7 +122,7 @@ See [`dependency.platforms.android.configuration`](dependencies.md#platformsandr

#### project.android.watchModeCommandParams

Array of strings that will be passed to the `react-native run-android` command when running in watch mode.
Array of strings that will be passed to the `npx react-native run-android` command when running in watch mode.

#### project.android.unstable_reactLegacyComponentNames

Expand Down
6 changes: 5 additions & 1 deletion jest/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ function handleTestFailure(
result: {[key: string]: any},
args: string[] | undefined,
) {
if (!options.expectedFailure && result.code !== 0) {
if (
!options.expectedFailure &&
result.code !== undefined &&
result.code !== 0
) {
console.log(`Running ${cmd} command failed for unexpected reason. Here's more info:
${chalk.bold('cmd:')} ${cmd}
${chalk.bold('options:')} ${JSON.stringify(options)}
Expand Down
6 changes: 3 additions & 3 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "12.0.0-alpha.7",
"version": "12.0.0-alpha.11",
"npmClient": "yarn",
"useWorkspaces": true,
"exact": true
"exact": true,
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@react-native-community/eslint-config": "^2.0.0",
"@types/glob": "^7.1.1",
"@types/jest": "^26.0.15",
"@types/node": "^16.0.0",
"@types/node": "^18.0.0",
"@types/node-fetch": "^2.3.7",
"@types/readable-stream": "^2.3.0",
"@types/rimraf": "^3.0.2",
Expand All @@ -49,17 +49,17 @@
"jest": "^26.6.2",
"jest-circus": "^26.6.2",
"jest-snapshot-serializer-raw": "^1.1.0",
"lerna": "^4.0.0",
"lerna": "^7.1.3",
"lint-staged": "^13.1.0",
"metro-memory-fs": "0.77.0",
"metro-memory-fs": "0.78.0",
"micromatch": "^4.0.4",
"rimraf": "^3.0.2",
"slash": "^3.0.0",
"string-length": "^2.0.0",
"typescript": "^4.9.5"
},
"resolutions": {
"@types/node": "^16.0.0"
"@types/node": "^18.0.0"
},
"lint-staged": {
"./packages/**/*.ts": [
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-clean/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ yarn add @react-native-community/cli-clean
Usage:

```sh
react-native clean
npx react-native clean
```

Cleans caches. Commonly used to ensure build failures are not due to stale cache. By default, it will prompt which caches to purge, with Watchman and Metro already checked. To omit interactive prompt (e.g. in scripts), please use `--include` flag.
Expand Down
10 changes: 5 additions & 5 deletions packages/cli-clean/package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"name": "@react-native-community/cli-clean",
"version": "12.0.0-alpha.7",
"version": "12.0.0-alpha.11",
"license": "MIT",
"main": "build/index.js",
"publishConfig": {
"access": "public"
},
"types": "build/index.d.ts",
"dependencies": {
"@react-native-community/cli-tools": "12.0.0-alpha.7",
"@react-native-community/cli-tools": "12.0.0-alpha.11",
"chalk": "^4.1.2",
"execa": "^5.0.0",
"prompts": "^2.4.0"
"prompts": "^2.4.2"
},
"files": [
"build",
"!*.d.ts",
"!*.map"
],
"devDependencies": {
"@react-native-community/cli-types": "12.0.0-alpha.7",
"@types/prompts": "^2.0.9"
"@react-native-community/cli-types": "12.0.0-alpha.11",
"@types/prompts": "^2.4.4"
},
"homepage": "https://github.com/react-native-community/cli/tree/main/packages/cli-clean",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ yarn add @react-native-community/cli-config
Usage:

```sh
react-native config
npx react-native config
```

Output project and dependencies configuration in JSON format to stdout. Used by [autolinking](./../../docs/autolinking.md).
Loading

0 comments on commit 3b472af

Please sign in to comment.