@rnx-kit/cli 0.16.21 → 0.16.23

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.
Files changed (85) hide show
  1. package/lib/bundle/hermes.js +14 -6
  2. package/package.json +21 -10
  3. package/src/bundle/hermes.ts +18 -8
  4. package/CHANGELOG.md +0 -1659
  5. package/coverage/clover.xml +0 -323
  6. package/coverage/coverage-final.json +0 -8
  7. package/coverage/lcov-report/base.css +0 -224
  8. package/coverage/lcov-report/block-navigation.js +0 -87
  9. package/coverage/lcov-report/favicon.png +0 -0
  10. package/coverage/lcov-report/index.html +0 -131
  11. package/coverage/lcov-report/prettify.css +0 -1
  12. package/coverage/lcov-report/prettify.js +0 -2
  13. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  14. package/coverage/lcov-report/sorter.js +0 -196
  15. package/coverage/lcov-report/src/bundle/defaultPlugins.ts.html +0 -133
  16. package/coverage/lcov-report/src/bundle/index.html +0 -161
  17. package/coverage/lcov-report/src/bundle/kit-config.ts.html +0 -328
  18. package/coverage/lcov-report/src/bundle/metro.ts.html +0 -283
  19. package/coverage/lcov-report/src/bundle/overrides.ts.html +0 -238
  20. package/coverage/lcov-report/src/copy-assets.ts.html +0 -1720
  21. package/coverage/lcov-report/src/index.html +0 -146
  22. package/coverage/lcov-report/src/metro-config.ts.html +0 -709
  23. package/coverage/lcov-report/src/test.ts.html +0 -496
  24. package/coverage/lcov.info +0 -605
  25. package/eslint.config.js +0 -1
  26. package/lib/align-deps.d.ts.map +0 -1
  27. package/lib/align-deps.js.map +0 -1
  28. package/lib/bundle/cliOptions.d.ts.map +0 -1
  29. package/lib/bundle/cliOptions.js.map +0 -1
  30. package/lib/bundle/defaultPlugins.d.ts.map +0 -1
  31. package/lib/bundle/defaultPlugins.js.map +0 -1
  32. package/lib/bundle/hermes.d.ts.map +0 -1
  33. package/lib/bundle/hermes.js.map +0 -1
  34. package/lib/bundle/kit-config.d.ts.map +0 -1
  35. package/lib/bundle/kit-config.js.map +0 -1
  36. package/lib/bundle/metro.d.ts.map +0 -1
  37. package/lib/bundle/metro.js.map +0 -1
  38. package/lib/bundle/overrides.d.ts.map +0 -1
  39. package/lib/bundle/overrides.js.map +0 -1
  40. package/lib/bundle/types.d.ts.map +0 -1
  41. package/lib/bundle/types.js.map +0 -1
  42. package/lib/bundle.d.ts.map +0 -1
  43. package/lib/bundle.js.map +0 -1
  44. package/lib/clean.d.ts.map +0 -1
  45. package/lib/clean.js.map +0 -1
  46. package/lib/copy-assets.d.ts.map +0 -1
  47. package/lib/copy-assets.js.map +0 -1
  48. package/lib/index.d.ts.map +0 -1
  49. package/lib/index.js.map +0 -1
  50. package/lib/metro-config.d.ts.map +0 -1
  51. package/lib/metro-config.js.map +0 -1
  52. package/lib/parsers.d.ts.map +0 -1
  53. package/lib/parsers.js.map +0 -1
  54. package/lib/ram-bundle.d.ts.map +0 -1
  55. package/lib/ram-bundle.js.map +0 -1
  56. package/lib/serve/external.d.ts.map +0 -1
  57. package/lib/serve/external.js.map +0 -1
  58. package/lib/serve/help.d.ts.map +0 -1
  59. package/lib/serve/help.js.map +0 -1
  60. package/lib/serve/keyboard.d.ts.map +0 -1
  61. package/lib/serve/keyboard.js.map +0 -1
  62. package/lib/serve/kit-config.d.ts.map +0 -1
  63. package/lib/serve/kit-config.js.map +0 -1
  64. package/lib/serve/types.d.ts.map +0 -1
  65. package/lib/serve/types.js.map +0 -1
  66. package/lib/start.d.ts.map +0 -1
  67. package/lib/start.js.map +0 -1
  68. package/lib/test.d.ts.map +0 -1
  69. package/lib/test.js.map +0 -1
  70. package/lib/write-third-party-notices.d.ts.map +0 -1
  71. package/lib/write-third-party-notices.js.map +0 -1
  72. package/test/__mocks__/child_process.js +0 -5
  73. package/test/__mocks__/fs-extra.js +0 -20
  74. package/test/__mocks__/fs.js +0 -1
  75. package/test/bundle/__mocks__/@rnx-kit/config.js +0 -14
  76. package/test/bundle/__mocks__/@rnx-kit/console.js +0 -1
  77. package/test/bundle/__mocks__/@rnx-kit/metro-service.js +0 -1
  78. package/test/bundle/kit-config.test.ts +0 -160
  79. package/test/bundle/metro.test.ts +0 -78
  80. package/test/bundle/overrides.test.ts +0 -85
  81. package/test/copy-assets/assembleAarBundle.test.ts +0 -313
  82. package/test/copy-assets/copyAssets.test.ts +0 -122
  83. package/test/metro-config.test.ts +0 -206
  84. package/test/test.test.ts +0 -11
  85. package/tsconfig.json +0 -4
@@ -1,313 +0,0 @@
1
- import * as path from "path";
2
- import { assembleAarBundle } from "../../src/copy-assets";
3
-
4
- jest.mock("child_process");
5
- jest.mock("fs");
6
- jest.unmock("@rnx-kit/console");
7
-
8
- describe("assembleAarBundle", () => {
9
- const fs = require("fs");
10
- const fsx = require("fs-extra");
11
-
12
- const consoleWarnSpy = jest.spyOn(global.console, "warn");
13
- const spawnSyncSpy = jest.spyOn(require("child_process"), "spawnSync");
14
-
15
- const options = {
16
- platform: "android" as const,
17
- assetsDest: "dist",
18
- bundleAar: true,
19
- };
20
-
21
- const context = {
22
- projectRoot: path.resolve(__dirname, "..", ".."),
23
- manifest: {
24
- name: "@rnx-kit/cli",
25
- version: "0.0.0-dev",
26
- },
27
- options,
28
- };
29
-
30
- const dummyManifest = JSON.stringify({ version: "0.0.0-dev" });
31
-
32
- function findFiles() {
33
- return Object.entries(fsx.__toJSON());
34
- }
35
-
36
- function mockFiles(files: Record<string, string> = {}) {
37
- fs.__setMockFiles(files);
38
- fsx.__setMockFiles(files);
39
- }
40
-
41
- afterEach(() => {
42
- mockFiles();
43
- consoleWarnSpy.mockReset();
44
- });
45
-
46
- afterAll(() => {
47
- jest.resetAllMocks();
48
- });
49
-
50
- test("returns early if there is nothing to assemble", async () => {
51
- mockFiles({
52
- gradlew: "",
53
- "gradlew.bat": "",
54
- });
55
-
56
- await assembleAarBundle(context, context.manifest.name, {});
57
-
58
- expect(consoleWarnSpy).not.toHaveBeenCalled();
59
- expect(findFiles()).toEqual([
60
- [expect.stringMatching(/[/\\]gradlew$/), ""],
61
- [expect.stringMatching(/[/\\]gradlew.bat$/), ""],
62
- ]);
63
- });
64
-
65
- test("returns early if Gradle wrapper cannot be found", async () => {
66
- await assembleAarBundle(context, context.manifest.name, { aar: {} });
67
-
68
- expect(consoleWarnSpy).toHaveBeenCalledWith(
69
- expect.anything(),
70
- expect.stringMatching(/cannot find `gradlew(.bat)?`$/)
71
- );
72
- expect(spawnSyncSpy).not.toHaveBeenCalled();
73
- expect(findFiles()).toEqual([]);
74
- });
75
-
76
- test("throws if target package cannot be found", async () => {
77
- mockFiles({
78
- gradlew: "",
79
- "gradlew.bat": "",
80
- });
81
-
82
- expect(
83
- assembleAarBundle(context, context.manifest.name, { aar: {} })
84
- ).rejects.toThrow();
85
- expect(findFiles()).toEqual([
86
- [expect.stringMatching(/[/\\]gradlew$/), ""],
87
- [expect.stringMatching(/[/\\]gradlew.bat$/), ""],
88
- ]);
89
- });
90
-
91
- test("returns early if Gradle project cannot be found", async () => {
92
- mockFiles({
93
- gradlew: "",
94
- "gradlew.bat": "",
95
- "node_modules/@rnx-kit/react-native-auth/package.json": dummyManifest,
96
- });
97
-
98
- await assembleAarBundle(context, "@rnx-kit/react-native-auth", { aar: {} });
99
-
100
- expect(consoleWarnSpy).toHaveBeenCalledWith(
101
- expect.anything(),
102
- expect.stringMatching(/cannot find `build.gradle`/)
103
- );
104
- expect(spawnSyncSpy).not.toHaveBeenCalled();
105
- expect(findFiles()).toEqual([
106
- [expect.stringMatching(/[/\\]gradlew$/), ""],
107
- [expect.stringMatching(/[/\\]gradlew.bat$/), ""],
108
- [
109
- expect.stringMatching(
110
- /[/\\]node_modules[/\\]@rnx-kit[/\\]react-native-auth[/\\]package.json$/
111
- ),
112
- dummyManifest,
113
- ],
114
- ]);
115
- });
116
-
117
- test("generates Android project if necessary", async () => {
118
- mockFiles({
119
- gradlew: "",
120
- "gradlew.bat": "",
121
- "node_modules/@rnx-kit/react-native-auth/android/build.gradle":
122
- "build.gradle",
123
- "node_modules/@rnx-kit/react-native-auth/android/build/outputs/aar/rnx-kit_react-native-auth-release.aar":
124
- "rnx-kit_react-native-auth-release.aar",
125
- "node_modules/@rnx-kit/react-native-auth/package.json": dummyManifest,
126
- "node_modules/react-native/package.json": dummyManifest,
127
- });
128
-
129
- await assembleAarBundle(context, "@rnx-kit/react-native-auth", { aar: {} });
130
-
131
- expect(consoleWarnSpy).not.toHaveBeenCalled();
132
- expect(spawnSyncSpy).toHaveBeenCalledWith(
133
- expect.stringMatching(/[/\\]gradlew(?:\.bat)?$/),
134
- [":rnx-kit_react-native-auth:assembleRelease"],
135
- expect.objectContaining({
136
- cwd: expect.stringMatching(
137
- /[/\\]node_modules[/\\].rnx-gradle-build[/\\]rnx-kit_react-native-auth$/
138
- ),
139
- })
140
- );
141
- expect(findFiles()).toEqual([
142
- [expect.stringMatching(/[/\\]gradlew$/), ""],
143
- [expect.stringMatching(/[/\\]gradlew.bat$/), ""],
144
- [
145
- expect.stringMatching(
146
- /[/\\]node_modules[/\\]@rnx-kit[/\\]react-native-auth[/\\]android[/\\]build.gradle$/
147
- ),
148
- "build.gradle",
149
- ],
150
- [
151
- expect.stringMatching(
152
- /[/\\]node_modules[/\\]@rnx-kit[/\\]react-native-auth[/\\]android[/\\]build[/\\]outputs[/\\]aar[/\\]rnx-kit_react-native-auth-release.aar$/
153
- ),
154
- "rnx-kit_react-native-auth-release.aar",
155
- ],
156
- [
157
- expect.stringMatching(
158
- /[/\\]node_modules[/\\]@rnx-kit[/\\]react-native-auth[/\\]package.json$/
159
- ),
160
- dummyManifest,
161
- ],
162
- [
163
- expect.stringMatching(
164
- /[/\\]node_modules[/\\]react-native[/\\]package.json$/
165
- ),
166
- dummyManifest,
167
- ],
168
- [
169
- expect.stringMatching(
170
- /[/\\]node_modules[/\\].rnx-gradle-build[/\\]rnx-kit_react-native-auth[/\\]build.gradle$/
171
- ),
172
- expect.stringMatching(/^buildscript/),
173
- ],
174
- [
175
- expect.stringMatching(
176
- /[/\\]node_modules[/\\].rnx-gradle-build[/\\]rnx-kit_react-native-auth[/\\]gradle.properties/
177
- ),
178
- expect.stringMatching(/^android.useAndroidX=true/),
179
- ],
180
- [
181
- expect.stringMatching(
182
- /[/\\]node_modules[/\\].rnx-gradle-build[/\\]rnx-kit_react-native-auth[/\\]settings.gradle$/
183
- ),
184
- expect.stringMatching(
185
- /include\(":rnx-kit_react-native-auth"\)\nproject\(":rnx-kit_react-native-auth"\).projectDir = file\(".*?(\/|\\\\)node_modules(\/|\\\\)@rnx-kit(\/|\\\\)react-native-auth(\/|\\\\)android"\)/
186
- ),
187
- ],
188
- [
189
- expect.stringMatching(
190
- /[/\\]dist[/\\]aar[/\\]rnx-kit_react-native-auth-0.0.0-dev.aar$/
191
- ),
192
- "rnx-kit_react-native-auth-release.aar",
193
- ],
194
- ]);
195
- });
196
-
197
- test("assembles Android archive using existing project", async () => {
198
- mockFiles({
199
- gradlew: "",
200
- "gradlew.bat": "",
201
- "node_modules/@rnx-kit/react-native-auth/android/build.gradle":
202
- "build.gradle",
203
- "node_modules/@rnx-kit/react-native-auth/android/build/outputs/aar/rnx-kit_react-native-auth-release.aar":
204
- "rnx-kit_react-native-auth-release.aar",
205
- "node_modules/@rnx-kit/react-native-auth/android/settings.gradle":
206
- "settings.gradle",
207
- "node_modules/@rnx-kit/react-native-auth/package.json": dummyManifest,
208
- "node_modules/react-native/package.json": dummyManifest,
209
- });
210
-
211
- await assembleAarBundle(context, "@rnx-kit/react-native-auth", { aar: {} });
212
-
213
- expect(consoleWarnSpy).not.toHaveBeenCalled();
214
- expect(spawnSyncSpy).toHaveBeenCalledWith(
215
- expect.stringMatching(/[/\\]gradlew(?:\.bat)?$/),
216
- [":rnx-kit_react-native-auth:assembleRelease"],
217
- expect.objectContaining({
218
- cwd: expect.stringMatching(
219
- /[/\\]node_modules[/\\]@rnx-kit[/\\]react-native-auth[/\\]android$/
220
- ),
221
- })
222
- );
223
- expect(findFiles()).toEqual([
224
- [expect.stringMatching(/[/\\]gradlew$/), ""],
225
- [expect.stringMatching(/[/\\]gradlew.bat$/), ""],
226
- [
227
- expect.stringMatching(
228
- /[/\\]node_modules[/\\]@rnx-kit[/\\]react-native-auth[/\\]android[/\\]build.gradle$/
229
- ),
230
- "build.gradle",
231
- ],
232
- [
233
- expect.stringMatching(
234
- /[/\\]node_modules[/\\]@rnx-kit[/\\]react-native-auth[/\\]android[/\\]build[/\\]outputs[/\\]aar[/\\]rnx-kit_react-native-auth-release.aar$/
235
- ),
236
- "rnx-kit_react-native-auth-release.aar",
237
- ],
238
- [
239
- expect.stringMatching(
240
- /[/\\]node_modules[/\\]@rnx-kit[/\\]react-native-auth[/\\]android[/\\]settings.gradle$/
241
- ),
242
- "settings.gradle",
243
- ],
244
- [
245
- expect.stringMatching(
246
- /[/\\]node_modules[/\\]@rnx-kit[/\\]react-native-auth[/\\]package.json$/
247
- ),
248
- dummyManifest,
249
- ],
250
- [
251
- expect.stringMatching(
252
- /[/\\]node_modules[/\\]react-native[/\\]package.json$/
253
- ),
254
- dummyManifest,
255
- ],
256
- [
257
- expect.stringMatching(
258
- /[/\\]dist[/\\]aar[/\\]rnx-kit_react-native-auth-0.0.0-dev.aar$/
259
- ),
260
- "rnx-kit_react-native-auth-release.aar",
261
- ],
262
- ]);
263
- });
264
-
265
- test("allows the generated Android project to be configured", async () => {
266
- mockFiles({
267
- gradlew: "",
268
- "gradlew.bat": "",
269
- "node_modules/@rnx-kit/react-native-auth/android/build.gradle":
270
- "build.gradle",
271
- "node_modules/@rnx-kit/react-native-auth/android/build/outputs/aar/rnx-kit_react-native-auth-release.aar":
272
- "rnx-kit_react-native-auth-release.aar",
273
- "node_modules/@rnx-kit/react-native-auth/package.json": dummyManifest,
274
- "node_modules/react-native/package.json": dummyManifest,
275
- });
276
-
277
- await assembleAarBundle(context, "@rnx-kit/react-native-auth", {
278
- aar: {
279
- android: {
280
- androidPluginVersion: "7.1.3",
281
- compileSdkVersion: 31,
282
- defaultConfig: {
283
- minSdkVersion: 26,
284
- targetSdkVersion: 30,
285
- },
286
- },
287
- },
288
- });
289
-
290
- expect(consoleWarnSpy).not.toHaveBeenCalled();
291
- expect(spawnSyncSpy).toHaveBeenCalledWith(
292
- expect.stringMatching(/[/\\]gradlew(?:\.bat)?$/),
293
- [":rnx-kit_react-native-auth:assembleRelease"],
294
- expect.objectContaining({
295
- cwd: expect.stringMatching(
296
- /[/\\]node_modules[/\\].rnx-gradle-build[/\\]rnx-kit_react-native-auth$/
297
- ),
298
- })
299
- );
300
- expect(findFiles()).toEqual(
301
- expect.arrayContaining([
302
- [
303
- expect.stringMatching(
304
- /[/\\]node_modules[/\\].rnx-gradle-build[/\\]rnx-kit_react-native-auth[/\\]build.gradle$/
305
- ),
306
- expect.stringMatching(
307
- /compileSdkVersion = 31\s+minSdkVersion = 26\s+targetSdkVersion = 30\s+androidPluginVersion = "7\.1\.3"/
308
- ),
309
- ],
310
- ])
311
- );
312
- });
313
- });
@@ -1,122 +0,0 @@
1
- import * as path from "path";
2
- import { copyAssets, gatherConfigs, versionOf } from "../../src/copy-assets";
3
-
4
- const options = {
5
- platform: "ios" as const,
6
- assetsDest: "dist",
7
- bundleAar: false,
8
- xcassetsDest: "xcassets",
9
- };
10
-
11
- const context = {
12
- projectRoot: path.resolve(__dirname, "..", ".."),
13
- manifest: {
14
- name: "@rnx-kit/cli",
15
- version: "0.0.0-dev",
16
- },
17
- options,
18
- };
19
-
20
- describe("copyAssets", () => {
21
- const fs = require("fs-extra");
22
-
23
- function findFiles() {
24
- return Object.entries(fs.__toJSON());
25
- }
26
-
27
- function mockFiles(files: Record<string, string> = {}) {
28
- fs.__setMockFiles(files);
29
- }
30
-
31
- afterEach(() => {
32
- mockFiles();
33
- });
34
-
35
- afterAll(() => {
36
- jest.clearAllMocks();
37
- });
38
-
39
- test("returns early if there is nothing to copy", async () => {
40
- await copyAssets(context, "test", {});
41
- expect(findFiles()).toEqual([]);
42
- });
43
-
44
- test("copies assets", async () => {
45
- const filename = "arnolds-greatest-movies.md";
46
- const content = "all of them";
47
- mockFiles({ [filename]: content });
48
-
49
- await copyAssets(context, "test", { assets: [filename] });
50
-
51
- expect(findFiles()).toEqual([
52
- [expect.stringContaining(filename), content],
53
- [
54
- expect.stringMatching(
55
- `dist[/\\\\]assets[/\\\\]test[/\\\\]${filename}$`
56
- ),
57
- content,
58
- ],
59
- ]);
60
- });
61
-
62
- test("copies strings", async () => {
63
- const filename = "arnolds-greatest-lines.md";
64
- const content = "all of them";
65
- mockFiles({ [filename]: content });
66
-
67
- await copyAssets(context, "test", { strings: [filename] });
68
-
69
- expect(findFiles()).toEqual([
70
- [expect.stringContaining(filename), content],
71
- [
72
- expect.stringMatching(
73
- `dist[/\\\\]strings[/\\\\]test[/\\\\]${filename}$`
74
- ),
75
- content,
76
- ],
77
- ]);
78
- });
79
-
80
- test("copies Xcode asset catalogs", async () => {
81
- const filename = "arnolds-greatest-assets.xcassets";
82
- const content = "all of them";
83
- mockFiles({ [filename]: content });
84
-
85
- await copyAssets(context, "test", { xcassets: [filename] });
86
-
87
- expect(findFiles()).toEqual([
88
- [expect.stringContaining(filename), content],
89
- [expect.stringMatching(`xcassets[/\\\\]${filename}$`), content],
90
- ]);
91
- });
92
-
93
- test("does not copy Xcode asset catalogs if destination path is unset", async () => {
94
- const filename = "arnolds-greatest-assets.xcassets";
95
- const content = "all of them";
96
- mockFiles({ [filename]: content });
97
-
98
- await copyAssets(
99
- { ...context, options: { ...options, xcassetsDest: undefined } },
100
- "test",
101
- { xcassets: [filename] }
102
- );
103
-
104
- expect(findFiles()).toEqual([[expect.stringContaining(filename), content]]);
105
- });
106
- });
107
-
108
- describe("gatherConfigs", () => {
109
- test("returns early if there is nothing to copy", async () => {
110
- expect(await gatherConfigs(context)).toBeUndefined();
111
- });
112
- });
113
-
114
- describe("versionOf", () => {
115
- test("returns the version of specified package", () => {
116
- expect(versionOf("@rnx-kit/tools-node")).toMatch(/^\d+[.\d]+$/);
117
- });
118
-
119
- test("throws if package is not installed", () => {
120
- expect(() => versionOf("some-package-that-does-not-exist")).toThrow();
121
- });
122
- });
@@ -1,206 +0,0 @@
1
- import CyclicDependencies from "@rnx-kit/metro-plugin-cyclic-dependencies-detector";
2
- import DuplicateDependencies from "@rnx-kit/metro-plugin-duplicates-checker";
3
- import type { InputConfigT } from "metro-config";
4
- import { customizeMetroConfig } from "../src/metro-config";
5
-
6
- function mockPlugin(moduleName: string) {
7
- const state: { timesCalled: number; options?: Record<string, unknown> } = {
8
- timesCalled: 0,
9
- };
10
-
11
- function PluginMock(options: Record<string, unknown>) {
12
- state.timesCalled = state.timesCalled + 1;
13
- state.options = options;
14
- return () => ({});
15
- }
16
-
17
- const Plugin = jest.requireActual(moduleName);
18
- PluginMock.type = Plugin.default.type;
19
- PluginMock.__context = state;
20
- PluginMock.mockClear = () => {
21
- state.timesCalled = 0;
22
- state.options = undefined;
23
- };
24
-
25
- return PluginMock;
26
- }
27
-
28
- jest.mock("@rnx-kit/metro-plugin-cyclic-dependencies-detector", () => {
29
- return mockPlugin("@rnx-kit/metro-plugin-cyclic-dependencies-detector");
30
- });
31
-
32
- jest.mock("@rnx-kit/metro-plugin-duplicates-checker", () => {
33
- return mockPlugin("@rnx-kit/metro-plugin-duplicates-checker");
34
- });
35
-
36
- // Always use a new mock since `customizeMetroConfig()` modifies the object.
37
- function makeMockConfig(): InputConfigT {
38
- return {
39
- serializer: {
40
- customSerializer: false,
41
- experimentalSerializerHook: false,
42
- },
43
- transformer: {},
44
- } as unknown as InputConfigT;
45
- }
46
-
47
- function toMock(module: unknown): ReturnType<typeof mockPlugin> {
48
- return module as ReturnType<typeof mockPlugin>;
49
- }
50
-
51
- describe("cli/metro-config/customizeMetroConfig", () => {
52
- afterEach(() => {
53
- toMock(CyclicDependencies).mockClear();
54
- toMock(DuplicateDependencies).mockClear();
55
- });
56
-
57
- test("returns a config with plugins by default", () => {
58
- const inputConfig = makeMockConfig();
59
- customizeMetroConfig(inputConfig, {});
60
-
61
- expect(inputConfig).toEqual({
62
- serializer: {
63
- customSerializer: expect.anything(),
64
- experimentalSerializerHook: expect.anything(),
65
- },
66
- transformer: {},
67
- });
68
- expect(typeof inputConfig.serializer.customSerializer).toBe("function");
69
- expect(typeof inputConfig.serializer.experimentalSerializerHook).toBe(
70
- "function"
71
- );
72
- expect(toMock(CyclicDependencies).__context).toEqual({ timesCalled: 1 });
73
- expect(toMock(DuplicateDependencies).__context).toEqual({ timesCalled: 1 });
74
- });
75
-
76
- test("returns a config without a custom serializer when there are no plugins", () => {
77
- const inputConfig = makeMockConfig();
78
- customizeMetroConfig(inputConfig, {
79
- plugins: ["@rnx-kit/metro-plugin-typescript"],
80
- });
81
-
82
- expect(inputConfig).toEqual({
83
- serializer: {
84
- experimentalSerializerHook: expect.anything(),
85
- },
86
- transformer: {},
87
- });
88
- expect(inputConfig.serializer.customSerializer).toBeUndefined();
89
- expect(typeof inputConfig.serializer.experimentalSerializerHook).toBe(
90
- "function"
91
- );
92
- expect(toMock(CyclicDependencies).__context).toEqual({ timesCalled: 0 });
93
- expect(toMock(DuplicateDependencies).__context).toEqual({ timesCalled: 0 });
94
- });
95
-
96
- test("returns a config with only duplicates plugin", () => {
97
- const inputConfig = makeMockConfig();
98
- customizeMetroConfig(inputConfig, {
99
- plugins: [
100
- "@rnx-kit/metro-plugin-duplicates-checker",
101
- "@rnx-kit/metro-plugin-typescript",
102
- ],
103
- });
104
-
105
- expect(inputConfig).toEqual({
106
- serializer: {
107
- customSerializer: expect.anything(),
108
- experimentalSerializerHook: expect.anything(),
109
- },
110
- transformer: {},
111
- });
112
- expect(typeof inputConfig.serializer.customSerializer).toBe("function");
113
- expect(typeof inputConfig.serializer.experimentalSerializerHook).toBe(
114
- "function"
115
- );
116
- expect(toMock(CyclicDependencies).__context).toEqual({ timesCalled: 0 });
117
- expect(toMock(DuplicateDependencies).__context).toEqual({ timesCalled: 1 });
118
- });
119
-
120
- test("returns a config with only cyclic dependencies plugin", () => {
121
- const inputConfig = makeMockConfig();
122
- customizeMetroConfig(inputConfig, {
123
- plugins: [
124
- "@rnx-kit/metro-plugin-cyclic-dependencies-detector",
125
- "@rnx-kit/metro-plugin-typescript",
126
- ],
127
- });
128
-
129
- expect(inputConfig).toEqual({
130
- serializer: {
131
- customSerializer: expect.anything(),
132
- experimentalSerializerHook: expect.anything(),
133
- },
134
- transformer: {},
135
- });
136
- expect(typeof inputConfig.serializer.customSerializer).toBe("function");
137
- expect(typeof inputConfig.serializer.experimentalSerializerHook).toBe(
138
- "function"
139
- );
140
- expect(toMock(CyclicDependencies).__context).toEqual({ timesCalled: 1 });
141
- expect(toMock(DuplicateDependencies).__context).toEqual({ timesCalled: 0 });
142
- });
143
-
144
- test("forwards plugin options", () => {
145
- const inputConfig = makeMockConfig();
146
- const cyclicDependenciesOptions = { cyclicDependencies: true };
147
- const duplicateDependencesOptions = { duplicateDependencies: true };
148
- customizeMetroConfig(inputConfig, {
149
- plugins: [
150
- [
151
- "@rnx-kit/metro-plugin-cyclic-dependencies-detector",
152
- cyclicDependenciesOptions,
153
- ],
154
- [
155
- "@rnx-kit/metro-plugin-duplicates-checker",
156
- duplicateDependencesOptions,
157
- ],
158
- "@rnx-kit/metro-plugin-typescript",
159
- ],
160
- });
161
-
162
- expect(inputConfig).toEqual({
163
- serializer: {
164
- customSerializer: expect.anything(),
165
- experimentalSerializerHook: expect.anything(),
166
- },
167
- transformer: {},
168
- });
169
- expect(typeof inputConfig.serializer.customSerializer).toBe("function");
170
- expect(typeof inputConfig.serializer.experimentalSerializerHook).toBe(
171
- "function"
172
- );
173
- expect(toMock(CyclicDependencies).__context).toEqual({
174
- timesCalled: 1,
175
- options: cyclicDependenciesOptions,
176
- });
177
- expect(toMock(DuplicateDependencies).__context).toEqual({
178
- timesCalled: 1,
179
- options: duplicateDependencesOptions,
180
- });
181
- });
182
-
183
- test("returns a config with a custom serializer when tree shaking is enabled", () => {
184
- const inputConfig = makeMockConfig();
185
- customizeMetroConfig(inputConfig, {
186
- treeShake: true,
187
- plugins: ["@rnx-kit/metro-plugin-typescript"],
188
- });
189
-
190
- expect(inputConfig).toEqual({
191
- serializer: {
192
- customSerializer: expect.anything(),
193
- experimentalSerializerHook: expect.anything(),
194
- },
195
- transformer: expect.objectContaining({
196
- minifierPath: expect.stringContaining("metro-serializer-esbuild"),
197
- }),
198
- });
199
- expect(typeof inputConfig.serializer.customSerializer).toBe("function");
200
- expect(typeof inputConfig.serializer.experimentalSerializerHook).toBe(
201
- "function"
202
- );
203
- expect(toMock(CyclicDependencies).__context).toEqual({ timesCalled: 0 });
204
- expect(toMock(DuplicateDependencies).__context).toEqual({ timesCalled: 0 });
205
- });
206
- });
package/test/test.test.ts DELETED
@@ -1,11 +0,0 @@
1
- import { jestOptions } from "../src/test";
2
-
3
- describe("rnx-test", () => {
4
- test("retrieves options from 'jest-cli'", () => {
5
- const options = jestOptions();
6
- expect(options.length).toBeGreaterThan(1);
7
-
8
- const updateSnapshot = options.find(({ name }) => name.startsWith("-u,"));
9
- expect(updateSnapshot).toBeDefined();
10
- });
11
- });
package/tsconfig.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "@rnx-kit/scripts/tsconfig-shared.json",
3
- "include": ["src"]
4
- }