Commit Graph

67 Commits

Author SHA1 Message Date
Tim Yung 84de8a075e RN: Delete @oncall Annotations (#51416)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51416

Deletes `oncall` annotations from the `facebook/react-native` repository.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D74902524

fbshipit-source-id: 32a6a5b2ff27281792d572f151e2b094d9a79029
2025-05-17 16:18:05 -07:00
Rob Hogan f4936894f0 Miscellaneous lint fixes (#51099)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51099

Fix up some misc broken lints and add temporary suppressions to reduce noise in the subsequent stack.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D74141669

fbshipit-source-id: dc19378e41f6d8d45fc7d2ecf18c1c01a1e501be
2025-05-05 09:48:46 -07:00
Rob Hogan 93f22e79d4 community-cli-plugin: Use TerminalReporter type from metro, replace deep imports (#51092)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51092

`TerminalReporter` is re-exported from `metro` (since [0.76.7](https://github.com/facebook/metro/releases/tag/v0.76.7)), so we can update these deep imports to use public exports.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D74141704

fbshipit-source-id: 22cd3209868ed9ab260e199f9099ef98335feaeb
2025-05-04 09:57:57 -07:00
Jakub Grzywacz 864833fca9 Generate keep.xml to prevent resource shrinking on Android (#50620)
Summary:
On Android, when resource shrinking is enabled, all resources added by Metro may be removed as react-native is accessing resources based on strings rather than references, so AGP can't see its usage.

Example output of `android/app/build/outputs/mapping/release/resources.txt `when `shrinkResources` is enabled.
```
raw/__node_modules_expo_vectoricons_build_vendor_reactnativevectoricons_fonts_materialcommunityicons : reachable=false
drawable/__common_assets_haptics_icon : reachable=false
```

It’s a coincidence that most of the resources are currently working, as many file names begin with strings that already exist in the String Pool. For example, `node_modules...` is flagged as used because 'node' is present in the String Pool, causing it to be whitelisted. However, this does not guarantee that the same will apply to all files - especially in a monorepo setup, where paths are significantly different. For example
* `__node_modules_expo_vectoricons_build_vendor_reactnativevectoricons_fonts_materialcommunityicons`
* `__common_assets_haptics_icon`

To prevent that behavior, metro during assets export should create `keep.xml` listing all resources generated by metro.
https://developer.android.com/build/shrink-code#keep-resources

We have already made a similar change in expo cli: https://github.com/expo/expo/pull/35465

## Changelog:

[ANDROID][ADDED] - Generate keep.xml to prevent resource shrinking

Pull Request resolved: https://github.com/facebook/react-native/pull/50620

Test Plan:
1. Enable resource shrinking in RNTester by adding this to `android.buildTypes.release` to `packages/rn-tester/android/app/build.gradle.kts`
```gradle
isMinifyEnabled = true
isShrinkResources = true
```
2. Use some resources in playground, for example:
```diff
 diff --git a/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js b/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js
index 9dbacb99701..9ac9c231f3f 100644
 --- a/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js
+++ b/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js
@@ -11,16 +11,14 @@

 import type {RNTesterModuleExample} from '../../types/RNTesterTypes';

-import RNTesterText from '../../components/RNTesterText';
 import * as React from 'react';
 import {StyleSheet, View} from 'react-native';
+import {Header} from "react-native/Libraries/NewAppScreen";

 function Playground() {
   return (
     <View style={styles.container}>
-      <RNTesterText>
-        Edit "RNTesterPlayground.js" to change this file
-      </RNTesterText>
+      <Header />
     </View>
   );
 }
```

3. Build app using `hermesRelease` variant
4. See Playground screen

| Before | After |
|---|---|
| <img width="488" alt="Zrzut ekranu 2025-04-10 o 12 17 53" src="https://github.com/user-attachments/assets/24fcaa7b-6ddb-4ba6-9fe5-65c27bcbc931" /> | <img width="488" alt="Zrzut ekranu 2025-04-10 o 12 15 58" src="https://github.com/user-attachments/assets/09a1ce77-be26-4571-a4b8-c466bf19e026" /> |

5. Inspect `packages/rn-tester/android/app/build/outputs/mapping/hermesRelease/resources.txt`

| Before | After |
|---|---|
| `drawable/_reactnative_libraries_newappscreen_components_logo : reachable=false` | `drawable/_reactnative_libraries_newappscreen_components_logo : reachable=true` |

Reviewed By: cortinico

Differential Revision: D72960028

Pulled By: huntie

fbshipit-source-id: df725fa2ea50150cd67687a97986976ffbbb5b40
2025-04-14 07:33:27 -07:00
Rob Hogan cdaa1aa9aa community-cli-plugin: resolve cli-server-api via peer dependency on cli (#49518)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49518

`react-native/community-cli-plugin` depends on `createDevServerMiddleware` from `react-native-community/cli-server-api`.

`react-native/community-cli-plugin` currently [declares an optional peer dependency](https://github.com/facebook/react-native/blob/bae895500052bda2f55e1832b0c8a63a1b449de3/packages/community-cli-plugin/package.json#L39-L45) on `react-native-community/cli-server-api`, however because the latter isn't a dependency of `react-native` or the community template, the peer dependency is not available to package managers that enforce isolated node_modules - see https://github.com/facebook/react-native/issues/47309.

Rather than add an unnecessary dependency to the template (like [this](https://github.com/react-native-community/template/pull/105)), my proposal is to switch to a peer dependency on only `react-native-community/cli`, because that *is* a dependency of the community template and therefore will be resolvable.

Because `react-native-community/cli` doesn't re-export `createDevServerMiddleware` from its dependency on `cli-server-api`, we need to resolve the latter through the former. This can be cleaned up once a re-export lands - https://github.com/react-native-community/cli/pull/2605.

Changelog:
[GENERAL][FIXED] Fix registering of `start` and `bundle` commands with community CLI and isolated node_modules.

Reviewed By: huntie

Differential Revision: D69848688

fbshipit-source-id: 009b8ffd43b2ab2d84fcc71e9e48382eb8950bb1
2025-02-19 10:11:03 -08:00
Sam Zhou a1eb6de691 Pre-suppress errors ahead of 0.261.1 release in xplat
Summary: Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D69610953

fbshipit-source-id: 3eec28d72e26c2f48542523dd610590e298eba69
2025-02-13 13:04:53 -08:00
Panos Vekris 413730ecb3 Back out "Deploy 0.261.0 to xplat"
Summary:
Original commit changeset: cf5953b1afc2

Original Phabricator Diff: D69562137

Reviewed By: SamChou19815

Differential Revision: D69570236

fbshipit-source-id: 7cfa9cf51aa3662d4339e020f8ae5065c8f5c358
2025-02-12 19:14:21 -08:00
Sam Zhou 9a401c8103 Deploy 0.261.0 to xplat
Summary: Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D69562137

fbshipit-source-id: cf5953b1afc242bf2571ad7c4362ef9485d8e846
2025-02-12 18:12:54 -08:00
Alex Hunt 0d66c524cf Restore Metro log streaming via CLI flag (#49353)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49353

This change adds an opt-in to restore JavaScript log streaming via the Metro dev server, [removed from React Native core in 0.77](https://reactnative.dev/blog/2025/01/21/version-0.77#removal-of-consolelog-streaming-in-metro).

Users can opt into this legacy behaviour by adding the `--client-logs` flag to `npx react-native-community/cli start`.

- The default experience remains without streamed JS logs.
- The existing "JavaScript logs have moved! ..." notice is printed in all cases, and we do not advertise the new flag for new users.
- Under non-Community CLI dev servers (i.e. Expo), log streaming is restored implicitly.

We will clean up this functionality again when we eventually remove JS log streaming over `HMRClient`, tasked in T214991636.

**Implementation notes**

- Logs are always sent over `HMRClient` (previous status quo), even with log streaming off in the dev server. This is a necessary evil to be able to flag this functionality in a user-accessible place, and to move fast for 0.78.
- Necessarily, emitting `fusebox_console_notice` moves to the dev server itself, on first device (Fusebox) connection.

Changelog:
[General][Added] - Add opt in for legacy Metro log streaming via `--client-logs` flag

Reviewed By: robhogan

Differential Revision: D69469039

fbshipit-source-id: be99d02a3b1c977a59bf7d2726f0e6cf2e60b28a
2025-02-12 07:17:15 -08:00
Alex Hunt 1cfc53bb70 Improve error log for failed open-debugger fetch (#49295)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49295

Motivated by https://github.com/facebook/react-native/issues/49287.

This improves on the less useful output of "fetch failed" currently. We expect failing to make a request to the dev server (made from the dev server!) to be a rare edge case, in which case we want to log as much info as possible.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D69395983

fbshipit-source-id: ee96d72ade5a887d190397c3b798a5b545152587
2025-02-10 06:01:48 -08:00
Alex Hunt e1575857dd Relocate babel-register script (#49102)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49102

Moves this script one level up. In the next diff, will be used to support execution of scripts themselves, as well as `packages/`.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D68960279

fbshipit-source-id: 7b62420c269dc1c1366ac9a827db078d34cb86c5
2025-02-03 03:49:23 -08:00
Alex Hunt bb1e3cdb04 Update cli-server-api middleware imports (#48997)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48997

Follows https://github.com/react-native-community/cli/pull/2584.

- Also add FIXME comment flagging potential core APIs gap without CLI.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D68766565

fbshipit-source-id: 60747715f76c4323e306c39ab0613fb4818b4914
2025-01-28 07:11:13 -08:00
Jakub Romanczyk 881d8a720f refactor(community-cli-plugin): use node builtin fetch (#47397)
Summary:
Removed `node-fetch` in favour of node builtin fetch to get rid of the deprecated `punycode` warning when using Node 22.

`react-native/community-cli-plugin` already requires Node >= 18 where it was made available by default (without `--experimental-fetch` flag).

This change is similar to the one made in https://github.com/facebook/react-native/pull/45227

## Changelog:

[GENERAL] [CHANGED] - Drop node-fetch in favor of Node's built-in fetch from undici in `react-native/community-cli-plugin`

Pull Request resolved: https://github.com/facebook/react-native/pull/47397

Test Plan: tests pass

Reviewed By: blakef

Differential Revision: D66512595

Pulled By: NickGerleman

fbshipit-source-id: c4e01baf388f9fae8cea7b4bfe25034bff28b461
2024-11-27 10:39:39 -08:00
Blake Friedman e0be2efe4e fix/cli start (#47450)
Summary:
When decoupling the community-cli-plugin from the react-native-community/cli-server-api (https://github.com/facebook/react-native/issues/45311), a middleware stub was created to allow a runtime stub to be used in this case. This middleware should be used so as not to break when the optional cli-server-api dependency isn't present.

Changelog:
[General][Fixed] - Fix npm react-native start when cli-server-api isn't installed

Pull Request resolved: https://github.com/facebook/react-native/pull/47450

Test Plan:
Forced a runtime exception simulating the package not being dependent and was able to build rn-tester.

![CleanShot 2024-11-06 at 10 49 58@2x](https://github.com/user-attachments/assets/c040ec5b-7000-43bd-ba54-52a672ff3675)

Reviewed By: cipolleschi

Differential Revision: D65532486

Pulled By: blakef

fbshipit-source-id: 2b380607de63ac2da906ef0cb1e48b9ef263cb68
2024-11-06 07:26:30 -08:00
Alex Hunt 2f07130bb3 Align logIfUpdateAvailable to use resolved RN version from CLI (#46777)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46777

Simplifies this internal logic plus ensures there is one source of truth for `reactNativeVersion` in our CLI plugin. Also, renames the `ctx` variable to `cliConfig`, to more clearly signal that this is an integration point with the Community CLI.

Completes this wave of `community-cli-plugin` simplifications.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D63534247

fbshipit-source-id: bf5779fcf971dee1e0caf58b071df360636c53e9
2024-10-07 05:53:37 -07:00
Alex Hunt 19b971ff94 Remove run on iOS/Android key handlers (#46781)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46781

Implements https://github.com/react-native-community/discussions-and-proposals/discussions/821.

Changelog:
[General][Removed] - Remove "run on iOS" and "run on Android" from the dev server key commands

Reviewed By: cortinico

Differential Revision: D63534248

fbshipit-source-id: 003d4c639bbf9128f921936508a62de2caadac5e
2024-10-03 03:39:04 -07:00
Alex Hunt c430083fa0 Update modern inspector targets to directly send CDP title and description (#46780)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46780

This is primarily a debugger server change to better-align the `title` and `description` fields (visible in via the CDP `/json/list` endpoint), reporting them directly from the device.

For React Native users, the net effect of this change is to improve/align the display name for each debugger target in the CLI multi-select menu (`j` to debug). This change may also be useful for discovery in non-Fusebox frontends such as VS Code (`vscode-expo` extension).

Changes:
- Rename `title` prop on `InspectorPageDescription`/`IInspector::addPage` to `description` (no call site changes).
- Add `deviceName` param to `InspectorPackagerConnection`.
- Move the page `description` to the `description` JSON field.
- Update `InspectorPackagerConnection::Impl::pages()` to return new `title` and `description` fields.
- Align `OpenDebuggerKeyboardHandler` to display `title` field.
- Deprecate the nonstandard `deviceName` field.

**Before**

```
[
    {
        "id": "3c9f24bedab0e73fca6a1b295030e7af9346a8c0-1",
        "title": "React Native Bridgeless [C++ connection]",
        "description": "com.facebook.RNTester",
         ...
    }
```

The `description` field was previously the closest thing we had to a target identifier. Today, this is not needed, since we have the stable `reactNative.logicalDeviceId` field.

**After**

```
[
    {
        "id": "3c9f24bedab0e73fca6a1b295030e7af9346a8c0-1",
        "title": "com.facebook.RNTester (iPhone 16 Pro)",
        "description": "React Native Bridgeless [C++ connection]",
         ...
    }
```

The `title` field is now more human readable and aligned with what we render in the window title of React Native DevTools. The `description` field describes the type of debugger target (the specific React Native implementation).

Changelog: [Internal]

Reviewed By: vzaidman

Differential Revision: D63329456

fbshipit-source-id: cfe98f77e31c729431005925cfc66e2780ef8c72
2024-10-02 07:30:31 -07:00
Alex Hunt ebc699ce7f Tweak start command output (#46770)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46770

Small updates to the `react-native start` command CLI output:

- Change "Welcome..." text to blue.
- Display server base URL instead of port only.
- Embolden key command letters.
- "Ctrl+C to exit" prompt.
- Extra newlines for balance.

Changelog: [Internal]

Reviewed By: cortinico, cipolleschi

Differential Revision: D63328267

fbshipit-source-id: 119ddb2ba68c99df532840285c3c1f922e727e8b
2024-10-01 17:14:43 -07:00
Alex Hunt df8f4d6b5d Replace and remove optional dep on cli-tools logger (#46769)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46769

(Further refactors to logging after D63255296.)

Fully decouples `community-cli-plugin` from the unlisted optional dependency on `react-native-community/cli-tools'`. This is motivated by changes in https://github.com/facebook/react-native/pull/46627 which switch to using Metro's `TerminalReporter` API for emitting logs safely.

- Swaps out logs in the dev server for the `unstable_server_log` Metro reporter event.
- Swaps out `logger.debug()` calls for the `debug` package, currently used by Metro and `dev-middleware`.
- Swaps out other logs in the `bundle` command for `console`.
- (Also specify missing `semver` dep.)

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D63328268

fbshipit-source-id: f552748ecc3456bd5fb8870c3a51d744a6bf3e70
2024-10-01 17:14:43 -07:00
Alex Hunt b52bbb4d21 Simplify key handling in start command (#46768)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46768

Remove the `KeyPressHandler` util in favour of using the `process.stdin` APIs inline.

This reduces complexity (where we were effectively not using the conditional interception this previously implemented — see also https://github.com/facebook/react-native/pull/46416), and more closely mirrors our internal dev server setup.

Resolves https://github.com/facebook/react-native/issues/46571.

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D63255321

fbshipit-source-id: 5cdf7a480053a2215fa50f544733f443bab07ef2
2024-10-01 17:14:43 -07:00
Alex Hunt 7186fdeb1c Replace execa with child_process (#46767)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46767

Swaps out `execa` dependency for Node's built in `child_process`.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D63255320

fbshipit-source-id: ce7ef5e2ea78aa96c61815ff8c1e054a8f04e8b0
2024-10-01 17:14:43 -07:00
Alex Hunt aa55d765e5 Add CLI selection of multiple debug targets (#46627)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46627

IMPORTANT: Requires a Metro bump, CI will fail until updated.

Introduces a target selection API for launching React Native DevTools when more than one device is connected.

Credit to robhogan for the initial internal implementation of `OpenDebuggerKeyboardHandler`!

(This leverages recent additions to Metro's reporter API — which we should follow up on to use for the rest of `community-cli-plugin`. Notably, using `TerminalReporter` ensures server output won't conflict with Metro's own event and progress logs.)

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D63255295

fbshipit-source-id: da93500358791eabe4cab433cad31b82d518fb5f
2024-10-01 11:27:41 -07:00
Vitali Zaidman 23e738fb6d allow waiting for metro to be torn down (#46620)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46620

The following error was thrown when the test `packages/metro/src/integration_tests/__tests__/server-test.js` was running on Metro:
{F1816961963}

It led me to investigate why don't we wait for Metro to be torn down.

Currently we close metro by closing the http server that it launches.
```
const httpServer = await Metro.runServer(/* ... */);
httpServer.close(callback);
```
While we can listen to the callback fired when the server is closed, it only covers one of the systems running internally in metro. The systems that are not covered are:
* File watchers
* File map workers
* Dependency graph
* Bundler

And many systems that were themselves listening to the above like "eslint file map" or the "dependency analysis".

**These systems are closed by us _after_ the server is closed.** This means that a listener to `server.on('close'` would only get the indication where these systems has started to close rather than actually got closed.
https://www.internalfb.com/code/fbsource/[17e03bc6bd86]/xplat/js/tools/metro/packages/metro/src/index.flow.js?lines=359-361

This diff introduces a way to wait for all of metro to be closed.

In this diff I use that new way of listening to Metro closure to get rid of the jest test warning mentioned above in `packages/metro/src/integration_tests/__tests__/server-test.js`:
```
  let serverClosedPromise;

  beforeEach(async () => {
    config = await Metro.loadConfig({
      config: require.resolve('../metro.config.js'),
    });

    let onCloseResolve;
    serverClosedPromise = new Promise(resolve => (onCloseResolve = resolve));
    httpServer = await Metro.runServer(config, {
      reporter: {update() {}},
      onClose: () => {
        onCloseResolve();
      },
    });
  });

  afterEach(async () => {
    httpServer.close();
    await serverClosedPromise;
  });
```

Changelog: [Feature] add `onClose` to `Metro.runServer` configuration allowing to wait for metro and all associated processes to be closed.

Reviewed By: huntie

Differential Revision: D61594124

fbshipit-source-id: e3c50ef986077503bce0caa42a9f9430efc65272
2024-09-26 03:42:49 -07:00
Dawid 42bad68220 fix app crashing when reloads overlap (#46416)
Summary:
Regarding the [issue](https://github.com/facebook/react-native/issues/44755) where the app sometimes crashes due to race condition when two reloads overlap in unfortunate way. This PR fixes it in some way by introducing throttling on reload command. For now I set it to 700ms as I was still able to reproduce it on 500-550ms for provided repro in the issue. The problem may still happen for bigger apps where reload may take more time to finish.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[GENERAL] [FIXED] - throttle reload command

Pull Request resolved: https://github.com/facebook/react-native/pull/46416

Test Plan: I've tested on provided repro and a smaller app trying to brake it.

Reviewed By: huntie

Differential Revision: D62847076

Pulled By: cipolleschi

fbshipit-source-id: 6471f792d6b692e87e3e98a699443a88c6ef43cd
2024-09-18 07:32:59 -07:00
Alex Hunt 94e7a87f23 Remove --experimental-debugger option (#46231)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46231

Removes this option from `npx react-native start`. Flipper will no longer be the default launch flow in 0.76.

The debugger frontend variant remains controlled by `target.reactNative.capabilities?.prefersFuseboxFrontend`. This will always be Fusebox, since D60893243.

Changelog:
[General][Changed] Remove `--experimental-debugger` option from start command

Reviewed By: robhogan

Differential Revision: D61852415

fbshipit-source-id: 3351f0e12c24717916a70dd1ea28f8690bb5509f
2024-08-28 03:20:17 -07:00
Szymon Rybczak 396bdd87d8 fix: ensure --build-output destination exists (#45182)
Summary:
Replicates https://github.com/react-native-community/cli/commit/48d4c29bba4e8b16cbc8307bd1b4c5349f3651d8, which landed inside `cli-plugin-metro` inside RNC CLI, but because of migration of code to `community-cli-plugin` it looks like apparently the fix wasn't replicated.

## Changelog:

[GENERAL] [FIXED] - Ensure `--build-output` destination exists

Pull Request resolved: https://github.com/facebook/react-native/pull/45182

Test Plan:
Specify a new directory that doesn't exists inside `--build-output`:

`npx react-native bundle --build-output dist/new-dir/index.bundle`

and this command shouldn't fail.

Reviewed By: christophpurrer

Differential Revision: D61850942

Pulled By: huntie

fbshipit-source-id: 90e57f19c661ace8206162d6fa2e6a27acb31e20
2024-08-27 09:04:14 -07:00
Blake Friedman 2ac997abcc Remove references to old template (#46082)
Summary:
## Summary
There are old references to the react-native/template. This code has
moved to react-native-community/template.

Changelog: [Internal]

Pull Request resolved: https://github.com/facebook/react-native/pull/46082

Test Plan:
CI

closes facebook/metro#1324

Reviewed By: cipolleschi

Differential Revision: D61472439

Pulled By: blakef

fbshipit-source-id: fc40145c03002a7c3117b72d07981a96aa3d8760
2024-08-19 09:19:35 -07:00
wh201906 6390cf67d0 Add upper case keys to the debug key handler (#45559)
Summary:
The CLI of Metro bundler only accepts key presses when the Caps Lock is off. This is somehow inconvenient because the developers might think the Metro bundler doesn't response when the Caps Lock is on.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[GENERAL] [ADDED] - Add upper case keys to the debug key handler

Pull Request resolved: https://github.com/facebook/react-native/pull/45559

Test Plan: n/a

Reviewed By: huntie

Differential Revision: D60107316

Pulled By: dmytrorykun

fbshipit-source-id: 045dcd382d84c4781dff75a1ff913cd3ccc8d288
2024-07-23 03:57:39 -07:00
Blake Friedman 24997dc5ae allow use without @react-native-community/cli-server-api (#45311)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45311

Allows Gradle and Xcode builds to continue without the rnc dependency.

Reviewed By: cipolleschi

Differential Revision: D59377223

fbshipit-source-id: b0daddae7377b8a0d2ee2a25b2ff10124e5db549
2024-07-15 09:28:58 -07:00
Blake Friedman 9aaadd9b2e remove rnc/cli-tools version & errors deps (#45380)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45380

Removed the use of version checking and error code that is in react-native-community/cli-tools.

Changelog:
[Internal] [Changed] - Removed community-cli-plugin version & error dependencies

Reviewed By: robhogan

Differential Revision: D59378012

fbshipit-source-id: b009edc615b873ff2bff31296ac5d87a4482944f
2024-07-15 04:35:26 -07:00
Blake Friedman 6547b157b5 Remove dependency on rnc/cli-tools logger (#45381)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45381

Removing the remaining dependencies from the react-native-community/*. This
inlines a copy of the logger.

Changelog:
[Internal][Changed] Removed react-native-community/cli-tools logger dependency

Reviewed By: cipolleschi

Differential Revision: D59378011

fbshipit-source-id: ef93d9fff1c623658e33c36b6329f5d548f649e8
2024-07-15 04:35:26 -07:00
szymonrybczak d1bf828398 fix(cli): replace querystring with URLSearchParam (#45125)
Summary:
[`querystring`](https://www.npmjs.com/package/querystring) package is deprecated. In this Pull Request I've replaced usage of `querystring` with `URLSearchParam` what is recommended by Node.js.

It's also causing a warning when installing dependencies inside a React Native app:
```
warning react-native > react-native/community-cli-plugin > querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
```

## Changelog:

[INTERNAL] [FIXED] - Replace `querystring` package with `URLSearchParam`

Pull Request resolved: https://github.com/facebook/react-native/pull/45125

Test Plan:
Params should be parsed in the same way and warning shouldn't be presented.

js1 jest xplat/js/tools/metro/packages/metro/src/cli/__tests__/parseKeyValueParamArray-test.js

Reviewed By: cipolleschi

Differential Revision: D58948498

Pulled By: GijsWeterings

fbshipit-source-id: 79b1f7b3feae230d2d3641205c513b98b3fda511
2024-07-04 08:04:56 -07:00
Sam Zhou 3c6762a5f8 Pre-suppress errors ahead of v0.239 release
Summary: Changelog: [Internal]

Reviewed By: mvitousek

Differential Revision: D59308716

fbshipit-source-id: d741ee004e153810fc913da96505706e43814ec1
2024-07-02 23:37:15 -07:00
Afonso 0950916846 Fix custom port listening configuration through metro.config.js (#44957)
Summary:
After updating my project to 0.73.2 I noticed that even though I had a specific port set in my `metro.config.js`, every time I'd start my project, it was running on port 8081. Passing the `--port` argument would allow me to change the port, but the config from metro did not.  I checked if the metro config was being properly applied, using `--verbose` and it was.

So I dug a bit, trying to figure out what had changed and noticed the coalescing of the value, whenever the argument `--port` is not present. That seemed odd since it meant that there's always a port defined for the `options` of `loadMetroConfig`, which would always be used in the `loadConfig` step.

To confirm I was on the right track I went to the [cli-plugin-metro](https://github.com/react-native-community/cli/blob/v11.3.10/packages/cli-plugin-metro) repo, to the last release before the move here, and noticed that there was [no coalescing in the same method](https://github.com/react-native-community/cli/blob/v11.3.10/packages/cli-plugin-metro/src/commands/start/runServer.ts#L60).

In this PR, I remove the coalescing of the port from `runServer.js` from the `community-cli-plugin`, to allow the port configuration through `metro.config.js`.

## Changelog:
[INTERNAL] [FIXED] - Fix server port configuration via `metro.config.js`
<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: https://github.com/facebook/react-native/pull/44957

Test Plan:
Running `yarn start` and verifying that:
- it would listen to port `8081` if no argument nor a custom port was set in `metro.config.js`
- it would listen to port `8082` if that one was defined in `metro.config.js`
- it would listend to port `8083` if that port was passed as an argument to the command (i.e. `yarn start --port 8083` even though port 8082 was defined in `metro.config.js`

Reviewed By: cortinico

Differential Revision: D58605152

Pulled By: robhogan

fbshipit-source-id: 9cf7a8b6a0d9de3af1ca4092906b4c648acee373
2024-06-17 05:52:16 -07:00
Alex Hunt a569c82eb5 Back out "chore(dev-middleware): add localhost as default host in start command config" (#44800)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44800

This is a revert of https://github.com/facebook/react-native/pull/44244, as we've observed [breaking behaviour](https://github.com/facebook/react-native/pull/44244#issuecomment-2078957734) where Android emulators could not connect to the dev server with default settings.

The team doesn't have bandwidth/prio to figure this out with the default `host` value just now, so we are reverting.

Changelog: [Internal] (Nullifies c402dcf)

Reviewed By: cipolleschi

Differential Revision: D58192651

fbshipit-source-id: dd2183d6baa6499ab59e21365adfe62e7a786dfc
2024-06-05 09:48:16 -07:00
Blake Friedman 3ddf509924 Back out "conditional Babel registration no longer necessary"
Summary:
Original commit changeset: 6bec706c639f

Original Phabricator Diff: D56839521

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D57052476

fbshipit-source-id: 7c598f43b23959f1accf555be38abc95e4ef35fd
2024-05-07 08:36:04 -07:00
Blake Friedman 47848ad15f conditional Babel registration no longer necessary (#44362)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44362

Packages that are built and directly run in the monorepo no longer need to worry about
conditionally registering themselves to transpile Flow -> JS at runtime. Our build step
strips this file now.

Changelog: [Internal] changes in published packages no longer require conditional calls to Babel register.

Reviewed By: huntie

Differential Revision: D56839521

fbshipit-source-id: 6bec706c639f1ab4138e0b790be8a07654333046
2024-05-07 03:16:00 -07:00
Blake Friedman c754755cd8 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
2024-04-29 05:04:26 -07:00
szymonrybczak c402dcfe57 chore(dev-middleware): add localhost as default host in start command config (#44244)
Summary:
Inside [Re.Pack](https://github.com/callstack/repack) we consume command's options, to reduce the amount of assumptions that 3rd party tools need to make - we can move assigning default value to config command level, so default values will be aligned across tools.

For default `start` command this change doesn't change any behaviour.

## Changelog:

[INTERNAL] [CHANGED] - Add `localhost` as default host in `start` command config

Pull Request resolved: https://github.com/facebook/react-native/pull/44244

Test Plan: `start` command should work the same way as before.

Reviewed By: huntie

Differential Revision: D56567793

Pulled By: blakef

fbshipit-source-id: fe8f3686ae39a3d2996de11930a0d03364692adc
2024-04-25 03:01:51 -07:00
Blake Friedman 58b45e86a6 Remove RFC-0759 ram-bundle command from cli (#43292)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43292

The ram-bundle command isn't necessary now that Hermes is our default VM.  The RFC specifically calls for the CLI command to be removed [1].

[1] https://github.com/react-native-community/discussions-and-proposals/blob/main/proposals/0759-react-native-frameworks.md#commands-to-be-removed

Changelog:
[General][Removed] - RFC-0759 remove ram-bundle command.

Reviewed By: NickGerleman, cipolleschi

Differential Revision: D54430289

fbshipit-source-id: 49d519c007b739f89ffe9032fec905c56ea49f4a
2024-03-04 04:47:34 -08:00
Edmond Chui 635732aa8f Fix order of Metro hotkey console messages (#42896)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42896

Changelog:
[General][Fixed] Fix order of Metro hotkey console messages

# Existing

Key handler is printing messages to the console _after_ it has been processed, this causes error messages to appear before the `info` message.

# In this PR

The `info` messages are logged before the event is processed.

Reviewed By: GijsWeterings

Differential Revision: D53479732

fbshipit-source-id: 25af47450662de4eb03d0dfd52af5af014ef3e49
2024-02-07 07:44:24 -08:00
Tommy Nguyen e350859d72 fix: cannot find module react-native-*/Libraries/Core/InitializeCore (#42875)
Summary:
`react-native/community-cli-plugin` is unable to resolve out-of-tree platforms in monorepos because the package may not be hoisted to the same location. For example, if `react-native/community-cli-plugin` was hoisted:

```
/~/node_modules/react-native/community-cli-plugin/dist/utils
```

It may never find `react-native-macos` if it wasn't hoisted:

```
/~/packages/my-app/node_modules/react-native-macos
```

## Changelog:

[GENERAL] [FIXED] - Fix `react-native/community-cli-plugin` is unable to resolve out-of-tree platforms in monorepos

Pull Request resolved: https://github.com/facebook/react-native/pull/42875

Test Plan: Tested in an internal project.

Reviewed By: cipolleschi

Differential Revision: D53426607

Pulled By: robhogan

fbshipit-source-id: 29b9fe92d5773d0160bba375d2e92ec688652e3e
2024-02-05 09:56:10 -08:00
Alex Hunt 4e92f87dfd Align parsing of custom resolver options, rename arg (#42392)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42392

Follow-up to https://github.com/facebook/react-native/pull/42333 following internal feedback. We are now aligning this to match the [`metro build` command](https://github.com/facebook/metro/blob/702e1b8fc7ab8b973bcd53f1a41f7e797cbf7dca/packages/metro/src/commands/build.js#L85-L91). This also improves validation on parsing (done after initial `commander` arg parsing as variadic string).

Changelog: [Internal]
(same as https://github.com/facebook/react-native/pull/42333)

Reviewed By: motiz88

Differential Revision: D52911017

fbshipit-source-id: 54049aa20c9db344a0f485fddf62fb267e672376
2024-01-22 10:31:51 -08:00
Szymon Rybczak 31a162f48c feat: add --custom-resolver-options to bundle command (#42333)
Summary:
Added `--custom-resolver-options` to `--bundle` command. This options is also [available](https://github.com/facebook/metro/blob/main/docs/CLI.md#options) in Metro's CLI.

## Changelog:

[INTERNAL] [ADDED] - Add `--resolver-options` to `bundle` command

Pull Request resolved: https://github.com/facebook/react-native/pull/42333

Test Plan:
1. Build all packages by running `yarn build` in the root
2. Go to `packages/rn-tester` and run `npx react-native bundle --custom-resolver-options key=value` and the options should be passed to the Config.

Reviewed By: blakef

Differential Revision: D52869452

Pulled By: huntie

fbshipit-source-id: 9a2c2d94b72cfb47477cf58b9c0472c5a8551c84
2024-01-18 04:51:39 -08:00
Janic Duplessis d5114a4b9f Fix cleanAssetCatalog error (#41865)
Summary:
There is currently an error when building in release on iOS when using asset catalogs (experimental feature that is partially merged https://github.com/facebook/react-native/pull/30129)

This was probably incorrectly migrated from the community cli repo. `.imageset` is actually folders so it needs to be removed with `{recursive: true, force: true}`. I also renamed the variable `files` which is confusing since its folders.

## Changelog:

[IOS] [FIXED] - Fix cleanAssetCatalog error

Pull Request resolved: https://github.com/facebook/react-native/pull/41865

Test Plan: Tested in an app that uses asset catalogs

Reviewed By: NickGerleman

Differential Revision: D52032258

Pulled By: huntie

fbshipit-source-id: 1dc0ca09e0da0d514b03d7d72707bdcaef03301d
2023-12-12 13:34:19 -08:00
Oskar Kwaśniewski 4ccd6e1242 feat: allow OOT platforms to use custom resolver.resolveRequest (#41697)
Summary:
Currently, when we have an additional platform in `react-native.config.js`, users cannot use custom `resolver.resolveRequest` functions as they are overwritten by `reactNativePlatformResolver`. Goal of this PR is to allow OOT platforms to use additional custom resolvers besides remapping react native imports.

## Changelog:

[GENERAL] [FIXED] - Allow Out Of Tree platforms to pass custom resolvers

Pull Request resolved: https://github.com/facebook/react-native/pull/41697

Test Plan:
1. Add additional platform in `react-native.config.js`
2. Pass custom resolver to `metro.config.js`:

```js
resolveRequest: (context, moduleName, platform) => {
      console.log('resolveRequest', moduleName, platform);
      return context.resolveRequest(context, moduleName, platform);
 }
```
3. Check if user's `resolveRequest` function is called.

Reviewed By: huntie

Differential Revision: D51659721

Pulled By: robhogan

fbshipit-source-id: 952589b59a6fa34e9406d36c900be53a7c1a79c3
2023-11-29 05:53:54 -08:00
Moti Zilberman d6e0bc714a Enable lint/sort-imports everywhere (#41334)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41334

TSIA.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D51025812

fbshipit-source-id: e10d437be775a6b80946483aa96460f34927f870
2023-11-06 12:59:38 -08:00
Alex Hunt 8c36aaa2db Add "Hermes only" to open debugger key prompt
Summary: Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D50327180

fbshipit-source-id: 6ee08fadd313828ddbc7702d5b3b1174a91b1ac1
2023-10-17 02:57:55 -07:00
Alex Hunt fb6ac26e40 Refactor dev server URL creation creation to use url.format (#39503)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39503

Changelog: [Internal]

Reviewed By: blakef

Differential Revision: D49317314

fbshipit-source-id: 85b71340686a1cd19d63a7e73a5388a803d22c42
2023-10-16 09:42:52 -07:00
Alex Hunt 79ded77fcd Disable --experimental-debugger by default (#40795)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40795

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D50178494

fbshipit-source-id: b833b6accadd2902d97a45e030cd48d1b62ac438
2023-10-12 05:26:11 -07:00