@rnx-kit/cli 0.16.29 → 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/align-deps.js +5 -5
- 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/cliOptions.d.ts +2 -2
- package/lib/bundle/cliOptions.js +27 -27
- package/lib/bundle/hermes.d.ts +2 -1
- package/lib/bundle/hermes.js +9 -15
- package/lib/bundle/metro.js +6 -9
- package/lib/bundle.d.ts +3 -3
- package/lib/bundle.js +4 -4
- package/lib/clean.d.ts +3 -3
- package/lib/clean.js +47 -67
- package/lib/copy-assets.d.ts +5 -3
- package/lib/copy-assets.js +31 -28
- package/lib/helpers/externals.d.ts +4 -0
- package/lib/{serve/external.js → helpers/externals.js} +10 -8
- package/lib/helpers/filesystem.d.ts +3 -0
- package/lib/helpers/filesystem.js +31 -0
- package/lib/{metro-config.js → helpers/metro-config.js} +1 -1
- package/lib/{parsers.d.ts → helpers/parsers.d.ts} +1 -1
- package/lib/{parsers.js → helpers/parsers.js} +17 -15
- package/lib/index.d.ts +2 -188
- package/lib/index.js +1 -5
- package/lib/ram-bundle.d.ts +4 -4
- package/lib/ram-bundle.js +2 -2
- package/lib/serve/keyboard.js +3 -6
- package/lib/serve/types.d.ts +2 -2
- package/lib/start.d.ts +1 -1
- package/lib/start.js +34 -34
- package/lib/test.d.ts +2 -1
- package/lib/test.js +7 -5
- package/lib/write-third-party-notices.js +13 -13
- package/package.json +24 -23
- package/lib/serve/external.d.ts +0 -7
- package/src/align-deps.ts +0 -82
- package/src/bundle/cliOptions.ts +0 -82
- package/src/bundle/defaultPlugins.ts +0 -16
- package/src/bundle/hermes.ts +0 -114
- package/src/bundle/kit-config.ts +0 -81
- package/src/bundle/metro.ts +0 -66
- package/src/bundle/overrides.ts +0 -51
- package/src/bundle/types.ts +0 -41
- package/src/bundle.ts +0 -69
- package/src/clean.ts +0 -223
- package/src/copy-assets.ts +0 -545
- package/src/index.ts +0 -34
- package/src/metro-config.ts +0 -208
- package/src/parsers.ts +0 -44
- package/src/ram-bundle.ts +0 -78
- package/src/serve/external.ts +0 -62
- package/src/serve/help.ts +0 -59
- package/src/serve/keyboard.ts +0 -76
- package/src/serve/kit-config.ts +0 -47
- package/src/serve/types.ts +0 -87
- package/src/start.ts +0 -316
- package/src/test.ts +0 -137
- package/src/write-third-party-notices.ts +0 -85
- /package/lib/{metro-config.d.ts → helpers/metro-config.d.ts} +0 -0
package/lib/start.js
CHANGED
|
@@ -27,10 +27,10 @@ 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"));
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
30
|
+
const path = __importStar(require("node:path"));
|
|
31
|
+
const externals_1 = require("./helpers/externals");
|
|
32
|
+
const metro_config_1 = require("./helpers/metro-config");
|
|
33
|
+
const parsers_1 = require("./helpers/parsers");
|
|
34
34
|
const help_1 = require("./serve/help");
|
|
35
35
|
const keyboard_1 = require("./serve/keyboard");
|
|
36
36
|
const kit_config_1 = require("./serve/kit-config");
|
|
@@ -40,7 +40,7 @@ function hasAttachToServerFunction(devServer) {
|
|
|
40
40
|
async function rnxStart(_argv, ctx, args) {
|
|
41
41
|
var _a;
|
|
42
42
|
const serverConfig = (0, kit_config_1.getKitServerConfig)(args);
|
|
43
|
-
const { createDevServerMiddleware, indexPageMiddleware } = (0,
|
|
43
|
+
const { createDevServerMiddleware, indexPageMiddleware } = (0, externals_1.requireExternal)("@react-native-community/cli-server-api", ctx.root, ctx.reactNativePath);
|
|
44
44
|
// interactive mode requires raw access to stdin
|
|
45
45
|
let interactive = args.interactive;
|
|
46
46
|
if (interactive) {
|
|
@@ -90,7 +90,7 @@ async function rnxStart(_argv, ctx, args) {
|
|
|
90
90
|
const coreDevMiddleware = (() => {
|
|
91
91
|
try {
|
|
92
92
|
// https://github.com/facebook/react-native/blob/7888338295476f4d4f00733309e54b8d22318e1e/packages/community-cli-plugin/src/commands/start/runServer.js#L115
|
|
93
|
-
const { createDevMiddleware } = (0,
|
|
93
|
+
const { createDevMiddleware } = (0, externals_1.requireExternal)("@react-native/dev-middleware", ctx.root, ctx.reactNativePath);
|
|
94
94
|
return createDevMiddleware({
|
|
95
95
|
projectRoot,
|
|
96
96
|
serverBaseUrl: devServerUrl,
|
|
@@ -189,76 +189,76 @@ async function rnxStart(_argv, ctx, args) {
|
|
|
189
189
|
exports.rnxStartCommand = {
|
|
190
190
|
name: "rnx-start",
|
|
191
191
|
func: rnxStart,
|
|
192
|
-
description: "Start a
|
|
192
|
+
description: "Start a React Native development server",
|
|
193
193
|
options: [
|
|
194
194
|
{
|
|
195
|
-
name: "--port
|
|
196
|
-
description: "Host port to use when listening for incoming server requests
|
|
195
|
+
name: "--port <number>",
|
|
196
|
+
description: "Host port to use when listening for incoming server requests",
|
|
197
197
|
parse: parsers_1.asNumber,
|
|
198
198
|
default: 8081,
|
|
199
199
|
},
|
|
200
200
|
{
|
|
201
|
-
name: "--host
|
|
202
|
-
description: "Host name or address to bind when listening for incoming server requests
|
|
201
|
+
name: "--host <string>",
|
|
202
|
+
description: "Host name or address to bind when listening for incoming server requests; when not specified, requests from all addresses are accepted",
|
|
203
203
|
default: "",
|
|
204
204
|
},
|
|
205
205
|
{
|
|
206
|
-
name: "--
|
|
207
|
-
description: "Path to the root of your react-native project
|
|
206
|
+
name: "--project-root <path>",
|
|
207
|
+
description: "Path to the root of your react-native project; the bundle server uses this path to resolve all web requests",
|
|
208
208
|
parse: parsers_1.asResolvedPath,
|
|
209
209
|
},
|
|
210
210
|
{
|
|
211
|
-
name: "--
|
|
212
|
-
description: "Additional folders which will be added to the
|
|
211
|
+
name: "--watch-folders <paths>",
|
|
212
|
+
description: "Additional folders which will be added to the watched files list, comma-separated; by default, Metro watches all project files",
|
|
213
213
|
parse: (val) => (0, parsers_1.asStringArray)(val).map(parsers_1.asResolvedPath),
|
|
214
214
|
},
|
|
215
215
|
{
|
|
216
|
-
name: "--
|
|
217
|
-
description: "Additional asset plugins to be used by
|
|
216
|
+
name: "--asset-plugins <list>",
|
|
217
|
+
description: "Additional asset plugins to be used by Metro's Babel transformer; comma-separated list containing plugin module names or absolute paths to plugin packages",
|
|
218
218
|
parse: parsers_1.asStringArray,
|
|
219
219
|
},
|
|
220
220
|
{
|
|
221
|
-
name: "--
|
|
222
|
-
description: "Additional source
|
|
221
|
+
name: "--source-exts <list>",
|
|
222
|
+
description: "Additional source file extensions to include when generating bundles; comma-separated list, excluding the leading dot",
|
|
223
223
|
parse: parsers_1.asStringArray,
|
|
224
224
|
},
|
|
225
225
|
{
|
|
226
|
-
name: "--max-workers
|
|
227
|
-
description: "Specifies the maximum number of parallel worker threads to use for transforming files
|
|
226
|
+
name: "--max-workers <number>",
|
|
227
|
+
description: "Specifies the maximum number of parallel worker threads to use for transforming files; defaults to the number of cores available on your machine",
|
|
228
228
|
parse: parsers_1.asNumber,
|
|
229
229
|
},
|
|
230
230
|
{
|
|
231
231
|
name: "--reset-cache",
|
|
232
|
-
description: "Reset the Metro cache
|
|
232
|
+
description: "Reset the Metro cache",
|
|
233
233
|
},
|
|
234
234
|
{
|
|
235
|
-
name: "--custom-log-reporter-path
|
|
236
|
-
description: "Path to a JavaScript file which exports a Metro 'TerminalReporter' function
|
|
235
|
+
name: "--custom-log-reporter-path <string>",
|
|
236
|
+
description: "Path to a JavaScript file which exports a Metro 'TerminalReporter' function; replaces the default reporter that writes all messages to the Metro console",
|
|
237
237
|
},
|
|
238
238
|
{
|
|
239
239
|
name: "--https",
|
|
240
|
-
description: "Use a secure (https) web server
|
|
240
|
+
description: "Use a secure (https) web server; when not specified, an insecure (http) web server is used",
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
|
-
name: "--key
|
|
244
|
-
description: "Path to a custom SSL private key file to use for secure (https) communication
|
|
243
|
+
name: "--key <path>",
|
|
244
|
+
description: "Path to a custom SSL private key file to use for secure (https) communication",
|
|
245
245
|
},
|
|
246
246
|
{
|
|
247
|
-
name: "--cert
|
|
248
|
-
description: "Path to a custom SSL certificate file to use for secure (https) communication
|
|
247
|
+
name: "--cert <path>",
|
|
248
|
+
description: "Path to a custom SSL certificate file to use for secure (https) communication",
|
|
249
249
|
},
|
|
250
250
|
{
|
|
251
|
-
name: "--config
|
|
252
|
-
description: "Path to the Metro configuration file
|
|
251
|
+
name: "--config <string>",
|
|
252
|
+
description: "Path to the Metro configuration file",
|
|
253
253
|
parse: parsers_1.asResolvedPath,
|
|
254
254
|
},
|
|
255
255
|
{
|
|
256
256
|
name: "--no-interactive",
|
|
257
|
-
description: "Disables interactive mode
|
|
257
|
+
description: "Disables interactive mode",
|
|
258
258
|
},
|
|
259
259
|
{
|
|
260
|
-
name: "--id
|
|
261
|
-
description: "Specify which bundle configuration to use if server configuration is missing
|
|
260
|
+
name: "--id <string>",
|
|
261
|
+
description: "Specify which bundle configuration to use if server configuration is missing",
|
|
262
262
|
},
|
|
263
263
|
],
|
|
264
264
|
};
|
package/lib/test.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Config as CLIConfig } from "@react-native-community/cli-types";
|
|
2
|
+
import type { AllPlatforms } from "@rnx-kit/tools-react-native/platform";
|
|
2
3
|
type Args = {
|
|
3
|
-
platform:
|
|
4
|
+
platform: AllPlatforms;
|
|
4
5
|
};
|
|
5
6
|
type Options = {
|
|
6
7
|
name: string;
|
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,12 +98,12 @@ 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: [
|
|
103
105
|
{
|
|
104
|
-
name: "--platform
|
|
106
|
+
name: "--platform <android|ios|macos|windows|win32>",
|
|
105
107
|
description: "Platform to target",
|
|
106
108
|
parse: platform_1.parsePlatform,
|
|
107
109
|
},
|
|
@@ -23,36 +23,36 @@ exports.rnxWriteThirdPartyNoticesCommand = {
|
|
|
23
23
|
options: [
|
|
24
24
|
{
|
|
25
25
|
name: "--root-path <path>",
|
|
26
|
-
description: "The root of the repo
|
|
26
|
+
description: "The root of the repo — the starting point for finding each module in the source map dependency graph",
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
name: "--source-map-file <file>",
|
|
30
|
-
description: "The source map file associated with the package's entry file
|
|
30
|
+
description: "The source map file associated with the package's entry file — this source map eventually leads to all package dependencies and their licenses",
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
name: "--json",
|
|
34
|
-
description: "Format the 3rd-party notice file as JSON instead of text
|
|
34
|
+
description: "Format the 3rd-party notice file as JSON instead of text",
|
|
35
35
|
default: false,
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
|
-
name: "--output-file
|
|
39
|
-
description: "The path to use when writing the 3rd-party notice file
|
|
38
|
+
name: "--output-file <file>",
|
|
39
|
+
description: "The path to use when writing the 3rd-party notice file",
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
|
-
name: "--ignore-scopes
|
|
43
|
-
description: "Comma-separated list of
|
|
42
|
+
name: "--ignore-scopes <string>",
|
|
43
|
+
description: "Comma-separated list of npm scopes to ignore when traversing the source map dependency graph",
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
|
-
name: "--ignore-modules
|
|
47
|
-
description: "Comma-separated list of modules to ignore when traversing the source map dependency graph
|
|
46
|
+
name: "--ignore-modules <string>",
|
|
47
|
+
description: "Comma-separated list of modules to ignore when traversing the source map dependency graph",
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
|
-
name: "--preamble-text
|
|
51
|
-
description: "A string to prepend to the start of the 3rd-party notice
|
|
50
|
+
name: "--preamble-text <string>",
|
|
51
|
+
description: "A string to prepend to the start of the 3rd-party notice",
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
|
-
name: "--additional-text
|
|
55
|
-
description: "A string to append to the end of the 3rd-party notice
|
|
54
|
+
name: "--additional-text <string>",
|
|
55
|
+
description: "A string to append to the end of the 3rd-party notice",
|
|
56
56
|
},
|
|
57
57
|
],
|
|
58
58
|
};
|
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,20 +9,23 @@
|
|
|
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
|
-
"react-native.config.js"
|
|
15
|
-
"src"
|
|
15
|
+
"react-native.config.js"
|
|
16
16
|
],
|
|
17
17
|
"main": "lib/index.js",
|
|
18
|
+
"bin": {
|
|
19
|
+
"rnx-cli": "bin/rnx-cli.cjs"
|
|
20
|
+
},
|
|
18
21
|
"types": "lib/index.d.ts",
|
|
19
22
|
"exports": {
|
|
20
23
|
".": {
|
|
21
24
|
"types": "./lib/index.d.ts",
|
|
22
25
|
"default": "./lib/index.js"
|
|
23
26
|
},
|
|
24
|
-
"./
|
|
25
|
-
"./
|
|
27
|
+
"./react-native.config.js": "./react-native.config.js",
|
|
28
|
+
"./package.json": "./package.json"
|
|
26
29
|
},
|
|
27
30
|
"repository": {
|
|
28
31
|
"type": "git",
|
|
@@ -37,24 +40,22 @@
|
|
|
37
40
|
"test": "rnx-kit-scripts test"
|
|
38
41
|
},
|
|
39
42
|
"dependencies": {
|
|
40
|
-
"@rnx-kit/align-deps": "^2.5.
|
|
43
|
+
"@rnx-kit/align-deps": "^2.5.2",
|
|
41
44
|
"@rnx-kit/config": "^0.6.6",
|
|
42
45
|
"@rnx-kit/console": "^1.1.0",
|
|
43
46
|
"@rnx-kit/metro-plugin-cyclic-dependencies-detector": "^1.1.1",
|
|
44
47
|
"@rnx-kit/metro-plugin-duplicates-checker": "^2.1.1",
|
|
45
48
|
"@rnx-kit/metro-plugin-typescript": "^0.4.4",
|
|
46
49
|
"@rnx-kit/metro-serializer": "^1.0.14",
|
|
47
|
-
"@rnx-kit/metro-serializer-esbuild": "^0.1.
|
|
50
|
+
"@rnx-kit/metro-serializer-esbuild": "^0.1.36",
|
|
48
51
|
"@rnx-kit/metro-service": "^3.1.6",
|
|
49
52
|
"@rnx-kit/third-party-notices": "^1.3.4",
|
|
50
53
|
"@rnx-kit/tools-language": "^2.0.0",
|
|
51
54
|
"@rnx-kit/tools-node": "^2.1.1",
|
|
52
|
-
"@rnx-kit/tools-react-native": "^1.
|
|
53
|
-
"
|
|
54
|
-
"node-fetch": "^2.6.7",
|
|
55
|
+
"@rnx-kit/tools-react-native": "^1.4.0",
|
|
56
|
+
"commander": "^11.1.0",
|
|
55
57
|
"ora": "^5.4.1",
|
|
56
|
-
"qrcode": "^1.5.0"
|
|
57
|
-
"readline": "^1.3.0"
|
|
58
|
+
"qrcode": "^1.5.0"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
60
61
|
"jest": ">=26.0",
|
|
@@ -71,35 +72,35 @@
|
|
|
71
72
|
"devDependencies": {
|
|
72
73
|
"@babel/core": "^7.20.0",
|
|
73
74
|
"@babel/preset-env": "^7.20.0",
|
|
74
|
-
"@react-native-community/cli-
|
|
75
|
-
"@react-native-community/cli-types": "^12.3.0",
|
|
75
|
+
"@react-native-community/cli-types": "^13.6.4",
|
|
76
76
|
"@rnx-kit/eslint-config": "*",
|
|
77
77
|
"@rnx-kit/jest-preset": "*",
|
|
78
78
|
"@rnx-kit/scripts": "*",
|
|
79
|
+
"@rnx-kit/tools-filesystem": "*",
|
|
79
80
|
"@rnx-kit/tsconfig": "*",
|
|
80
81
|
"@types/connect": "^3.4.36",
|
|
81
|
-
"@types/fs-extra": "^9.0.0",
|
|
82
82
|
"@types/jest": "^29.2.1",
|
|
83
83
|
"@types/node": "^20.0.0",
|
|
84
|
-
"@types/node-fetch": "^2.6.5",
|
|
85
84
|
"@types/qrcode": "^1.4.2",
|
|
86
85
|
"eslint": "^8.56.0",
|
|
87
86
|
"jest": "^29.2.1",
|
|
88
|
-
"
|
|
89
|
-
"metro": "^0.80.
|
|
87
|
+
"markdown-table": "^3.0.0",
|
|
88
|
+
"metro": "^0.80.3",
|
|
90
89
|
"metro-babel-transformer": "^0.80.0",
|
|
91
|
-
"metro-config": "^0.80.
|
|
90
|
+
"metro-config": "^0.80.3",
|
|
92
91
|
"prettier": "^3.0.0",
|
|
93
92
|
"react": "18.2.0",
|
|
94
|
-
"react-native": "^0.
|
|
93
|
+
"react-native": "^0.74.0",
|
|
94
|
+
"tsx": "^4.15.0",
|
|
95
95
|
"type-fest": "^4.0.0",
|
|
96
96
|
"typescript": "^5.0.0"
|
|
97
97
|
},
|
|
98
|
+
"engines": {
|
|
99
|
+
"node": ">=16.17"
|
|
100
|
+
},
|
|
98
101
|
"depcheck": {
|
|
99
102
|
"ignoreMatches": [
|
|
100
|
-
"connect"
|
|
101
|
-
"jest-cli",
|
|
102
|
-
"readline"
|
|
103
|
+
"connect"
|
|
103
104
|
]
|
|
104
105
|
},
|
|
105
106
|
"jest": {
|
package/lib/serve/external.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { CliServerApi, CoreDevMiddleware } from "./types";
|
|
2
|
-
type CliClean = typeof import("@react-native-community/cli-clean");
|
|
3
|
-
export declare function requireExternal(module: "@react-native-community/cli-clean"): CliClean;
|
|
4
|
-
export declare function requireExternal(module: "@react-native-community/cli-server-api"): CliServerApi;
|
|
5
|
-
export declare function requireExternal(module: "@react-native/dev-middleware"): CoreDevMiddleware;
|
|
6
|
-
export {};
|
|
7
|
-
//# sourceMappingURL=external.d.ts.map
|
package/src/align-deps.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { Config as CLIConfig } from "@react-native-community/cli-types";
|
|
2
|
-
import { cli, cliOptions } from "@rnx-kit/align-deps";
|
|
3
|
-
import { pickValues } from "@rnx-kit/tools-language/properties";
|
|
4
|
-
|
|
5
|
-
type CLIArgs = Record<string, string | number | boolean | undefined>;
|
|
6
|
-
|
|
7
|
-
const optionsMap: Partial<Record<keyof typeof cliOptions, string>> = {
|
|
8
|
-
"exclude-packages": "excludePackages",
|
|
9
|
-
init: "init",
|
|
10
|
-
presets: "presets",
|
|
11
|
-
requirements: "requirements",
|
|
12
|
-
"set-version": "setVersion",
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export function rnxAlignDeps(
|
|
16
|
-
_argv: string[],
|
|
17
|
-
_config: CLIConfig,
|
|
18
|
-
args: CLIArgs
|
|
19
|
-
): void {
|
|
20
|
-
cli({
|
|
21
|
-
...pickValues(args, Object.values(optionsMap), Object.keys(optionsMap)),
|
|
22
|
-
"diff-mode": args.diffMode?.toString(),
|
|
23
|
-
loose: Boolean(args.loose),
|
|
24
|
-
"migrate-config": Boolean(args.migrateConfig),
|
|
25
|
-
"no-unmanaged": Boolean(args.noUnmanaged),
|
|
26
|
-
verbose: Boolean(args.verbose),
|
|
27
|
-
write: Boolean(args.write),
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const rnxAlignDepsCommand = {
|
|
32
|
-
name: "rnx-align-deps",
|
|
33
|
-
description:
|
|
34
|
-
"Manage dependencies within a repository and across many repositories",
|
|
35
|
-
func: rnxAlignDeps,
|
|
36
|
-
options: [
|
|
37
|
-
{
|
|
38
|
-
name: `--diff-mode [${cliOptions["diff-mode"].choices.join("|")}]`,
|
|
39
|
-
description: cliOptions["diff-mode"].description,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: "--exclude-packages [packages]",
|
|
43
|
-
description: cliOptions["exclude-packages"].description,
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: `--init [${cliOptions.init.choices?.join("|")}]`,
|
|
47
|
-
description: cliOptions.init.description,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: "--loose",
|
|
51
|
-
description: cliOptions.loose.description,
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
name: "--migrate-config",
|
|
55
|
-
description: cliOptions["migrate-config"].description,
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: "--no-unmanaged",
|
|
59
|
-
description: cliOptions["no-unmanaged"].description,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
name: "--presets [presets]",
|
|
63
|
-
description: cliOptions.presets.description,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "--requirements [requirements]",
|
|
67
|
-
description: cliOptions.requirements.description,
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: "--set-version [versions]",
|
|
71
|
-
description: cliOptions["set-version"].description,
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
name: "--verbose",
|
|
75
|
-
description: cliOptions.verbose.description,
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: "--write",
|
|
79
|
-
description: cliOptions.write.description,
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
};
|
package/src/bundle/cliOptions.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { parsePlatform } from "@rnx-kit/tools-react-native/platform";
|
|
2
|
-
import { asBoolean, asNumber, parseTransformProfile } from "../parsers";
|
|
3
|
-
|
|
4
|
-
export const commonBundleCommandOptions = [
|
|
5
|
-
{
|
|
6
|
-
name: "--id [id]",
|
|
7
|
-
description:
|
|
8
|
-
"Target bundle definition. This is only needed when the rnx-kit configuration has multiple bundle definitions.",
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
name: "--entry-file [path]",
|
|
12
|
-
description:
|
|
13
|
-
"Path to the root JavaScript or TypeScript file, either absolute or relative to the package.",
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
name: "--platform [ios|android|windows|win32|macos]",
|
|
17
|
-
description:
|
|
18
|
-
"Target platform. When not given, all platforms in the rnx-kit configuration are bundled.",
|
|
19
|
-
parse: parsePlatform,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: "--dev [boolean]",
|
|
23
|
-
description: "If false, warnings are disabled and the bundle is minified.",
|
|
24
|
-
default: true,
|
|
25
|
-
parse: asBoolean,
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: "--minify [boolean]",
|
|
29
|
-
description:
|
|
30
|
-
"Controls whether or not the bundle is minified. Disabling minification is useful for test builds.",
|
|
31
|
-
parse: asBoolean,
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: "--bundle-output [string]",
|
|
35
|
-
description:
|
|
36
|
-
"Path to the output bundle file, either absolute or relative to the package.",
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: "--bundle-encoding [utf8|utf16le|ascii]",
|
|
40
|
-
description: "Character encoding to use when writing the bundle file.",
|
|
41
|
-
default: "utf8",
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: "--max-workers [number]",
|
|
45
|
-
description:
|
|
46
|
-
"Specifies the maximum number of parallel worker threads to use for transforming files. This defaults to the number of cores available on your machine.",
|
|
47
|
-
parse: asNumber,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: "--sourcemap-output [string]",
|
|
51
|
-
description:
|
|
52
|
-
"Path where the bundle source map is written, either absolute or relative to the package.",
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: "--sourcemap-sources-root [string]",
|
|
56
|
-
description:
|
|
57
|
-
"Path to use when relativizing file entries in the bundle source map.",
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: "--sourcemap-use-absolute-path",
|
|
61
|
-
description: "Report SourceMapURL using its full path",
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: "--assets-dest [path]",
|
|
65
|
-
description:
|
|
66
|
-
"Path where bundle assets like images are written, either absolute or relative to the package. If not given, assets are ignored.",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: "--unstable-transform-profile [string]",
|
|
70
|
-
description:
|
|
71
|
-
"Experimental, transform JS for a specific JS engine. Currently supported: hermes, hermes-canary, default",
|
|
72
|
-
parse: parseTransformProfile,
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: "--reset-cache",
|
|
76
|
-
description: "Reset the Metro cache.",
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
name: "--config [string]",
|
|
80
|
-
description: "Path to the Metro configuration file.",
|
|
81
|
-
},
|
|
82
|
-
];
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { BundleParameters } from "@rnx-kit/config";
|
|
2
|
-
|
|
3
|
-
type DefaultPlugins = Pick<Required<BundleParameters>, "plugins" | "treeShake">;
|
|
4
|
-
|
|
5
|
-
const defaultPlugins: DefaultPlugins = {
|
|
6
|
-
plugins: [
|
|
7
|
-
"@rnx-kit/metro-plugin-cyclic-dependencies-detector",
|
|
8
|
-
"@rnx-kit/metro-plugin-duplicates-checker",
|
|
9
|
-
"@rnx-kit/metro-plugin-typescript",
|
|
10
|
-
],
|
|
11
|
-
treeShake: false,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export function getDefaultBundlerPlugins(): DefaultPlugins {
|
|
15
|
-
return defaultPlugins;
|
|
16
|
-
}
|
package/src/bundle/hermes.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import type { HermesOptions } from "@rnx-kit/config";
|
|
2
|
-
import { error, info } from "@rnx-kit/console";
|
|
3
|
-
import { findPackageDependencyDir } from "@rnx-kit/tools-node/package";
|
|
4
|
-
import { requireModuleFromMetro } from "@rnx-kit/tools-react-native/metro";
|
|
5
|
-
import { spawnSync } from "child_process";
|
|
6
|
-
import * as fs from "fs";
|
|
7
|
-
import * as os from "os";
|
|
8
|
-
import * as path from "path";
|
|
9
|
-
|
|
10
|
-
function hermesBinaryInDir(hermesc: string): string | null {
|
|
11
|
-
switch (os.platform()) {
|
|
12
|
-
case "darwin":
|
|
13
|
-
return path.join(hermesc, "osx-bin", "hermesc");
|
|
14
|
-
case "linux":
|
|
15
|
-
return path.join(hermesc, "linux64-bin", "hermesc");
|
|
16
|
-
case "win32":
|
|
17
|
-
return path.join(hermesc, "win64-bin", "hermesc.exe");
|
|
18
|
-
default:
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function findHermesBinary() {
|
|
24
|
-
const locations = [
|
|
25
|
-
() => {
|
|
26
|
-
const rnPath = findPackageDependencyDir("react-native");
|
|
27
|
-
if (!rnPath) {
|
|
28
|
-
throw new Error("Cannot find module 'react-native'");
|
|
29
|
-
}
|
|
30
|
-
return path.join(rnPath, "sdks", "hermesc");
|
|
31
|
-
},
|
|
32
|
-
() => findPackageDependencyDir("hermes-engine"),
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
for (const getLocation of locations) {
|
|
36
|
-
const location = getLocation();
|
|
37
|
-
if (location) {
|
|
38
|
-
const hermesc = hermesBinaryInDir(location);
|
|
39
|
-
if (hermesc && fs.existsSync(hermesc)) {
|
|
40
|
-
return hermesc;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function getOutput(args: string[]): string | null {
|
|
49
|
-
const length = args.length;
|
|
50
|
-
for (let i = 0; i < length; ++i) {
|
|
51
|
-
const flag = args[i];
|
|
52
|
-
if (flag === "-out") {
|
|
53
|
-
return args[i + 1];
|
|
54
|
-
} else if (flag.startsWith("-out=")) {
|
|
55
|
-
return flag.substring(5);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function emitBytecode(
|
|
62
|
-
input: string,
|
|
63
|
-
sourcemap: string | undefined,
|
|
64
|
-
options: HermesOptions
|
|
65
|
-
): void {
|
|
66
|
-
const cmd = options.command || findHermesBinary();
|
|
67
|
-
if (!cmd) {
|
|
68
|
-
error("No Hermes compiler was found");
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const args = [
|
|
73
|
-
"-emit-binary",
|
|
74
|
-
// If Hermes can't detect the width of the terminal, it will set the limit
|
|
75
|
-
// to "unlimited". Since we might be passing a minified bundle to Hermes,
|
|
76
|
-
// limit output width to avoid issues when it outputs diagnostics. See:
|
|
77
|
-
// - https://github.com/microsoft/rnx-kit/issues/2416
|
|
78
|
-
// - https://github.com/microsoft/rnx-kit/issues/2419
|
|
79
|
-
// - https://github.com/microsoft/rnx-kit/issues/2424
|
|
80
|
-
"-max-diagnostic-width=80",
|
|
81
|
-
...(options.flags ?? ["-O", "-output-source-map", "-w"]),
|
|
82
|
-
];
|
|
83
|
-
|
|
84
|
-
let output = getOutput(args);
|
|
85
|
-
if (!output) {
|
|
86
|
-
output = input + ".hbc";
|
|
87
|
-
args.push("-out", output);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
args.push(input);
|
|
91
|
-
|
|
92
|
-
info("Emitting bytecode to:", output);
|
|
93
|
-
const result = spawnSync(cmd, args, { stdio: "inherit" });
|
|
94
|
-
if (result.status !== 0) {
|
|
95
|
-
throw result.error;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (sourcemap && args.includes("-output-source-map")) {
|
|
99
|
-
const outputMap = output + ".map";
|
|
100
|
-
info(`Combining source maps: ${sourcemap} + ${outputMap}`);
|
|
101
|
-
|
|
102
|
-
const options = { encoding: "utf-8" } as const;
|
|
103
|
-
const packagerSourcemap = JSON.parse(fs.readFileSync(sourcemap, options));
|
|
104
|
-
const compilerSourcemap = JSON.parse(fs.readFileSync(outputMap, options));
|
|
105
|
-
|
|
106
|
-
// `composeSourceMaps` was introduced in 0.56 — see
|
|
107
|
-
// https://github.com/facebook/metro/commit/6017085bdad96ca5cec39d50038eb5622ce1097b
|
|
108
|
-
// @ts-expect-error Property 'composeSourceMaps' does not exist
|
|
109
|
-
const { composeSourceMaps } = requireModuleFromMetro("metro-source-map");
|
|
110
|
-
|
|
111
|
-
const composed = composeSourceMaps([packagerSourcemap, compilerSourcemap]);
|
|
112
|
-
fs.writeFileSync(outputMap, JSON.stringify(composed));
|
|
113
|
-
}
|
|
114
|
-
}
|