@rnx-kit/cli 0.18.14 → 0.18.17
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 +26 -20
- package/lib/bin/context.d.ts +1 -1
- package/lib/bin/context.js +10 -10
- package/lib/bin/externalCommands.js +2 -2
- package/lib/bin/rnx-cli.js +4 -4
- package/lib/build/android.d.ts +1 -1
- package/lib/build/android.js +2 -2
- package/lib/build/apple.d.ts +1 -1
- package/lib/build/apple.js +2 -2
- package/lib/build/ios.d.ts +2 -2
- package/lib/build/ios.js +6 -2
- package/lib/build/macos.d.ts +2 -2
- package/lib/build/macos.js +19 -14
- package/lib/build/types.d.ts +11 -1
- package/lib/build/windows.d.ts +11 -0
- package/lib/build/windows.js +116 -0
- package/lib/build.d.ts +4 -4
- package/lib/build.js +20 -12
- package/lib/bundle/cliOptions.d.ts +1 -1
- package/lib/bundle/cliOptions.js +5 -5
- package/lib/bundle/kit-config.d.ts +1 -1
- package/lib/bundle/kit-config.js +2 -2
- package/lib/bundle/metro.d.ts +1 -1
- package/lib/bundle/metro.js +2 -2
- package/lib/bundle/overrides.d.ts +1 -1
- package/lib/bundle.d.ts +4 -4
- package/lib/bundle.js +13 -13
- package/lib/clean.d.ts +1 -1
- package/lib/clean.js +2 -2
- package/lib/helpers/externals.d.ts +1 -1
- package/lib/helpers/metro-config.js +2 -2
- package/lib/index.d.ts +8 -8
- package/lib/index.js +32 -32
- package/lib/ram-bundle.d.ts +5 -5
- package/lib/ram-bundle.js +9 -9
- package/lib/run/android.d.ts +1 -1
- package/lib/run/android.js +2 -2
- package/lib/run/ios.d.ts +1 -1
- package/lib/run/ios.js +2 -2
- package/lib/run/macos.d.ts +1 -1
- package/lib/run/macos.js +2 -2
- package/lib/run/windows.d.ts +6 -0
- package/lib/run/windows.js +13 -0
- package/lib/run.d.ts +6 -6
- package/lib/run.js +13 -10
- package/lib/serve/keyboard.d.ts +1 -1
- package/lib/serve/keyboard.js +1 -1
- package/lib/serve/kit-config.js +2 -2
- package/lib/start.d.ts +2 -2
- package/lib/start.js +28 -21
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -200,13 +200,16 @@ yarn rnx-cli build [options]
|
|
|
200
200
|
|
|
201
201
|
<!-- @rnx-kit/cli/build start -->
|
|
202
202
|
|
|
203
|
-
| Option | Description
|
|
204
|
-
| ------------------------------ |
|
|
205
|
-
| -p, --platform <string> | Target platform
|
|
206
|
-
| --
|
|
207
|
-
| --
|
|
208
|
-
| --
|
|
209
|
-
| --
|
|
203
|
+
| Option | Description |
|
|
204
|
+
| ------------------------------ | ------------------------------------------------------------------------------------- |
|
|
205
|
+
| -p, --platform <string> | Target platform |
|
|
206
|
+
| --solution <string> | Path, relative to project root, of the Visual Studio solution to build (Windows only) |
|
|
207
|
+
| --workspace <string> | Path, relative to project root, of the Xcode workspace to build (macOS only) |
|
|
208
|
+
| --scheme <string> | Name of scheme to build (Apple platforms only) |
|
|
209
|
+
| --configuration <string> | Build configuration for building the app; 'Debug' or 'Release' |
|
|
210
|
+
| --destination <string> | Destination of the built app; 'device', 'emulator', or 'simulator' |
|
|
211
|
+
| --ccache-dir <string> | Path to Ccache config |
|
|
212
|
+
| --ccache-home <string> | Path to Ccache installation |
|
|
210
213
|
|
|
211
214
|
<!-- @rnx-kit/cli/build end -->
|
|
212
215
|
|
|
@@ -226,14 +229,17 @@ yarn rnx-cli run [options]
|
|
|
226
229
|
|
|
227
230
|
<!-- @rnx-kit/cli/run start -->
|
|
228
231
|
|
|
229
|
-
| Option | Description
|
|
230
|
-
| ------------------------------ |
|
|
231
|
-
| -p, --platform <string> | Target platform
|
|
232
|
-
| --
|
|
233
|
-
| --
|
|
234
|
-
| --
|
|
235
|
-
| --
|
|
236
|
-
|
|
|
232
|
+
| Option | Description |
|
|
233
|
+
| ------------------------------ | ------------------------------------------------------------------------------------- |
|
|
234
|
+
| -p, --platform <string> | Target platform |
|
|
235
|
+
| --solution <string> | Path, relative to project root, of the Visual Studio solution to build (Windows only) |
|
|
236
|
+
| --workspace <string> | Path, relative to project root, of the Xcode workspace to build (macOS only) |
|
|
237
|
+
| --scheme <string> | Name of scheme to build (Apple platforms only) |
|
|
238
|
+
| --configuration <string> | Build configuration for building the app; 'Debug' or 'Release' |
|
|
239
|
+
| --destination <string> | Destination of the built app; 'device', 'emulator', or 'simulator' |
|
|
240
|
+
| --ccache-dir <string> | Path to Ccache config |
|
|
241
|
+
| --ccache-home <string> | Path to Ccache installation |
|
|
242
|
+
| -d, --device <string> | The name of the device to launch the app in |
|
|
237
243
|
|
|
238
244
|
<!-- @rnx-kit/cli/run end -->
|
|
239
245
|
|
|
@@ -263,11 +269,11 @@ yarn rnx-cli clean [options]
|
|
|
263
269
|
|
|
264
270
|
<!-- @rnx-kit/cli/clean start -->
|
|
265
271
|
|
|
266
|
-
| Option
|
|
267
|
-
|
|
|
268
|
-
| --include <android,cocoapods,metro,npm,watchman,yarn> | Comma-separated flag of caches to clear e.g., `npm,yarn` |
|
|
269
|
-
| --project-root <path>
|
|
270
|
-
| --verify-cache
|
|
272
|
+
| Option | Description |
|
|
273
|
+
| ----------------------------------------------------------------- | -------------------------------------------------------- |
|
|
274
|
+
| --include <android,cocoapods,metro,npm,watchman,xcode,yarn> | Comma-separated flag of caches to clear e.g., `npm,yarn` |
|
|
275
|
+
| --project-root <path> | Root path to your React Native project |
|
|
276
|
+
| --verify-cache | Whether to verify the integrity of the cache |
|
|
271
277
|
|
|
272
278
|
<!-- @rnx-kit/cli/clean end -->
|
|
273
279
|
|
package/lib/bin/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command as BaseCommand, Config as BaseConfig } from "@react-native-community/cli-types";
|
|
2
|
-
import { RNX_FAST_PATH } from "./constants";
|
|
2
|
+
import { RNX_FAST_PATH } from "./constants.ts";
|
|
3
3
|
type Command = BaseCommand<false> | BaseCommand<true>;
|
|
4
4
|
type Config = BaseConfig & {
|
|
5
5
|
[RNX_FAST_PATH]?: true;
|
package/lib/bin/context.js
CHANGED
|
@@ -5,13 +5,13 @@ exports.loadContextForCommand = loadContextForCommand;
|
|
|
5
5
|
const package_1 = require("@rnx-kit/tools-node/package");
|
|
6
6
|
const cache_1 = require("@rnx-kit/tools-react-native/cache");
|
|
7
7
|
const context_1 = require("@rnx-kit/tools-react-native/context");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const index_ts_1 = require("../index.js");
|
|
9
|
+
const constants_ts_1 = require("./constants.js");
|
|
10
10
|
function canUseFastPath(userCommand) {
|
|
11
|
-
const cmd =
|
|
12
|
-
for (const command of
|
|
11
|
+
const cmd = constants_ts_1.RNX_PREFIX + userCommand;
|
|
12
|
+
for (const command of index_ts_1.reactNativeConfig.commands) {
|
|
13
13
|
if (command.name === cmd) {
|
|
14
|
-
return !(
|
|
14
|
+
return !(constants_ts_1.RNX_FAST_PATH in command) || command[constants_ts_1.RNX_FAST_PATH] !== false;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
return false;
|
|
@@ -30,8 +30,8 @@ function uniquify(commands) {
|
|
|
30
30
|
const uniqueCommands = {};
|
|
31
31
|
for (const command of commands) {
|
|
32
32
|
const { name } = command;
|
|
33
|
-
if (name.startsWith(
|
|
34
|
-
command.name = name.substring(
|
|
33
|
+
if (name.startsWith(constants_ts_1.RNX_PREFIX)) {
|
|
34
|
+
command.name = name.substring(constants_ts_1.RNX_PREFIX.length);
|
|
35
35
|
uniqueCommands[command.name] = command;
|
|
36
36
|
}
|
|
37
37
|
else if (!uniqueCommands[name]) {
|
|
@@ -56,7 +56,7 @@ async function loadContextForCommand(userCommand, root = process.cwd()) {
|
|
|
56
56
|
let reactNativePath;
|
|
57
57
|
let reactNativeVersion;
|
|
58
58
|
return {
|
|
59
|
-
[
|
|
59
|
+
[constants_ts_1.RNX_FAST_PATH]: true,
|
|
60
60
|
root,
|
|
61
61
|
get reactNativePath() {
|
|
62
62
|
if (!reactNativePath) {
|
|
@@ -77,8 +77,8 @@ async function loadContextForCommand(userCommand, root = process.cwd()) {
|
|
|
77
77
|
},
|
|
78
78
|
assets: [],
|
|
79
79
|
get commands() {
|
|
80
|
-
const start =
|
|
81
|
-
return
|
|
80
|
+
const start = constants_ts_1.RNX_PREFIX.length;
|
|
81
|
+
return index_ts_1.reactNativeConfig.commands.map((command) => ({
|
|
82
82
|
...command,
|
|
83
83
|
name: command.name.substring(start),
|
|
84
84
|
}));
|
|
@@ -2,7 +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
|
|
5
|
+
const constants_ts_1 = require("./constants.js");
|
|
6
6
|
function tryImport(module, fromDir) {
|
|
7
7
|
try {
|
|
8
8
|
const p = require.resolve(module, { paths: [fromDir] });
|
|
@@ -13,7 +13,7 @@ function tryImport(module, fromDir) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
function findExternalCommands(config) {
|
|
16
|
-
if (
|
|
16
|
+
if (constants_ts_1.RNX_FAST_PATH in config) {
|
|
17
17
|
// Fast path means we don't need to do anything here
|
|
18
18
|
return [];
|
|
19
19
|
}
|
package/lib/bin/rnx-cli.js
CHANGED
|
@@ -36,16 +36,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.main = main;
|
|
37
37
|
const commander_1 = require("commander");
|
|
38
38
|
const path = __importStar(require("node:path"));
|
|
39
|
-
const
|
|
40
|
-
const
|
|
39
|
+
const context_ts_1 = require("./context.js");
|
|
40
|
+
const externalCommands_ts_1 = require("./externalCommands.js");
|
|
41
41
|
function parseDefaultValue(defaultValue, context) {
|
|
42
42
|
const value = typeof defaultValue === "function" ? defaultValue(context) : defaultValue;
|
|
43
43
|
return typeof value === "number" ? value.toString() : value;
|
|
44
44
|
}
|
|
45
45
|
async function main() {
|
|
46
46
|
const [, , userCommand] = process.argv;
|
|
47
|
-
const context = await (0,
|
|
48
|
-
const allCommands = context.commands.concat((0,
|
|
47
|
+
const context = await (0, context_ts_1.loadContextForCommand)(userCommand);
|
|
48
|
+
const allCommands = context.commands.concat((0, externalCommands_ts_1.findExternalCommands)(context));
|
|
49
49
|
const program = new commander_1.Command(path.basename(__filename, ".js"));
|
|
50
50
|
for (const { name, description, detached, options = [], func, } of allCommands) {
|
|
51
51
|
const command = program.command(name).description(description ?? name);
|
package/lib/build/android.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Config } from "@react-native-community/cli-types";
|
|
2
2
|
import ora from "ora";
|
|
3
|
-
import type { AndroidBuildParams } from "./types";
|
|
3
|
+
import type { AndroidBuildParams } from "./types.ts";
|
|
4
4
|
export type BuildResult = string | number | null;
|
|
5
5
|
export declare function buildAndroid(config: Config, buildParams: AndroidBuildParams, additionalArgs: string[], logger?: ora.Ora): Promise<BuildResult>;
|
|
6
6
|
//# sourceMappingURL=android.d.ts.map
|
package/lib/build/android.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.buildAndroid = buildAndroid;
|
|
7
7
|
const cache_1 = require("@rnx-kit/tools-react-native/cache");
|
|
8
8
|
const ora_1 = __importDefault(require("ora"));
|
|
9
|
-
const
|
|
9
|
+
const watcher_ts_1 = require("./watcher.js");
|
|
10
10
|
function buildAndroid(config, buildParams, additionalArgs, logger = (0, ora_1.default)()) {
|
|
11
11
|
const { sourceDir } = config.project.android ?? {};
|
|
12
12
|
if (!sourceDir) {
|
|
@@ -17,7 +17,7 @@ function buildAndroid(config, buildParams, additionalArgs, logger = (0, ora_1.de
|
|
|
17
17
|
}
|
|
18
18
|
return import("@rnx-kit/tools-android").then(({ assemble }) => {
|
|
19
19
|
const gradle = assemble(sourceDir, buildParams, additionalArgs);
|
|
20
|
-
return (0,
|
|
20
|
+
return (0, watcher_ts_1.watch)(gradle, logger, () => sourceDir);
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
//# sourceMappingURL=android.js.map
|
package/lib/build/apple.d.ts
CHANGED
package/lib/build/apple.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runBuild = runBuild;
|
|
4
|
-
const
|
|
4
|
+
const watcher_ts_1 = require("./watcher.js");
|
|
5
5
|
function runBuild(xcworkspace, buildParams, logger) {
|
|
6
6
|
return import("@rnx-kit/tools-apple").then(({ checkPodsManifestLock, xcodebuild }) => {
|
|
7
7
|
if (!checkPodsManifestLock(xcworkspace)) {
|
|
@@ -10,7 +10,7 @@ function runBuild(xcworkspace, buildParams, logger) {
|
|
|
10
10
|
}
|
|
11
11
|
const log = (message) => logger.info(message);
|
|
12
12
|
const build = xcodebuild(xcworkspace, buildParams, log);
|
|
13
|
-
return (0,
|
|
13
|
+
return (0, watcher_ts_1.watch)(build, logger, () => ({
|
|
14
14
|
xcworkspace,
|
|
15
15
|
args: build.spawnargs,
|
|
16
16
|
}));
|
package/lib/build/ios.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Config } from "@react-native-community/cli-types";
|
|
2
2
|
import ora from "ora";
|
|
3
|
-
import type { BuildResult } from "./apple";
|
|
4
|
-
import type { AppleInputParams } from "./types";
|
|
3
|
+
import type { BuildResult } from "./apple.ts";
|
|
4
|
+
import type { AppleInputParams } from "./types.ts";
|
|
5
5
|
export declare function buildIOS(config: Config, buildParams: AppleInputParams, logger?: ora.Ora): Promise<BuildResult>;
|
|
6
6
|
//# sourceMappingURL=ios.d.ts.map
|
package/lib/build/ios.js
CHANGED
|
@@ -40,9 +40,13 @@ exports.buildIOS = buildIOS;
|
|
|
40
40
|
const cache_1 = require("@rnx-kit/tools-react-native/cache");
|
|
41
41
|
const path = __importStar(require("node:path"));
|
|
42
42
|
const ora_1 = __importDefault(require("ora"));
|
|
43
|
-
const
|
|
43
|
+
const apple_ts_1 = require("./apple.js");
|
|
44
44
|
function buildIOS(config, buildParams, logger = (0, ora_1.default)()) {
|
|
45
45
|
const { platform } = buildParams;
|
|
46
|
+
if (process.platform !== "darwin") {
|
|
47
|
+
logger.fail(`${platform} builds can only be performed on macOS hosts`);
|
|
48
|
+
return Promise.resolve(1);
|
|
49
|
+
}
|
|
46
50
|
const { sourceDir, xcodeProject } = config.project[platform] ?? {};
|
|
47
51
|
if (!sourceDir || !xcodeProject) {
|
|
48
52
|
(0, cache_1.invalidateState)();
|
|
@@ -61,6 +65,6 @@ function buildIOS(config, buildParams, logger = (0, ora_1.default)()) {
|
|
|
61
65
|
const xcworkspace = projectDir
|
|
62
66
|
? path.resolve(sourceDir, projectDir, name)
|
|
63
67
|
: path.resolve(sourceDir, name);
|
|
64
|
-
return (0,
|
|
68
|
+
return (0, apple_ts_1.runBuild)(xcworkspace, buildParams, logger);
|
|
65
69
|
}
|
|
66
70
|
//# sourceMappingURL=ios.js.map
|
package/lib/build/macos.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Config } from "@react-native-community/cli-types";
|
|
2
2
|
import ora from "ora";
|
|
3
|
-
import type { BuildResult } from "./apple";
|
|
4
|
-
import type { AppleInputParams } from "./types";
|
|
3
|
+
import type { BuildResult } from "./apple.ts";
|
|
4
|
+
import type { AppleInputParams } from "./types.ts";
|
|
5
5
|
export declare function buildMacOS(_config: Config, { workspace, ...buildParams }: AppleInputParams, logger?: ora.Ora): Promise<BuildResult>;
|
|
6
6
|
//# sourceMappingURL=macos.d.ts.map
|
package/lib/build/macos.js
CHANGED
|
@@ -41,28 +41,33 @@ const cache_1 = require("@rnx-kit/tools-react-native/cache");
|
|
|
41
41
|
const fs = __importStar(require("node:fs"));
|
|
42
42
|
const path = __importStar(require("node:path"));
|
|
43
43
|
const ora_1 = __importDefault(require("ora"));
|
|
44
|
-
const
|
|
45
|
-
function findXcodeWorkspaces(searchDir) {
|
|
46
|
-
|
|
44
|
+
const apple_ts_1 = require("./apple.js");
|
|
45
|
+
function findXcodeWorkspaces(searchDir, logger) {
|
|
46
|
+
const workspaces = fs.existsSync(searchDir)
|
|
47
47
|
? fs.readdirSync(searchDir).filter((file) => file.endsWith(".xcworkspace"))
|
|
48
48
|
: [];
|
|
49
|
-
}
|
|
50
|
-
function buildMacOS(_config, { workspace, ...buildParams }, logger = (0, ora_1.default)()) {
|
|
51
|
-
if (workspace) {
|
|
52
|
-
return (0, apple_1.runBuild)(workspace, buildParams, logger);
|
|
53
|
-
}
|
|
54
|
-
const sourceDir = "macos";
|
|
55
|
-
const workspaces = findXcodeWorkspaces(sourceDir);
|
|
56
49
|
if (workspaces.length === 0) {
|
|
57
50
|
(0, cache_1.invalidateState)();
|
|
58
51
|
process.exitCode = 1;
|
|
59
52
|
logger.fail("No Xcode workspaces were found; specify an Xcode workspace with `--workspace`");
|
|
60
|
-
return
|
|
53
|
+
return undefined;
|
|
61
54
|
}
|
|
62
55
|
if (workspaces.length > 1) {
|
|
63
|
-
logger.
|
|
64
|
-
logger.
|
|
56
|
+
logger.info(`Multiple Xcode workspaces were found; picking the first one: ${workspaces.join(", ")}`);
|
|
57
|
+
logger.info("If this is wrong, specify another workspace with `--workspace`");
|
|
58
|
+
}
|
|
59
|
+
return path.join(searchDir, workspaces[0]);
|
|
60
|
+
}
|
|
61
|
+
function buildMacOS(_config, { workspace, ...buildParams }, logger = (0, ora_1.default)()) {
|
|
62
|
+
if (process.platform !== "darwin") {
|
|
63
|
+
logger.fail("macOS builds can only be performed on macOS hosts");
|
|
64
|
+
return Promise.resolve(1);
|
|
65
|
+
}
|
|
66
|
+
const sourceDir = "macos";
|
|
67
|
+
const xcworkspace = workspace || findXcodeWorkspaces(sourceDir, logger);
|
|
68
|
+
if (!xcworkspace) {
|
|
69
|
+
return Promise.resolve(1);
|
|
65
70
|
}
|
|
66
|
-
return (0,
|
|
71
|
+
return (0, apple_ts_1.runBuild)(xcworkspace, buildParams, logger);
|
|
67
72
|
}
|
|
68
73
|
//# sourceMappingURL=macos.js.map
|
package/lib/build/types.d.ts
CHANGED
|
@@ -38,5 +38,15 @@ export type AppleInputParams = AppleBuildParams & {
|
|
|
38
38
|
device?: string;
|
|
39
39
|
workspace?: string;
|
|
40
40
|
};
|
|
41
|
-
export type
|
|
41
|
+
export type WindowsBuildParams = {
|
|
42
|
+
platform: "windows";
|
|
43
|
+
configuration?: BuildConfiguration;
|
|
44
|
+
architecture?: "arm64" | "x64";
|
|
45
|
+
launch?: boolean;
|
|
46
|
+
deploy?: boolean;
|
|
47
|
+
};
|
|
48
|
+
export type WindowsInputParams = WindowsBuildParams & {
|
|
49
|
+
solution?: string;
|
|
50
|
+
};
|
|
51
|
+
export type InputParams = AndroidInputParams | AppleInputParams | WindowsInputParams;
|
|
42
52
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Command, Config } from "@react-native-community/cli-types";
|
|
2
|
+
import ora from "ora";
|
|
3
|
+
import type { WindowsInputParams } from "./types.ts";
|
|
4
|
+
export type BuildArgs = {
|
|
5
|
+
solution: string;
|
|
6
|
+
args: string[];
|
|
7
|
+
};
|
|
8
|
+
export type BuildResult = BuildArgs | number | null;
|
|
9
|
+
export declare function runWindowsCommand(config: Config, params: WindowsInputParams, logger: ora.Ora, callback: (solution: string, run: Command["func"], options: Record<string, unknown>) => Promise<BuildResult>): Promise<BuildResult>;
|
|
10
|
+
export declare function buildWindows(config: Config, params: WindowsInputParams, additionalArgs: string[], logger?: ora.Ora): Promise<BuildResult>;
|
|
11
|
+
//# sourceMappingURL=windows.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.runWindowsCommand = runWindowsCommand;
|
|
40
|
+
exports.buildWindows = buildWindows;
|
|
41
|
+
const cache_1 = require("@rnx-kit/tools-react-native/cache");
|
|
42
|
+
const fs = __importStar(require("node:fs"));
|
|
43
|
+
const os = __importStar(require("node:os"));
|
|
44
|
+
const path = __importStar(require("node:path"));
|
|
45
|
+
const ora_1 = __importDefault(require("ora"));
|
|
46
|
+
function findRunCommand(startDir) {
|
|
47
|
+
try {
|
|
48
|
+
const fromProjectRoot = { paths: [startDir] };
|
|
49
|
+
const rnwPath = require.resolve("react-native-windows/package.json", fromProjectRoot);
|
|
50
|
+
const fromRnwDir = { paths: [path.dirname(rnwPath)] };
|
|
51
|
+
const cliPath = require.resolve("@react-native-windows/cli", fromRnwDir);
|
|
52
|
+
const cli = require(cliPath);
|
|
53
|
+
return cli.commands.find((cmd) => cmd.name === "run-windows");
|
|
54
|
+
}
|
|
55
|
+
catch (_) {
|
|
56
|
+
// Handled by caller
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
function findSolution(searchDir, logger) {
|
|
61
|
+
const solutions = fs.existsSync(searchDir)
|
|
62
|
+
? fs.readdirSync(searchDir).filter((file) => file.endsWith(".sln"))
|
|
63
|
+
: [];
|
|
64
|
+
if (solutions.length === 0) {
|
|
65
|
+
(0, cache_1.invalidateState)();
|
|
66
|
+
process.exitCode = 1;
|
|
67
|
+
logger.fail("No Visual Studio solutions were found; specify a Visual Studio solution with `--solution`");
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
if (solutions.length > 1) {
|
|
71
|
+
logger.info(`Multiple Visual Studio solutions were found; picking the first one: ${solutions.join(", ")}`);
|
|
72
|
+
logger.info("If this is wrong, specify another solution with `--solution`");
|
|
73
|
+
}
|
|
74
|
+
return path.join(searchDir, solutions[0]);
|
|
75
|
+
}
|
|
76
|
+
function toRunWindowsOptions(sln, { root }, { configuration, architecture, launch, deploy }) {
|
|
77
|
+
return {
|
|
78
|
+
release: configuration === "Release",
|
|
79
|
+
root,
|
|
80
|
+
arch: architecture ?? os.arch(),
|
|
81
|
+
packager: false,
|
|
82
|
+
bundle: false,
|
|
83
|
+
launch: Boolean(launch),
|
|
84
|
+
autolink: true,
|
|
85
|
+
build: true,
|
|
86
|
+
deploy: Boolean(deploy),
|
|
87
|
+
sln,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function runWindowsCommand(config, params, logger, callback) {
|
|
91
|
+
if (process.platform !== "win32") {
|
|
92
|
+
logger.fail("Windows builds can only be performed on Windows hosts");
|
|
93
|
+
return Promise.resolve(1);
|
|
94
|
+
}
|
|
95
|
+
const sourceDir = "windows";
|
|
96
|
+
const solution = params.solution || findSolution(sourceDir, logger);
|
|
97
|
+
if (!solution) {
|
|
98
|
+
return Promise.resolve(1);
|
|
99
|
+
}
|
|
100
|
+
const runCommand = findRunCommand(config.root);
|
|
101
|
+
if (!runCommand) {
|
|
102
|
+
logger.fail("Failed to find `@react-native-windows/cli`, make sure `react-native-windows` is installed.");
|
|
103
|
+
return Promise.resolve(1);
|
|
104
|
+
}
|
|
105
|
+
const options = toRunWindowsOptions(solution, config, params);
|
|
106
|
+
return callback(solution, runCommand.func, options);
|
|
107
|
+
}
|
|
108
|
+
function buildWindows(config, params, additionalArgs, logger = (0, ora_1.default)()) {
|
|
109
|
+
return runWindowsCommand(config, params, logger, (solution, run, options) => {
|
|
110
|
+
const build = run(additionalArgs, config, options);
|
|
111
|
+
return build
|
|
112
|
+
? build.then(() => ({ solution, args: additionalArgs }))
|
|
113
|
+
: Promise.resolve(1);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=windows.js.map
|
package/lib/build.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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";
|
|
4
|
-
import type { BuildConfiguration, DeviceType, InputParams } from "./build/types";
|
|
2
|
+
import { RNX_FAST_PATH } from "./bin/constants.ts";
|
|
3
|
+
import { setCcacheDir } from "./build/ccache.ts";
|
|
4
|
+
import type { BuildConfiguration, DeviceType, InputParams } from "./build/types.ts";
|
|
5
5
|
declare function asConfiguration(configuration: string): BuildConfiguration;
|
|
6
6
|
declare function asDestination(destination: string): DeviceType;
|
|
7
|
-
export declare function rnxBuild(argv: string[], config: Config, buildParams: InputParams): Promise<import("./build/android").BuildResult> | Promise<import("./build/apple").BuildResult>;
|
|
7
|
+
export declare function rnxBuild(argv: string[], config: Config, buildParams: InputParams): Promise<import("./build/android.ts").BuildResult> | Promise<import("./build/apple.ts").BuildResult> | Promise<import("./build/windows.ts").BuildResult>;
|
|
8
8
|
export declare const rnxBuildCommand: {
|
|
9
9
|
[RNX_FAST_PATH]: boolean;
|
|
10
10
|
name: string;
|
package/lib/build.js
CHANGED
|
@@ -3,11 +3,12 @@ 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
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
6
|
+
const constants_ts_1 = require("./bin/constants.js");
|
|
7
|
+
const android_ts_1 = require("./build/android.js");
|
|
8
|
+
const ccache_ts_1 = require("./build/ccache.js");
|
|
9
|
+
const ios_ts_1 = require("./build/ios.js");
|
|
10
|
+
const macos_ts_1 = require("./build/macos.js");
|
|
11
|
+
const windows_ts_1 = require("./build/windows.js");
|
|
11
12
|
function asConfiguration(configuration) {
|
|
12
13
|
switch (configuration) {
|
|
13
14
|
case "Debug":
|
|
@@ -33,26 +34,29 @@ function asSupportedPlatform(platform) {
|
|
|
33
34
|
case "ios":
|
|
34
35
|
case "macos":
|
|
35
36
|
case "visionos":
|
|
37
|
+
case "windows":
|
|
36
38
|
return platform;
|
|
37
39
|
default:
|
|
38
|
-
throw new commander_1.InvalidArgumentError("Supported platforms: 'android', 'ios', 'macos', 'visionos'.");
|
|
40
|
+
throw new commander_1.InvalidArgumentError("Supported platforms: 'android', 'ios', 'macos', 'visionos', 'windows'.");
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
function rnxBuild(argv, config, buildParams) {
|
|
42
44
|
switch (buildParams.platform) {
|
|
43
45
|
case "android":
|
|
44
|
-
return (0,
|
|
46
|
+
return (0, android_ts_1.buildAndroid)(config, buildParams, argv);
|
|
45
47
|
case "ios":
|
|
46
48
|
case "visionos":
|
|
47
|
-
return (0,
|
|
49
|
+
return (0, ios_ts_1.buildIOS)(config, buildParams);
|
|
48
50
|
case "macos":
|
|
49
|
-
return (0,
|
|
51
|
+
return (0, macos_ts_1.buildMacOS)(config, buildParams);
|
|
52
|
+
case "windows":
|
|
53
|
+
return (0, windows_ts_1.buildWindows)(config, buildParams, argv);
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
exports.rnxBuildCommand = {
|
|
53
57
|
// The build command requires the `project` field, which currently requires
|
|
54
58
|
// loading the full config.
|
|
55
|
-
[
|
|
59
|
+
[constants_ts_1.RNX_FAST_PATH]: false,
|
|
56
60
|
name: "rnx-build",
|
|
57
61
|
description: "Build your native app for testing in emulator/simulator or on device",
|
|
58
62
|
func: rnxBuild,
|
|
@@ -62,6 +66,10 @@ exports.rnxBuildCommand = {
|
|
|
62
66
|
description: "Target platform",
|
|
63
67
|
parse: asSupportedPlatform,
|
|
64
68
|
},
|
|
69
|
+
{
|
|
70
|
+
name: "--solution <string>",
|
|
71
|
+
description: "Path, relative to project root, of the Visual Studio solution to build (Windows only)",
|
|
72
|
+
},
|
|
65
73
|
{
|
|
66
74
|
name: "--workspace <string>",
|
|
67
75
|
description: "Path, relative to project root, of the Xcode workspace to build (macOS only)",
|
|
@@ -85,12 +93,12 @@ exports.rnxBuildCommand = {
|
|
|
85
93
|
{
|
|
86
94
|
name: "--ccache-dir <string>",
|
|
87
95
|
description: "Path to Ccache config",
|
|
88
|
-
parse:
|
|
96
|
+
parse: ccache_ts_1.setCcacheDir,
|
|
89
97
|
},
|
|
90
98
|
{
|
|
91
99
|
name: "--ccache-home <string>",
|
|
92
100
|
description: "Path to Ccache installation",
|
|
93
|
-
parse:
|
|
101
|
+
parse: ccache_ts_1.setCcacheHome,
|
|
94
102
|
},
|
|
95
103
|
],
|
|
96
104
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parsePlatform } from "@rnx-kit/tools-react-native/platform";
|
|
2
|
-
import { asBoolean, asNumber, asTransformProfile } from "../helpers/parsers";
|
|
2
|
+
import { asBoolean, asNumber, asTransformProfile } from "../helpers/parsers.ts";
|
|
3
3
|
export declare const commonBundleCommandOptions: ({
|
|
4
4
|
name: string;
|
|
5
5
|
description: string;
|
package/lib/bundle/cliOptions.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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
|
|
5
|
+
const parsers_ts_1 = require("../helpers/parsers.js");
|
|
6
6
|
exports.commonBundleCommandOptions = [
|
|
7
7
|
{
|
|
8
8
|
name: "--id <id>",
|
|
@@ -21,12 +21,12 @@ exports.commonBundleCommandOptions = [
|
|
|
21
21
|
name: "--dev [boolean]",
|
|
22
22
|
description: "If false, warnings are disabled and the bundle is minified",
|
|
23
23
|
default: true,
|
|
24
|
-
parse:
|
|
24
|
+
parse: parsers_ts_1.asBoolean,
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
name: "--minify [boolean]",
|
|
28
28
|
description: "Controls whether or not the bundle is minified (useful for test builds)",
|
|
29
|
-
parse:
|
|
29
|
+
parse: parsers_ts_1.asBoolean,
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
name: "--bundle-output <string>",
|
|
@@ -40,7 +40,7 @@ exports.commonBundleCommandOptions = [
|
|
|
40
40
|
{
|
|
41
41
|
name: "--max-workers <number>",
|
|
42
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
|
-
parse:
|
|
43
|
+
parse: parsers_ts_1.asNumber,
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
name: "--sourcemap-output <string>",
|
|
@@ -61,7 +61,7 @@ exports.commonBundleCommandOptions = [
|
|
|
61
61
|
{
|
|
62
62
|
name: "--unstable-transform-profile <string>",
|
|
63
63
|
description: "[Experimental] Transform JS for a specific JS engine; currently supported: hermes, hermes-canary, default",
|
|
64
|
-
parse:
|
|
64
|
+
parse: parsers_ts_1.asTransformProfile,
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
name: "--reset-cache",
|
package/lib/bundle/kit-config.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getTargetPlatforms = getTargetPlatforms;
|
|
4
4
|
exports.getCliPlatformBundleConfigs = getCliPlatformBundleConfigs;
|
|
5
5
|
const config_1 = require("@rnx-kit/config");
|
|
6
|
-
const
|
|
6
|
+
const defaultPlugins_ts_1 = require("./defaultPlugins.js");
|
|
7
7
|
/**
|
|
8
8
|
* Get the list of target platforms for bundling.
|
|
9
9
|
*
|
|
@@ -49,7 +49,7 @@ function getCliPlatformBundleConfigs(id, overridePlatform, kitConfig = (0, confi
|
|
|
49
49
|
const platformBundleConfig = (0, config_1.getPlatformBundleConfig)(bundleConfig, platform);
|
|
50
50
|
// apply defaults to fill in any required props that are missing
|
|
51
51
|
return {
|
|
52
|
-
...(0,
|
|
52
|
+
...(0, defaultPlugins_ts_1.getDefaultBundlerPlugins)(),
|
|
53
53
|
...getDefaultBundleParameters(platform),
|
|
54
54
|
...platformBundleConfig,
|
|
55
55
|
platform,
|