@rnx-kit/cli 0.12.3 → 0.12.4
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 +6 -0
- package/coverage/clover.xml +2 -2
- package/coverage/lcov-report/index.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/typescript/index.html +1 -1
- package/coverage/lcov-report/src/typescript/project-cache.ts.html +1 -1
- package/lib/start.d.ts.map +1 -1
- package/lib/start.js +27 -8
- package/lib/start.js.map +1 -1
- package/package.json +1 -1
- package/src/start.ts +48 -8
package/CHANGELOG.md
CHANGED
package/coverage/clover.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="
|
|
3
|
-
<project timestamp="
|
|
2
|
+
<coverage generated="1652360259280" clover="3.2.0">
|
|
3
|
+
<project timestamp="1652360259280" name="All files">
|
|
4
4
|
<metrics statements="286" coveredstatements="143" conditionals="171" coveredconditionals="85" methods="44" coveredmethods="22" elements="501" coveredelements="250" complexity="0" loc="286" ncloc="286" packages="3" files="6" classes="6"/>
|
|
5
5
|
<package name="src">
|
|
6
6
|
<metrics statements="201" coveredstatements="107" conditionals="123" coveredconditionals="59" methods="27" coveredmethods="15"/>
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
132
132
|
Code coverage generated by
|
|
133
133
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
134
|
-
at
|
|
134
|
+
at Thu May 12 2022 12:57:39 GMT+0000 (Coordinated Universal Time)
|
|
135
135
|
</div>
|
|
136
136
|
<script src="prettify.js"></script>
|
|
137
137
|
<script>
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
132
132
|
Code coverage generated by
|
|
133
133
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
134
|
-
at
|
|
134
|
+
at Thu May 12 2022 12:57:39 GMT+0000 (Coordinated Universal Time)
|
|
135
135
|
</div>
|
|
136
136
|
<script src="../../prettify.js"></script>
|
|
137
137
|
<script>
|
|
@@ -367,7 +367,7 @@ export function getKitBundleConfigs(
|
|
|
367
367
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
368
368
|
Code coverage generated by
|
|
369
369
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
370
|
-
at
|
|
370
|
+
at Thu May 12 2022 12:57:39 GMT+0000 (Coordinated Universal Time)
|
|
371
371
|
</div>
|
|
372
372
|
<script src="../../prettify.js"></script>
|
|
373
373
|
<script>
|
|
@@ -343,7 +343,7 @@ export async function <span class="fstat-no" title="function not covered" >metro
|
|
|
343
343
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
344
344
|
Code coverage generated by
|
|
345
345
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
346
|
-
at
|
|
346
|
+
at Thu May 12 2022 12:57:39 GMT+0000 (Coordinated Universal Time)
|
|
347
347
|
</div>
|
|
348
348
|
<script src="../../prettify.js"></script>
|
|
349
349
|
<script>
|
|
@@ -232,7 +232,7 @@ export function applyKitBundleConfigOverrides(
|
|
|
232
232
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
233
233
|
Code coverage generated by
|
|
234
234
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
235
|
-
at
|
|
235
|
+
at Thu May 12 2022 12:57:39 GMT+0000 (Coordinated Universal Time)
|
|
236
236
|
</div>
|
|
237
237
|
<script src="../../prettify.js"></script>
|
|
238
238
|
<script>
|
|
@@ -1741,7 +1741,7 @@ export const rnxCopyAssetsCommand = {
|
|
|
1741
1741
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
1742
1742
|
Code coverage generated by
|
|
1743
1743
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
1744
|
-
at
|
|
1744
|
+
at Thu May 12 2022 12:57:39 GMT+0000 (Coordinated Universal Time)
|
|
1745
1745
|
</div>
|
|
1746
1746
|
<script src="../prettify.js"></script>
|
|
1747
1747
|
<script>
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
117
117
|
Code coverage generated by
|
|
118
118
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
119
|
-
at
|
|
119
|
+
at Thu May 12 2022 12:57:39 GMT+0000 (Coordinated Universal Time)
|
|
120
120
|
</div>
|
|
121
121
|
<script src="../prettify.js"></script>
|
|
122
122
|
<script>
|
|
@@ -565,7 +565,7 @@ export function customizeMetroConfig(
|
|
|
565
565
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
566
566
|
Code coverage generated by
|
|
567
567
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
568
|
-
at
|
|
568
|
+
at Thu May 12 2022 12:57:39 GMT+0000 (Coordinated Universal Time)
|
|
569
569
|
</div>
|
|
570
570
|
<script src="../prettify.js"></script>
|
|
571
571
|
<script>
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
102
102
|
Code coverage generated by
|
|
103
103
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
104
|
-
at
|
|
104
|
+
at Thu May 12 2022 12:57:39 GMT+0000 (Coordinated Universal Time)
|
|
105
105
|
</div>
|
|
106
106
|
<script src="../../prettify.js"></script>
|
|
107
107
|
<script>
|
|
@@ -616,7 +616,7 @@ export function createProjectCache(
|
|
|
616
616
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
617
617
|
Code coverage generated by
|
|
618
618
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
619
|
-
at
|
|
619
|
+
at Thu May 12 2022 12:57:39 GMT+0000 (Coordinated Universal Time)
|
|
620
620
|
</div>
|
|
621
621
|
<script src="../../prettify.js"></script>
|
|
622
622
|
<script>
|
package/lib/start.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,mCAAmC,CAAC;AA+B7E,oBAAY,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAkBF,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EACpB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,eAAe,GAC1B,OAAO,CAAC,IAAI,CAAC,CAyMf"}
|
package/lib/start.js
CHANGED
|
@@ -29,6 +29,9 @@ function friendlyRequire(module) {
|
|
|
29
29
|
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.`);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
+
function hasWebsocketEndpoints(devServer) {
|
|
33
|
+
return !("attachToServer" in devServer);
|
|
34
|
+
}
|
|
32
35
|
function rnxStart(_argv, cliConfig, cliOptions) {
|
|
33
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
37
|
const serverConfig = (0, kit_config_1.getKitServerConfig)(cliOptions);
|
|
@@ -89,11 +92,12 @@ function rnxStart(_argv, cliConfig, cliOptions) {
|
|
|
89
92
|
(0, metro_config_1.customizeMetroConfig)(metroConfig, serverConfig.detectCyclicDependencies, serverConfig.detectDuplicateDependencies, serverConfig.typescriptValidation ? typescriptValidationOptions : false, serverConfig.treeShake);
|
|
90
93
|
// create middleware -- a collection of plugins which handle incoming
|
|
91
94
|
// http(s) requests, routing them to static pages or JS functions.
|
|
92
|
-
const
|
|
95
|
+
const devServer = createDevServerMiddleware({
|
|
93
96
|
host: cliOptions.host,
|
|
94
97
|
port: metroConfig.server.port,
|
|
95
98
|
watchFolders: metroConfig.watchFolders,
|
|
96
99
|
});
|
|
100
|
+
const middleware = devServer.middleware;
|
|
97
101
|
middleware.use(indexPageMiddleware);
|
|
98
102
|
// merge the Metro config middleware with our middleware
|
|
99
103
|
const enhanceMiddleware = metroConfig.server.enhanceMiddleware;
|
|
@@ -104,16 +108,31 @@ function rnxStart(_argv, cliConfig, cliOptions) {
|
|
|
104
108
|
? enhanceMiddleware(metroMiddleware, metroServer)
|
|
105
109
|
: metroMiddleware);
|
|
106
110
|
};
|
|
111
|
+
// `createDevServerMiddleware` changed its return type in
|
|
112
|
+
// https://github.com/react-native-community/cli/pull/1560
|
|
113
|
+
let websocketEndpoints = undefined;
|
|
114
|
+
let messageSocketEndpoint;
|
|
115
|
+
if (hasWebsocketEndpoints(devServer)) {
|
|
116
|
+
websocketEndpoints = devServer.websocketEndpoints;
|
|
117
|
+
messageSocketEndpoint = devServer.messageSocketEndpoint;
|
|
118
|
+
// bind our `reportEvent` delegate to the Metro server
|
|
119
|
+
reportEventDelegate = devServer.eventsSocketEndpoint.reportEvent;
|
|
120
|
+
}
|
|
107
121
|
// start the Metro server
|
|
108
|
-
const
|
|
122
|
+
const serverOptions = {
|
|
109
123
|
host: cliOptions.host,
|
|
110
124
|
secure: cliOptions.https,
|
|
111
125
|
secureCert: cliOptions.cert,
|
|
112
126
|
secureKey: cliOptions.key,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
127
|
+
websocketEndpoints,
|
|
128
|
+
};
|
|
129
|
+
const serverInstance = yield (0, metro_service_1.startServer)(metroConfig, serverOptions);
|
|
130
|
+
if (!hasWebsocketEndpoints(devServer)) {
|
|
131
|
+
const { messageSocket, eventsSocket } = devServer.attachToServer(serverInstance);
|
|
132
|
+
messageSocketEndpoint = messageSocket;
|
|
133
|
+
// bind our `reportEvent` delegate to the Metro server
|
|
134
|
+
reportEventDelegate = eventsSocket.reportEvent;
|
|
135
|
+
}
|
|
117
136
|
// In Node 8, the default keep-alive for an HTTP connection is 5 seconds. In
|
|
118
137
|
// early versions of Node 8, this was implemented in a buggy way which caused
|
|
119
138
|
// some HTTP responses (like those containing large JS bundles) to be
|
|
@@ -159,11 +178,11 @@ function rnxStart(_argv, cliConfig, cliOptions) {
|
|
|
159
178
|
}
|
|
160
179
|
case "d":
|
|
161
180
|
terminal.log(chalk_1.default.green("Opening developer menu..."));
|
|
162
|
-
|
|
181
|
+
messageSocketEndpoint.broadcast("devMenu", undefined);
|
|
163
182
|
break;
|
|
164
183
|
case "r":
|
|
165
184
|
terminal.log(chalk_1.default.green("Reloading app..."));
|
|
166
|
-
|
|
185
|
+
messageSocketEndpoint.broadcast("reload", undefined);
|
|
167
186
|
break;
|
|
168
187
|
}
|
|
169
188
|
}
|
package/lib/start.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,0DAIgC;AAChC,kDAA0B;AAI1B,4CAAoB;AACpB,gDAAwB;AACxB,oDAA4B;AAC5B,wDAAgC;AAChC,iDAAsD;AACtD,mDAAwD;
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,0DAIgC;AAChC,kDAA0B;AAI1B,4CAAoB;AACpB,gDAAwB;AACxB,oDAA4B;AAC5B,wDAAgC;AAChC,iDAAsD;AACtD,mDAAwD;AAiCxD,SAAS,eAAe,CAAI,MAAc;IACxC,IAAI;QACF,OAAO,OAAO,CAAC,MAAM,CAAM,CAAC;KAC7B;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CACb,uBAAuB,MAAM,iTAAiT,CAC/U,CAAC;KACH;AACH,CAAC;AAED,SAAS,qBAAqB,CAC5B,SAAqD;IAErD,OAAO,CAAC,CAAC,gBAAgB,IAAI,SAAS,CAAC,CAAC;AAC1C,CAAC;AAED,SAAsB,QAAQ,CAC5B,KAAoB,EACpB,SAAoB,EACpB,UAA2B;;QAE3B,MAAM,YAAY,GAAG,IAAA,+BAAkB,EAAC,UAAU,CAAC,CAAC;QACpD,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC1B;QAED,MAAM,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,GAAG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AAQ,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE;gCACtD,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gCACjB,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;gCACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;4BACnB,CAAC,CAAC,CAAC;4BACH,MAAM;yBACP;wBAED,KAAK,GAAG;4BACN,QAAQ,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;4BACvD,qBAAqB,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;4BACtD,MAAM;wBAER,KAAK,GAAG;4BACN,QAAQ,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC;4BAC9C,qBAAqB,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;4BACrD,MAAM;qBACT;iBACF;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;CAAA;AA7MD,4BA6MC"}
|
package/package.json
CHANGED
package/src/start.ts
CHANGED
|
@@ -17,6 +17,19 @@ import { customizeMetroConfig } from "./metro-config";
|
|
|
17
17
|
import { getKitServerConfig } from "./serve/kit-config";
|
|
18
18
|
import type { TypeScriptValidationOptions } from "./types";
|
|
19
19
|
|
|
20
|
+
type DevServerMiddleware = ReturnType<
|
|
21
|
+
typeof CliServerApi["createDevServerMiddleware"]
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
type DevServer = ReturnType<DevServerMiddleware["attachToServer"]>;
|
|
25
|
+
|
|
26
|
+
type DevServerMiddleware7 = Pick<DevServerMiddleware, "middleware"> & {
|
|
27
|
+
websocketEndpoints: unknown;
|
|
28
|
+
debuggerProxyEndpoint: DevServer["debuggerProxy"];
|
|
29
|
+
messageSocketEndpoint: DevServer["messageSocket"];
|
|
30
|
+
eventsSocketEndpoint: DevServer["eventsSocket"];
|
|
31
|
+
};
|
|
32
|
+
|
|
20
33
|
export type CLIStartOptions = {
|
|
21
34
|
host: string;
|
|
22
35
|
port: number;
|
|
@@ -44,6 +57,12 @@ function friendlyRequire<T>(module: string): T {
|
|
|
44
57
|
}
|
|
45
58
|
}
|
|
46
59
|
|
|
60
|
+
function hasWebsocketEndpoints(
|
|
61
|
+
devServer: DevServerMiddleware | DevServerMiddleware7
|
|
62
|
+
): devServer is DevServerMiddleware7 {
|
|
63
|
+
return !("attachToServer" in devServer);
|
|
64
|
+
}
|
|
65
|
+
|
|
47
66
|
export async function rnxStart(
|
|
48
67
|
_argv: Array<string>,
|
|
49
68
|
cliConfig: CLIConfig,
|
|
@@ -136,11 +155,12 @@ export async function rnxStart(
|
|
|
136
155
|
|
|
137
156
|
// create middleware -- a collection of plugins which handle incoming
|
|
138
157
|
// http(s) requests, routing them to static pages or JS functions.
|
|
139
|
-
const
|
|
158
|
+
const devServer = createDevServerMiddleware({
|
|
140
159
|
host: cliOptions.host,
|
|
141
160
|
port: metroConfig.server.port,
|
|
142
161
|
watchFolders: metroConfig.watchFolders,
|
|
143
162
|
});
|
|
163
|
+
const middleware = devServer.middleware;
|
|
144
164
|
middleware.use(indexPageMiddleware);
|
|
145
165
|
|
|
146
166
|
// merge the Metro config middleware with our middleware
|
|
@@ -158,17 +178,37 @@ export async function rnxStart(
|
|
|
158
178
|
);
|
|
159
179
|
};
|
|
160
180
|
|
|
181
|
+
// `createDevServerMiddleware` changed its return type in
|
|
182
|
+
// https://github.com/react-native-community/cli/pull/1560
|
|
183
|
+
let websocketEndpoints: unknown = undefined;
|
|
184
|
+
let messageSocketEndpoint: DevServer["messageSocket"];
|
|
185
|
+
|
|
186
|
+
if (hasWebsocketEndpoints(devServer)) {
|
|
187
|
+
websocketEndpoints = devServer.websocketEndpoints;
|
|
188
|
+
messageSocketEndpoint = devServer.messageSocketEndpoint;
|
|
189
|
+
|
|
190
|
+
// bind our `reportEvent` delegate to the Metro server
|
|
191
|
+
reportEventDelegate = devServer.eventsSocketEndpoint.reportEvent;
|
|
192
|
+
}
|
|
193
|
+
|
|
161
194
|
// start the Metro server
|
|
162
|
-
const
|
|
195
|
+
const serverOptions = {
|
|
163
196
|
host: cliOptions.host,
|
|
164
197
|
secure: cliOptions.https,
|
|
165
198
|
secureCert: cliOptions.cert,
|
|
166
199
|
secureKey: cliOptions.key,
|
|
167
|
-
|
|
168
|
-
|
|
200
|
+
websocketEndpoints,
|
|
201
|
+
};
|
|
202
|
+
const serverInstance = await startServer(metroConfig, serverOptions);
|
|
203
|
+
|
|
204
|
+
if (!hasWebsocketEndpoints(devServer)) {
|
|
205
|
+
const { messageSocket, eventsSocket } =
|
|
206
|
+
devServer.attachToServer(serverInstance);
|
|
207
|
+
messageSocketEndpoint = messageSocket;
|
|
169
208
|
|
|
170
|
-
|
|
171
|
-
|
|
209
|
+
// bind our `reportEvent` delegate to the Metro server
|
|
210
|
+
reportEventDelegate = eventsSocket.reportEvent;
|
|
211
|
+
}
|
|
172
212
|
|
|
173
213
|
// In Node 8, the default keep-alive for an HTTP connection is 5 seconds. In
|
|
174
214
|
// early versions of Node 8, this was implemented in a buggy way which caused
|
|
@@ -217,12 +257,12 @@ export async function rnxStart(
|
|
|
217
257
|
|
|
218
258
|
case "d":
|
|
219
259
|
terminal.log(chalk.green("Opening developer menu..."));
|
|
220
|
-
|
|
260
|
+
messageSocketEndpoint.broadcast("devMenu", undefined);
|
|
221
261
|
break;
|
|
222
262
|
|
|
223
263
|
case "r":
|
|
224
264
|
terminal.log(chalk.green("Reloading app..."));
|
|
225
|
-
|
|
265
|
+
messageSocketEndpoint.broadcast("reload", undefined);
|
|
226
266
|
break;
|
|
227
267
|
}
|
|
228
268
|
}
|