expo 58.0.0 → 58.0.2

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 (41) hide show
  1. package/android/build.gradle +2 -2
  2. package/android/proguard-rules.pro +4 -0
  3. package/android/src/main/java/expo/modules/fetch/NativeResponse.kt +5 -1
  4. package/android/src/main/java/expo/modules/fetch/OkHttpFileUrlInterceptor.kt +5 -1
  5. package/build/winter/runtime.native.js +0 -2
  6. package/build/winter/runtime.native.js.map +1 -1
  7. package/bundledNativeModules.json +76 -76
  8. package/ios/Expo/ExpoReactNativeFactory.swift +2 -2
  9. package/ios/ExpoObjC/AppDelegates/EXReactRootViewFactory.mm +16 -2
  10. package/ios/ExpoObjC/include/Expo/EXReactRootViewFactory.h +2 -1
  11. package/package.json +13 -13
  12. package/scripts/spm/README.md +0 -3
  13. package/scripts/spm/__tests__/app-target.test.js +105 -1
  14. package/scripts/spm/__tests__/autolink-gate.test.js +188 -0
  15. package/scripts/spm/__tests__/classify.test.js +17 -19
  16. package/scripts/spm/__tests__/cli.test.js +57 -1
  17. package/scripts/spm/__tests__/diagnostics.test.js +806 -183
  18. package/scripts/spm/__tests__/flavored-frameworks.test.js +9 -0
  19. package/scripts/spm/__tests__/helpers.js +88 -0
  20. package/scripts/spm/__tests__/manifests.test.js +1330 -104
  21. package/scripts/spm/__tests__/metadata.test.js +120 -0
  22. package/scripts/spm/__tests__/plugin.test.js +3304 -111
  23. package/scripts/spm/__tests__/podspec.test.js +27 -138
  24. package/scripts/spm/__tests__/spm-dependencies.test.js +344 -0
  25. package/scripts/spm/app-target.js +42 -1
  26. package/scripts/spm/autolink-gate.js +40 -0
  27. package/scripts/spm/classify.js +78 -79
  28. package/scripts/spm/cli.js +23 -9
  29. package/scripts/spm/diagnostics.js +605 -192
  30. package/scripts/spm/flavored-frameworks.js +231 -64
  31. package/scripts/spm/manifests.js +565 -196
  32. package/scripts/spm/metadata.js +152 -0
  33. package/scripts/spm/plugin.js +679 -205
  34. package/scripts/spm/podspec.js +57 -170
  35. package/src/winter/runtime.native.ts +0 -2
  36. package/template.tgz +0 -0
  37. package/build/winter/AbortSignal.d.ts +0 -3
  38. package/build/winter/AbortSignal.js +0 -96
  39. package/build/winter/AbortSignal.js.map +0 -1
  40. package/src/winter/AbortSignal.ts +0 -132
  41. package/src/winter/__tests__/AbortSignal.test.native.ts +0 -163
@@ -8,25 +8,23 @@ const {
8
8
  UnsupportedModulesError,
9
9
  UNMAPPED_POD_ALLOWLIST,
10
10
  classifyUnsupported,
11
- podspecDependencies,
12
11
  unmappedPodDependencies,
13
12
  renderUnsupportedReport,
14
13
  reportUnsupported,
15
14
  renderUnmappedDependencyWarning,
16
- spmConfigProduct,
15
+ renderLeftOutCompanionWarning,
16
+ collectDuplicatePods,
17
+ collectRootConflicts,
18
+ renderRootConflictWarning,
19
+ renderPartlyProvidedPackageWarning,
20
+ renderExtraPodsWarning,
17
21
  } = require('../diagnostics');
22
+ const { resolvePodIdentities, uncoveredPod } = require('../plugin');
23
+ const { podspecDependencies } = require('../podspec');
18
24
 
19
- function withModuleDir(files, run) {
20
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'expo-spm-diag-'));
21
- try {
22
- for (const [name, contents] of Object.entries(files)) {
23
- fs.writeFileSync(path.join(dir, name), contents);
24
- }
25
- return run(dir);
26
- } finally {
27
- fs.rmSync(dir, { recursive: true, force: true });
28
- }
29
- }
25
+ /** An uncovered pod, from the facts the plugin gathers and the refusal pass 2 recorded. */
26
+ const pendingPod = ({ hasSources = true, prebuildProduct = null, refusal = null, ...subject }) =>
27
+ uncoveredPod({ ...subject, prebuildProduct, sources: { hasSources } }, refusal);
30
28
 
31
29
  describe('classifyUnsupported', () => {
32
30
  it('reports a missing interface tree once, not per module', () => {
@@ -43,13 +41,12 @@ describe('classifyUnsupported', () => {
43
41
  it('classifies a mixed-language module with no checked-in manifest', () => {
44
42
  const [entry] = classifyUnsupported({
45
43
  pending: [
46
- {
44
+ pendingPod({
47
45
  podName: 'ExpoAudio',
48
46
  packageName: 'expo-audio',
49
47
  moduleRoot: '/m/expo-audio',
50
- pureSwift: false,
51
48
  hasSources: true,
52
- },
49
+ }),
53
50
  ],
54
51
  coreAvailable: true,
55
52
  });
@@ -59,14 +56,13 @@ describe('classifyUnsupported', () => {
59
56
  it('prefers the prebuild route when the module declares a prebuildable product', () => {
60
57
  const [entry] = classifyUnsupported({
61
58
  pending: [
62
- {
59
+ pendingPod({
63
60
  podName: 'ExpoAudio',
64
61
  packageName: 'expo-audio',
65
62
  moduleRoot: '/m/expo-audio',
66
- pureSwift: false,
67
63
  hasSources: true,
68
64
  prebuildProduct: { name: 'ExpoAudio', sourceOnly: false },
69
- },
65
+ }),
70
66
  ],
71
67
  coreAvailable: true,
72
68
  });
@@ -76,14 +72,13 @@ describe('classifyUnsupported', () => {
76
72
  it('does not offer the prebuild route for a source-only product', () => {
77
73
  const [entry] = classifyUnsupported({
78
74
  pending: [
79
- {
75
+ pendingPod({
80
76
  podName: 'ExpoModulesWorkletsAdapter',
81
77
  packageName: 'expo-modules-core',
82
78
  moduleRoot: '/m/expo-modules-core',
83
- pureSwift: false,
84
79
  hasSources: true,
85
80
  prebuildProduct: { name: 'ExpoModulesWorkletsAdapter', sourceOnly: true },
86
- },
81
+ }),
87
82
  ],
88
83
  coreAvailable: true,
89
84
  });
@@ -93,13 +88,12 @@ describe('classifyUnsupported', () => {
93
88
  it('classifies a module whose apple sources could not be located', () => {
94
89
  const [entry] = classifyUnsupported({
95
90
  pending: [
96
- {
91
+ pendingPod({
97
92
  podName: 'ExpoWeird',
98
93
  packageName: 'expo-weird',
99
94
  moduleRoot: '/m/expo-weird',
100
- pureSwift: true,
101
95
  hasSources: false,
102
- },
96
+ }),
103
97
  ],
104
98
  coreAvailable: true,
105
99
  });
@@ -107,131 +101,24 @@ describe('classifyUnsupported', () => {
107
101
  });
108
102
  });
109
103
 
110
- describe('spmConfigProduct', () => {
111
- const config = JSON.stringify({
112
- products: [
113
- { name: 'ExpoModulesCore', podName: 'ExpoModulesCore' },
114
- { name: 'ExpoModulesWorklets', podName: 'ExpoModulesWorklets' },
115
- {
116
- name: 'ExpoModulesWorkletsAdapter',
117
- podName: 'ExpoModulesWorkletsAdapter',
118
- sourceOnly: true,
119
- },
120
- ],
121
- });
122
-
123
- it('finds the product declaring a pod', () => {
124
- withModuleDir({ 'spm.config.json': config }, (dir) => {
125
- expect(spmConfigProduct(dir, 'ExpoModulesWorklets')).toEqual({
126
- name: 'ExpoModulesWorklets',
127
- sourceOnly: false,
128
- });
129
- });
130
- });
131
-
132
- it('reports a source-only product as such', () => {
133
- withModuleDir({ 'spm.config.json': config }, (dir) => {
134
- expect(spmConfigProduct(dir, 'ExpoModulesWorkletsAdapter')).toEqual({
135
- name: 'ExpoModulesWorkletsAdapter',
136
- sourceOnly: true,
137
- });
138
- });
139
- });
140
-
141
- it('falls back to the product name when podName is absent', () => {
142
- withModuleDir(
143
- { 'spm.config.json': JSON.stringify({ products: [{ name: 'ExpoFoo' }] }) },
144
- (dir) => {
145
- expect(spmConfigProduct(dir, 'ExpoFoo')).toEqual({ name: 'ExpoFoo', sourceOnly: false });
146
- }
147
- );
148
- });
149
-
150
- it('returns null for an undeclared pod, a missing file, and malformed JSON', () => {
151
- withModuleDir({ 'spm.config.json': config }, (dir) => {
152
- expect(spmConfigProduct(dir, 'ExpoAudio')).toBeNull();
153
- });
154
- withModuleDir({}, (dir) => expect(spmConfigProduct(dir, 'ExpoAudio')).toBeNull());
155
- withModuleDir({ 'spm.config.json': '{ not json' }, (dir) =>
156
- expect(spmConfigProduct(dir, 'ExpoAudio')).toBeNull()
157
- );
158
- });
159
- });
160
-
161
- describe('unsupported podspec syntax', () => {
162
- const podspecError = {
163
- file: '/m/expo-bad/ios/ExpoBad.podspec',
164
- line: 12,
165
- snippet: 's.platforms = { :ios => MIN_IOS }',
166
- reason: "`MIN_IOS` where a version literal like '16.4' belongs",
167
- };
168
-
169
- it('classifies a module whose podspec the reader refused', () => {
170
- expect(
171
- classifyUnsupported({
172
- pending: [
173
- {
174
- podName: 'ExpoBad',
175
- packageName: 'expo-bad',
176
- moduleRoot: '/m/expo-bad',
177
- podspecError,
178
- },
179
- ],
180
- coreAvailable: true,
181
- })
182
- ).toEqual([
183
- {
184
- reason: 'unsupported-podspec-syntax',
185
- podName: 'ExpoBad',
186
- packageName: 'expo-bad',
187
- moduleRoot: '/m/expo-bad',
188
- file: podspecError.file,
189
- line: podspecError.line,
190
- snippet: podspecError.snippet,
191
- problem: podspecError.reason,
192
- },
193
- ]);
194
- });
195
-
196
- it('reports the file, line and snippet, and how to fix it', () => {
197
- const report = renderUnsupportedReport(
198
- classifyUnsupported({
199
- pending: [
200
- { podName: 'ExpoBad', packageName: 'expo-bad', moduleRoot: '/m/expo-bad', podspecError },
201
- ],
202
- coreAvailable: true,
203
- })
204
- );
205
- expect(report).toContain('error: Expo module "expo-bad" (pod ExpoBad)');
206
- expect(report).toContain('iOS deployment floor');
207
- expect(report).toContain('/m/expo-bad/ios/ExpoBad.podspec:12');
208
- expect(report).toContain('s.platforms = { :ios => MIN_IOS }');
209
- expect(report).toContain("{ :ios => '16.4' }");
210
- expect(report).toContain("s.ios.deployment_target = '16.4'");
211
- expect(report).toContain('platforms: [.iOS("16.4")]');
212
- expect(report).toContain('patch-package expo-bad');
213
- expect(report).not.toContain('linkage');
214
- });
215
- });
216
-
217
104
  describe('diagnostic priority', () => {
218
105
  it('asks for the prebuild first, even when the podspec also needs attention', () => {
219
106
  expect(
220
107
  classifyUnsupported({
221
108
  pending: [
222
- {
109
+ pendingPod({
223
110
  podName: 'ExpoBad',
224
111
  packageName: 'expo-bad',
225
112
  moduleRoot: '/m/expo-bad',
226
113
  hasSources: true,
227
114
  prebuildProduct: { name: 'ExpoBad', sourceOnly: false },
228
- podspecLinkage: {
115
+ refusal: {
116
+ reason: 'needs-manifest-for-linkage',
229
117
  file: '/m/expo-bad/ios/ExpoBad.podspec',
230
118
  line: 19,
231
119
  snippet: "s.frameworks = 'Photos'",
232
120
  },
233
- podspecError: null,
234
- },
121
+ }),
235
122
  ],
236
123
  coreAvailable: true,
237
124
  })
@@ -248,43 +135,31 @@ describe('diagnostic priority', () => {
248
135
  });
249
136
 
250
137
  describe('diagnostic priority order', () => {
251
- const pending = (extra) => ({
252
- podName: 'ExpoBad',
253
- packageName: 'expo-bad',
254
- moduleRoot: '/m/expo-bad',
255
- hasSources: true,
256
- ...extra,
257
- });
258
- const reasonFor = (extra) =>
259
- classifyUnsupported({ pending: [pending(extra)], coreAvailable: true })[0].reason;
260
- const podspecError = {
261
- file: '/m/expo-bad/ios/ExpoBad.podspec',
262
- line: 12,
263
- snippet: 's.platforms = { :ios => MIN_IOS }',
264
- reason: 'a computed floor',
265
- };
138
+ const subject = { podName: 'ExpoBad', packageName: 'expo-bad', moduleRoot: '/m/expo-bad' };
139
+ const reasonFor = (pod) => classifyUnsupported({ pending: [pod], coreAvailable: true })[0].reason;
266
140
  const podspecLinkage = {
141
+ reason: 'needs-manifest-for-linkage',
267
142
  file: '/m/expo-bad/ios/ExpoBad.podspec',
268
143
  line: 19,
269
144
  snippet: "s.frameworks = 'Photos'",
270
145
  };
271
-
272
- it('reports the unreadable floor before the linkage the same podspec declares', () => {
273
- expect(reasonFor({ podspecError, podspecLinkage })).toBe('unsupported-podspec-syntax');
274
- });
146
+ const unresolvedTargets = { reason: 'unresolvable-target-path', targetNames: ['Main'] };
275
147
 
276
148
  it('reports the linkage before targets whose sources it could not find', () => {
277
- expect(reasonFor({ podspecLinkage, unresolvedTargets: ['Main'] })).toBe(
149
+ expect(reasonFor({ ...subject, refusals: [unresolvedTargets, podspecLinkage] })).toBe(
278
150
  'needs-manifest-for-linkage'
279
151
  );
280
152
  });
281
153
 
282
154
  it('asks for the prebuild before reporting targets it could not resolve', () => {
283
155
  expect(
284
- reasonFor({
285
- unresolvedTargets: ['Main'],
286
- prebuildProduct: { name: 'ExpoBad', sourceOnly: false },
287
- })
156
+ reasonFor(
157
+ pendingPod({
158
+ ...subject,
159
+ refusal: unresolvedTargets,
160
+ prebuildProduct: { name: 'ExpoBad', sourceOnly: false },
161
+ })
162
+ )
288
163
  ).toBe('prebuild-available');
289
164
  });
290
165
  });
@@ -298,7 +173,12 @@ describe('linkage declared in a podspec', () => {
298
173
  const entries = () =>
299
174
  classifyUnsupported({
300
175
  pending: [
301
- { podName: 'ExpoBad', packageName: 'expo-bad', moduleRoot: '/m/expo-bad', podspecLinkage },
176
+ pendingPod({
177
+ podName: 'ExpoBad',
178
+ packageName: 'expo-bad',
179
+ moduleRoot: '/m/expo-bad',
180
+ refusal: { reason: 'needs-manifest-for-linkage', ...podspecLinkage },
181
+ }),
302
182
  ],
303
183
  coreAvailable: true,
304
184
  });
@@ -377,6 +257,15 @@ describe('unmappedPodDependencies', () => {
377
257
  expect(UNMAPPED_POD_ALLOWLIST.has('sqlite3')).toBe(true);
378
258
  expect(unmappedPodDependencies(['sqlite3', 'SDWebImage'])).toEqual(['SDWebImage']);
379
259
  });
260
+
261
+ it('drops a dependency whose full name or root name is a resolved SwiftPM dependency', () => {
262
+ expect(
263
+ unmappedPodDependencies(
264
+ ['SDWebImage', 'libavif', 'libavif/libdav1d', 'ZXingObjC/OneD'],
265
+ new Set(['SDWebImage', 'libavif'])
266
+ )
267
+ ).toEqual(['ZXingObjC/OneD']);
268
+ });
380
269
  });
381
270
 
382
271
  describe('renderUnsupportedReport', () => {
@@ -477,6 +366,112 @@ describe('renderUnsupportedReport', () => {
477
366
  expect(text).toContain('expo-weird');
478
367
  expect(text).toMatch(/ios|apple/);
479
368
  });
369
+
370
+ describe('a gated companion product its module would leave out', () => {
371
+ const companion = (autolinkWhen) =>
372
+ renderUnsupportedReport([
373
+ {
374
+ reason: 'unchecked-autolink-condition',
375
+ podName: 'ExpoCameraBarcodeScanning',
376
+ productName: 'ExpoCameraBarcodeScanning',
377
+ packageName: 'expo-camera',
378
+ moduleRoot: '/m/expo-camera',
379
+ precompiled: true,
380
+ linkedThrough: 'ExpoCamera',
381
+ autolinkWhen,
382
+ },
383
+ ]);
384
+
385
+ const scannerProperty = 'expo.camera.barcode-scanner-enabled';
386
+ const gates = {
387
+ podfileProperty: {
388
+ gate: 'a Podfile property',
389
+ autolinkWhen: { podfileProperty: scannerProperty, disabledValue: 'false' },
390
+ because: `the Podfile property "${scannerProperty}" is not "false"`,
391
+ turnOff: `set "${scannerProperty}" to "false" in ios/Podfile.properties.json`,
392
+ },
393
+ podfilePropertyWithoutValue: {
394
+ gate: 'a Podfile property with no disabled value',
395
+ autolinkWhen: { podfileProperty: scannerProperty },
396
+ because: `the Podfile property "${scannerProperty}" is set`,
397
+ turnOff: `remove "${scannerProperty}" from ios/Podfile.properties.json`,
398
+ },
399
+ };
400
+
401
+ it.each(Object.values(gates))(
402
+ 'says why CocoaPods links it and where to report it, for $gate',
403
+ ({ autolinkWhen, because }) => {
404
+ const text = companion(autolinkWhen);
405
+
406
+ expect(text).toContain(`CocoaPods links "ExpoCameraBarcodeScanning" because ${because}.`);
407
+ expect(text).toContain('Swift Package Manager cannot link "ExpoCameraBarcodeScanning" yet');
408
+ expect(text).toContain('https://github.com/expo/expo/issues');
409
+ expect(text).not.toContain('Package.swift');
410
+ }
411
+ );
412
+
413
+ // `npx expo prebuild` rewrites Podfile.properties.json from config plugins.
414
+ it.each(Object.values(gates))(
415
+ 'tells the app how to turn it off, by hand or through prebuild, for $gate',
416
+ ({ autolinkWhen, turnOff }) => {
417
+ expect(companion(autolinkWhen)).toContain(
418
+ `If the app does not need "ExpoCameraBarcodeScanning", ${turnOff}. If ios/ is generated by npx expo prebuild, set the matching option in the module's config plugin instead.`
419
+ );
420
+ }
421
+ );
422
+ });
423
+
424
+ describe('a gated companion product its checked-in manifest does not export', () => {
425
+ const scannerGate = {
426
+ podfileProperty: 'expo.camera.barcode-scanner-enabled',
427
+ disabledValue: 'false',
428
+ };
429
+ const render = (autolinkWhen = scannerGate) =>
430
+ renderUnsupportedReport([
431
+ {
432
+ reason: 'companion-not-exported-by-manifest',
433
+ podName: 'ExpoCameraBarcodeScanning',
434
+ productName: 'ExpoCameraBarcodeScanning',
435
+ packageName: 'expo-camera',
436
+ moduleRoot: '/m/expo-camera',
437
+ autolinkWhen,
438
+ },
439
+ ]);
440
+
441
+ it('says which product the manifest leaves out, and why its condition is met', () => {
442
+ expect(render()).toContain(
443
+ 'error: Expo module "expo-camera" does not export its companion product "ExpoCameraBarcodeScanning" in its Package.swift, although the product\'s autolinkWhen condition is met: the Podfile property "expo.camera.barcode-scanner-enabled" is not "false".'
444
+ );
445
+ });
446
+
447
+ it('says the feature would be missing at runtime', () => {
448
+ const text = render();
449
+ expect(text).toContain('CocoaPods links "ExpoCameraBarcodeScanning" for this app');
450
+ expect(text).toContain('missing at runtime');
451
+ });
452
+
453
+ it('tells the module to export the product, not the app to remove a pod', () => {
454
+ const text = render();
455
+ expect(text).toContain(
456
+ 'Add a `.library(name: "ExpoCameraBarcodeScanning", …)` product to /m/expo-camera/Package.swift'
457
+ );
458
+ expect(text).not.toContain('remove the pod');
459
+ });
460
+
461
+ it('tells the app how to turn it off, for a Podfile property gate', () => {
462
+ expect(render()).toContain(
463
+ 'If the app does not need "ExpoCameraBarcodeScanning", set "expo.camera.barcode-scanner-enabled" to "false" in ios/Podfile.properties.json. If ios/ is generated by npx expo prebuild, set the matching option in the module\'s config plugin instead.'
464
+ );
465
+ });
466
+
467
+ it('offers no switch for a gate the app cannot turn off', () => {
468
+ const text = render({ npmPackage: 'react-native-worklets' });
469
+
470
+ expect(text).toContain('the app depends on react-native-worklets');
471
+ expect(text).not.toContain('If the app does not need');
472
+ expect(text).not.toContain('Podfile.properties.json');
473
+ });
474
+ });
480
475
  });
481
476
 
482
477
  describe('renderUnmappedDependencyWarning', () => {
@@ -499,6 +494,74 @@ describe('renderUnmappedDependencyWarning', () => {
499
494
  });
500
495
  });
501
496
 
497
+ describe('renderLeftOutCompanionWarning', () => {
498
+ const adapter = (autolinkWhen, precompiled = true) => ({
499
+ podName: 'ExpoModulesWorkletsAdapter',
500
+ productName: 'ExpoModulesWorkletsAdapter',
501
+ packageName: 'expo-modules-core',
502
+ moduleRoot: '/m/expo-modules-core',
503
+ precompiled,
504
+ linkedThrough: 'ExpoModulesCore',
505
+ autolinkWhen,
506
+ });
507
+
508
+ it.each([
509
+ {
510
+ gate: 'a pod',
511
+ autolinkWhen: { podName: 'RNWorklets' },
512
+ because: 'the app has the RNWorklets pod',
513
+ },
514
+ {
515
+ gate: 'an npm package',
516
+ autolinkWhen: { npmPackage: 'react-native-worklets' },
517
+ because: 'the app depends on react-native-worklets',
518
+ },
519
+ ])(
520
+ 'says which product is left out although CocoaPods links it, for $gate',
521
+ ({ autolinkWhen, because }) => {
522
+ const text = renderLeftOutCompanionWarning([adapter(autolinkWhen)]);
523
+
524
+ expect(text).toContain(
525
+ 'warning: Expo module "expo-modules-core" links its pod ExpoModulesCore as a precompiled XCFramework, so its product "ExpoModulesWorkletsAdapter" is left out of the app.'
526
+ );
527
+ expect(text).toContain(`CocoaPods links "ExpoModulesWorkletsAdapter" because ${because}.`);
528
+ }
529
+ );
530
+
531
+ it('says the feature is unavailable and how Swift Package Manager would link it', () => {
532
+ const text = renderLeftOutCompanionWarning([adapter({ podName: 'RNWorklets' }, false)]);
533
+
534
+ expect(text).toContain('from source without a checked-in Package.swift');
535
+ expect(text).toContain('unavailable at runtime');
536
+ expect(text).toContain('`.library(name: "ExpoModulesWorkletsAdapter", …)`');
537
+ expect(text).toContain(
538
+ 'Otherwise, if the app needs "ExpoModulesWorkletsAdapter", build the app with CocoaPods.'
539
+ );
540
+ expect(text).not.toContain('until then');
541
+ expect(text).not.toContain('https://github.com/expo/expo/issues');
542
+ expect(text).not.toContain('error: ');
543
+ });
544
+
545
+ it('names every left-out companion', () => {
546
+ const text = renderLeftOutCompanionWarning([
547
+ adapter({ podName: 'RNWorklets' }),
548
+ {
549
+ ...adapter({ npmPackage: 'expo-camera' }),
550
+ podName: 'ExpoCameraBarcodeScanning',
551
+ productName: 'ExpoCameraBarcodeScanning',
552
+ packageName: 'expo-camera',
553
+ },
554
+ ]);
555
+
556
+ expect(text).toContain('"ExpoModulesWorkletsAdapter"');
557
+ expect(text).toContain('"ExpoCameraBarcodeScanning"');
558
+ });
559
+
560
+ it('returns an empty string when nothing is left out', () => {
561
+ expect(renderLeftOutCompanionWarning([])).toBe('');
562
+ });
563
+ });
564
+
502
565
  describe('reportUnsupported', () => {
503
566
  it('returns null and prints nothing when every module is covered', () => {
504
567
  const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
@@ -528,14 +591,14 @@ describe('reportUnsupported', () => {
528
591
 
529
592
  describe('unresolvable target paths', () => {
530
593
  const pending = [
531
- {
594
+ pendingPod({
532
595
  podName: 'ExpoFoo',
533
596
  packageName: 'expo-foo',
534
597
  moduleRoot: '/node_modules/expo-foo',
535
598
  hasSources: true,
536
599
  prebuildProduct: null,
537
- unresolvedTargets: ['Example'],
538
- },
600
+ refusal: { reason: 'unresolvable-target-path', targetNames: ['Example'] },
601
+ }),
539
602
  ];
540
603
 
541
604
  it('classifies a module whose target sources could not be located', () => {
@@ -561,16 +624,16 @@ describe('unresolvable target paths', () => {
561
624
  });
562
625
 
563
626
  describe('dependencies on targets the generated package cannot declare', () => {
564
- const pending = [
565
- {
627
+ const podDependingOn = (dependencies) =>
628
+ pendingPod({
566
629
  podName: 'ExpoFoo',
567
630
  packageName: 'expo-foo',
568
631
  moduleRoot: '/node_modules/expo-foo',
569
632
  hasSources: true,
570
633
  prebuildProduct: null,
571
- unsupportedTargetDeps: [{ target: 'ExpoFoo', dependsOn: 'FooKit', kind: 'binary' }],
572
- },
573
- ];
634
+ refusal: { reason: 'unsupported-target-dependency', dependencies },
635
+ });
636
+ const pending = [podDependingOn([{ target: 'ExpoFoo', dependsOn: 'FooKit', kind: 'binary' }])];
574
637
 
575
638
  it('classifies a module whose manifest depends on a non-regular target', () => {
576
639
  expect(classifyUnsupported({ pending, coreAvailable: true })).toEqual([
@@ -600,13 +663,10 @@ describe('dependencies on targets the generated package cannot declare', () => {
600
663
  const report = renderUnsupportedReport(
601
664
  classifyUnsupported({
602
665
  pending: [
603
- {
604
- ...pending[0],
605
- unsupportedTargetDeps: [
606
- { target: 'ExpoFoo', dependsOn: 'FooSystem', kind: 'systemLibrary' },
607
- { target: 'ExpoFoo', dependsOn: 'FooMystery' },
608
- ],
609
- },
666
+ podDependingOn([
667
+ { target: 'ExpoFoo', dependsOn: 'FooSystem', kind: 'systemLibrary' },
668
+ { target: 'ExpoFoo', dependsOn: 'FooMystery' },
669
+ ]),
610
670
  ],
611
671
  coreAvailable: true,
612
672
  })
@@ -621,13 +681,10 @@ describe('dependencies on targets the generated package cannot declare', () => {
621
681
  const report = renderUnsupportedReport(
622
682
  classifyUnsupported({
623
683
  pending: [
624
- {
625
- ...pending[0],
626
- unsupportedTargetDeps: [
627
- { target: 'ExpoFoo', dependsOn: 'FooKit', kind: 'binary' },
628
- { target: 'ExpoFooObjC', dependsOn: 'FooMacros', kind: 'macro' },
629
- ],
630
- },
684
+ podDependingOn([
685
+ { target: 'ExpoFoo', dependsOn: 'FooKit', kind: 'binary' },
686
+ { target: 'ExpoFooObjC', dependsOn: 'FooMacros', kind: 'macro' },
687
+ ]),
631
688
  ],
632
689
  coreAvailable: true,
633
690
  })
@@ -637,3 +694,569 @@ describe('dependencies on targets the generated package cannot declare', () => {
637
694
  expect(report).toContain('macro target');
638
695
  });
639
696
  });
697
+
698
+ describe('a module installed twice', () => {
699
+ let tmp;
700
+ const dir = (...segments) => {
701
+ const created = path.join(tmp, ...segments);
702
+ fs.mkdirSync(created, { recursive: true });
703
+ return created;
704
+ };
705
+ const conflicts = (documented, autolinked) =>
706
+ collectRootConflicts(
707
+ resolvePodIdentities(
708
+ [{ packageName: 'expo-camera', pods: [{ podName: 'ExpoCamera' }] }],
709
+ new Map([['ExpoCamera', { packageRoot: documented }]]),
710
+ new Map([['expo-camera', autolinked]])
711
+ )
712
+ );
713
+
714
+ beforeAll(() => {
715
+ tmp = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'expo-spm-roots-')));
716
+ });
717
+
718
+ afterEach(() => jest.restoreAllMocks());
719
+
720
+ it('finds no conflict when both roots are the same directory through a symlink', () => {
721
+ const packageRoot = dir('node_modules', 'expo-camera');
722
+ const link = path.join(dir('links'), 'expo-camera');
723
+ fs.symlinkSync(packageRoot, link, 'dir');
724
+
725
+ expect(conflicts(packageRoot, link)).toEqual([]);
726
+ });
727
+
728
+ it('finds a conflict when the two roots are different directories', () => {
729
+ const packageRoot = dir('node_modules', 'expo-camera');
730
+ const autolinkedRoot = dir('node_modules', 'some-lib', 'node_modules', 'expo-camera');
731
+
732
+ expect(conflicts(packageRoot, autolinkedRoot)).toEqual([
733
+ { packageName: 'expo-camera', moduleRoot: packageRoot, autolinkedRoot },
734
+ ]);
735
+ });
736
+
737
+ it('finds no conflict for a documented root that is gone', () => {
738
+ expect(conflicts(path.join(tmp, 'vanished'), dir('node_modules', 'expo-camera'))).toEqual([]);
739
+ });
740
+
741
+ // A path that cannot be resolved cannot be compared, and a diagnostic is never
742
+ // worth failing a sync over.
743
+ it('reports nothing, and does not throw, when a root cannot be resolved', () => {
744
+ const packageRoot = dir('node_modules', 'expo-camera');
745
+ jest.spyOn(fs, 'realpathSync').mockImplementation(() => {
746
+ throw Object.assign(new Error('ENOENT'), { code: 'ENOENT' });
747
+ });
748
+
749
+ expect(conflicts(packageRoot, path.join(tmp, 'elsewhere'))).toEqual([]);
750
+ });
751
+
752
+ // The copies can be different versions, so the mismatch is not confined to runtime.
753
+ it('names both directories, what uses each, both failure modes, and how to deduplicate', () => {
754
+ const report = renderRootConflictWarning([
755
+ {
756
+ packageName: 'expo-camera',
757
+ moduleRoot: '/app/node_modules/expo-camera',
758
+ autolinkedRoot: '/app/node_modules/some-lib/node_modules/expo-camera',
759
+ },
760
+ ]);
761
+ expect(report).toMatch(/^warning: Expo module "expo-camera"/);
762
+ expect(report).toContain('/app/node_modules/expo-camera');
763
+ expect(report).toContain('/app/node_modules/some-lib/node_modules/expo-camera');
764
+ expect(report).toContain('npm ls expo-camera');
765
+ expect(report).toContain('dedupe');
766
+ expect(report).toContain("your app's JavaScript imports the second");
767
+ expect(report).toContain('usually surfaces at runtime');
768
+ expect(report).toContain('can fail the build');
769
+ });
770
+
771
+ it('renders nothing when no module is installed twice', () => {
772
+ expect(renderRootConflictWarning([])).toBe('');
773
+ });
774
+ });
775
+
776
+ describe('a package kept for more than the products a precompiled framework provides', () => {
777
+ it('names the package, both sets of products, why that can duplicate one, and the fixes', () => {
778
+ const report = renderPartlyProvidedPackageWarning([
779
+ {
780
+ packageName: 'expo-maps-extra',
781
+ moduleRoot: '/app/node_modules/expo-maps-extra',
782
+ url: 'https://github.com/SDWebImage/SDWebImage.git',
783
+ providedProducts: ['SDWebImage'],
784
+ keptProducts: ['SDWebImageMapKit'],
785
+ },
786
+ ]);
787
+ expect(report).toMatch(
788
+ /^warning: Expo module "expo-maps-extra" still declares https:\/\/github\.com\/SDWebImage\/SDWebImage\.git for "SDWebImageMapKit"/
789
+ );
790
+ expect(report).toContain('"SDWebImage" comes from a precompiled framework');
791
+ expect(report).toContain('second copy');
792
+ expect(report).toContain('stop using "SDWebImageMapKit"');
793
+ expect(report).toContain('from source');
794
+ expect(report).toContain('Module path: /app/node_modules/expo-maps-extra');
795
+ });
796
+
797
+ it('names a product depended on by name without a package, and every package kept', () => {
798
+ const report = renderPartlyProvidedPackageWarning([
799
+ {
800
+ packageName: 'expo-maps-extra',
801
+ moduleRoot: '/app/node_modules/expo-maps-extra',
802
+ providedProducts: ['SDWebImage'],
803
+ keptPackages: ['https://github.com/SDWebImage/libavif-Xcode.git'],
804
+ },
805
+ ]);
806
+ expect(report).toMatch(
807
+ /^warning: Expo module "expo-maps-extra" names "SDWebImage" without a package, and it comes from a precompiled framework\./
808
+ );
809
+ expect(report).toContain(
810
+ 'may still build it from https://github.com/SDWebImage/libavif-Xcode.git, which'
811
+ );
812
+ expect(report).toContain('stop using https://github.com/SDWebImage/libavif-Xcode.git');
813
+ expect(report).toContain('from source');
814
+ expect(report).toContain('Module path: /app/node_modules/expo-maps-extra');
815
+ });
816
+
817
+ it('says "one of" only when more than one package is still declared', () => {
818
+ const report = renderPartlyProvidedPackageWarning([
819
+ {
820
+ packageName: 'expo-maps-extra',
821
+ moduleRoot: '/app/node_modules/expo-maps-extra',
822
+ providedProducts: ['SDWebImage'],
823
+ keptPackages: [
824
+ 'https://github.com/SDWebImage/libavif-Xcode.git',
825
+ 'https://github.com/airbnb/lottie-spm.git',
826
+ ],
827
+ },
828
+ ]);
829
+ expect(report).toContain(
830
+ 'may still build it from one of https://github.com/SDWebImage/libavif-Xcode.git, https://github.com/airbnb/lottie-spm.git, which'
831
+ );
832
+ });
833
+
834
+ // Only the package's own products can be attributed to it.
835
+ it('names a remaining byName dependency as possibly, not certainly, from the package', () => {
836
+ const report = renderPartlyProvidedPackageWarning([
837
+ {
838
+ packageName: 'expo-maps-extra',
839
+ moduleRoot: '/app/node_modules/expo-maps-extra',
840
+ url: 'https://github.com/SDWebImage/SDWebImage.git',
841
+ providedProducts: ['SDWebImage'],
842
+ keptProducts: [],
843
+ unattributedNames: ['Lottie'],
844
+ },
845
+ ]);
846
+ expect(report).toMatch(
847
+ /^warning: Expo module "expo-maps-extra" still declares https:\/\/github\.com\/SDWebImage\/SDWebImage\.git, while "SDWebImage" comes from a precompiled framework\./
848
+ );
849
+ expect(report).not.toContain('for "Lottie"');
850
+ expect(report).not.toContain('for ""');
851
+ expect(report).toContain('names "Lottie" without a package, which may come from it');
852
+ });
853
+
854
+ it('names each product the module uses once, joined as alternatives', () => {
855
+ const report = renderPartlyProvidedPackageWarning([
856
+ {
857
+ packageName: 'expo-maps-extra',
858
+ moduleRoot: '/app/node_modules/expo-maps-extra',
859
+ url: 'https://github.com/SDWebImage/SDWebImage.git',
860
+ providedProducts: ['SDWebImage'],
861
+ keptProducts: ['SDWebImageMapKit'],
862
+ unattributedNames: ['SDWebImageMapKit', 'Lottie'],
863
+ },
864
+ ]);
865
+ expect(report).toContain('If "SDWebImageMapKit" or "Lottie" depends on "SDWebImage"');
866
+ expect(report).toContain('stop using "SDWebImageMapKit" or "Lottie" in "expo-maps-extra"');
867
+ });
868
+
869
+ it('renders nothing when every such package was left out', () => {
870
+ expect(renderPartlyProvidedPackageWarning([])).toBe('');
871
+ });
872
+ });
873
+
874
+ describe('separate copies of one pod name', () => {
875
+ let tmp;
876
+ beforeAll(() => {
877
+ tmp = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'expo-spm-copies-')));
878
+ });
879
+ const dir = (name) => {
880
+ const created = path.join(tmp, name);
881
+ fs.mkdirSync(created, { recursive: true });
882
+ return created;
883
+ };
884
+ const duplicatesIn = (...listings) =>
885
+ collectDuplicatePods(
886
+ new Map(
887
+ listings.map(([packageName, declaringRoot], index) => [
888
+ index,
889
+ { podName: 'ExpoX', packageName, declaringRoot },
890
+ ])
891
+ )
892
+ );
893
+
894
+ // P at r1 and P at r2 are one package; Q at r2 is the directory P at r2 is in.
895
+ // Joined either way, all three are one copy.
896
+ it('is one copy for listings joined through a shared package or directory, in any order', () => {
897
+ const a = ['expo-p', dir('r1')];
898
+ const b = ['expo-q', dir('r2')];
899
+ const c = ['expo-p', dir('r2')];
900
+
901
+ for (const order of [
902
+ [a, b, c],
903
+ [a, c, b],
904
+ [b, a, c],
905
+ [b, c, a],
906
+ [c, a, b],
907
+ [c, b, a],
908
+ ]) {
909
+ expect(duplicatesIn(...order)).toEqual([]);
910
+ }
911
+ });
912
+
913
+ it('shows each copy by its lowest root, in any order', () => {
914
+ const a = ['expo-p', dir('r1')];
915
+ const c = ['expo-p', dir('r2')];
916
+ const d = ['expo-z', dir('r3')];
917
+ const copies = [
918
+ { packageName: 'expo-p', moduleRoot: a[1] },
919
+ { packageName: 'expo-z', moduleRoot: d[1] },
920
+ ];
921
+
922
+ for (const order of [
923
+ [a, c, d],
924
+ [a, d, c],
925
+ [c, a, d],
926
+ [c, d, a],
927
+ [d, a, c],
928
+ [d, c, a],
929
+ ]) {
930
+ expect(duplicatesIn(...order)).toEqual([
931
+ { reason: 'duplicate-pod-name', podName: 'ExpoX', copies },
932
+ ]);
933
+ }
934
+ });
935
+
936
+ it('is one copy for one directory reached through a symlink', () => {
937
+ const link = path.join(tmp, 'alias');
938
+ fs.symlinkSync(dir('shared'), link, 'dir');
939
+
940
+ expect(duplicatesIn(['expo-a', dir('shared')], ['expo-b', link])).toEqual([]);
941
+ });
942
+
943
+ it('keeps two roots that cannot be resolved apart, in any order', () => {
944
+ const a = ['expo-a', path.join(tmp, 'missing-a')];
945
+ const b = ['expo-b', path.join(tmp, 'missing-b')];
946
+ const duplicate = [
947
+ {
948
+ reason: 'duplicate-pod-name',
949
+ podName: 'ExpoX',
950
+ copies: [
951
+ { packageName: a[0], moduleRoot: a[1] },
952
+ { packageName: b[0], moduleRoot: b[1] },
953
+ ],
954
+ },
955
+ ];
956
+
957
+ expect(duplicatesIn(a, b)).toEqual(duplicate);
958
+ expect(duplicatesIn(b, a)).toEqual(duplicate);
959
+ });
960
+
961
+ it('is one copy for one unresolvable root two packages name identically', () => {
962
+ const missing = path.join(tmp, 'missing');
963
+
964
+ expect(duplicatesIn(['expo-a', missing], ['expo-b', missing])).toEqual([]);
965
+ });
966
+
967
+ it('names every copy, why the sync fails, and how to keep one', () => {
968
+ const report = renderUnsupportedReport([
969
+ {
970
+ reason: 'duplicate-pod-name',
971
+ podName: 'ExpoX',
972
+ copies: [
973
+ { packageName: 'expo-x', moduleRoot: '/app/node_modules/expo-x' },
974
+ { packageName: 'expo-x-fork', moduleRoot: '/app/node_modules/expo-x-fork' },
975
+ { packageName: 'expo-x-next', moduleRoot: '/app/node_modules/expo-x-next' },
976
+ ],
977
+ },
978
+ ]);
979
+
980
+ expect(report).toMatch(/^error: The pod ExpoX is declared by 3 different packages/);
981
+ expect(report).toContain('\n "expo-x" at /app/node_modules/expo-x\n');
982
+ expect(report).toContain('\n "expo-x-fork" at /app/node_modules/expo-x-fork\n');
983
+ expect(report).toContain('links a pod name only once');
984
+ expect(report).toContain('"exclude": ["expo-x-fork", "expo-x-next"]');
985
+ });
986
+ });
987
+
988
+ describe('extra CocoaPods dependencies', () => {
989
+ const FIREBASE_GIT = 'https://github.com/firebase/firebase-ios-sdk.git';
990
+ const origins = [
991
+ [
992
+ 'MyLocalPod (local path: ../vendor/MyLocalPod)',
993
+ { name: 'MyLocalPod', path: '../vendor/MyLocalPod' },
994
+ ],
995
+ [`Firebase (git: ${FIREBASE_GIT})`, { name: 'Firebase', git: FIREBASE_GIT }],
996
+ ['AppCenter (published pod)', { name: 'AppCenter' }],
997
+ [
998
+ 'InternalSDK (spec repo: https://specs.example.com/private.git, version 2.1.0)',
999
+ { name: 'InternalSDK', source: 'https://specs.example.com/private.git', version: '2.1.0' },
1000
+ ],
1001
+ ['AppCenter (published pod, version 5.0.0)', { name: 'AppCenter', version: '5.0.0' }],
1002
+ // A git pod's ref is the only thing that says which code it means.
1003
+ [
1004
+ `Firebase (git: ${FIREBASE_GIT}, tag 10.0.0)`,
1005
+ { name: 'Firebase', git: FIREBASE_GIT, tag: '10.0.0' },
1006
+ ],
1007
+ [
1008
+ 'Sentry (git: https://github.com/getsentry/sentry-cocoa.git, branch main)',
1009
+ { name: 'Sentry', git: 'https://github.com/getsentry/sentry-cocoa.git', branch: 'main' },
1010
+ ],
1011
+ [
1012
+ 'Lottie (git: https://github.com/airbnb/lottie-ios.git, commit a1b2c3d)',
1013
+ { name: 'Lottie', git: 'https://github.com/airbnb/lottie-ios.git', commit: 'a1b2c3d' },
1014
+ ],
1015
+ ];
1016
+ const report = renderExtraPodsWarning(origins.map(([, pod]) => pod));
1017
+
1018
+ it.each(origins)('lists %s', (line) => {
1019
+ expect(report).toContain(line);
1020
+ });
1021
+
1022
+ it('says what declared them, how they fail, and what to do instead', () => {
1023
+ expect(report).toMatch(/^warning: /);
1024
+ expect(report).toContain('extraPods');
1025
+ expect(report).toContain('Podfile.properties.json');
1026
+ expect(report).toContain('fails to compile or link');
1027
+ expect(report).toContain('at runtime');
1028
+ expect(report).toContain('keep this app on CocoaPods');
1029
+ });
1030
+
1031
+ it('renders nothing when the app declares none', () => {
1032
+ expect(renderExtraPodsWarning([])).toBe('');
1033
+ });
1034
+ });
1035
+
1036
+ describe('Swift packages the generated package cannot declare', () => {
1037
+ const podDeclaring = (dependencies) =>
1038
+ pendingPod({
1039
+ podName: 'ExpoImage',
1040
+ packageName: 'expo-image',
1041
+ moduleRoot: '/node_modules/expo-image',
1042
+ hasSources: true,
1043
+ prebuildProduct: null,
1044
+ refusal: { reason: 'unsupported-package-dependency', dependencies },
1045
+ });
1046
+ const pending = [podDeclaring([{ form: 'local-path', identity: 'sdwebimage', target: null }])];
1047
+
1048
+ const report = (unsupportedPackageDeps) =>
1049
+ renderUnsupportedReport(
1050
+ classifyUnsupported({
1051
+ pending: [podDeclaring(unsupportedPackageDeps)],
1052
+ coreAvailable: true,
1053
+ })
1054
+ );
1055
+
1056
+ it('classifies a module whose manifest declares a package it cannot mirror', () => {
1057
+ expect(classifyUnsupported({ pending, coreAvailable: true })).toEqual([
1058
+ {
1059
+ reason: 'unsupported-package-dependency',
1060
+ podName: 'ExpoImage',
1061
+ packageName: 'expo-image',
1062
+ moduleRoot: '/node_modules/expo-image',
1063
+ dependencies: [{ form: 'local-path', identity: 'sdwebimage', target: null }],
1064
+ },
1065
+ ]);
1066
+ });
1067
+
1068
+ it('names the package, what is wrong with it, and the next step', () => {
1069
+ const text = renderUnsupportedReport(classifyUnsupported({ pending, coreAvailable: true }));
1070
+ expect(text).toMatch(/^error: Expo module "expo-image" \(pod ExpoImage\)/);
1071
+ expect(text).toContain('"sdwebimage"');
1072
+ expect(text).toContain('local path');
1073
+ expect(text).toContain('npx patch-package expo-image');
1074
+ expect(text).toContain('Module path: /node_modules/expo-image');
1075
+ });
1076
+
1077
+ it('names the target of a product whose package the manifest never declared', () => {
1078
+ const text = report([
1079
+ { form: 'undeclared-package', identity: 'libavif-Xcode', target: 'ExpoImage' },
1080
+ ]);
1081
+ expect(text).toContain('"libavif-Xcode"');
1082
+ expect(text).toContain('target "ExpoImage"');
1083
+ });
1084
+
1085
+ it('describes a product that names no package without printing a placeholder', () => {
1086
+ const text = report([{ form: 'undeclared-package', identity: null, target: 'ExpoImage' }]);
1087
+ expect(text).toContain('target "ExpoImage"');
1088
+ expect(text).not.toContain('null');
1089
+ expect(text).not.toContain('undefined');
1090
+ });
1091
+
1092
+ // One remedy cannot serve every cause: a collision is already declared the way a
1093
+ // local path should be, and an undeclared package needs a declaration ADDED.
1094
+ it('gives each fault its own next step', () => {
1095
+ const step = (form) => report([{ form, identity: 'acme', target: 'Main' }]);
1096
+ expect(step('local-path')).toContain('remote URL');
1097
+ expect(step('undeclared-package')).toContain('Declare that package');
1098
+ expect(step('unsupported-requirement')).toContain(
1099
+ 'an exact version, a branch, a revision or a version range'
1100
+ );
1101
+ expect(step('module-aliases')).toContain('alias');
1102
+ expect(step('unsupported-condition')).toContain('platform');
1103
+ expect(step('collides-with-injected')).toContain('React Native');
1104
+ expect(step('collides-with-injected')).not.toContain('remote URL');
1105
+ });
1106
+
1107
+ it('calls a package a package and a target dependency a dependency', () => {
1108
+ expect(
1109
+ report([{ form: 'unsupported-condition', identity: 'SDWebImage', target: 'Main' }])
1110
+ ).toContain('package "SDWebImage", used by target "Main",');
1111
+ const sibling = report([
1112
+ { form: 'unsupported-target-condition', identity: 'Helper', target: 'Main' },
1113
+ ]);
1114
+ expect(sibling).toContain('the dependency on "Helper" in target "Main"');
1115
+ expect(sibling).not.toContain('package "Helper"');
1116
+ });
1117
+
1118
+ it('names a package claimed twice without calling either one the package', () => {
1119
+ const text = report([{ form: 'ambiguous-package-name', identity: 'libavif', target: null }]);
1120
+ expect(text).toContain('"libavif" is claimed by two');
1121
+ expect(text).toContain('distinct');
1122
+ });
1123
+
1124
+ it('lists every dependency it found, not just the first', () => {
1125
+ const text = report([
1126
+ { form: 'registry', identity: 'acme.widgets', target: null },
1127
+ { form: 'unsupported-requirement', identity: 'futured', target: null },
1128
+ ]);
1129
+ expect(text).toContain('"acme.widgets"');
1130
+ expect(text).toContain('"futured"');
1131
+ });
1132
+
1133
+ it('renders every form as prose, never as the name the parser uses for it', () => {
1134
+ const dependencies = [
1135
+ { form: 'local-path', identity: 'alpha', target: null },
1136
+ { form: 'registry', identity: 'bravo', target: null },
1137
+ { form: 'unsupported-location', identity: 'charlie', target: null },
1138
+ { form: 'unsupported-requirement', identity: 'delta', target: null },
1139
+ { form: 'unknown-form', identity: 'echo', target: null },
1140
+ { form: 'undeclared-package', identity: 'foxtrot', target: 'Main' },
1141
+ { form: 'collides-with-injected', identity: 'golf', target: null },
1142
+ { form: 'module-aliases', identity: 'hotel', target: 'Main' },
1143
+ { form: 'unsupported-condition', identity: 'india', target: 'Main' },
1144
+ { form: 'unsupported-traits', identity: 'juliett', target: null },
1145
+ { form: 'unsupported-target-condition', identity: 'kilo', target: 'Main' },
1146
+ { form: 'ambiguous-package-name', identity: 'lima', target: null },
1147
+ ];
1148
+ const text = report(dependencies);
1149
+ for (const { form, identity } of dependencies) {
1150
+ expect(text).toContain(`"${identity}"`);
1151
+ // "registry" is also the plain English word the prose uses.
1152
+ if (form !== 'registry') expect(text).not.toContain(form);
1153
+ }
1154
+ expect(text).not.toContain('undefined');
1155
+ });
1156
+ });
1157
+
1158
+ describe('a module with only some pods precompiled', () => {
1159
+ const artifactDirs = [
1160
+ '/precompiled/expo-dual/output',
1161
+ '/repo/packages/precompile/.build/expo-dual/output',
1162
+ '/node_modules/expo-dual/prebuilds/output',
1163
+ ];
1164
+ const pending = ({
1165
+ prebuildProduct = null,
1166
+ precompiledSiblings = ['ExpoDual'],
1167
+ precompiledProducts = ['ExpoDual'],
1168
+ } = {}) =>
1169
+ pendingPod({
1170
+ podName: 'ExpoDualExtras',
1171
+ packageName: 'expo-dual',
1172
+ moduleRoot: '/node_modules/expo-dual',
1173
+ hasSources: true,
1174
+ prebuildProduct,
1175
+ refusal: {
1176
+ reason: 'partially-precompiled',
1177
+ precompiledSiblings,
1178
+ precompiledProducts,
1179
+ artifactDirs,
1180
+ prebuildProduct,
1181
+ },
1182
+ });
1183
+ const entries = (extra) =>
1184
+ classifyUnsupported({ pending: [pending(extra)], coreAvailable: true });
1185
+
1186
+ it('classifies the pod that is not precompiled, naming the siblings that are', () => {
1187
+ expect(entries()).toEqual([
1188
+ {
1189
+ reason: 'partially-precompiled',
1190
+ podName: 'ExpoDualExtras',
1191
+ packageName: 'expo-dual',
1192
+ moduleRoot: '/node_modules/expo-dual',
1193
+ precompiledSiblings: ['ExpoDual'],
1194
+ precompiledProducts: ['ExpoDual'],
1195
+ artifactDirs,
1196
+ prebuildProduct: null,
1197
+ },
1198
+ ]);
1199
+ });
1200
+
1201
+ it('reports it before the prebuild route, which would not explain the double link', () => {
1202
+ expect(
1203
+ entries({ prebuildProduct: { name: 'ExpoDualExtras', sourceOnly: false } })[0].reason
1204
+ ).toBe('partially-precompiled');
1205
+ });
1206
+
1207
+ it('names both pods, the double link, and the all-or-none remedies', () => {
1208
+ const report = renderUnsupportedReport(entries());
1209
+ expect(report).toMatch(/^error: Expo module "expo-dual" \(pod ExpoDualExtras\)/);
1210
+ expect(report).toContain('ExpoDual ');
1211
+ expect(report).toContain('twice');
1212
+ expect(report).toContain('et prebuild expo-dual');
1213
+ expect(report).toContain('spm.config.json');
1214
+ expect(report).toContain('"exclude": ["expo-dual"]');
1215
+ expect(report).toContain('Module path: /node_modules/expo-dual');
1216
+ });
1217
+
1218
+ it('lists every precompiled sibling', () => {
1219
+ const report = renderUnsupportedReport(
1220
+ entries({ precompiledSiblings: ['ExpoDual', 'ExpoDualKit'] })
1221
+ );
1222
+ expect(report).toContain('ExpoDual, ExpoDualKit');
1223
+ });
1224
+
1225
+ it('names every directory the artifact resolver searches, in its order, and both artifact forms', () => {
1226
+ const report = renderUnsupportedReport(entries());
1227
+ const positions = artifactDirs.map((dir) => report.indexOf(dir));
1228
+ expect(positions.every((position) => position >= 0)).toBe(true);
1229
+ expect(positions).toEqual([...positions].sort((a, b) => a - b));
1230
+ expect(report).toContain('ExpoDual.xcframework');
1231
+ expect(report).toContain('ExpoDual.tar.gz');
1232
+ expect(report).toContain('debug/xcframeworks');
1233
+ expect(report).toContain('release/xcframeworks');
1234
+ expect(report).toContain("add a product for ExpoDualExtras to expo-dual's spm.config.json");
1235
+ });
1236
+
1237
+ it('names the artifacts after the product a sibling ships, not after its pod', () => {
1238
+ const report = renderUnsupportedReport(
1239
+ entries({ precompiledSiblings: ['RNSkiaPod'], precompiledProducts: ['RNSkia'] })
1240
+ );
1241
+ expect(report).toContain('— RNSkia.xcframework or RNSkia.tar.gz, under');
1242
+ expect(report).not.toContain('RNSkiaPod.xcframework');
1243
+ expect(report).toContain('its sibling pod RNSkiaPod does');
1244
+ });
1245
+
1246
+ it('says so when spm.config.json already declares the pod it asks to build', () => {
1247
+ const report = renderUnsupportedReport(
1248
+ entries({ prebuildProduct: { name: 'ExpoDualExtras', sourceOnly: false } })
1249
+ );
1250
+ expect(report).toContain('already declares "ExpoDualExtras"');
1251
+ expect(report).toContain('et prebuild expo-dual');
1252
+ });
1253
+
1254
+ it('does not promise an XCFramework for a source-only product', () => {
1255
+ const report = renderUnsupportedReport(
1256
+ entries({ prebuildProduct: { name: 'ExpoDualExtras', sourceOnly: true } })
1257
+ );
1258
+ expect(report).toContain('sourceOnly');
1259
+ expect(report).not.toContain('et prebuild');
1260
+ expect(report).toMatch(/^ {2}1\. To build it from source instead/m);
1261
+ });
1262
+ });