@rnx-kit/cli 0.16.30 → 0.17.0
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/README.md +172 -98
- package/bin/rnx-cli.cjs +2 -0
- package/lib/bin/context.d.ts +25 -0
- package/lib/bin/context.js +98 -0
- package/lib/bin/externalCommands.d.ts +3 -0
- package/lib/bin/externalCommands.js +34 -0
- package/lib/bin/rnx-cli.d.ts +2 -0
- package/lib/bin/rnx-cli.js +55 -0
- package/lib/bundle/hermes.js +5 -5
- package/lib/bundle/metro.js +1 -1
- package/lib/clean.d.ts +1 -1
- package/lib/clean.js +11 -11
- package/lib/copy-assets.d.ts +5 -3
- package/lib/copy-assets.js +31 -28
- package/lib/helpers/filesystem.js +1 -1
- package/lib/helpers/parsers.js +1 -1
- package/lib/index.d.ts +2 -187
- package/lib/serve/keyboard.js +3 -6
- package/lib/serve/types.d.ts +2 -2
- package/lib/start.js +1 -1
- package/lib/test.js +6 -4
- package/package.json +19 -16
package/lib/clean.js
CHANGED
|
@@ -28,23 +28,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.rnxCleanCommand = void 0;
|
|
30
30
|
exports.rnxClean = rnxClean;
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const fs = __importStar(require("fs/promises"));
|
|
31
|
+
const node_child_process_1 = require("node:child_process");
|
|
32
|
+
const node_fs_1 = require("node:fs");
|
|
33
|
+
const fs = __importStar(require("node:fs/promises"));
|
|
34
|
+
const os = __importStar(require("node:os"));
|
|
35
|
+
const path = __importStar(require("node:path"));
|
|
34
36
|
const ora_1 = __importDefault(require("ora"));
|
|
35
|
-
const os = __importStar(require("os"));
|
|
36
|
-
const path = __importStar(require("path"));
|
|
37
37
|
const parsers_1 = require("./helpers/parsers");
|
|
38
38
|
async function rnxClean(_argv, { root = process.cwd() }, cliOptions) {
|
|
39
39
|
var _a, _b;
|
|
40
|
-
if (!(0,
|
|
40
|
+
if (!(0, node_fs_1.existsSync)(root)) {
|
|
41
41
|
throw new Error(`Invalid project root: ${root}`);
|
|
42
42
|
}
|
|
43
43
|
const npm = os.platform() === "win32" ? "npm.cmd" : "npm";
|
|
44
44
|
const yarn = os.platform() === "win32" ? "yarn.cmd" : "yarn";
|
|
45
45
|
const execute = (command, args, cwd = root) => {
|
|
46
46
|
return new Promise((resolve, reject) => {
|
|
47
|
-
const process = (0,
|
|
47
|
+
const process = (0, node_child_process_1.spawn)(command, args, {
|
|
48
48
|
cwd,
|
|
49
49
|
stdio: ["ignore", "pipe", "pipe"],
|
|
50
50
|
shell: command.endsWith(".bat") || command.endsWith(".cmd"),
|
|
@@ -104,7 +104,7 @@ async function rnxClean(_argv, { root = process.cwd() }, cliOptions) {
|
|
|
104
104
|
label: "Remove node_modules",
|
|
105
105
|
action: () => cleanDir(`${root}/node_modules`),
|
|
106
106
|
},
|
|
107
|
-
...(cliOptions.
|
|
107
|
+
...(cliOptions.verifyCache
|
|
108
108
|
? [
|
|
109
109
|
{
|
|
110
110
|
label: "Verify npm cache",
|
|
@@ -153,7 +153,7 @@ async function rnxClean(_argv, { root = process.cwd() }, cliOptions) {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
function cleanDir(path) {
|
|
156
|
-
if (!(0,
|
|
156
|
+
if (!(0, node_fs_1.existsSync)(path)) {
|
|
157
157
|
return Promise.resolve();
|
|
158
158
|
}
|
|
159
159
|
return fs.rm(path, { maxRetries: 3, recursive: true });
|
|
@@ -162,7 +162,7 @@ function findPath(startPath, files) {
|
|
|
162
162
|
// TODO: Find project files via `@react-native-community/cli`
|
|
163
163
|
for (const file of files) {
|
|
164
164
|
const filename = path.resolve(startPath, file);
|
|
165
|
-
if ((0,
|
|
165
|
+
if ((0, node_fs_1.existsSync)(filename)) {
|
|
166
166
|
return filename;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
@@ -185,7 +185,7 @@ exports.rnxCleanCommand = {
|
|
|
185
185
|
parse: parsers_1.asResolvedPath,
|
|
186
186
|
},
|
|
187
187
|
{
|
|
188
|
-
name: "--verify",
|
|
188
|
+
name: "--verify-cache",
|
|
189
189
|
description: "Whether to verify the integrity of the cache",
|
|
190
190
|
default: false,
|
|
191
191
|
},
|
package/lib/copy-assets.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Config as CLIConfig } from "@react-native-community/cli-types";
|
|
|
2
2
|
import type { PackageManifest } from "@rnx-kit/tools-node/package";
|
|
3
3
|
import type { AllPlatforms } from "@rnx-kit/tools-react-native";
|
|
4
4
|
import { parsePlatform } from "@rnx-kit/tools-react-native";
|
|
5
|
+
import * as nodefs from "fs";
|
|
5
6
|
export type AndroidArchive = {
|
|
6
7
|
targetName?: string;
|
|
7
8
|
version?: string;
|
|
@@ -36,13 +37,14 @@ export type Context = {
|
|
|
36
37
|
projectRoot: string;
|
|
37
38
|
manifest: PackageManifest;
|
|
38
39
|
options: Options;
|
|
40
|
+
reactNativePath: string;
|
|
39
41
|
};
|
|
40
42
|
export type AssetsConfig = {
|
|
41
43
|
getAssets?: (context: Context) => Promise<NativeAssets>;
|
|
42
44
|
};
|
|
43
45
|
export declare function versionOf(pkgName: string): string;
|
|
44
46
|
export declare function assembleAarBundle(context: Context, packageName: string, { aar }: NativeAssets): Promise<void>;
|
|
45
|
-
export declare function copyAssets({ options: { assetsDest, xcassetsDest } }: Context, packageName: string, { assets, strings, xcassets }: NativeAssets): Promise<void>;
|
|
47
|
+
export declare function copyAssets({ options: { assetsDest, xcassetsDest } }: Context, packageName: string, { assets, strings, xcassets }: NativeAssets, fs?: typeof nodefs): Promise<void>;
|
|
46
48
|
export declare function gatherConfigs({ projectRoot, manifest, }: Context): Promise<Record<string, AssetsConfig | null> | undefined>;
|
|
47
49
|
/**
|
|
48
50
|
* Copies additional assets not picked by bundlers into desired directory.
|
|
@@ -97,11 +99,11 @@ export declare function gatherConfigs({ projectRoot, manifest, }: Context): Prom
|
|
|
97
99
|
*
|
|
98
100
|
* @param options Options dictate what gets copied where
|
|
99
101
|
*/
|
|
100
|
-
export declare function copyProjectAssets(options: Options): Promise<void>;
|
|
102
|
+
export declare function copyProjectAssets(options: Options, { root: projectRoot, reactNativePath }: CLIConfig): Promise<void>;
|
|
101
103
|
export declare const rnxCopyAssetsCommand: {
|
|
102
104
|
name: string;
|
|
103
105
|
description: string;
|
|
104
|
-
func: (_argv: string[],
|
|
106
|
+
func: (_argv: string[], config: CLIConfig, options: Options) => Promise<void>;
|
|
105
107
|
options: ({
|
|
106
108
|
name: string;
|
|
107
109
|
description: string;
|
package/lib/copy-assets.js
CHANGED
|
@@ -35,9 +35,11 @@ const package_1 = require("@rnx-kit/tools-node/package");
|
|
|
35
35
|
const path_1 = require("@rnx-kit/tools-node/path");
|
|
36
36
|
const tools_react_native_1 = require("@rnx-kit/tools-react-native");
|
|
37
37
|
const child_process_1 = require("child_process");
|
|
38
|
-
const fs = __importStar(require("fs
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const nodefs = __importStar(require("fs"));
|
|
39
40
|
const os = __importStar(require("os"));
|
|
40
41
|
const path = __importStar(require("path"));
|
|
42
|
+
const filesystem_1 = require("./helpers/filesystem");
|
|
41
43
|
const defaultAndroidConfig = {
|
|
42
44
|
androidPluginVersion: "7.2.2",
|
|
43
45
|
compileSdkVersion: 33,
|
|
@@ -47,6 +49,12 @@ const defaultAndroidConfig = {
|
|
|
47
49
|
},
|
|
48
50
|
kotlinVersion: "1.7.22",
|
|
49
51
|
};
|
|
52
|
+
function cloneFile(src, dest) {
|
|
53
|
+
return fs.promises.copyFile(src, dest, fs.constants.COPYFILE_FICLONE);
|
|
54
|
+
}
|
|
55
|
+
function cp_r(source, destination, fs = nodefs) {
|
|
56
|
+
return fs.promises.cp(source, destination, { recursive: true });
|
|
57
|
+
}
|
|
50
58
|
function ensureOption(options, opt, flag = opt) {
|
|
51
59
|
if (options[opt] == null) {
|
|
52
60
|
(0, console_1.error)(`Missing required option: --${flag}`);
|
|
@@ -145,7 +153,7 @@ async function assembleAarBundle(context, packageName, { aar }) {
|
|
|
145
153
|
...customEnv,
|
|
146
154
|
};
|
|
147
155
|
const outputDir = path.join(context.options.assetsDest, "aar");
|
|
148
|
-
|
|
156
|
+
(0, filesystem_1.ensureDir)(outputDir);
|
|
149
157
|
const dest = path.join(outputDir, `${targetName}-${version}.aar`);
|
|
150
158
|
const targets = [`:${targetName}:assembleRelease`];
|
|
151
159
|
const targetsToCopy = [[output, dest]];
|
|
@@ -169,17 +177,13 @@ async function assembleAarBundle(context, packageName, { aar }) {
|
|
|
169
177
|
run(gradlew, targets, { cwd: androidProject, stdio: "inherit", env });
|
|
170
178
|
}
|
|
171
179
|
else {
|
|
172
|
-
const reactNativePath = (0, package_1.findPackageDependencyDir)("react-native");
|
|
173
|
-
if (!reactNativePath) {
|
|
174
|
-
throw new Error("Could not find 'react-native'");
|
|
175
|
-
}
|
|
176
180
|
const buildDir = path.join(process.cwd(), "node_modules", ".rnx-gradle-build", targetName);
|
|
177
181
|
const compileSdkVersion = (_a = android === null || android === void 0 ? void 0 : android.compileSdkVersion) !== null && _a !== void 0 ? _a : defaultAndroidConfig.compileSdkVersion;
|
|
178
182
|
const minSdkVersion = (_c = (_b = android === null || android === void 0 ? void 0 : android.defaultConfig) === null || _b === void 0 ? void 0 : _b.minSdkVersion) !== null && _c !== void 0 ? _c : defaultAndroidConfig.defaultConfig.minSdkVersion;
|
|
179
183
|
const targetSdkVersion = (_e = (_d = android === null || android === void 0 ? void 0 : android.defaultConfig) === null || _d === void 0 ? void 0 : _d.targetSdkVersion) !== null && _e !== void 0 ? _e : defaultAndroidConfig.defaultConfig.targetSdkVersion;
|
|
180
184
|
const androidPluginVersion = (_f = android === null || android === void 0 ? void 0 : android.androidPluginVersion) !== null && _f !== void 0 ? _f : defaultAndroidConfig.androidPluginVersion;
|
|
181
185
|
const kotlinVersion = (_g = android === null || android === void 0 ? void 0 : android.kotlinVersion) !== null && _g !== void 0 ? _g : defaultAndroidConfig.kotlinVersion;
|
|
182
|
-
const buildRelativeReactNativePath = path.relative(buildDir, reactNativePath);
|
|
186
|
+
const buildRelativeReactNativePath = path.relative(buildDir, context.reactNativePath);
|
|
183
187
|
const buildGradle = [
|
|
184
188
|
"buildscript {",
|
|
185
189
|
" ext {",
|
|
@@ -219,31 +223,31 @@ async function assembleAarBundle(context, packageName, { aar }) {
|
|
|
219
223
|
`project(":${targetName}").projectDir = file(${JSON.stringify(androidProject)})`,
|
|
220
224
|
"",
|
|
221
225
|
].join("\n");
|
|
222
|
-
|
|
226
|
+
(0, filesystem_1.ensureDir)(buildDir);
|
|
223
227
|
fs.writeFileSync(path.join(buildDir, "build.gradle"), buildGradle);
|
|
224
228
|
fs.writeFileSync(path.join(buildDir, "gradle.properties"), gradleProperties);
|
|
225
229
|
fs.writeFileSync(path.join(buildDir, "settings.gradle"), settingsGradle);
|
|
226
230
|
// Run only one Gradle task at a time
|
|
227
231
|
run(gradlew, targets, { cwd: buildDir, stdio: "inherit", env });
|
|
228
232
|
}
|
|
229
|
-
await Promise.all(targetsToCopy.map(([src, dest]) =>
|
|
233
|
+
await Promise.all(targetsToCopy.map(([src, dest]) => cloneFile(src, dest)));
|
|
230
234
|
}
|
|
231
|
-
function copyFiles(files, destination) {
|
|
235
|
+
function copyFiles(files, destination, fs = nodefs) {
|
|
232
236
|
if (!Array.isArray(files) || files.length === 0) {
|
|
233
237
|
return [];
|
|
234
238
|
}
|
|
235
|
-
|
|
239
|
+
(0, filesystem_1.ensureDir)(destination, fs);
|
|
236
240
|
return files.map((file) => {
|
|
237
|
-
return
|
|
241
|
+
return cp_r(file, `${destination}/${path.basename(file)}`, fs);
|
|
238
242
|
});
|
|
239
243
|
}
|
|
240
|
-
async function copyAssets({ options: { assetsDest, xcassetsDest } }, packageName, { assets, strings, xcassets }) {
|
|
244
|
+
async function copyAssets({ options: { assetsDest, xcassetsDest } }, packageName, { assets, strings, xcassets }, fs = nodefs) {
|
|
241
245
|
const tasks = [
|
|
242
|
-
...copyFiles(assets, `${assetsDest}/assets/${packageName}
|
|
243
|
-
...copyFiles(strings, `${assetsDest}/strings/${packageName}
|
|
246
|
+
...copyFiles(assets, `${assetsDest}/assets/${packageName}`, fs),
|
|
247
|
+
...copyFiles(strings, `${assetsDest}/strings/${packageName}`, fs),
|
|
244
248
|
];
|
|
245
249
|
if (typeof xcassetsDest === "string") {
|
|
246
|
-
tasks.push(...copyFiles(xcassets, xcassetsDest));
|
|
250
|
+
tasks.push(...copyFiles(xcassets, xcassetsDest, fs));
|
|
247
251
|
}
|
|
248
252
|
await Promise.all(tasks);
|
|
249
253
|
}
|
|
@@ -336,10 +340,9 @@ async function gatherConfigs({ projectRoot, manifest, }) {
|
|
|
336
340
|
*
|
|
337
341
|
* @param options Options dictate what gets copied where
|
|
338
342
|
*/
|
|
339
|
-
async function copyProjectAssets(options) {
|
|
340
|
-
const projectRoot = (0, package_1.findPackageDir)() || process.cwd();
|
|
343
|
+
async function copyProjectAssets(options, { root: projectRoot, reactNativePath }) {
|
|
341
344
|
const manifest = (0, package_1.readPackage)(projectRoot);
|
|
342
|
-
const context = { projectRoot, manifest, options };
|
|
345
|
+
const context = { projectRoot, manifest, options, reactNativePath };
|
|
343
346
|
const assetConfigs = await gatherConfigs(context);
|
|
344
347
|
if (!assetConfigs) {
|
|
345
348
|
return;
|
|
@@ -372,7 +375,7 @@ async function copyProjectAssets(options) {
|
|
|
372
375
|
if (output &&
|
|
373
376
|
(!fs.existsSync(destination) || fs.statSync(destination).isDirectory())) {
|
|
374
377
|
(0, console_1.info)(`Copying Android Archive of "${dependencyName}"`);
|
|
375
|
-
copyTasks.push(
|
|
378
|
+
copyTasks.push(cloneFile(output, destination));
|
|
376
379
|
}
|
|
377
380
|
}
|
|
378
381
|
await Promise.all(copyTasks);
|
|
@@ -380,30 +383,30 @@ async function copyProjectAssets(options) {
|
|
|
380
383
|
}
|
|
381
384
|
exports.rnxCopyAssetsCommand = {
|
|
382
385
|
name: "rnx-copy-assets",
|
|
383
|
-
description: "Copies additional assets not picked by bundlers into desired directory
|
|
384
|
-
func: (_argv,
|
|
386
|
+
description: "Copies additional assets not picked by bundlers into desired directory",
|
|
387
|
+
func: (_argv, config, options) => {
|
|
385
388
|
ensureOption(options, "platform");
|
|
386
389
|
ensureOption(options, "assetsDest", "assets-dest");
|
|
387
|
-
return copyProjectAssets(options);
|
|
390
|
+
return copyProjectAssets(options, config);
|
|
388
391
|
},
|
|
389
392
|
options: [
|
|
390
393
|
{
|
|
391
394
|
name: "--platform <string>",
|
|
392
|
-
description: "
|
|
395
|
+
description: "Platform to target",
|
|
393
396
|
parse: tools_react_native_1.parsePlatform,
|
|
394
397
|
},
|
|
395
398
|
{
|
|
396
399
|
name: "--assets-dest <string>",
|
|
397
|
-
description: "
|
|
400
|
+
description: "Path of the directory to copy assets into",
|
|
398
401
|
},
|
|
399
402
|
{
|
|
400
|
-
name: "--bundle-aar
|
|
401
|
-
description: "
|
|
403
|
+
name: "--bundle-aar [boolean]",
|
|
404
|
+
description: "Whether to bundle AARs of dependencies",
|
|
402
405
|
default: false,
|
|
403
406
|
},
|
|
404
407
|
{
|
|
405
408
|
name: "--xcassets-dest <string>",
|
|
406
|
-
description: "
|
|
409
|
+
description: "Path of the directory to copy Xcode asset catalogs into; asset catalogs will only be copied if a destination path is specified",
|
|
407
410
|
},
|
|
408
411
|
],
|
|
409
412
|
};
|
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.ensureDir = ensureDir;
|
|
27
|
-
const nodefs = __importStar(require("fs"));
|
|
27
|
+
const nodefs = __importStar(require("fs")); // Cannot use `node:fs` because of Jest mocks
|
|
28
28
|
function ensureDir(p, fs = nodefs) {
|
|
29
29
|
fs.mkdirSync(p, { recursive: true, mode: 0o755 });
|
|
30
30
|
}
|
package/lib/helpers/parsers.js
CHANGED
|
@@ -28,7 +28,7 @@ exports.asNumber = asNumber;
|
|
|
28
28
|
exports.asResolvedPath = asResolvedPath;
|
|
29
29
|
exports.asStringArray = asStringArray;
|
|
30
30
|
exports.asTransformProfile = asTransformProfile;
|
|
31
|
-
const path = __importStar(require("path"));
|
|
31
|
+
const path = __importStar(require("node:path"));
|
|
32
32
|
function asBoolean(value) {
|
|
33
33
|
switch (value) {
|
|
34
34
|
case "false":
|
package/lib/index.d.ts
CHANGED
|
@@ -1,191 +1,6 @@
|
|
|
1
|
+
import type { Command } from "@react-native-community/cli-types";
|
|
1
2
|
export declare const reactNativeConfig: {
|
|
2
|
-
commands:
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
func: typeof import("./align-deps").rnxAlignDeps;
|
|
6
|
-
options: {
|
|
7
|
-
name: string;
|
|
8
|
-
description: string;
|
|
9
|
-
}[];
|
|
10
|
-
} | {
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
func: typeof import("./bundle").rnxBundle;
|
|
14
|
-
options: ({
|
|
15
|
-
name: string;
|
|
16
|
-
description: string;
|
|
17
|
-
parse?: undefined;
|
|
18
|
-
default?: undefined;
|
|
19
|
-
} | {
|
|
20
|
-
name: string;
|
|
21
|
-
description: string;
|
|
22
|
-
parse: typeof import("@rnx-kit/tools-react-native").parsePlatform;
|
|
23
|
-
default?: undefined;
|
|
24
|
-
} | {
|
|
25
|
-
name: string;
|
|
26
|
-
description: string;
|
|
27
|
-
default: boolean;
|
|
28
|
-
parse: typeof import("./helpers/parsers").asBoolean;
|
|
29
|
-
} | {
|
|
30
|
-
name: string;
|
|
31
|
-
description: string;
|
|
32
|
-
parse: typeof import("./helpers/parsers").asBoolean;
|
|
33
|
-
default?: undefined;
|
|
34
|
-
} | {
|
|
35
|
-
name: string;
|
|
36
|
-
description: string;
|
|
37
|
-
default: string;
|
|
38
|
-
parse?: undefined;
|
|
39
|
-
} | {
|
|
40
|
-
name: string;
|
|
41
|
-
description: string;
|
|
42
|
-
parse: typeof import("./helpers/parsers").asNumber;
|
|
43
|
-
default?: undefined;
|
|
44
|
-
} | {
|
|
45
|
-
name: string;
|
|
46
|
-
description: string;
|
|
47
|
-
parse: typeof import("./helpers/parsers").asTransformProfile;
|
|
48
|
-
default?: undefined;
|
|
49
|
-
})[];
|
|
50
|
-
} | {
|
|
51
|
-
name: string;
|
|
52
|
-
func: typeof import("./clean").rnxClean;
|
|
53
|
-
description: string;
|
|
54
|
-
options: ({
|
|
55
|
-
name: string;
|
|
56
|
-
description: string;
|
|
57
|
-
default: string;
|
|
58
|
-
parse?: undefined;
|
|
59
|
-
} | {
|
|
60
|
-
name: string;
|
|
61
|
-
description: string;
|
|
62
|
-
default: string;
|
|
63
|
-
parse: typeof import("./helpers/parsers").asResolvedPath;
|
|
64
|
-
} | {
|
|
65
|
-
name: string;
|
|
66
|
-
description: string;
|
|
67
|
-
default: boolean;
|
|
68
|
-
parse?: undefined;
|
|
69
|
-
})[];
|
|
70
|
-
} | {
|
|
71
|
-
name: string;
|
|
72
|
-
description: string;
|
|
73
|
-
func: (_argv: string[], _config: import("@react-native-community/cli-types").Config, options: import("./copy-assets").Options) => Promise<void>;
|
|
74
|
-
options: ({
|
|
75
|
-
name: string;
|
|
76
|
-
description: string;
|
|
77
|
-
parse: typeof import("@rnx-kit/tools-react-native").parsePlatform;
|
|
78
|
-
default?: undefined;
|
|
79
|
-
} | {
|
|
80
|
-
name: string;
|
|
81
|
-
description: string;
|
|
82
|
-
parse?: undefined;
|
|
83
|
-
default?: undefined;
|
|
84
|
-
} | {
|
|
85
|
-
name: string;
|
|
86
|
-
description: string;
|
|
87
|
-
default: boolean;
|
|
88
|
-
parse?: undefined;
|
|
89
|
-
})[];
|
|
90
|
-
} | {
|
|
91
|
-
name: string;
|
|
92
|
-
description: string;
|
|
93
|
-
func: typeof import("./ram-bundle").rnxRamBundle;
|
|
94
|
-
options: ({
|
|
95
|
-
name: string;
|
|
96
|
-
description: string;
|
|
97
|
-
parse?: undefined;
|
|
98
|
-
default?: undefined;
|
|
99
|
-
} | {
|
|
100
|
-
name: string;
|
|
101
|
-
description: string;
|
|
102
|
-
parse: typeof import("@rnx-kit/tools-react-native").parsePlatform;
|
|
103
|
-
default?: undefined;
|
|
104
|
-
} | {
|
|
105
|
-
name: string;
|
|
106
|
-
description: string;
|
|
107
|
-
default: boolean;
|
|
108
|
-
parse: typeof import("./helpers/parsers").asBoolean;
|
|
109
|
-
} | {
|
|
110
|
-
name: string;
|
|
111
|
-
description: string;
|
|
112
|
-
parse: typeof import("./helpers/parsers").asBoolean;
|
|
113
|
-
default?: undefined;
|
|
114
|
-
} | {
|
|
115
|
-
name: string;
|
|
116
|
-
description: string;
|
|
117
|
-
default: string;
|
|
118
|
-
parse?: undefined;
|
|
119
|
-
} | {
|
|
120
|
-
name: string;
|
|
121
|
-
description: string;
|
|
122
|
-
parse: typeof import("./helpers/parsers").asNumber;
|
|
123
|
-
default?: undefined;
|
|
124
|
-
} | {
|
|
125
|
-
name: string;
|
|
126
|
-
description: string;
|
|
127
|
-
parse: typeof import("./helpers/parsers").asTransformProfile;
|
|
128
|
-
default?: undefined;
|
|
129
|
-
})[];
|
|
130
|
-
} | {
|
|
131
|
-
name: string;
|
|
132
|
-
func: typeof import("./start").rnxStart;
|
|
133
|
-
description: string;
|
|
134
|
-
options: ({
|
|
135
|
-
name: string;
|
|
136
|
-
description: string;
|
|
137
|
-
parse: typeof import("./helpers/parsers").asNumber;
|
|
138
|
-
default: number;
|
|
139
|
-
} | {
|
|
140
|
-
name: string;
|
|
141
|
-
description: string;
|
|
142
|
-
default: string;
|
|
143
|
-
parse?: undefined;
|
|
144
|
-
} | {
|
|
145
|
-
name: string;
|
|
146
|
-
description: string;
|
|
147
|
-
parse: typeof import("./helpers/parsers").asResolvedPath;
|
|
148
|
-
default?: undefined;
|
|
149
|
-
} | {
|
|
150
|
-
name: string;
|
|
151
|
-
description: string;
|
|
152
|
-
parse: (val: string) => string[];
|
|
153
|
-
default?: undefined;
|
|
154
|
-
} | {
|
|
155
|
-
name: string;
|
|
156
|
-
description: string;
|
|
157
|
-
parse: typeof import("./helpers/parsers").asNumber;
|
|
158
|
-
default?: undefined;
|
|
159
|
-
} | {
|
|
160
|
-
name: string;
|
|
161
|
-
description: string;
|
|
162
|
-
parse?: undefined;
|
|
163
|
-
default?: undefined;
|
|
164
|
-
})[];
|
|
165
|
-
} | {
|
|
166
|
-
name: string;
|
|
167
|
-
description: string;
|
|
168
|
-
func: typeof import("./test").rnxTest;
|
|
169
|
-
options: {
|
|
170
|
-
name: string;
|
|
171
|
-
description?: string;
|
|
172
|
-
parse?: (val: string) => unknown;
|
|
173
|
-
default?: string | boolean | number | ((config: import("@react-native-community/cli-types").Config) => string | boolean | number);
|
|
174
|
-
}[];
|
|
175
|
-
} | {
|
|
176
|
-
name: string;
|
|
177
|
-
description: string;
|
|
178
|
-
func: typeof import("./write-third-party-notices").rnxWriteThirdPartyNotices;
|
|
179
|
-
options: ({
|
|
180
|
-
name: string;
|
|
181
|
-
description: string;
|
|
182
|
-
default?: undefined;
|
|
183
|
-
} | {
|
|
184
|
-
name: string;
|
|
185
|
-
description: string;
|
|
186
|
-
default: boolean;
|
|
187
|
-
})[];
|
|
188
|
-
})[];
|
|
3
|
+
commands: Command<false>[];
|
|
189
4
|
};
|
|
190
5
|
export { rnxAlignDeps, rnxAlignDepsCommand } from "./align-deps";
|
|
191
6
|
export { rnxBundle, rnxBundleCommand } from "./bundle";
|
package/lib/serve/keyboard.js
CHANGED
|
@@ -5,9 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.attachKeyHandlers = attachKeyHandlers;
|
|
7
7
|
const console_1 = require("@rnx-kit/console");
|
|
8
|
-
const
|
|
8
|
+
const node_readline_1 = __importDefault(require("node:readline"));
|
|
9
9
|
const qrcode_1 = __importDefault(require("qrcode"));
|
|
10
|
-
const readline_1 = __importDefault(require("readline"));
|
|
11
10
|
function attachKeyHandlers({ devServerUrl, help, messageSocketEndpoint, terminal, }) {
|
|
12
11
|
process.stdin.setRawMode(true);
|
|
13
12
|
process.stdin.on("keypress", (_key, data) => {
|
|
@@ -34,9 +33,7 @@ function attachKeyHandlers({ devServerUrl, help, messageSocketEndpoint, terminal
|
|
|
34
33
|
break;
|
|
35
34
|
case "j": {
|
|
36
35
|
(0, console_1.info)("Opening debugger...");
|
|
37
|
-
|
|
38
|
-
const ftch = "fetch" in globalThis ? fetch : node_fetch_1.default;
|
|
39
|
-
ftch(devServerUrl + "/open-debugger", { method: "POST" });
|
|
36
|
+
fetch(devServerUrl + "/open-debugger", { method: "POST" });
|
|
40
37
|
break;
|
|
41
38
|
}
|
|
42
39
|
case "q": {
|
|
@@ -58,6 +55,6 @@ function attachKeyHandlers({ devServerUrl, help, messageSocketEndpoint, terminal
|
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
57
|
});
|
|
61
|
-
|
|
58
|
+
node_readline_1.default.emitKeypressEvents(process.stdin);
|
|
62
59
|
}
|
|
63
60
|
//# sourceMappingURL=keyboard.js.map
|
package/lib/serve/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type * as logger from "@rnx-kit/console";
|
|
2
2
|
import type { Server as Middleware } from "connect";
|
|
3
|
-
import type { Server as HttpServer } from "http";
|
|
4
|
-
import type { Server as HttpsServer } from "https";
|
|
5
3
|
import type { RunServerOptions } from "metro";
|
|
4
|
+
import type { Server as HttpServer } from "node:http";
|
|
5
|
+
import type { Server as HttpsServer } from "node:https";
|
|
6
6
|
type MiddlewareOptions = {
|
|
7
7
|
host?: string;
|
|
8
8
|
watchFolders: readonly string[];
|
package/lib/start.js
CHANGED
|
@@ -27,7 +27,7 @@ exports.rnxStartCommand = void 0;
|
|
|
27
27
|
exports.rnxStart = rnxStart;
|
|
28
28
|
const logger = __importStar(require("@rnx-kit/console"));
|
|
29
29
|
const metro_service_1 = require("@rnx-kit/metro-service");
|
|
30
|
-
const path = __importStar(require("path"));
|
|
30
|
+
const path = __importStar(require("node:path"));
|
|
31
31
|
const externals_1 = require("./helpers/externals");
|
|
32
32
|
const metro_config_1 = require("./helpers/metro-config");
|
|
33
33
|
const parsers_1 = require("./helpers/parsers");
|
package/lib/test.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.jestOptions = jestOptions;
|
|
|
6
6
|
const console_1 = require("@rnx-kit/console");
|
|
7
7
|
const package_1 = require("@rnx-kit/tools-node/package");
|
|
8
8
|
const platform_1 = require("@rnx-kit/tools-react-native/platform");
|
|
9
|
-
const
|
|
9
|
+
const COMMAND_NAMES = ["rnx-test", "test"];
|
|
10
10
|
const JEST_CLI = ["jest", "jest-cli"];
|
|
11
11
|
function rnxTest(_argv, { root }, { platform }) {
|
|
12
12
|
const runJest = (() => {
|
|
@@ -19,7 +19,7 @@ function rnxTest(_argv, { root }, { platform }) {
|
|
|
19
19
|
throw e;
|
|
20
20
|
}
|
|
21
21
|
})();
|
|
22
|
-
const commandIndex = process.argv.
|
|
22
|
+
const commandIndex = process.argv.findIndex((arg) => COMMAND_NAMES.includes(arg));
|
|
23
23
|
if (commandIndex < 0) {
|
|
24
24
|
throw new Error("Failed to parse command arguments");
|
|
25
25
|
}
|
|
@@ -27,7 +27,9 @@ function rnxTest(_argv, { root }, { platform }) {
|
|
|
27
27
|
const argv = process.argv.slice(commandIndex + 1);
|
|
28
28
|
const platformIndex = argv.indexOf("--platform");
|
|
29
29
|
if (platformIndex < 0) {
|
|
30
|
-
|
|
30
|
+
(0, console_1.error)("A target platform must be specified");
|
|
31
|
+
process.exitCode = process.exitCode || 1;
|
|
32
|
+
return;
|
|
31
33
|
}
|
|
32
34
|
// Remove `--platform` otherwise Jest will complain about an unrecognized
|
|
33
35
|
// option. We can pass the rest of the arguments to Jest as they are.
|
|
@@ -96,7 +98,7 @@ function jestOptions() {
|
|
|
96
98
|
});
|
|
97
99
|
}
|
|
98
100
|
exports.rnxTestCommand = {
|
|
99
|
-
name:
|
|
101
|
+
name: COMMAND_NAMES[0],
|
|
100
102
|
description: "Test runner for React Native apps",
|
|
101
103
|
func: rnxTest,
|
|
102
104
|
options: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnx-kit/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Command-line interface for working with kit packages in your repo",
|
|
5
5
|
"homepage": "https://github.com/microsoft/rnx-kit/tree/main/packages/cli#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,11 +9,15 @@
|
|
|
9
9
|
"email": "microsoftopensource@users.noreply.github.com"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
+
"bin/rnx-cli.mjs",
|
|
12
13
|
"lib/**/*.d.ts",
|
|
13
14
|
"lib/**/*.js",
|
|
14
15
|
"react-native.config.js"
|
|
15
16
|
],
|
|
16
17
|
"main": "lib/index.js",
|
|
18
|
+
"bin": {
|
|
19
|
+
"rnx-cli": "bin/rnx-cli.cjs"
|
|
20
|
+
},
|
|
17
21
|
"types": "lib/index.d.ts",
|
|
18
22
|
"exports": {
|
|
19
23
|
".": {
|
|
@@ -36,7 +40,7 @@
|
|
|
36
40
|
"test": "rnx-kit-scripts test"
|
|
37
41
|
},
|
|
38
42
|
"dependencies": {
|
|
39
|
-
"@rnx-kit/align-deps": "^2.5.
|
|
43
|
+
"@rnx-kit/align-deps": "^2.5.2",
|
|
40
44
|
"@rnx-kit/config": "^0.6.6",
|
|
41
45
|
"@rnx-kit/console": "^1.1.0",
|
|
42
46
|
"@rnx-kit/metro-plugin-cyclic-dependencies-detector": "^1.1.1",
|
|
@@ -49,11 +53,9 @@
|
|
|
49
53
|
"@rnx-kit/tools-language": "^2.0.0",
|
|
50
54
|
"@rnx-kit/tools-node": "^2.1.1",
|
|
51
55
|
"@rnx-kit/tools-react-native": "^1.4.0",
|
|
52
|
-
"
|
|
53
|
-
"node-fetch": "^2.6.7",
|
|
56
|
+
"commander": "^11.1.0",
|
|
54
57
|
"ora": "^5.4.1",
|
|
55
|
-
"qrcode": "^1.5.0"
|
|
56
|
-
"readline": "^1.3.0"
|
|
58
|
+
"qrcode": "^1.5.0"
|
|
57
59
|
},
|
|
58
60
|
"peerDependencies": {
|
|
59
61
|
"jest": ">=26.0",
|
|
@@ -70,34 +72,35 @@
|
|
|
70
72
|
"devDependencies": {
|
|
71
73
|
"@babel/core": "^7.20.0",
|
|
72
74
|
"@babel/preset-env": "^7.20.0",
|
|
73
|
-
"@react-native-community/cli-types": "^
|
|
75
|
+
"@react-native-community/cli-types": "^13.6.4",
|
|
74
76
|
"@rnx-kit/eslint-config": "*",
|
|
75
77
|
"@rnx-kit/jest-preset": "*",
|
|
76
78
|
"@rnx-kit/scripts": "*",
|
|
79
|
+
"@rnx-kit/tools-filesystem": "*",
|
|
77
80
|
"@rnx-kit/tsconfig": "*",
|
|
78
81
|
"@types/connect": "^3.4.36",
|
|
79
|
-
"@types/fs-extra": "^9.0.0",
|
|
80
82
|
"@types/jest": "^29.2.1",
|
|
81
83
|
"@types/node": "^20.0.0",
|
|
82
|
-
"@types/node-fetch": "^2.6.5",
|
|
83
84
|
"@types/qrcode": "^1.4.2",
|
|
84
85
|
"eslint": "^8.56.0",
|
|
85
86
|
"jest": "^29.2.1",
|
|
86
|
-
"
|
|
87
|
-
"metro": "^0.80.
|
|
87
|
+
"markdown-table": "^3.0.0",
|
|
88
|
+
"metro": "^0.80.3",
|
|
88
89
|
"metro-babel-transformer": "^0.80.0",
|
|
89
|
-
"metro-config": "^0.80.
|
|
90
|
+
"metro-config": "^0.80.3",
|
|
90
91
|
"prettier": "^3.0.0",
|
|
91
92
|
"react": "18.2.0",
|
|
92
|
-
"react-native": "^0.
|
|
93
|
+
"react-native": "^0.74.0",
|
|
94
|
+
"tsx": "^4.15.0",
|
|
93
95
|
"type-fest": "^4.0.0",
|
|
94
96
|
"typescript": "^5.0.0"
|
|
95
97
|
},
|
|
98
|
+
"engines": {
|
|
99
|
+
"node": ">=16.17"
|
|
100
|
+
},
|
|
96
101
|
"depcheck": {
|
|
97
102
|
"ignoreMatches": [
|
|
98
|
-
"connect"
|
|
99
|
-
"jest-cli",
|
|
100
|
-
"readline"
|
|
103
|
+
"connect"
|
|
101
104
|
]
|
|
102
105
|
},
|
|
103
106
|
"jest": {
|