Commit Graph

6 Commits

Author SHA1 Message Date
Alex Hunt 196b3f9ef9 Improve start command interactive behaviour (#39544)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39544

Misc improvements to `npx react-native start` interactive behaviour:

- Attaches key handlers on Metro `initialize_done` event — printing key command info earlier (once the server starts listening to bundle requests).
- Shutdown behaviour:
    - Awaits closing of Metro's HTTP server.
    - Pauses key listener while awaiting shutdown (dependency on `cli-tools` `addInteractionListener` dropped).
    - Now observes `ctrl+d` (`ctrl+z` pause behaviour removed).
- Updates reload handler message to 'Reloading connected app(s)...' (since ).
- Adds newline below key commands printout (even spacing).

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D49422206

fbshipit-source-id: 8963b22ddb182df7a1116906fc63cc65bfe982fc
2023-09-20 03:47:13 -07:00
Alex Hunt 13eda31d43 Simplify occupied port handling in start command (#39078)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39078

Simplifies and hardens behaviour for detecting other processes / dev server instances when running `react-native start`.

- New flow:
    - Exits with error message if port is taken by another process (*no longer suggests next port*).
    - Exits with info message if port is taken by another instance of this dev server (**unchanged**).
    - Continues if result unknown.
    - *(No longer logs dedicated message for another RN server running in a different project root.)*
- This now checks if the TCP port is in use before attempting an HTTP fetch.

Previous behaviour: [`handlePortUnavailable`](https://github.com/react-native-community/cli/blob/734222118707fff41c71463528e4e0c227b31cc6/packages/cli-tools/src/handlePortUnavailable.ts#L8). This decouples us from some lower-level `react-native-community/cli-tools` utils, which remain reused by the `android` and `ios` commands.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D48433285

fbshipit-source-id: 7056001d5fe2f90faf52143f2777c9e2bdf0646e
2023-08-22 12:56:19 -07:00
Alex Hunt c82cf64a22 Move metro-inspector-proxy into dev-middleware (#39045)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39045

## Context

RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641

## Changes

- Relocates `metro-inspector-proxy` source from the Metro repo into the React Native repo as part of the `react-native/dev-middleware` package.
    - Drops the `runInspectorProxy` entry point.
- Attaches the Inspector Proxy to the `createDevMiddleware()` API as the new integration point for this functionality.
- Documents migrated endpoints + usage of `createDevMiddleware()` in README.

Changelog: [Internal]
Metro changelog: None (`metro-inspector-proxy` is now an internal component of `react-native`, covered in the [release notes for 0.78.1](https://github.com/facebook/metro/releases/tag/v0.78.1))

Reviewed By: motiz88, blakef

Differential Revision: D48066213

fbshipit-source-id: 3fbef5d881f6f451cb5955dcbbc362c53347437e
2023-08-18 01:38:10 -07:00
Alex Hunt 39a41fa2a0 Convert community-cli-plugin to Flow strict (#38961)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38961

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D48066180

fbshipit-source-id: 72b8b25a70062a71ab13aa1d62f3418582e99013
2023-08-15 02:33:22 -07:00
Alex Hunt 164133cada Sync latest cli-plugin-metro changes (#38944)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38944

- Update `cli-commands` package to reflect latest source `react-native-community/cli-plugin-metro` changes.
	- https://github.com/react-native-community/cli/pull/2021
	- https://github.com/react-native-community/cli/pull/2024
	- https://github.com/react-native-community/cli/pull/2043
	- https://github.com/react-native-community/cli/pull/2047

### To do

WARNING: ~~This PR is non-functional until the next CLI alpha is published and bumped in `package.json` — since it depends on corresponding new APIs in `react-native-community/cli-tools` (https://github.com/react-native-community/cli/pull/2021). This package (and the upcoming work which integrates it) has been tested against locally linked copies of latest CLI.~~

- [x] Bump CLI dependencies when next alpha published.
- [x] Ensure Metro bump from `0.77.0` to `0.78.0` is consistently applied with this.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D48066179

fbshipit-source-id: b3dc8891cf33e537788f942dcaddff4d2f11a31f
2023-08-15 02:33:22 -07:00
Alex Hunt e1998806b7 Migrate cli-plugin-metro into repo (#38795)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38795

## Context

RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641

## Changes

Inits new package `react-native/community-cli-plugin`. This migrates [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro) into the React Native repo, to enable faster iteration by the React Native core team. Specifically:

- This package contains several `metro` dependencies, which when removed from CLI will no longer require us to ship new CLI releases to get Metro patches and features to users.
- This package contains the `start`, `bundle`, and `ram-bundle` commands (central to the React Native development experience), for which we have incoming debugging-related changes.
- This package now **only** exports commands to be attached via a RN CLI plugin. With this move, we're aiming to **internalise** the default implementations of these dev commands within React Native — other RN CLI plugins can continue to override these, but must do so wholesale. (See also the recent fix for this: https://github.com/react-native-community/cli/pull/1999.)

In V15:
- (Microsoft feedback) Re-export  `unstable_buildBundleWithConfig`, marking as unstable. This gives us a time buffer to consider how we repackage this functionality in future.

The package source has been converted from TypeScript to Flow, with a number of new `flow-typed/` defs added to meet type coverage requirements.

## To dos

- For now, we aren't removing the existing [`react-native-community/cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro) source — until later PRs consolidate this move by changing dependencies in the `react-native` package.
- **Exported API is reduced!**: I'm working with szymonrybczak to decouple references from RN CLI packages https://github.com/react-native-community/cli/pull/2021.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D46801501

fbshipit-source-id: 7f6b72941a69f487fb437768cdba125a9aa3418d
2023-08-10 11:34:36 -07:00