@rnx-kit/cli 0.18.1 → 0.18.3
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/lib/bin/constants.d.ts +3 -0
- package/lib/bin/constants.js +6 -0
- package/lib/bin/context.d.ts +3 -17
- package/lib/bin/context.js +33 -24
- package/lib/bin/externalCommands.js +2 -1
- package/lib/bin/rnx-cli.d.ts +1 -1
- package/lib/bin/rnx-cli.js +2 -2
- package/lib/build/apple.js +9 -2
- package/lib/build/ccache.d.ts +3 -0
- package/lib/build/ccache.js +47 -0
- package/lib/build/watcher.js +1 -1
- package/lib/build.d.ts +8 -6
- package/lib/build.js +15 -0
- package/lib/run.d.ts +5 -5
- package/package.json +3 -3
package/lib/bin/context.d.ts
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
import type { Command as BaseCommand, Config as BaseConfig } from "@react-native-community/cli-types";
|
|
2
|
+
import { RNX_FAST_PATH } from "./constants";
|
|
2
3
|
type Command = BaseCommand<false> | BaseCommand<true>;
|
|
3
4
|
type Config = BaseConfig & {
|
|
4
|
-
|
|
5
|
+
[RNX_FAST_PATH]?: true;
|
|
5
6
|
commands: Command[];
|
|
6
7
|
};
|
|
7
|
-
export declare function getCoreCommands(): {
|
|
8
|
-
name: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
detached?: false | undefined;
|
|
11
|
-
examples?: Array<{
|
|
12
|
-
desc: string;
|
|
13
|
-
cmd: string;
|
|
14
|
-
}>;
|
|
15
|
-
pkg?: {
|
|
16
|
-
name: string;
|
|
17
|
-
version: string;
|
|
18
|
-
};
|
|
19
|
-
func: import("@react-native-community/cli-types").CommandFunction<Object>;
|
|
20
|
-
options?: import("@react-native-community/cli-types").CommandOption<(ctx: BaseConfig) => import("@react-native-community/cli-types").OptionValue>[] | undefined;
|
|
21
|
-
}[];
|
|
22
8
|
export declare function uniquify(commands: Command[]): Command[];
|
|
23
|
-
export declare function loadContextForCommand(userCommand: string, root?: string): Config
|
|
9
|
+
export declare function loadContextForCommand(userCommand: string, root?: string): Promise<Config>;
|
|
24
10
|
export {};
|
|
25
11
|
//# sourceMappingURL=context.d.ts.map
|
package/lib/bin/context.js
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCoreCommands = getCoreCommands;
|
|
4
3
|
exports.uniquify = uniquify;
|
|
5
4
|
exports.loadContextForCommand = loadContextForCommand;
|
|
6
5
|
const package_1 = require("@rnx-kit/tools-node/package");
|
|
7
6
|
const cache_1 = require("@rnx-kit/tools-react-native/cache");
|
|
8
7
|
const context_1 = require("@rnx-kit/tools-react-native/context");
|
|
9
8
|
const index_1 = require("../index");
|
|
10
|
-
const
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
function canUseFastPath(userCommand) {
|
|
11
|
+
const cmd = constants_1.RNX_PREFIX + userCommand;
|
|
12
|
+
for (const command of index_1.reactNativeConfig.commands) {
|
|
13
|
+
if (command.name === cmd) {
|
|
14
|
+
return !(constants_1.RNX_FAST_PATH in command) || command[constants_1.RNX_FAST_PATH] !== false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
11
19
|
function findReactNativePath(root, resolveSymlinks = false) {
|
|
12
20
|
const dir = (0, package_1.findPackageDependencyDir)("react-native", {
|
|
13
21
|
startDir: root,
|
|
@@ -18,19 +26,12 @@ function findReactNativePath(root, resolveSymlinks = false) {
|
|
|
18
26
|
}
|
|
19
27
|
return dir;
|
|
20
28
|
}
|
|
21
|
-
function getCoreCommands() {
|
|
22
|
-
const start = RNX_PREFIX.length;
|
|
23
|
-
return index_1.reactNativeConfig.commands.map((command) => ({
|
|
24
|
-
...command,
|
|
25
|
-
name: command.name.substring(start),
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
29
|
function uniquify(commands) {
|
|
29
30
|
const uniqueCommands = {};
|
|
30
31
|
for (const command of commands) {
|
|
31
32
|
const { name } = command;
|
|
32
|
-
if (name.startsWith(RNX_PREFIX)) {
|
|
33
|
-
command.name = name.substring(RNX_PREFIX.length);
|
|
33
|
+
if (name.startsWith(constants_1.RNX_PREFIX)) {
|
|
34
|
+
command.name = name.substring(constants_1.RNX_PREFIX.length);
|
|
34
35
|
uniqueCommands[command.name] = command;
|
|
35
36
|
}
|
|
36
37
|
else if (!uniqueCommands[name]) {
|
|
@@ -39,16 +40,23 @@ function uniquify(commands) {
|
|
|
39
40
|
}
|
|
40
41
|
return Object.values(uniqueCommands);
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
+
async function loadContextWithCLI(root) {
|
|
44
|
+
const rncli = (0, context_1.resolveCommunityCLI)(root);
|
|
45
|
+
const { loadConfig, loadConfigAsync } = require(rncli);
|
|
46
|
+
if (!loadConfigAsync) {
|
|
47
|
+
const options = loadConfig.length === 1 ? { projectRoot: root } : root;
|
|
48
|
+
return loadConfig(options);
|
|
49
|
+
}
|
|
50
|
+
return await loadConfigAsync({ projectRoot: root });
|
|
51
|
+
}
|
|
52
|
+
async function loadContextForCommand(userCommand, root = process.cwd()) {
|
|
43
53
|
// The fast path avoids traversing project dependencies because we know what
|
|
44
54
|
// information our commands depend on.
|
|
45
|
-
|
|
46
|
-
const useFastPath = coreCommands.some(({ name }) => name === userCommand);
|
|
47
|
-
if (useFastPath) {
|
|
55
|
+
if (canUseFastPath(userCommand)) {
|
|
48
56
|
let reactNativePath;
|
|
49
57
|
let reactNativeVersion;
|
|
50
58
|
return {
|
|
51
|
-
|
|
59
|
+
[constants_1.RNX_FAST_PATH]: true,
|
|
52
60
|
root,
|
|
53
61
|
get reactNativePath() {
|
|
54
62
|
if (!reactNativePath) {
|
|
@@ -68,7 +76,13 @@ function loadContextForCommand(userCommand, root = process.cwd()) {
|
|
|
68
76
|
throw new Error("Unexpected access to `dependencies`");
|
|
69
77
|
},
|
|
70
78
|
assets: [],
|
|
71
|
-
commands
|
|
79
|
+
get commands() {
|
|
80
|
+
const start = constants_1.RNX_PREFIX.length;
|
|
81
|
+
return index_1.reactNativeConfig.commands.map((command) => ({
|
|
82
|
+
...command,
|
|
83
|
+
name: command.name.substring(start),
|
|
84
|
+
}));
|
|
85
|
+
},
|
|
72
86
|
get healthChecks() {
|
|
73
87
|
throw new Error("Unexpected access to `healthChecks`");
|
|
74
88
|
},
|
|
@@ -76,16 +90,11 @@ function loadContextForCommand(userCommand, root = process.cwd()) {
|
|
|
76
90
|
throw new Error("Unexpected access to `platforms`");
|
|
77
91
|
},
|
|
78
92
|
get project() {
|
|
79
|
-
|
|
80
|
-
return (0, context_1.loadContext)(root).project;
|
|
93
|
+
throw new Error("Unexpected access to `project`");
|
|
81
94
|
},
|
|
82
95
|
};
|
|
83
96
|
}
|
|
84
|
-
const
|
|
85
|
-
const { loadConfig } = require(rncli);
|
|
86
|
-
const config = loadConfig.length === 1
|
|
87
|
-
? loadConfig({ projectRoot: root })
|
|
88
|
-
: loadConfig(root);
|
|
97
|
+
const config = await loadContextWithCLI(root);
|
|
89
98
|
// We will always load from disk because functions cannot be serialized.
|
|
90
99
|
// However, we should refresh the cache if needed.
|
|
91
100
|
const state = (0, cache_1.getCurrentState)(root);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findExternalCommands = findExternalCommands;
|
|
4
4
|
const context_1 = require("@rnx-kit/tools-react-native/context");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
5
6
|
function tryImport(module, fromDir) {
|
|
6
7
|
try {
|
|
7
8
|
const p = require.resolve(module, { paths: [fromDir] });
|
|
@@ -12,7 +13,7 @@ function tryImport(module, fromDir) {
|
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
function findExternalCommands(config) {
|
|
15
|
-
if (
|
|
16
|
+
if (constants_1.RNX_FAST_PATH in config) {
|
|
16
17
|
// Fast path means we don't need to do anything here
|
|
17
18
|
return [];
|
|
18
19
|
}
|
package/lib/bin/rnx-cli.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function main(): void
|
|
1
|
+
export declare function main(): Promise<void>;
|
|
2
2
|
//# sourceMappingURL=rnx-cli.d.ts.map
|
package/lib/bin/rnx-cli.js
CHANGED
|
@@ -28,9 +28,9 @@ const commander_1 = require("commander");
|
|
|
28
28
|
const path = __importStar(require("node:path"));
|
|
29
29
|
const context_1 = require("./context");
|
|
30
30
|
const externalCommands_1 = require("./externalCommands");
|
|
31
|
-
function main() {
|
|
31
|
+
async function main() {
|
|
32
32
|
const [, , userCommand] = process.argv;
|
|
33
|
-
const context = (0, context_1.loadContextForCommand)(userCommand);
|
|
33
|
+
const context = await (0, context_1.loadContextForCommand)(userCommand);
|
|
34
34
|
const allCommands = context.commands.concat((0, externalCommands_1.findExternalCommands)(context));
|
|
35
35
|
const program = new commander_1.Command(path.basename(__filename, ".js"));
|
|
36
36
|
for (const { name, description, detached, options = [], func, } of allCommands) {
|
package/lib/build/apple.js
CHANGED
|
@@ -3,10 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.runBuild = runBuild;
|
|
4
4
|
const watcher_1 = require("./watcher");
|
|
5
5
|
function runBuild(xcworkspace, buildParams, logger) {
|
|
6
|
-
return import("@rnx-kit/tools-apple").then(({ xcodebuild }) => {
|
|
6
|
+
return import("@rnx-kit/tools-apple").then(({ checkPodsManifestLock, xcodebuild }) => {
|
|
7
|
+
if (!checkPodsManifestLock(xcworkspace)) {
|
|
8
|
+
logger.fail("CocoaPods sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.");
|
|
9
|
+
return Promise.resolve(1);
|
|
10
|
+
}
|
|
7
11
|
const log = (message) => logger.info(message);
|
|
8
12
|
const build = xcodebuild(xcworkspace, buildParams, log);
|
|
9
|
-
return (0, watcher_1.watch)(build, logger, () => ({
|
|
13
|
+
return (0, watcher_1.watch)(build, logger, () => ({
|
|
14
|
+
xcworkspace,
|
|
15
|
+
args: build.spawnargs,
|
|
16
|
+
}));
|
|
10
17
|
});
|
|
11
18
|
}
|
|
12
19
|
//# sourceMappingURL=apple.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
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.setCcacheDir = setCcacheDir;
|
|
27
|
+
exports.setCcacheHome = setCcacheHome;
|
|
28
|
+
const fs = __importStar(require("node:fs"));
|
|
29
|
+
const path = __importStar(require("node:path"));
|
|
30
|
+
function setCcacheDir(dir) {
|
|
31
|
+
if (!fs.existsSync(dir)) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
process.env["CCACHE_DIR"] = dir;
|
|
35
|
+
return dir;
|
|
36
|
+
}
|
|
37
|
+
function setCcacheHome(dir) {
|
|
38
|
+
if (!fs.existsSync(dir)) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
process.env["CC"] = path.join(dir, "libexec", "clang");
|
|
42
|
+
process.env["CXX"] = path.join(dir, "libexec", "clang++");
|
|
43
|
+
process.env["CMAKE_C_COMPILER_LAUNCHER"] = path.join(dir, "bin", "ccache");
|
|
44
|
+
process.env["CMAKE_CXX_COMPILER_LAUNCHER"] = path.join(dir, "bin", "ccache");
|
|
45
|
+
return dir;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=ccache.js.map
|
package/lib/build/watcher.js
CHANGED
package/lib/build.d.ts
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import type { Config } from "@react-native-community/cli-types";
|
|
2
|
+
import { RNX_FAST_PATH } from "./bin/constants";
|
|
3
|
+
import { setCcacheDir } from "./build/ccache";
|
|
2
4
|
import type { BuildConfiguration, DeviceType, InputParams } from "./build/types";
|
|
3
5
|
declare function asConfiguration(configuration: string): BuildConfiguration;
|
|
4
6
|
declare function asDestination(destination: string): DeviceType;
|
|
5
|
-
declare function asSupportedPlatform(platform: string): InputParams["platform"];
|
|
6
7
|
export declare function rnxBuild(_argv: string[], config: Config, buildParams: InputParams): Promise<import("./build/android").BuildResult> | Promise<import("./build/apple").BuildResult>;
|
|
7
8
|
export declare const rnxBuildCommand: {
|
|
9
|
+
[RNX_FAST_PATH]: boolean;
|
|
8
10
|
name: string;
|
|
9
11
|
description: string;
|
|
10
12
|
func: typeof rnxBuild;
|
|
11
13
|
options: ({
|
|
12
14
|
name: string;
|
|
13
15
|
description: string;
|
|
14
|
-
parse: typeof asSupportedPlatform;
|
|
15
16
|
default?: undefined;
|
|
16
|
-
} | {
|
|
17
|
-
name: string;
|
|
18
|
-
description: string;
|
|
19
17
|
parse?: undefined;
|
|
20
|
-
default?: undefined;
|
|
21
18
|
} | {
|
|
22
19
|
name: string;
|
|
23
20
|
description: string;
|
|
@@ -28,6 +25,11 @@ export declare const rnxBuildCommand: {
|
|
|
28
25
|
description: string;
|
|
29
26
|
default: string;
|
|
30
27
|
parse: typeof asDestination;
|
|
28
|
+
} | {
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
parse: typeof setCcacheDir;
|
|
32
|
+
default?: undefined;
|
|
31
33
|
})[];
|
|
32
34
|
};
|
|
33
35
|
export {};
|
package/lib/build.js
CHANGED
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.rnxBuildCommand = void 0;
|
|
4
4
|
exports.rnxBuild = rnxBuild;
|
|
5
5
|
const commander_1 = require("commander");
|
|
6
|
+
const constants_1 = require("./bin/constants");
|
|
6
7
|
const android_1 = require("./build/android");
|
|
8
|
+
const ccache_1 = require("./build/ccache");
|
|
7
9
|
const ios_1 = require("./build/ios");
|
|
8
10
|
const macos_1 = require("./build/macos");
|
|
9
11
|
function asConfiguration(configuration) {
|
|
@@ -48,6 +50,9 @@ function rnxBuild(_argv, config, buildParams) {
|
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
exports.rnxBuildCommand = {
|
|
53
|
+
// The build command requires the `project` field, which currently requires
|
|
54
|
+
// loading the full config.
|
|
55
|
+
[constants_1.RNX_FAST_PATH]: false,
|
|
51
56
|
name: "rnx-build",
|
|
52
57
|
description: "Build your native app for testing in emulator/simulator or on device",
|
|
53
58
|
func: rnxBuild,
|
|
@@ -77,6 +82,16 @@ exports.rnxBuildCommand = {
|
|
|
77
82
|
default: "simulator",
|
|
78
83
|
parse: asDestination,
|
|
79
84
|
},
|
|
85
|
+
{
|
|
86
|
+
name: "--ccache-dir <string>",
|
|
87
|
+
description: "Path to Ccache config",
|
|
88
|
+
parse: ccache_1.setCcacheDir,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "--ccache-home <string>",
|
|
92
|
+
description: "Path to Ccache installation",
|
|
93
|
+
parse: ccache_1.setCcacheHome,
|
|
94
|
+
},
|
|
80
95
|
],
|
|
81
96
|
};
|
|
82
97
|
//# sourceMappingURL=build.js.map
|
package/lib/run.d.ts
CHANGED
|
@@ -8,13 +8,8 @@ export declare const rnxRunCommand: {
|
|
|
8
8
|
options: ({
|
|
9
9
|
name: string;
|
|
10
10
|
description: string;
|
|
11
|
-
parse: (platform: string) => InputParams["platform"];
|
|
12
11
|
default?: undefined;
|
|
13
|
-
} | {
|
|
14
|
-
name: string;
|
|
15
|
-
description: string;
|
|
16
12
|
parse?: undefined;
|
|
17
|
-
default?: undefined;
|
|
18
13
|
} | {
|
|
19
14
|
name: string;
|
|
20
15
|
description: string;
|
|
@@ -25,6 +20,11 @@ export declare const rnxRunCommand: {
|
|
|
25
20
|
description: string;
|
|
26
21
|
default: string;
|
|
27
22
|
parse: (destination: string) => import("./build/types").DeviceType;
|
|
23
|
+
} | {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
parse: typeof import("./build/ccache").setCcacheDir;
|
|
27
|
+
default?: undefined;
|
|
28
28
|
})[];
|
|
29
29
|
};
|
|
30
30
|
//# sourceMappingURL=run.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnx-kit/cli",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.3",
|
|
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",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@rnx-kit/metro-service": "^4.0.1",
|
|
51
51
|
"@rnx-kit/third-party-notices": "^2.0.0",
|
|
52
52
|
"@rnx-kit/tools-android": "^0.2.0",
|
|
53
|
-
"@rnx-kit/tools-apple": "^0.2.
|
|
53
|
+
"@rnx-kit/tools-apple": "^0.2.1",
|
|
54
54
|
"@rnx-kit/tools-language": "^3.0.0",
|
|
55
55
|
"@rnx-kit/tools-node": "^3.0.0",
|
|
56
56
|
"@rnx-kit/tools-react-native": "^2.0.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@types/jest": "^29.2.1",
|
|
84
84
|
"@types/node": "^20.0.0",
|
|
85
85
|
"@types/qrcode": "^1.4.2",
|
|
86
|
-
"eslint": "^
|
|
86
|
+
"eslint": "^9.0.0",
|
|
87
87
|
"jest": "^29.2.1",
|
|
88
88
|
"markdown-table": "^3.0.0",
|
|
89
89
|
"metro": "^0.80.3",
|