forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: ## Context RFC: Decoupling Flipper from React Native core: react-native-community/discussions-and-proposals#641 ## Changes Inits new package `react-native/cli-commands`. 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. 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 react-native-community/cli#2021. Changelog: [Internal] Differential Revision: D46801501 fbshipit-source-id: 41cc4b77023654a926aa2fe6d439a502b296c1e7
- Loading branch information
1 parent
599a2e3
commit e2c3bf0
Showing
35 changed files
with
2,348 additions
and
1 deletion.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
flow-typed/npm/@react-native-community/cli-server-api_v12.x.x.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
declare module '@react-native-community/cli-server-api' { | ||
import type {NextHandleFunction, Server} from 'connect'; | ||
|
||
declare type MiddlewareOptions = { | ||
host?: string, | ||
watchFolders: $ReadOnlyArray<string>, | ||
port: number, | ||
}; | ||
|
||
declare export function createDevServerMiddleware( | ||
options: MiddlewareOptions, | ||
): { | ||
middleware: Server, | ||
websocketEndpoints: { | ||
'/debugger-proxy': ws$WebSocketServer, | ||
'/message': ws$WebSocketServer, | ||
'/events': ws$WebSocketServer, | ||
}, | ||
debuggerProxyEndpoint: { | ||
server: ws$WebSocketServer, | ||
isDebuggerConnected: () => boolean, | ||
}, | ||
messageSocketEndpoint: { | ||
server: ws$WebSocketServer, | ||
broadcast: ( | ||
method: string, | ||
params?: Record<string, mixed> | null, | ||
) => void, | ||
}, | ||
eventsSocketEndpoint: { | ||
server: ws$WebSocketServer, | ||
reportEvent: (event: any) => void, | ||
}, | ||
... | ||
}; | ||
|
||
declare export const indexPageMiddleware: NextHandleFunction; | ||
} |
40 changes: 40 additions & 0 deletions
40
flow-typed/npm/@react-native-community/cli-tools_v12.x.x.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
declare module '@react-native-community/cli-tools' { | ||
declare export class CLIError extends Error { | ||
constructor(msg: string, originalError?: Error | mixed | string): this; | ||
} | ||
|
||
declare export function hookStdout(callback: Function): () => void; | ||
|
||
declare export const logger: $ReadOnly<{ | ||
success: (...message: Array<string>) => void, | ||
info: (...message: Array<string>) => void, | ||
warn: (...message: Array<string>) => void, | ||
error: (...message: Array<string>) => void, | ||
debug: (...message: Array<string>) => void, | ||
log: (...message: Array<string>) => void, | ||
setVerbose: (level: boolean) => void, | ||
isVerbose: () => boolean, | ||
disable: () => void, | ||
enable: () => void, | ||
}>; | ||
|
||
declare export function resolveNodeModuleDir( | ||
root: string, | ||
packageName: string, | ||
): string; | ||
|
||
declare export const version: $ReadOnly<{ | ||
logIfUpdateAvailable: (projectRoot: string) => Promise<void>, | ||
}>; | ||
} |
30 changes: 30 additions & 0 deletions
30
flow-typed/npm/@react-native-community/cli-types_v12.x.x.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
declare module '@react-native-community/cli-types' { | ||
declare type PlatformConfig = { | ||
npmPackageName: string, | ||
... | ||
}; | ||
|
||
declare export type Config = { | ||
root: string, | ||
reactNativePath: string, | ||
reactNativeVersion: string, | ||
project: Object, | ||
platforms: { | ||
android: PlatformConfig, | ||
ios: PlatformConfig, | ||
[name: string]: PlatformConfig, | ||
}, | ||
... | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
// Modified from flow-typed repo: | ||
// https://github.com/flow-typed/flow-typed/blob/master/definitions/npm/execa_v2.x.x/flow_v0.104.x-/execa_v2.x.x.js#L2 | ||
|
||
declare module 'execa' { | ||
declare type StdIoOption = | ||
| 'pipe' | ||
| 'ipc' | ||
| 'ignore' | ||
| 'inherit' | ||
| stream$Stream | ||
| number; | ||
|
||
declare type CommonOptions = { | ||
argv0?: string, | ||
cleanup?: boolean, | ||
cwd?: string, | ||
detached?: boolean, | ||
encoding?: string, | ||
env?: {[string]: string | void, ...}, | ||
extendEnv?: boolean, | ||
gid?: number, | ||
killSignal?: string | number, | ||
localDir?: string, | ||
maxBuffer?: number, | ||
preferLocal?: boolean, | ||
reject?: boolean, | ||
shell?: boolean | string, | ||
stderr?: ?StdIoOption, | ||
stdin?: ?StdIoOption, | ||
stdio?: 'pipe' | 'ignore' | 'inherit' | $ReadOnlyArray<?StdIoOption>, | ||
stdout?: ?StdIoOption, | ||
stripEof?: boolean, | ||
timeout?: number, | ||
uid?: number, | ||
windowsVerbatimArguments?: boolean, | ||
buffer?: boolean, | ||
all?: boolean, | ||
stripFinalNewline?: boolean, | ||
}; | ||
|
||
declare type SyncOptions = { | ||
...CommonOptions, | ||
input?: string | Buffer, | ||
}; | ||
|
||
declare type Options = { | ||
...CommonOptions, | ||
input?: string | Buffer | stream$Readable, | ||
}; | ||
|
||
declare type SyncResult = { | ||
stdout: string, | ||
stderr: string, | ||
exitCode: number, | ||
failed: boolean, | ||
signal: ?string, | ||
command: string, | ||
timedOut: boolean, | ||
}; | ||
|
||
declare type Result = { | ||
...SyncResult, | ||
killed: boolean, | ||
}; | ||
|
||
declare interface ExecaPromise | ||
extends Promise<Result>, | ||
child_process$ChildProcess { | ||
} | ||
|
||
declare interface ExecaError extends ErrnoError { | ||
stdout: string; | ||
stderr: string; | ||
failed: boolean; | ||
signal: ?string; | ||
command: string; | ||
timedOut: boolean; | ||
exitCode: number; | ||
} | ||
|
||
declare interface Execa { | ||
( | ||
file: string, | ||
args?: $ReadOnlyArray<string>, | ||
options?: $ReadOnly<Options>, | ||
): ExecaPromise; | ||
(file: string, options?: $ReadOnly<Options>): ExecaPromise; | ||
|
||
command(command: string, options?: $ReadOnly<Options>): ExecaPromise; | ||
commandSync(command: string, options?: $ReadOnly<Options>): ExecaPromise; | ||
|
||
node( | ||
path: string, | ||
args?: $ReadOnlyArray<string>, | ||
options?: $ReadOnly<Options>, | ||
): void; | ||
|
||
sync( | ||
file: string, | ||
args?: $ReadOnlyArray<string>, | ||
options?: $ReadOnly<SyncOptions>, | ||
): SyncResult; | ||
sync(file: string, options?: $ReadOnly<SyncOptions>): SyncResult; | ||
} | ||
|
||
declare module.exports: Execa; | ||
} |
Oops, something went wrong.