@rnx-kit/cli 0.16.29 → 0.16.30

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.
Files changed (52) hide show
  1. package/lib/align-deps.js +5 -5
  2. package/lib/bundle/cliOptions.d.ts +2 -2
  3. package/lib/bundle/cliOptions.js +27 -27
  4. package/lib/bundle/hermes.d.ts +2 -1
  5. package/lib/bundle/hermes.js +4 -10
  6. package/lib/bundle/metro.js +5 -8
  7. package/lib/bundle.d.ts +3 -3
  8. package/lib/bundle.js +4 -4
  9. package/lib/clean.d.ts +2 -2
  10. package/lib/clean.js +42 -62
  11. package/lib/helpers/externals.d.ts +4 -0
  12. package/lib/{serve/external.js → helpers/externals.js} +10 -8
  13. package/lib/helpers/filesystem.d.ts +3 -0
  14. package/lib/helpers/filesystem.js +31 -0
  15. package/lib/{metro-config.js → helpers/metro-config.js} +1 -1
  16. package/lib/{parsers.d.ts → helpers/parsers.d.ts} +1 -1
  17. package/lib/{parsers.js → helpers/parsers.js} +16 -14
  18. package/lib/index.d.ts +12 -13
  19. package/lib/index.js +1 -5
  20. package/lib/ram-bundle.d.ts +4 -4
  21. package/lib/ram-bundle.js +2 -2
  22. package/lib/start.d.ts +1 -1
  23. package/lib/start.js +33 -33
  24. package/lib/test.d.ts +2 -1
  25. package/lib/test.js +1 -1
  26. package/lib/write-third-party-notices.js +13 -13
  27. package/package.json +6 -8
  28. package/lib/serve/external.d.ts +0 -7
  29. package/src/align-deps.ts +0 -82
  30. package/src/bundle/cliOptions.ts +0 -82
  31. package/src/bundle/defaultPlugins.ts +0 -16
  32. package/src/bundle/hermes.ts +0 -114
  33. package/src/bundle/kit-config.ts +0 -81
  34. package/src/bundle/metro.ts +0 -66
  35. package/src/bundle/overrides.ts +0 -51
  36. package/src/bundle/types.ts +0 -41
  37. package/src/bundle.ts +0 -69
  38. package/src/clean.ts +0 -223
  39. package/src/copy-assets.ts +0 -545
  40. package/src/index.ts +0 -34
  41. package/src/metro-config.ts +0 -208
  42. package/src/parsers.ts +0 -44
  43. package/src/ram-bundle.ts +0 -78
  44. package/src/serve/external.ts +0 -62
  45. package/src/serve/help.ts +0 -59
  46. package/src/serve/keyboard.ts +0 -76
  47. package/src/serve/kit-config.ts +0 -47
  48. package/src/serve/types.ts +0 -87
  49. package/src/start.ts +0 -316
  50. package/src/test.ts +0 -137
  51. package/src/write-third-party-notices.ts +0 -85
  52. /package/lib/{metro-config.d.ts → helpers/metro-config.d.ts} +0 -0
package/lib/align-deps.js CHANGED
@@ -30,15 +30,15 @@ exports.rnxAlignDepsCommand = {
30
30
  func: rnxAlignDeps,
31
31
  options: [
32
32
  {
33
- name: `--diff-mode [${align_deps_1.cliOptions["diff-mode"].choices.join("|")}]`,
33
+ name: `--diff-mode <${align_deps_1.cliOptions["diff-mode"].choices.join("|")}>`,
34
34
  description: align_deps_1.cliOptions["diff-mode"].description,
35
35
  },
36
36
  {
37
- name: "--exclude-packages [packages]",
37
+ name: "--exclude-packages <packages>",
38
38
  description: align_deps_1.cliOptions["exclude-packages"].description,
39
39
  },
40
40
  {
41
- name: `--init [${(_a = align_deps_1.cliOptions.init.choices) === null || _a === void 0 ? void 0 : _a.join("|")}]`,
41
+ name: `--init <${(_a = align_deps_1.cliOptions.init.choices) === null || _a === void 0 ? void 0 : _a.join("|")}>`,
42
42
  description: align_deps_1.cliOptions.init.description,
43
43
  },
44
44
  {
@@ -54,11 +54,11 @@ exports.rnxAlignDepsCommand = {
54
54
  description: align_deps_1.cliOptions["no-unmanaged"].description,
55
55
  },
56
56
  {
57
- name: "--presets [presets]",
57
+ name: "--presets <presets>",
58
58
  description: align_deps_1.cliOptions.presets.description,
59
59
  },
60
60
  {
61
- name: "--requirements [requirements]",
61
+ name: "--requirements <requirements>",
62
62
  description: align_deps_1.cliOptions.requirements.description,
63
63
  },
64
64
  {
@@ -1,5 +1,5 @@
1
1
  import { parsePlatform } from "@rnx-kit/tools-react-native/platform";
2
- import { asBoolean, asNumber, parseTransformProfile } from "../parsers";
2
+ import { asBoolean, asNumber, asTransformProfile } from "../helpers/parsers";
3
3
  export declare const commonBundleCommandOptions: ({
4
4
  name: string;
5
5
  description: string;
@@ -33,7 +33,7 @@ export declare const commonBundleCommandOptions: ({
33
33
  } | {
34
34
  name: string;
35
35
  description: string;
36
- parse: typeof parseTransformProfile;
36
+ parse: typeof asTransformProfile;
37
37
  default?: undefined;
38
38
  })[];
39
39
  //# sourceMappingURL=cliOptions.d.ts.map
@@ -2,74 +2,74 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.commonBundleCommandOptions = void 0;
4
4
  const platform_1 = require("@rnx-kit/tools-react-native/platform");
5
- const parsers_1 = require("../parsers");
5
+ const parsers_1 = require("../helpers/parsers");
6
6
  exports.commonBundleCommandOptions = [
7
7
  {
8
- name: "--id [id]",
9
- description: "Target bundle definition. This is only needed when the rnx-kit configuration has multiple bundle definitions.",
8
+ name: "--id <id>",
9
+ description: "Target bundle definition; only needed when the rnx-kit configuration has multiple bundle definitions",
10
10
  },
11
11
  {
12
- name: "--entry-file [path]",
13
- description: "Path to the root JavaScript or TypeScript file, either absolute or relative to the package.",
12
+ name: "--entry-file <path>",
13
+ description: "Path to the root JavaScript or TypeScript file, either absolute or relative to the package",
14
14
  },
15
15
  {
16
- name: "--platform [ios|android|windows|win32|macos]",
17
- description: "Target platform. When not given, all platforms in the rnx-kit configuration are bundled.",
16
+ name: "--platform <ios|android|windows|win32|macos>",
17
+ description: "Target platform; when unspecified, all platforms in the rnx-kit configuration are bundled",
18
18
  parse: platform_1.parsePlatform,
19
19
  },
20
20
  {
21
21
  name: "--dev [boolean]",
22
- description: "If false, warnings are disabled and the bundle is minified.",
22
+ description: "If false, warnings are disabled and the bundle is minified",
23
23
  default: true,
24
24
  parse: parsers_1.asBoolean,
25
25
  },
26
26
  {
27
27
  name: "--minify [boolean]",
28
- description: "Controls whether or not the bundle is minified. Disabling minification is useful for test builds.",
28
+ description: "Controls whether or not the bundle is minified (useful for test builds)",
29
29
  parse: parsers_1.asBoolean,
30
30
  },
31
31
  {
32
- name: "--bundle-output [string]",
33
- description: "Path to the output bundle file, either absolute or relative to the package.",
32
+ name: "--bundle-output <string>",
33
+ description: "Path to the output bundle file, either absolute or relative to the package",
34
34
  },
35
35
  {
36
- name: "--bundle-encoding [utf8|utf16le|ascii]",
37
- description: "Character encoding to use when writing the bundle file.",
36
+ name: "--bundle-encoding <utf8|utf16le|ascii>",
37
+ description: "Character encoding to use when writing the bundle file",
38
38
  default: "utf8",
39
39
  },
40
40
  {
41
- name: "--max-workers [number]",
42
- description: "Specifies the maximum number of parallel worker threads to use for transforming files. This defaults to the number of cores available on your machine.",
41
+ name: "--max-workers <number>",
42
+ description: "Specifies the maximum number of parallel worker threads to use for transforming files; defaults to the number of cores available on your machine",
43
43
  parse: parsers_1.asNumber,
44
44
  },
45
45
  {
46
- name: "--sourcemap-output [string]",
47
- description: "Path where the bundle source map is written, either absolute or relative to the package.",
46
+ name: "--sourcemap-output <string>",
47
+ description: "Path where the bundle source map is written, either absolute or relative to the package",
48
48
  },
49
49
  {
50
- name: "--sourcemap-sources-root [string]",
51
- description: "Path to use when relativizing file entries in the bundle source map.",
50
+ name: "--sourcemap-sources-root <string>",
51
+ description: "Path to use when relativizing file entries in the bundle source map",
52
52
  },
53
53
  {
54
54
  name: "--sourcemap-use-absolute-path",
55
55
  description: "Report SourceMapURL using its full path",
56
56
  },
57
57
  {
58
- name: "--assets-dest [path]",
59
- description: "Path where bundle assets like images are written, either absolute or relative to the package. If not given, assets are ignored.",
58
+ name: "--assets-dest <path>",
59
+ description: "Path where bundle assets like images are written, either absolute or relative to the package; if unspecified, assets are ignored",
60
60
  },
61
61
  {
62
- name: "--unstable-transform-profile [string]",
63
- description: "Experimental, transform JS for a specific JS engine. Currently supported: hermes, hermes-canary, default",
64
- parse: parsers_1.parseTransformProfile,
62
+ name: "--unstable-transform-profile <string>",
63
+ description: "[Experimental] Transform JS for a specific JS engine; currently supported: hermes, hermes-canary, default",
64
+ parse: parsers_1.asTransformProfile,
65
65
  },
66
66
  {
67
67
  name: "--reset-cache",
68
- description: "Reset the Metro cache.",
68
+ description: "Reset the Metro cache",
69
69
  },
70
70
  {
71
- name: "--config [string]",
72
- description: "Path to the Metro configuration file.",
71
+ name: "--config <string>",
72
+ description: "Path to the Metro configuration file",
73
73
  },
74
74
  ];
75
75
  //# sourceMappingURL=cliOptions.js.map
@@ -1,3 +1,4 @@
1
+ import type { Config as CLIConfig } from "@react-native-community/cli-types";
1
2
  import type { HermesOptions } from "@rnx-kit/config";
2
- export declare function emitBytecode(input: string, sourcemap: string | undefined, options: HermesOptions): void;
3
+ export declare function emitBytecode(cliConfig: CLIConfig, input: string, sourcemap: string | undefined, options: HermesOptions): void;
3
4
  //# sourceMappingURL=hermes.d.ts.map
@@ -43,15 +43,9 @@ function hermesBinaryInDir(hermesc) {
43
43
  return null;
44
44
  }
45
45
  }
46
- function findHermesBinary() {
46
+ function findHermesBinary({ reactNativePath }) {
47
47
  const locations = [
48
- () => {
49
- const rnPath = (0, package_1.findPackageDependencyDir)("react-native");
50
- if (!rnPath) {
51
- throw new Error("Cannot find module 'react-native'");
52
- }
53
- return path.join(rnPath, "sdks", "hermesc");
54
- },
48
+ () => path.join(reactNativePath, "sdks", "hermesc"),
55
49
  () => (0, package_1.findPackageDependencyDir)("hermes-engine"),
56
50
  ];
57
51
  for (const getLocation of locations) {
@@ -78,9 +72,9 @@ function getOutput(args) {
78
72
  }
79
73
  return null;
80
74
  }
81
- function emitBytecode(input, sourcemap, options) {
75
+ function emitBytecode(cliConfig, input, sourcemap, options) {
82
76
  var _a;
83
- const cmd = options.command || findHermesBinary();
77
+ const cmd = options.command || findHermesBinary(cliConfig);
84
78
  if (!cmd) {
85
79
  (0, console_1.error)("No Hermes compiler was found");
86
80
  return;
@@ -26,12 +26,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.metroBundle = metroBundle;
27
27
  const console_1 = require("@rnx-kit/console");
28
28
  const metro_service_1 = require("@rnx-kit/metro-service");
29
- const fs = __importStar(require("fs"));
30
29
  const path = __importStar(require("path"));
31
- const metro_config_1 = require("../metro-config");
32
- function ensureDir(p) {
33
- fs.mkdirSync(p, { recursive: true, mode: 0o755 });
34
- }
30
+ const filesystem_1 = require("../helpers/filesystem");
31
+ const metro_config_1 = require("../helpers/metro-config");
35
32
  /**
36
33
  * Run the Metro bundler.
37
34
  *
@@ -66,12 +63,12 @@ async function metroBundle(metroConfig, bundleConfig, dev, minify, output = metr
66
63
  minify,
67
64
  };
68
65
  // ensure all output directories exist
69
- ensureDir(path.dirname(metroBundleArgs.bundleOutput));
66
+ (0, filesystem_1.ensureDir)(path.dirname(metroBundleArgs.bundleOutput));
70
67
  if (metroBundleArgs.sourcemapOutput) {
71
- ensureDir(path.dirname(metroBundleArgs.sourcemapOutput));
68
+ (0, filesystem_1.ensureDir)(path.dirname(metroBundleArgs.sourcemapOutput));
72
69
  }
73
70
  if (metroBundleArgs.assetsDest) {
74
- ensureDir(metroBundleArgs.assetsDest);
71
+ (0, filesystem_1.ensureDir)(metroBundleArgs.assetsDest);
75
72
  }
76
73
  // create the bundle
77
74
  await output(metroBundleArgs, metroConfig);
package/lib/bundle.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Config as CLIConfig } from "@react-native-community/cli-types";
2
2
  import type { CLICommonBundleOptions } from "./bundle/types";
3
- import { asBoolean } from "./parsers";
3
+ import { asBoolean } from "./helpers/parsers";
4
4
  type CLIBundleOptions = CLICommonBundleOptions & {
5
5
  treeShake?: boolean;
6
6
  };
@@ -37,12 +37,12 @@ export declare const rnxBundleCommand: {
37
37
  } | {
38
38
  name: string;
39
39
  description: string;
40
- parse: typeof import("./parsers").asNumber;
40
+ parse: typeof import("./helpers/parsers").asNumber;
41
41
  default?: undefined;
42
42
  } | {
43
43
  name: string;
44
44
  description: string;
45
- parse: typeof import("./parsers").parseTransformProfile;
45
+ parse: typeof import("./helpers/parsers").asTransformProfile;
46
46
  default?: undefined;
47
47
  })[];
48
48
  };
package/lib/bundle.js CHANGED
@@ -8,7 +8,7 @@ const hermes_1 = require("./bundle/hermes");
8
8
  const kit_config_1 = require("./bundle/kit-config");
9
9
  const metro_1 = require("./bundle/metro");
10
10
  const overrides_1 = require("./bundle/overrides");
11
- const parsers_1 = require("./parsers");
11
+ const parsers_1 = require("./helpers/parsers");
12
12
  async function rnxBundle(_argv, cliConfig, cliOptions) {
13
13
  const metroConfig = await (0, metro_service_1.loadMetroConfig)(cliConfig, cliOptions);
14
14
  const bundleConfigs = (0, kit_config_1.getCliPlatformBundleConfigs)(cliOptions.id, cliOptions.platform);
@@ -21,19 +21,19 @@ async function rnxBundle(_argv, cliConfig, cliOptions) {
21
21
  await (0, metro_1.metroBundle)(metroConfig, bundleConfig, cliOptions.dev, cliOptions.minify);
22
22
  const { bundleOutput, hermes, sourcemapOutput } = bundleConfig;
23
23
  if (hermes) {
24
- (0, hermes_1.emitBytecode)(bundleOutput, sourcemapOutput, hermes === true ? {} : hermes);
24
+ (0, hermes_1.emitBytecode)(cliConfig, bundleOutput, sourcemapOutput, hermes === true ? {} : hermes);
25
25
  }
26
26
  }
27
27
  }
28
28
  exports.rnxBundleCommand = {
29
29
  name: "rnx-bundle",
30
- description: "Bundle your rnx-kit package for offline use. See https://aka.ms/rnx-kit.",
30
+ description: "Bundle your JavaScript for offline use",
31
31
  func: rnxBundle,
32
32
  options: [
33
33
  ...cliOptions_1.commonBundleCommandOptions,
34
34
  {
35
35
  name: "--tree-shake [boolean]",
36
- description: "Enable tree shaking to remove unused code and reduce the bundle size.",
36
+ description: "Enable tree shaking to remove unused code and reduce the bundle size",
37
37
  parse: parsers_1.asBoolean,
38
38
  },
39
39
  ],
package/lib/clean.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import type { Config as CLIConfig } from "@react-native-community/cli-types";
2
- import { asResolvedPath } from "./parsers";
2
+ import { asResolvedPath } from "./helpers/parsers";
3
3
  type Args = {
4
4
  include?: string;
5
5
  projectRoot?: string;
6
6
  verify?: boolean;
7
7
  };
8
- export declare function rnxClean(_argv: string[], _config: CLIConfig, cliOptions: Args): Promise<void>;
8
+ export declare function rnxClean(_argv: string[], { root }: CLIConfig, cliOptions: Args): Promise<void>;
9
9
  export declare const rnxCleanCommand: {
10
10
  name: string;
11
11
  func: typeof rnxClean;
package/lib/clean.js CHANGED
@@ -29,28 +29,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.rnxCleanCommand = void 0;
30
30
  exports.rnxClean = rnxClean;
31
31
  const child_process_1 = require("child_process");
32
- const fs = __importStar(require("fs-extra"));
32
+ const fs_1 = require("fs");
33
+ const fs = __importStar(require("fs/promises"));
33
34
  const ora_1 = __importDefault(require("ora"));
34
35
  const os = __importStar(require("os"));
35
36
  const path = __importStar(require("path"));
36
- const parsers_1 = require("./parsers");
37
- const external_1 = require("./serve/external");
38
- async function rnxClean(_argv, _config, cliOptions) {
39
- var _a, _b, _c;
40
- const projectRoot = (_a = cliOptions.projectRoot) !== null && _a !== void 0 ? _a : process.cwd();
41
- if (!fs.existsSync(projectRoot)) {
42
- throw new Error(`Invalid path provided! ${projectRoot}`);
43
- }
44
- const spinner = (0, ora_1.default)();
45
- try {
46
- (0, external_1.requireExternal)("@react-native-community/cli-clean");
47
- spinner.warn("`rnx-clean` has been upstreamed to `@react-native-community/cli`. Please use `npx react-native clean` instead.");
48
- }
49
- catch (_) {
50
- // Ignore
37
+ const parsers_1 = require("./helpers/parsers");
38
+ async function rnxClean(_argv, { root = process.cwd() }, cliOptions) {
39
+ var _a, _b;
40
+ if (!(0, fs_1.existsSync)(root)) {
41
+ throw new Error(`Invalid project root: ${root}`);
51
42
  }
52
43
  const npm = os.platform() === "win32" ? "npm.cmd" : "npm";
53
44
  const yarn = os.platform() === "win32" ? "yarn.cmd" : "yarn";
45
+ const execute = (command, args, cwd = root) => {
46
+ return new Promise((resolve, reject) => {
47
+ const process = (0, child_process_1.spawn)(command, args, {
48
+ cwd,
49
+ stdio: ["ignore", "pipe", "pipe"],
50
+ shell: command.endsWith(".bat") || command.endsWith(".cmd"),
51
+ });
52
+ process.on("error", (e) => {
53
+ const code = "code" in e ? e.code : "errno" in e ? e.errno : "1";
54
+ reject(`${e.message} (code: ${code})`);
55
+ });
56
+ process.on("close", (code) => {
57
+ if (code === 0) {
58
+ resolve();
59
+ }
60
+ });
61
+ });
62
+ };
54
63
  const COMMANDS = {
55
64
  android: [
56
65
  {
@@ -59,7 +68,7 @@ async function rnxClean(_argv, _config, cliOptions) {
59
68
  const candidates = os.platform() === "win32"
60
69
  ? ["android/gradlew.bat", "gradlew.bat"]
61
70
  : ["android/gradlew", "gradlew"];
62
- const gradlew = findPath(projectRoot, candidates);
71
+ const gradlew = findPath(root, candidates);
63
72
  if (gradlew) {
64
73
  const script = path.basename(gradlew);
65
74
  return execute(os.platform() === "win32" ? script : `./${script}`, ["clean"], path.dirname(gradlew));
@@ -73,7 +82,7 @@ async function rnxClean(_argv, _config, cliOptions) {
73
82
  cocoapods: [
74
83
  {
75
84
  label: "Clean CocoaPods cache",
76
- action: () => execute("pod", ["cache", "clean", "--all"], projectRoot),
85
+ action: () => execute("pod", ["cache", "clean", "--all"]),
77
86
  },
78
87
  ],
79
88
  metro: [
@@ -93,13 +102,13 @@ async function rnxClean(_argv, _config, cliOptions) {
93
102
  npm: [
94
103
  {
95
104
  label: "Remove node_modules",
96
- action: () => cleanDir(`${projectRoot}/node_modules`),
105
+ action: () => cleanDir(`${root}/node_modules`),
97
106
  },
98
107
  ...(cliOptions.verify
99
108
  ? [
100
109
  {
101
110
  label: "Verify npm cache",
102
- action: () => execute(npm, ["cache", "verify"], projectRoot),
111
+ action: () => execute(npm, ["cache", "verify"]),
103
112
  },
104
113
  ]
105
114
  : []),
@@ -107,26 +116,24 @@ async function rnxClean(_argv, _config, cliOptions) {
107
116
  watchman: [
108
117
  {
109
118
  label: "Stop Watchman",
110
- action: () => execute(os.platform() === "win32" ? "tskill" : "killall", ["watchman"], projectRoot),
119
+ action: () => execute(os.platform() === "win32" ? "tskill" : "killall", [
120
+ "watchman",
121
+ ]),
111
122
  },
112
123
  {
113
124
  label: "Delete Watchman cache",
114
- action: () => execute("watchman", ["watch-del-all"], projectRoot),
125
+ action: () => execute("watchman", ["watch-del-all"]),
115
126
  },
116
127
  ],
117
128
  yarn: [
118
129
  {
119
130
  label: "Clean Yarn cache",
120
- action: () => execute(yarn, ["cache", "clean"], projectRoot),
131
+ action: () => execute(yarn, ["cache", "clean"]),
121
132
  },
122
133
  ],
123
134
  };
124
- const categories = (_c = (_b = cliOptions.include) === null || _b === void 0 ? void 0 : _b.split(",")) !== null && _c !== void 0 ? _c : [
125
- "metro",
126
- "npm",
127
- "watchman",
128
- "yarn",
129
- ];
135
+ const categories = (_b = (_a = cliOptions.include) === null || _a === void 0 ? void 0 : _a.split(",")) !== null && _b !== void 0 ? _b : ["metro", "watchman"];
136
+ const spinner = (0, ora_1.default)();
130
137
  for (const category of categories) {
131
138
  const commands = COMMANDS[category];
132
139
  if (!commands) {
@@ -146,57 +153,30 @@ async function rnxClean(_argv, _config, cliOptions) {
146
153
  }
147
154
  }
148
155
  function cleanDir(path) {
149
- if (!fs.existsSync(path)) {
156
+ if (!(0, fs_1.existsSync)(path)) {
150
157
  return Promise.resolve();
151
158
  }
152
- return fs.rmdir(path, { maxRetries: 3, recursive: true });
159
+ return fs.rm(path, { maxRetries: 3, recursive: true });
153
160
  }
154
161
  function findPath(startPath, files) {
155
162
  // TODO: Find project files via `@react-native-community/cli`
156
163
  for (const file of files) {
157
164
  const filename = path.resolve(startPath, file);
158
- if (fs.existsSync(filename)) {
165
+ if ((0, fs_1.existsSync)(filename)) {
159
166
  return filename;
160
167
  }
161
168
  }
162
169
  return undefined;
163
170
  }
164
- function execute(command, args, cwd) {
165
- return new Promise((resolve, reject) => {
166
- const process = (0, child_process_1.spawn)(command, args, {
167
- cwd,
168
- stdio: ["inherit", null, null],
169
- shell: command.endsWith(".bat") || command.endsWith(".cmd"),
170
- });
171
- const stderr = [];
172
- process.stderr.on("data", (data) => {
173
- stderr.push(data);
174
- });
175
- process.on("close", (code, signal) => {
176
- if (code === 0) {
177
- resolve();
178
- }
179
- else if (stderr) {
180
- reject(Buffer.concat(stderr).toString().trimEnd());
181
- }
182
- else if (signal) {
183
- reject(`Failed with signal ${signal}`);
184
- }
185
- else {
186
- reject(`Failed with exit code ${code}`);
187
- }
188
- });
189
- });
190
- }
191
171
  exports.rnxCleanCommand = {
192
172
  name: "rnx-clean",
193
173
  func: rnxClean,
194
174
  description: "Clears React Native project related caches",
195
175
  options: [
196
176
  {
197
- name: "--include [android,cocoapods,metro,npm,watchman,yarn]",
198
- description: "Comma-separated flag of caches to clear, e.g. `npm,yarn`. When not specified, only non-platform specific caches are cleared.",
199
- default: "metro,npm,watchman,yarn",
177
+ name: "--include <android,cocoapods,metro,npm,watchman,yarn>",
178
+ description: "Comma-separated flag of caches to clear e.g., `npm,yarn`",
179
+ default: "metro,watchman",
200
180
  },
201
181
  {
202
182
  name: "--project-root <path>",
@@ -0,0 +1,4 @@
1
+ import type { CliServerApi, CoreDevMiddleware } from "../serve/types";
2
+ export declare function requireExternal(module: "@react-native-community/cli-server-api", projectRoot: string, reactNativePath: string): CliServerApi;
3
+ export declare function requireExternal(module: "@react-native/dev-middleware", projectRoot: string, reactNativePath: string): CoreDevMiddleware;
4
+ //# sourceMappingURL=externals.d.ts.map
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requireExternal = requireExternal;
4
4
  const package_1 = require("@rnx-kit/tools-node/package");
5
- function friendlyRequire(...modules) {
5
+ const context_1 = require("@rnx-kit/tools-react-native/context");
6
+ function friendlyRequire(modules, startDir) {
6
7
  try {
7
- const modulePath = (0, package_1.resolveDependencyChain)(modules);
8
+ const modulePath = (0, package_1.resolveDependencyChain)(modules, startDir);
8
9
  return require(modulePath);
9
10
  }
10
11
  catch (_) {
@@ -16,14 +17,15 @@ function friendlyRequire(...modules) {
16
17
  "file a bug at https://github.com/microsoft/rnx-kit/issues.");
17
18
  }
18
19
  }
19
- function requireExternal(module) {
20
+ function requireExternal(module, projectRoot, reactNativePath) {
20
21
  switch (module) {
21
- case "@react-native-community/cli-clean":
22
- return friendlyRequire("react-native", "@react-native-community/cli", "@react-native-community/cli-clean");
23
22
  case "@react-native-community/cli-server-api":
24
- return friendlyRequire("react-native", "@react-native-community/cli", "@react-native-community/cli-server-api");
23
+ return friendlyRequire([
24
+ "@react-native-community/cli",
25
+ "@react-native-community/cli-server-api",
26
+ ], (0, context_1.resolveCommunityCLI)(projectRoot, reactNativePath));
25
27
  case "@react-native/dev-middleware":
26
- return friendlyRequire("react-native", "@react-native/community-cli-plugin", "@react-native/dev-middleware");
28
+ return friendlyRequire(["@react-native/community-cli-plugin", "@react-native/dev-middleware"], reactNativePath);
27
29
  }
28
30
  }
29
- //# sourceMappingURL=external.js.map
31
+ //# sourceMappingURL=externals.js.map
@@ -0,0 +1,3 @@
1
+ import * as nodefs from "fs";
2
+ export declare function ensureDir(p: string, fs?: typeof nodefs): void;
3
+ //# sourceMappingURL=filesystem.d.ts.map
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ensureDir = ensureDir;
27
+ const nodefs = __importStar(require("fs"));
28
+ function ensureDir(p, fs = nodefs) {
29
+ fs.mkdirSync(p, { recursive: true, mode: 0o755 });
30
+ }
31
+ //# sourceMappingURL=filesystem.js.map
@@ -7,7 +7,7 @@ const metro_plugin_duplicates_checker_1 = require("@rnx-kit/metro-plugin-duplica
7
7
  const metro_plugin_typescript_1 = require("@rnx-kit/metro-plugin-typescript");
8
8
  const metro_serializer_1 = require("@rnx-kit/metro-serializer");
9
9
  const metro_serializer_esbuild_1 = require("@rnx-kit/metro-serializer-esbuild");
10
- const defaultPlugins_1 = require("./bundle/defaultPlugins");
10
+ const defaultPlugins_1 = require("../bundle/defaultPlugins");
11
11
  function resolvePlugin(name) {
12
12
  try {
13
13
  return require.resolve(name);
@@ -3,5 +3,5 @@ export declare function asBoolean(value: string): boolean;
3
3
  export declare function asNumber(value: string): number;
4
4
  export declare function asResolvedPath(value: string): string;
5
5
  export declare function asStringArray(value: string): string[];
6
- export declare function parseTransformProfile(val: string): TransformProfile;
6
+ export declare function asTransformProfile(val: string): TransformProfile;
7
7
  //# sourceMappingURL=parsers.d.ts.map
@@ -27,7 +27,7 @@ exports.asBoolean = asBoolean;
27
27
  exports.asNumber = asNumber;
28
28
  exports.asResolvedPath = asResolvedPath;
29
29
  exports.asStringArray = asStringArray;
30
- exports.parseTransformProfile = parseTransformProfile;
30
+ exports.asTransformProfile = asTransformProfile;
31
31
  const path = __importStar(require("path"));
32
32
  function asBoolean(value) {
33
33
  switch (value) {
@@ -36,7 +36,7 @@ function asBoolean(value) {
36
36
  case "true":
37
37
  return true;
38
38
  default:
39
- throw new Error("Invalid boolean value '" + value + "' — must be true or false");
39
+ throw new Error(`Expected 'true' or 'false; got '${value}'`);
40
40
  }
41
41
  }
42
42
  function asNumber(value) {
@@ -48,18 +48,20 @@ function asResolvedPath(value) {
48
48
  function asStringArray(value) {
49
49
  return value.split(",");
50
50
  }
51
- function parseTransformProfile(val) {
52
- const allowedProfiles = [
53
- "hermes-stable",
54
- "hermes-canary",
55
- "default",
56
- ];
57
- if (val in allowedProfiles) {
58
- return val;
51
+ function asTransformProfile(val) {
52
+ switch (val) {
53
+ case "hermes-stable":
54
+ case "hermes-canary":
55
+ case "default":
56
+ return val;
57
+ default: {
58
+ const profiles = [
59
+ "hermes-stable",
60
+ "hermes-canary",
61
+ "default",
62
+ ];
63
+ throw new Error(`Expected '${profiles.join("', '")}'; got ${val}`);
64
+ }
59
65
  }
60
- throw new Error("Invalid transform profile '" +
61
- val +
62
- "' -- must be one of " +
63
- allowedProfiles.join(", "));
64
66
  }
65
67
  //# sourceMappingURL=parsers.js.map