@rnx-kit/cli 0.16.12 → 0.16.14
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/CHANGELOG.md +18 -0
- package/coverage/clover.xml +2 -2
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/src/bundle/defaultPlugins.ts.html +1 -1
- package/coverage/lcov-report/src/bundle/index.html +1 -1
- package/coverage/lcov-report/src/bundle/kit-config.ts.html +1 -1
- package/coverage/lcov-report/src/bundle/metro.ts.html +1 -1
- package/coverage/lcov-report/src/bundle/overrides.ts.html +1 -1
- package/coverage/lcov-report/src/copy-assets.ts.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/metro-config.ts.html +1 -1
- package/coverage/lcov-report/src/test.ts.html +1 -1
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.d.ts.map +1 -1
- package/lib/bundle.js.map +1 -1
- package/lib/clean.d.ts.map +1 -1
- package/lib/clean.js.map +1 -1
- package/lib/ram-bundle.d.ts +1 -1
- package/lib/ram-bundle.d.ts.map +1 -1
- package/lib/ram-bundle.js.map +1 -1
- package/lib/serve/external.d.ts +4 -0
- package/lib/serve/external.d.ts.map +1 -0
- package/lib/serve/external.js +29 -0
- package/lib/serve/external.js.map +1 -0
- package/lib/serve/help.d.ts +7 -0
- package/lib/serve/help.d.ts.map +1 -0
- package/lib/serve/help.js +50 -0
- package/lib/serve/help.js.map +1 -0
- package/lib/serve/keyboard.d.ts +11 -0
- package/lib/serve/keyboard.d.ts.map +1 -0
- package/lib/serve/keyboard.js +61 -0
- package/lib/serve/keyboard.js.map +1 -0
- package/lib/serve/types.d.ts +76 -0
- package/lib/serve/types.d.ts.map +1 -0
- package/lib/serve/types.js +3 -0
- package/lib/serve/types.js.map +1 -0
- package/lib/start.d.ts +3 -19
- package/lib/start.d.ts.map +1 -1
- package/lib/start.js +103 -128
- package/lib/start.js.map +1 -1
- package/lib/write-third-party-notices.d.ts +1 -1
- package/lib/write-third-party-notices.d.ts.map +1 -1
- package/lib/write-third-party-notices.js.map +1 -1
- package/package.json +17 -13
- package/src/bundle.ts +1 -1
- package/src/clean.ts +1 -3
- package/src/ram-bundle.ts +1 -1
- package/src/serve/external.ts +50 -0
- package/src/serve/help.ts +60 -0
- package/src/serve/keyboard.ts +73 -0
- package/src/serve/types.ts +86 -0
- package/src/start.ts +138 -186
- package/src/write-third-party-notices.ts +1 -1
package/lib/start.js
CHANGED
|
@@ -22,82 +22,37 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
26
|
exports.rnxStart = void 0;
|
|
27
|
+
const logger = __importStar(require("@rnx-kit/console"));
|
|
30
28
|
const metro_service_1 = require("@rnx-kit/metro-service");
|
|
31
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
32
|
-
const os = __importStar(require("os"));
|
|
33
29
|
const path = __importStar(require("path"));
|
|
34
|
-
const qrcode_1 = __importDefault(require("qrcode"));
|
|
35
|
-
const readline_1 = __importDefault(require("readline"));
|
|
36
30
|
const metro_config_1 = require("./metro-config");
|
|
31
|
+
const external_1 = require("./serve/external");
|
|
32
|
+
const help_1 = require("./serve/help");
|
|
33
|
+
const keyboard_1 = require("./serve/keyboard");
|
|
37
34
|
const kit_config_1 = require("./serve/kit-config");
|
|
38
|
-
function friendlyRequire(...modules) {
|
|
39
|
-
try {
|
|
40
|
-
const modulePath = modules.reduce((startDir, module) => {
|
|
41
|
-
return require.resolve(module, { paths: [startDir] });
|
|
42
|
-
}, process.cwd());
|
|
43
|
-
return require(modulePath);
|
|
44
|
-
}
|
|
45
|
-
catch (_) {
|
|
46
|
-
const module = modules[modules.length - 1];
|
|
47
|
-
throw new Error(`Cannot find module '${module}'. This probably means that '@rnx-kit/cli' is not compatible with the version of '@react-native-community/cli' that you are currently using. Please update to the latest version and try again. If the issue still persists after the update, please file a bug at https://github.com/microsoft/rnx-kit/issues.`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
35
|
function hasAttachToServerFunction(devServer) {
|
|
51
36
|
return "attachToServer" in devServer;
|
|
52
37
|
}
|
|
53
|
-
async function rnxStart(_argv,
|
|
54
|
-
|
|
55
|
-
const
|
|
38
|
+
async function rnxStart(_argv, ctx, args) {
|
|
39
|
+
var _a;
|
|
40
|
+
const serverConfig = (0, kit_config_1.getKitServerConfig)(args);
|
|
41
|
+
const { createDevServerMiddleware, indexPageMiddleware } = (0, external_1.requireExternal)("@react-native-community/cli-server-api");
|
|
56
42
|
// interactive mode requires raw access to stdin
|
|
57
|
-
let interactive =
|
|
43
|
+
let interactive = args.interactive;
|
|
58
44
|
if (interactive) {
|
|
59
45
|
interactive = process.stdin.isTTY;
|
|
60
46
|
if (!interactive) {
|
|
61
|
-
|
|
47
|
+
logger.warn("Interactive mode is not supported in this environment");
|
|
62
48
|
}
|
|
63
49
|
}
|
|
64
|
-
// create a Metro terminal and reporter for writing to the console
|
|
65
|
-
const { terminal, reporter: terminalReporter } = (0, metro_service_1.createTerminal)(cliOptions.customLogReporterPath);
|
|
66
|
-
const printHelp = () => {
|
|
67
|
-
const dim = chalk_1.default.dim;
|
|
68
|
-
const press = dim(" › Press ");
|
|
69
|
-
[
|
|
70
|
-
["r", "reload the app"],
|
|
71
|
-
["d", "open developer menu"],
|
|
72
|
-
["a", "show bundler address QR code"],
|
|
73
|
-
["h", "show this help message"],
|
|
74
|
-
["ctrl-c", "quit"],
|
|
75
|
-
].forEach(([key, description]) => {
|
|
76
|
-
terminal.log(press + key + dim(` to ${description}.`));
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
// create a reporter function, to be bound to the Metro configuration.
|
|
80
|
-
// which writes to the Metro terminal and
|
|
81
|
-
// also notifies the `reportEvent` delegate.
|
|
82
|
-
let reportEventDelegate = undefined;
|
|
83
|
-
const reporter = {
|
|
84
|
-
update(event) {
|
|
85
|
-
terminalReporter.update(event);
|
|
86
|
-
if (reportEventDelegate) {
|
|
87
|
-
reportEventDelegate(event);
|
|
88
|
-
}
|
|
89
|
-
if (interactive && event.type === "dep_graph_loading") {
|
|
90
|
-
printHelp();
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
50
|
// load Metro configuration, applying overrides from the command line
|
|
95
|
-
const metroConfig = await (0, metro_service_1.loadMetroConfig)(
|
|
96
|
-
...
|
|
51
|
+
const metroConfig = await (0, metro_service_1.loadMetroConfig)(ctx, {
|
|
52
|
+
...args,
|
|
97
53
|
...(serverConfig.projectRoot
|
|
98
54
|
? { projectRoot: path.resolve(serverConfig.projectRoot) }
|
|
99
55
|
: undefined),
|
|
100
|
-
reporter,
|
|
101
56
|
...(serverConfig.sourceExts
|
|
102
57
|
? { sourceExts: serverConfig.sourceExts }
|
|
103
58
|
: undefined),
|
|
@@ -107,52 +62,112 @@ async function rnxStart(_argv, cliConfig, cliOptions) {
|
|
|
107
62
|
}
|
|
108
63
|
: undefined),
|
|
109
64
|
});
|
|
65
|
+
// create a Metro terminal and reporter for writing to the console
|
|
66
|
+
const { terminal, reporter: terminalReporter } = (0, metro_service_1.createTerminal)(args.customLogReporterPath);
|
|
110
67
|
// customize the metro config to include plugins, presets, etc.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
68
|
+
const log = (message) => terminal.log(message);
|
|
69
|
+
(0, metro_config_1.customizeMetroConfig)(metroConfig, serverConfig, log);
|
|
70
|
+
const { projectRoot, server: { port }, watchFolders, } = metroConfig;
|
|
71
|
+
const scheme = args.https === true ? "https" : "http";
|
|
72
|
+
const serverStatus = await (0, metro_service_1.isDevServerRunning)(scheme, args.host, port, projectRoot);
|
|
73
|
+
switch (serverStatus) {
|
|
74
|
+
case "already_running":
|
|
75
|
+
logger.info(`A dev server is already running for this project on port ${port}. ` +
|
|
76
|
+
"Exiting...");
|
|
77
|
+
return;
|
|
78
|
+
case "in_use":
|
|
79
|
+
logger.error(`Another process is using port ${port}. Please terminate this ` +
|
|
80
|
+
"process and try again, or try another port with `--port`.");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
114
83
|
// create middleware -- a collection of plugins which handle incoming
|
|
115
84
|
// http(s) requests, routing them to static pages or JS functions.
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
85
|
+
const host = ((_a = args.host) === null || _a === void 0 ? void 0 : _a.length) ? args.host : "localhost";
|
|
86
|
+
const devServer = createDevServerMiddleware({ host, port, watchFolders });
|
|
87
|
+
const coreDevMiddleware = (() => {
|
|
88
|
+
try {
|
|
89
|
+
// https://github.com/facebook/react-native/blob/3e7a873f2d1c5170a7f4c88064897e74a149c5d5/packages/community-cli-plugin/src/commands/start/runServer.js#L115
|
|
90
|
+
const { createDevMiddleware } = (0, external_1.requireExternal)("@react-native/dev-middleware");
|
|
91
|
+
return createDevMiddleware({
|
|
92
|
+
projectRoot,
|
|
93
|
+
logger,
|
|
94
|
+
unstable_experiments: {
|
|
95
|
+
// NOTE: Only affects the /open-debugger endpoint
|
|
96
|
+
enableCustomDebuggerFrontend: true,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (_) {
|
|
101
|
+
// Fallback to the behavior from before 0.73
|
|
102
|
+
const middleware = devServer.middleware;
|
|
103
|
+
middleware.use(indexPageMiddleware);
|
|
104
|
+
// merge the Metro config middleware with our middleware
|
|
105
|
+
const enhanceMiddleware = metroConfig.server.enhanceMiddleware;
|
|
106
|
+
// @ts-expect-error We want to override `enhanceMiddleware`
|
|
107
|
+
metroConfig.server.enhanceMiddleware = (metroMiddleware, metroServer) => {
|
|
108
|
+
return middleware.use(enhanceMiddleware
|
|
109
|
+
? enhanceMiddleware(metroMiddleware, metroServer)
|
|
110
|
+
: metroMiddleware);
|
|
111
|
+
};
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
})();
|
|
131
115
|
// `createDevServerMiddleware` changed its return type in
|
|
132
116
|
// https://github.com/react-native-community/cli/pull/1560
|
|
133
117
|
let websocketEndpoints = undefined;
|
|
134
118
|
let messageSocketEndpoint;
|
|
119
|
+
let reportEventDelegate = undefined;
|
|
135
120
|
if (!hasAttachToServerFunction(devServer)) {
|
|
136
121
|
websocketEndpoints = devServer.websocketEndpoints;
|
|
137
122
|
messageSocketEndpoint = devServer.messageSocketEndpoint;
|
|
138
123
|
// bind our `reportEvent` delegate to the Metro server
|
|
139
124
|
reportEventDelegate = devServer.eventsSocketEndpoint.reportEvent;
|
|
140
125
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
126
|
+
const printHelp = (0, help_1.makeHelp)(terminal, {
|
|
127
|
+
hasDebugger: Boolean(coreDevMiddleware),
|
|
128
|
+
});
|
|
129
|
+
// @ts-expect-error We want to override `reporter`
|
|
130
|
+
metroConfig.reporter = {
|
|
131
|
+
update(event) {
|
|
132
|
+
terminalReporter.update(event);
|
|
133
|
+
if (reportEventDelegate) {
|
|
134
|
+
reportEventDelegate(event);
|
|
135
|
+
}
|
|
136
|
+
if (interactive && event.type === "dep_graph_loading") {
|
|
137
|
+
printHelp();
|
|
138
|
+
}
|
|
139
|
+
},
|
|
148
140
|
};
|
|
149
|
-
const serverInstance = await (0, metro_service_1.startServer)(metroConfig,
|
|
141
|
+
const serverInstance = await (0, metro_service_1.startServer)(metroConfig, {
|
|
142
|
+
host: args.host,
|
|
143
|
+
secure: args.https,
|
|
144
|
+
secureCert: args.cert,
|
|
145
|
+
secureKey: args.key,
|
|
146
|
+
...(coreDevMiddleware
|
|
147
|
+
? {
|
|
148
|
+
unstable_extraMiddleware: [
|
|
149
|
+
devServer.middleware,
|
|
150
|
+
indexPageMiddleware,
|
|
151
|
+
coreDevMiddleware.middleware,
|
|
152
|
+
],
|
|
153
|
+
websocketEndpoints: {
|
|
154
|
+
...websocketEndpoints,
|
|
155
|
+
...coreDevMiddleware.websocketEndpoints,
|
|
156
|
+
},
|
|
157
|
+
}
|
|
158
|
+
: { websocketEndpoints }),
|
|
159
|
+
});
|
|
150
160
|
if (hasAttachToServerFunction(devServer)) {
|
|
151
161
|
const { messageSocket, eventsSocket } = devServer.attachToServer(serverInstance);
|
|
152
162
|
messageSocketEndpoint = messageSocket;
|
|
153
163
|
// bind our `reportEvent` delegate to the Metro server
|
|
154
164
|
reportEventDelegate = eventsSocket.reportEvent;
|
|
155
165
|
}
|
|
166
|
+
else {
|
|
167
|
+
// `messageSocketEndpoint` should already be set at this point. But this
|
|
168
|
+
// makes TypeScript happier.
|
|
169
|
+
messageSocketEndpoint = devServer.messageSocketEndpoint;
|
|
170
|
+
}
|
|
156
171
|
// In Node 8, the default keep-alive for an HTTP connection is 5 seconds. In
|
|
157
172
|
// early versions of Node 8, this was implemented in a buggy way which caused
|
|
158
173
|
// some HTTP responses (like those containing large JS bundles) to be
|
|
@@ -167,51 +182,11 @@ async function rnxStart(_argv, cliConfig, cliOptions) {
|
|
|
167
182
|
// in interactive mode, listen for keyboard events from stdin and bind
|
|
168
183
|
// them to specific actions.
|
|
169
184
|
if (interactive) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
switch (name) {
|
|
176
|
-
case "c":
|
|
177
|
-
terminal.log(chalk_1.default.green("Exiting..."));
|
|
178
|
-
process.exit();
|
|
179
|
-
break;
|
|
180
|
-
case "z":
|
|
181
|
-
process.emit("SIGTSTP", "SIGTSTP");
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
switch (name) {
|
|
187
|
-
case "a": {
|
|
188
|
-
const protocol = cliOptions.https ? "https" : "http";
|
|
189
|
-
const host = cliOptions.host || os.hostname();
|
|
190
|
-
const port = metroConfig.server.port;
|
|
191
|
-
const url = `${protocol}://${host}:${port}/index.bundle`;
|
|
192
|
-
qrcode_1.default.toString(url, { type: "terminal" }, (_err, qr) => {
|
|
193
|
-
terminal.log("");
|
|
194
|
-
terminal.log(url + ":");
|
|
195
|
-
terminal.log(qr);
|
|
196
|
-
});
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
case "d":
|
|
200
|
-
terminal.log(chalk_1.default.green("Opening developer menu..."));
|
|
201
|
-
messageSocketEndpoint.broadcast("devMenu", undefined);
|
|
202
|
-
break;
|
|
203
|
-
case "h":
|
|
204
|
-
printHelp();
|
|
205
|
-
break;
|
|
206
|
-
case "r":
|
|
207
|
-
terminal.log(chalk_1.default.green("Reloading app..."));
|
|
208
|
-
messageSocketEndpoint.broadcast("reload", undefined);
|
|
209
|
-
break;
|
|
210
|
-
case "return":
|
|
211
|
-
terminal.log("");
|
|
212
|
-
break;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
185
|
+
(0, keyboard_1.attachKeyHandlers)({
|
|
186
|
+
devServerUrl: `${scheme}://${host}:${port}`,
|
|
187
|
+
help: printHelp,
|
|
188
|
+
messageSocketEndpoint,
|
|
189
|
+
terminal,
|
|
215
190
|
});
|
|
216
191
|
}
|
|
217
192
|
}
|
package/lib/start.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yDAA2C;AAC3C,0DAKgC;AAIhC,2CAA6B;AAC7B,iDAAsD;AACtD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gBAAgB,GAAG,KAAK,CAAC;IAExC,sEAAsE;IACtE,4BAA4B;IAC5B,IAAI,WAAW,EAAE;QACf,IAAA,4BAAiB,EAAC;YAChB,YAAY,EAAE,GAAG,MAAM,MAAM,IAAI,IAAI,IAAI,EAAE;YAC3C,IAAI,EAAE,SAAS;YACf,qBAAqB;YACrB,QAAQ;SACT,CAAC,CAAC;KACJ;AACH,CAAC;AA1MD,4BA0MC"}
|
|
@@ -9,6 +9,6 @@ type CliThirdPartyNoticesOptions = {
|
|
|
9
9
|
preambleText?: string;
|
|
10
10
|
additionalText?: string;
|
|
11
11
|
};
|
|
12
|
-
export declare function rnxWriteThirdPartyNotices(_argv:
|
|
12
|
+
export declare function rnxWriteThirdPartyNotices(_argv: string[], _config: CLIConfig, { additionalText, ignoreModules, ignoreScopes, json, outputFile, preambleText, rootPath, sourceMapFile, }: CliThirdPartyNoticesOptions): void;
|
|
13
13
|
export {};
|
|
14
14
|
//# sourceMappingURL=write-third-party-notices.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-third-party-notices.d.ts","sourceRoot":"","sources":["../src/write-third-party-notices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAG7E,KAAK,2BAA2B,GAAG;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"write-third-party-notices.d.ts","sourceRoot":"","sources":["../src/write-third-party-notices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAG7E,KAAK,2BAA2B,GAAG;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,EAAE,SAAS,EAClB,EACE,cAAc,EACd,aAAa,EACb,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,aAAa,GACd,EAAE,2BAA2B,GAC7B,IAAI,CAYN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-third-party-notices.js","sourceRoot":"","sources":["../src/write-third-party-notices.ts"],"names":[],"mappings":";;;AACA,sEAAsE;AAatE,SAAgB,yBAAyB,CACvC,
|
|
1
|
+
{"version":3,"file":"write-third-party-notices.js","sourceRoot":"","sources":["../src/write-third-party-notices.ts"],"names":[],"mappings":";;;AACA,sEAAsE;AAatE,SAAgB,yBAAyB,CACvC,KAAe,EACf,OAAkB,EAClB,EACE,cAAc,EACd,aAAa,EACb,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,aAAa,GACe;IAE9B,6EAA6E;IAC7E,IAAA,4CAAsB,EAAC;QACrB,QAAQ;QACR,aAAa;QACb,IAAI;QACJ,UAAU;QACV,YAAY,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,CAAC,GAAG,CAAC;QACtC,aAAa,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,KAAK,CAAC,GAAG,CAAC;QACxC,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS;QACvD,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS;KAC9D,CAAC,CAAC;AACL,CAAC;AAzBD,8DAyBC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnx-kit/cli",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.14",
|
|
4
4
|
"description": "Command-line interface for working with kit packages in your repo",
|
|
5
|
-
"homepage": "https://github.com/microsoft/rnx-kit/tree/main/packages/cli",
|
|
5
|
+
"homepage": "https://github.com/microsoft/rnx-kit/tree/main/packages/cli#readme",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"types": "lib/index.d.ts",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@rnx-kit/metro-plugin-duplicates-checker": "^2.1.1",
|
|
27
27
|
"@rnx-kit/metro-plugin-typescript": "^0.4.4",
|
|
28
28
|
"@rnx-kit/metro-serializer": "^1.0.12",
|
|
29
|
-
"@rnx-kit/metro-serializer-esbuild": "^0.1.
|
|
30
|
-
"@rnx-kit/metro-service": "^3.1.
|
|
29
|
+
"@rnx-kit/metro-serializer-esbuild": "^0.1.29",
|
|
30
|
+
"@rnx-kit/metro-service": "^3.1.2",
|
|
31
31
|
"@rnx-kit/third-party-notices": "^1.3.4",
|
|
32
32
|
"@rnx-kit/tools-language": "^2.0.0",
|
|
33
33
|
"@rnx-kit/tools-node": "^2.0.0",
|
|
@@ -35,12 +35,14 @@
|
|
|
35
35
|
"chalk": "^4.1.0",
|
|
36
36
|
"find-up": "^5.0.0",
|
|
37
37
|
"fs-extra": "^10.0.0",
|
|
38
|
+
"node-fetch": "^2.6.7",
|
|
38
39
|
"ora": "^5.4.1",
|
|
39
40
|
"qrcode": "^1.5.0",
|
|
40
41
|
"readline": "^1.3.0"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"@react-native-community/cli": ">=5.0.1",
|
|
45
|
+
"@react-native-community/cli-clean": ">=8.0.0",
|
|
44
46
|
"@react-native-community/cli-server-api": ">=5.0.1",
|
|
45
47
|
"jest-cli": ">=26.0",
|
|
46
48
|
"react-native": ">=0.64"
|
|
@@ -49,6 +51,9 @@
|
|
|
49
51
|
"@react-native-community/cli": {
|
|
50
52
|
"optional": true
|
|
51
53
|
},
|
|
54
|
+
"@react-native-community/cli-clean": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
52
57
|
"@react-native-community/cli-server-api": {
|
|
53
58
|
"optional": true
|
|
54
59
|
},
|
|
@@ -60,25 +65,24 @@
|
|
|
60
65
|
}
|
|
61
66
|
},
|
|
62
67
|
"devDependencies": {
|
|
63
|
-
"@react-native-community/cli-types": "^
|
|
68
|
+
"@react-native-community/cli-types": "^11.0.0",
|
|
64
69
|
"@rnx-kit/scripts": "*",
|
|
65
|
-
"@types/
|
|
66
|
-
"@types/
|
|
67
|
-
"@types/metro-config": "^0.76.0",
|
|
70
|
+
"@types/connect": "^3.4.36",
|
|
71
|
+
"@types/node-fetch": "^2.6.5",
|
|
68
72
|
"@types/qrcode": "^1.4.2",
|
|
69
73
|
"eslint": "^8.0.0",
|
|
70
74
|
"jest": "^29.2.1",
|
|
71
75
|
"memfs": "^4.0.0",
|
|
72
|
-
"metro
|
|
76
|
+
"metro": "^0.76.5",
|
|
77
|
+
"metro-babel-transformer": "^0.76.8",
|
|
78
|
+
"metro-config": "^0.76.5",
|
|
73
79
|
"prettier": "^3.0.0",
|
|
74
|
-
"type-fest": "^
|
|
80
|
+
"type-fest": "^4.0.0",
|
|
75
81
|
"typescript": "^5.0.0"
|
|
76
82
|
},
|
|
77
83
|
"depcheck": {
|
|
78
84
|
"ignoreMatches": [
|
|
79
|
-
"
|
|
80
|
-
"metro",
|
|
81
|
-
"metro-babel-transformer",
|
|
85
|
+
"connect",
|
|
82
86
|
"readline"
|
|
83
87
|
]
|
|
84
88
|
},
|
package/src/bundle.ts
CHANGED
package/src/clean.ts
CHANGED
package/src/ram-bundle.ts
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { CliServerApi, CoreDevMiddleware } from "./types";
|
|
2
|
+
|
|
3
|
+
type ExternalModule =
|
|
4
|
+
| "@react-native-community/cli-server-api"
|
|
5
|
+
| "@react-native/dev-middleware";
|
|
6
|
+
|
|
7
|
+
function friendlyRequire<T>(...modules: string[]): T {
|
|
8
|
+
try {
|
|
9
|
+
const modulePath = modules.reduce((startDir, module) => {
|
|
10
|
+
return require.resolve(module, { paths: [startDir] });
|
|
11
|
+
}, process.cwd());
|
|
12
|
+
return require(modulePath) as T;
|
|
13
|
+
} catch (_) {
|
|
14
|
+
const module = modules[modules.length - 1];
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Cannot find module '${module}'. This probably means that ` +
|
|
17
|
+
"'@rnx-kit/cli' is not compatible with the version of 'react-native' " +
|
|
18
|
+
"that you are currently using. Please update to the latest version " +
|
|
19
|
+
"and try again. If the issue still persists after the update, please " +
|
|
20
|
+
"file a bug at https://github.com/microsoft/rnx-kit/issues."
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function requireExternal(
|
|
26
|
+
module: "@react-native-community/cli-server-api"
|
|
27
|
+
): CliServerApi;
|
|
28
|
+
|
|
29
|
+
export function requireExternal(
|
|
30
|
+
module: "@react-native/dev-middleware"
|
|
31
|
+
): CoreDevMiddleware;
|
|
32
|
+
|
|
33
|
+
export function requireExternal(
|
|
34
|
+
module: ExternalModule
|
|
35
|
+
): CliServerApi | CoreDevMiddleware {
|
|
36
|
+
switch (module) {
|
|
37
|
+
case "@react-native-community/cli-server-api":
|
|
38
|
+
return friendlyRequire<CliServerApi>(
|
|
39
|
+
"react-native",
|
|
40
|
+
"@react-native-community/cli",
|
|
41
|
+
"@react-native-community/cli-server-api"
|
|
42
|
+
);
|
|
43
|
+
case "@react-native/dev-middleware":
|
|
44
|
+
return friendlyRequire<CoreDevMiddleware>(
|
|
45
|
+
"react-native",
|
|
46
|
+
"@react-native/community-cli-plugin",
|
|
47
|
+
"@react-native/dev-middleware"
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { MetroTerminal } from "@rnx-kit/metro-service";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
|
|
4
|
+
type HelpOptions = {
|
|
5
|
+
hasDebugger: boolean;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
type MenuItem = [string, string];
|
|
9
|
+
|
|
10
|
+
export function makeHelp(
|
|
11
|
+
terminal: MetroTerminal["terminal"],
|
|
12
|
+
{ hasDebugger }: HelpOptions
|
|
13
|
+
): () => void {
|
|
14
|
+
const openDebugger: MenuItem | null = hasDebugger
|
|
15
|
+
? ["J", "Open debugger"]
|
|
16
|
+
: null;
|
|
17
|
+
|
|
18
|
+
const menuItems: ("" | MenuItem)[] = [
|
|
19
|
+
["D", "Open developer menu"],
|
|
20
|
+
...(openDebugger ? [openDebugger] : []),
|
|
21
|
+
["Q", "Show bundler address QR code"],
|
|
22
|
+
["R", "Reload the app"],
|
|
23
|
+
"",
|
|
24
|
+
["H", "Show this help message"],
|
|
25
|
+
["Ctrl-C", "Quit"],
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const margin = 4;
|
|
29
|
+
const maxColumnWidth = (index: number) => {
|
|
30
|
+
return (max: number, item: (typeof menuItems)[number]) => {
|
|
31
|
+
if (!item) {
|
|
32
|
+
return max;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const width = item[index].length;
|
|
36
|
+
return width > max ? width : max;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const keyWidth = menuItems.reduce(maxColumnWidth(0), 0);
|
|
41
|
+
const labelWidth = menuItems.reduce(maxColumnWidth(1), 0);
|
|
42
|
+
const separator = `┠${"─".repeat(labelWidth + keyWidth + margin + 1)}`;
|
|
43
|
+
|
|
44
|
+
const dim = chalk.dim;
|
|
45
|
+
const lines = menuItems.map((item) => {
|
|
46
|
+
if (!item) {
|
|
47
|
+
return separator;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const [key, label] = item;
|
|
51
|
+
const labelPadding = labelWidth - label.length;
|
|
52
|
+
const keyPadding = keyWidth - key.length;
|
|
53
|
+
const padding = " ".repeat(labelPadding + keyPadding + margin);
|
|
54
|
+
return `┃ ${dim(label)}${padding}${key}`;
|
|
55
|
+
});
|
|
56
|
+
lines.push("");
|
|
57
|
+
|
|
58
|
+
const help = lines.join("\n");
|
|
59
|
+
return () => terminal.log(help);
|
|
60
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { info } from "@rnx-kit/console";
|
|
2
|
+
import type { MetroTerminal } from "@rnx-kit/metro-service";
|
|
3
|
+
import fetch from "node-fetch";
|
|
4
|
+
import qrcode from "qrcode";
|
|
5
|
+
import readline from "readline";
|
|
6
|
+
import type { DevServerMiddleware } from "./types";
|
|
7
|
+
|
|
8
|
+
type Options = {
|
|
9
|
+
devServerUrl: string;
|
|
10
|
+
help: () => void;
|
|
11
|
+
messageSocketEndpoint: DevServerMiddleware["messageSocketEndpoint"];
|
|
12
|
+
terminal: MetroTerminal["terminal"];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function attachKeyHandlers({
|
|
16
|
+
devServerUrl,
|
|
17
|
+
help,
|
|
18
|
+
messageSocketEndpoint,
|
|
19
|
+
terminal,
|
|
20
|
+
}: Options) {
|
|
21
|
+
process.stdin.setRawMode(true);
|
|
22
|
+
process.stdin.on("keypress", (_key, data) => {
|
|
23
|
+
const { ctrl, name } = data;
|
|
24
|
+
if (ctrl === true) {
|
|
25
|
+
switch (name) {
|
|
26
|
+
case "c":
|
|
27
|
+
info("Exiting...");
|
|
28
|
+
process.exit();
|
|
29
|
+
break;
|
|
30
|
+
case "z":
|
|
31
|
+
process.emit("SIGTSTP", "SIGTSTP");
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
switch (name) {
|
|
36
|
+
case "d":
|
|
37
|
+
info("Opening developer menu...");
|
|
38
|
+
messageSocketEndpoint.broadcast("devMenu", undefined);
|
|
39
|
+
break;
|
|
40
|
+
|
|
41
|
+
case "h":
|
|
42
|
+
help();
|
|
43
|
+
break;
|
|
44
|
+
|
|
45
|
+
case "j": {
|
|
46
|
+
fetch(devServerUrl + "/open-debugger", { method: "POST" });
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
case "q": {
|
|
51
|
+
const url = `${devServerUrl}/index.bundle`;
|
|
52
|
+
qrcode.toString(url, { type: "terminal" }, (_err, qr) => {
|
|
53
|
+
terminal.log("");
|
|
54
|
+
terminal.log(url + ":");
|
|
55
|
+
terminal.log(qr);
|
|
56
|
+
});
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
case "r":
|
|
61
|
+
info("Reloading app...");
|
|
62
|
+
messageSocketEndpoint.broadcast("reload", undefined);
|
|
63
|
+
break;
|
|
64
|
+
|
|
65
|
+
case "return":
|
|
66
|
+
terminal.log("");
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
readline.emitKeypressEvents(process.stdin);
|
|
73
|
+
}
|