@rnx-kit/cli 0.16.17 → 0.16.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/start.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import type { Config } from "@react-native-community/cli-types";
2
2
  import * as logger from "@rnx-kit/console";
3
3
  import {
4
- createTerminal,
5
4
  isDevServerRunning,
6
5
  loadMetroConfig,
6
+ makeReporter,
7
+ makeTerminal,
7
8
  startServer,
8
9
  } from "@rnx-kit/metro-service";
9
10
  import type { ReportableEvent, Reporter, RunServerOptions } from "metro";
@@ -65,20 +66,14 @@ export async function rnxStart(
65
66
  : undefined),
66
67
  });
67
68
 
68
- // create a Metro terminal and reporter for writing to the console
69
- const { terminal, reporter: terminalReporter } = createTerminal(
70
- args.customLogReporterPath
71
- );
69
+ const { projectRoot, watchFolders } = metroConfig;
70
+ const terminal = makeTerminal(projectRoot);
72
71
 
73
72
  // customize the metro config to include plugins, presets, etc.
74
73
  const log = (message: string): void => terminal.log(message);
75
74
  customizeMetroConfig(metroConfig, serverConfig, log);
76
75
 
77
- const {
78
- projectRoot,
79
- server: { port },
80
- watchFolders,
81
- } = metroConfig;
76
+ const { port } = metroConfig.server;
82
77
  const scheme = args.https === true ? "https" : "http";
83
78
  const serverStatus = await isDevServerRunning(
84
79
  scheme,
@@ -160,6 +155,11 @@ export async function rnxStart(
160
155
  }
161
156
 
162
157
  const help = makeHelp(terminal, { hasDebugger: Boolean(coreDevMiddleware) });
158
+ const terminalReporter = makeReporter(
159
+ args.customLogReporterPath,
160
+ terminal,
161
+ projectRoot
162
+ );
163
163
 
164
164
  // @ts-expect-error We want to override `reporter`
165
165
  metroConfig.reporter = {
@@ -223,3 +223,94 @@ export async function rnxStart(
223
223
  attachKeyHandlers({ devServerUrl, help, messageSocketEndpoint, terminal });
224
224
  }
225
225
  }
226
+
227
+ export const rnxStartCommand = {
228
+ name: "rnx-start",
229
+ func: rnxStart,
230
+ description:
231
+ "Start a bundle-server to host your react-native experience during development",
232
+ options: [
233
+ {
234
+ name: "--port [number]",
235
+ description:
236
+ "Host port to use when listening for incoming server requests.",
237
+ parse: parseInt,
238
+ default: 8081,
239
+ },
240
+ {
241
+ name: "--host [string]",
242
+ description:
243
+ "Host name or address to bind when listening for incoming server requests. When not given, requests from all addresses are accepted.",
244
+ default: "",
245
+ },
246
+ {
247
+ name: "--projectRoot [path]",
248
+ description:
249
+ "Path to the root of your react-native project. The bundle server uses this root path to resolve all web requests.",
250
+ parse: (val: string) => path.resolve(val),
251
+ },
252
+ {
253
+ name: "--watchFolders [paths]",
254
+ description:
255
+ "Additional folders which will be added to the file-watch list. Comma-separated. By default, Metro watches all project files.",
256
+ parse: (val: string) =>
257
+ val.split(",").map((folder) => path.resolve(folder)),
258
+ },
259
+ {
260
+ name: "--assetPlugins [list]",
261
+ description:
262
+ "Additional asset plugins to be used by the Metro Babel transformer. Comma-separated list containing plugin module names or absolute paths to plugin packages.",
263
+ parse: (val: string) => val.split(","),
264
+ },
265
+ {
266
+ name: "--sourceExts [list]",
267
+ description:
268
+ "Additional source-file extensions to include when generating bundles. Comma-separated list, excluding the leading dot.",
269
+ parse: (val: string) => val.split(","),
270
+ },
271
+ {
272
+ name: "--max-workers [number]",
273
+ description:
274
+ "Specifies the maximum number of parallel worker threads to use for transforming files. This defaults to the number of cores available on your machine.",
275
+ parse: parseInt,
276
+ },
277
+ {
278
+ name: "--reset-cache",
279
+ description: "Reset the Metro cache.",
280
+ },
281
+ {
282
+ name: "--custom-log-reporter-path [string]",
283
+ description:
284
+ "Path to a JavaScript file which exports a Metro 'TerminalReporter' function. This replaces the default reporter, which writes all messages to the Metro console.",
285
+ },
286
+ {
287
+ name: "--https",
288
+ description:
289
+ "Use a secure (https) web server. When not specified, an insecure (http) web server is used.",
290
+ },
291
+ {
292
+ name: "--key [path]",
293
+ description:
294
+ "Path to a custom SSL private key file to use for secure (https) communication.",
295
+ },
296
+ {
297
+ name: "--cert [path]",
298
+ description:
299
+ "Path to a custom SSL certificate file to use for secure (https) communication.",
300
+ },
301
+ {
302
+ name: "--config [string]",
303
+ description: "Path to the Metro configuration file.",
304
+ parse: (val: string) => path.resolve(val),
305
+ },
306
+ {
307
+ name: "--no-interactive",
308
+ description: "Disables interactive mode.",
309
+ },
310
+ {
311
+ name: "--id [string]",
312
+ description:
313
+ "Specify which bundle configuration to use if server configuration is missing.",
314
+ },
315
+ ],
316
+ };
@@ -1,5 +1,6 @@
1
1
  import type { Config as CLIConfig } from "@react-native-community/cli-types";
2
2
  import { writeThirdPartyNotices } from "@rnx-kit/third-party-notices";
3
+ import { parseBoolean } from "./parsers";
3
4
 
4
5
  type CliThirdPartyNoticesOptions = {
5
6
  rootPath: string;
@@ -38,3 +39,49 @@ export function rnxWriteThirdPartyNotices(
38
39
  additionalText: additionalText ? [additionalText] : undefined,
39
40
  });
40
41
  }
42
+
43
+ export const rnxWriteThirdPartyNoticesCommand = {
44
+ name: "rnx-write-third-party-notices",
45
+ description: "Writes third party notices based on the given bundle",
46
+ func: rnxWriteThirdPartyNotices,
47
+ options: [
48
+ {
49
+ name: "--root-path <path>",
50
+ description:
51
+ "The root of the repo. This is the starting point for finding each module in the source map dependency graph.",
52
+ },
53
+ {
54
+ name: "--source-map-file <file>",
55
+ description:
56
+ "The source map file associated with the package's entry file. This source map eventually leads to all package dependencies and their licenses.",
57
+ },
58
+ {
59
+ name: "--json",
60
+ description: "Format the 3rd-party notice file as JSON instead of text.",
61
+ default: false,
62
+ parse: parseBoolean,
63
+ },
64
+ {
65
+ name: "--output-file [file]",
66
+ description: "The path to use when writing the 3rd-party notice file.",
67
+ },
68
+ {
69
+ name: "--ignore-scopes [string]",
70
+ description:
71
+ "Comma-separated list of `npm` scopes to ignore when traversing the source map dependency graph.",
72
+ },
73
+ {
74
+ name: "--ignore-modules [string]",
75
+ description:
76
+ "Comma-separated list of modules to ignore when traversing the source map dependency graph.",
77
+ },
78
+ {
79
+ name: "--preamble-text [string]",
80
+ description: "A string to prepend to the start of the 3rd-party notice.",
81
+ },
82
+ {
83
+ name: "--additional-text [path]",
84
+ description: "A string to append to the end of the 3rd-party notice.",
85
+ },
86
+ ],
87
+ };