expo 58.0.1 → 58.0.3
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/android/build.gradle +2 -2
- package/build/winter/runtime.native.js +0 -2
- package/build/winter/runtime.native.js.map +1 -1
- package/bundledNativeModules.json +77 -77
- package/ios/Expo/ExpoReactNativeFactory.swift +2 -2
- package/ios/ExpoObjC/AppDelegates/EXReactRootViewFactory.mm +16 -2
- package/ios/ExpoObjC/include/Expo/EXReactRootViewFactory.h +2 -1
- package/package.json +17 -18
- package/scripts/spm/__tests__/app-target.test.js +105 -1
- package/scripts/spm/__tests__/autolink-gate.test.js +188 -0
- package/scripts/spm/__tests__/classify.test.js +17 -19
- package/scripts/spm/__tests__/diagnostics.test.js +705 -132
- package/scripts/spm/__tests__/manifests.test.js +1086 -75
- package/scripts/spm/__tests__/metadata.test.js +120 -0
- package/scripts/spm/__tests__/plugin.test.js +2549 -346
- package/scripts/spm/app-target.js +44 -1
- package/scripts/spm/autolink-gate.js +40 -0
- package/scripts/spm/classify.js +54 -77
- package/scripts/spm/diagnostics.js +540 -147
- package/scripts/spm/flavored-frameworks.js +80 -125
- package/scripts/spm/manifests.js +523 -205
- package/scripts/spm/metadata.js +152 -0
- package/scripts/spm/plugin.js +592 -277
- package/scripts/spm/podspec.js +56 -19
- package/src/async-require/__tests__/loadBundle.test.ios.ts +2 -2
- package/src/winter/__tests__/{TextDecoderStream.test.ios.ts → TextDecoderStream.test.native.ts} +23 -2
- package/src/winter/runtime.native.ts +0 -2
- package/template.tgz +0 -0
- package/build/winter/TextDecoder.d.ts +0 -13
- package/build/winter/TextDecoder.js +0 -357
- package/build/winter/TextDecoder.js.map +0 -1
- package/src/winter/TextDecoder.ts +0 -427
- package/src/winter/__tests__/TextDecoder.test.native.ts +0 -549
|
@@ -10,12 +10,23 @@ const { runDumpPackage } = require('../cli');
|
|
|
10
10
|
const {
|
|
11
11
|
parseDumpedManifest,
|
|
12
12
|
renderSourceManifest,
|
|
13
|
-
|
|
13
|
+
pureSwiftManifest,
|
|
14
14
|
emitSourceManifestPackage,
|
|
15
15
|
emitPureSwiftSourcePackage,
|
|
16
16
|
raiseFloor,
|
|
17
|
+
spmPackageIdentity,
|
|
18
|
+
documentedPackage,
|
|
19
|
+
packageDeclaration,
|
|
17
20
|
} = require('../manifests');
|
|
18
21
|
|
|
22
|
+
/** A pure-Swift module rendered the way `emitPureSwiftSourcePackage` renders it. */
|
|
23
|
+
const renderPureSwift = ({ frameworkSearchPath, extraSwiftFlags, ...module }) =>
|
|
24
|
+
renderSourceManifest({
|
|
25
|
+
manifest: pureSwiftManifest(module),
|
|
26
|
+
frameworkSearchPath,
|
|
27
|
+
extraSwiftFlags,
|
|
28
|
+
});
|
|
29
|
+
|
|
19
30
|
describe('parseDumpedManifest', () => {
|
|
20
31
|
const dumped = JSON.stringify({
|
|
21
32
|
name: 'expo-file-system',
|
|
@@ -57,7 +68,7 @@ describe('parseDumpedManifest', () => {
|
|
|
57
68
|
sources: [],
|
|
58
69
|
resources: [],
|
|
59
70
|
settings: [],
|
|
60
|
-
|
|
71
|
+
dependencies: ['ExpoFileSystemObjC'],
|
|
61
72
|
},
|
|
62
73
|
{
|
|
63
74
|
name: 'ExpoFileSystemObjC',
|
|
@@ -67,7 +78,7 @@ describe('parseDumpedManifest', () => {
|
|
|
67
78
|
sources: [],
|
|
68
79
|
resources: [],
|
|
69
80
|
settings: [],
|
|
70
|
-
|
|
81
|
+
dependencies: [],
|
|
71
82
|
},
|
|
72
83
|
]);
|
|
73
84
|
});
|
|
@@ -105,9 +116,9 @@ describe('parseDumpedManifest target dependencies', () => {
|
|
|
105
116
|
],
|
|
106
117
|
});
|
|
107
118
|
|
|
108
|
-
it('accepts both the .target and .byName forms and
|
|
119
|
+
it('accepts both the .target and .byName forms and drops a product of an undeclared package', () => {
|
|
109
120
|
const [main] = parseDumpedManifest(dumped).targets;
|
|
110
|
-
expect(main.
|
|
121
|
+
expect(main.dependencies).toEqual([
|
|
111
122
|
'Helper',
|
|
112
123
|
'Plain',
|
|
113
124
|
{ name: 'Conditioned', platforms: ['ios', 'macos'] },
|
|
@@ -125,13 +136,13 @@ describe('renderSourceManifest', () => {
|
|
|
125
136
|
name: 'ExpoFileSystem',
|
|
126
137
|
path: 'ios/ExpoFileSystem',
|
|
127
138
|
publicHeadersPath: null,
|
|
128
|
-
|
|
139
|
+
dependencies: ['ExpoFileSystemObjC'],
|
|
129
140
|
},
|
|
130
141
|
{
|
|
131
142
|
name: 'ExpoFileSystemObjC',
|
|
132
143
|
path: 'ios/ExpoFileSystemObjC',
|
|
133
144
|
publicHeadersPath: 'include',
|
|
134
|
-
|
|
145
|
+
dependencies: [],
|
|
135
146
|
},
|
|
136
147
|
],
|
|
137
148
|
};
|
|
@@ -170,8 +181,8 @@ describe('renderSourceManifest', () => {
|
|
|
170
181
|
});
|
|
171
182
|
});
|
|
172
183
|
|
|
173
|
-
describe('
|
|
174
|
-
const out =
|
|
184
|
+
describe('a rendered pure-Swift manifest', () => {
|
|
185
|
+
const out = renderPureSwift({
|
|
175
186
|
product: 'ExpoAsset',
|
|
176
187
|
srcRel: 'ios',
|
|
177
188
|
frameworkSearchPath: '/abs/interfaces',
|
|
@@ -206,8 +217,8 @@ describe('macro plugin flags', () => {
|
|
|
206
217
|
'"-load-plugin-executable", "-Xfrontend", ' +
|
|
207
218
|
'"/abs/macros/ExpoModulesMacros#ExpoModulesMacros"])]';
|
|
208
219
|
|
|
209
|
-
describe('
|
|
210
|
-
const out =
|
|
220
|
+
describe('a pure-Swift manifest', () => {
|
|
221
|
+
const out = renderPureSwift({
|
|
211
222
|
product: 'ExpoCrypto',
|
|
212
223
|
srcRel: 'ios',
|
|
213
224
|
frameworkSearchPath: '/abs/interfaces',
|
|
@@ -229,7 +240,7 @@ describe('macro plugin flags', () => {
|
|
|
229
240
|
manifest: {
|
|
230
241
|
name: 'TestModule',
|
|
231
242
|
products: [{ name: 'TestModule', targets: ['Main'] }],
|
|
232
|
-
targets: [{ name: 'Main', path: 'Main', publicHeadersPath: null,
|
|
243
|
+
targets: [{ name: 'Main', path: 'Main', publicHeadersPath: null, dependencies: [] }],
|
|
233
244
|
},
|
|
234
245
|
frameworkSearchPath: '/abs/interfaces',
|
|
235
246
|
extraSwiftFlags: MACRO_FLAGS,
|
|
@@ -266,8 +277,7 @@ describe('macro plugin flags', () => {
|
|
|
266
277
|
targets: [{ name: 'Main', type: 'regular', path: 'Main', dependencies: [] }],
|
|
267
278
|
})
|
|
268
279
|
);
|
|
269
|
-
emitSourceManifestPackage({
|
|
270
|
-
moduleRoot,
|
|
280
|
+
emitSourceManifestPackage(moduleRoot, {
|
|
271
281
|
frameworkSearchPath: '/abs/interfaces',
|
|
272
282
|
outDir,
|
|
273
283
|
macroFlags: MACRO_FLAGS,
|
|
@@ -279,13 +289,10 @@ describe('macro plugin flags', () => {
|
|
|
279
289
|
});
|
|
280
290
|
|
|
281
291
|
it('carries the flags through emitPureSwiftSourcePackage', () => {
|
|
282
|
-
emitPureSwiftSourcePackage(
|
|
283
|
-
moduleRoot,
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
outDir,
|
|
287
|
-
macroFlags: MACRO_FLAGS,
|
|
288
|
-
});
|
|
292
|
+
emitPureSwiftSourcePackage(
|
|
293
|
+
{ moduleRoot, product: 'ExpoCrypto' },
|
|
294
|
+
{ frameworkSearchPath: '/abs/interfaces', outDir, macroFlags: MACRO_FLAGS }
|
|
295
|
+
);
|
|
289
296
|
|
|
290
297
|
expect(
|
|
291
298
|
fs.readFileSync(path.join(outDir, 'expo-source', 'ExpoCrypto', 'Package.swift'), 'utf8')
|
|
@@ -295,12 +302,12 @@ describe('macro plugin flags', () => {
|
|
|
295
302
|
});
|
|
296
303
|
|
|
297
304
|
describe('renderSourceManifest target dependency conditions', () => {
|
|
298
|
-
const render = (
|
|
305
|
+
const render = (dependencies) =>
|
|
299
306
|
renderSourceManifest({
|
|
300
307
|
manifest: {
|
|
301
308
|
name: 'TestModule',
|
|
302
309
|
products: [{ name: 'TestModule', targets: ['Main'] }],
|
|
303
|
-
targets: [{ name: 'Main', path: 'Main', publicHeadersPath: null,
|
|
310
|
+
targets: [{ name: 'Main', path: 'Main', publicHeadersPath: null, dependencies }],
|
|
304
311
|
},
|
|
305
312
|
frameworkSearchPath: '/abs/interfaces',
|
|
306
313
|
});
|
|
@@ -343,7 +350,7 @@ describe('implicit target source paths', () => {
|
|
|
343
350
|
});
|
|
344
351
|
|
|
345
352
|
const emit = () =>
|
|
346
|
-
emitSourceManifestPackage(
|
|
353
|
+
emitSourceManifestPackage(moduleRoot, { frameworkSearchPath: '/abs/interfaces', outDir });
|
|
347
354
|
const emittedManifest = () =>
|
|
348
355
|
fs.readFileSync(path.join(outDir, 'expo-source', 'TestModule', 'Package.swift'), 'utf8');
|
|
349
356
|
|
|
@@ -355,7 +362,7 @@ describe('implicit target source paths', () => {
|
|
|
355
362
|
fs.mkdirSync(path.join(moduleRoot, 'Sources', 'Example'), { recursive: true });
|
|
356
363
|
runDumpPackage.mockReturnValue(dumpWithoutPath);
|
|
357
364
|
|
|
358
|
-
expect(emit().packageDep).toEqual({
|
|
365
|
+
expect(emit().ok.packageDep).toEqual({
|
|
359
366
|
name: 'TestModule',
|
|
360
367
|
path: path.join(outDir, 'expo-source', 'TestModule'),
|
|
361
368
|
});
|
|
@@ -378,8 +385,11 @@ describe('implicit target source paths', () => {
|
|
|
378
385
|
runDumpPackage.mockReturnValue(dumpWithoutPath);
|
|
379
386
|
const result = emit();
|
|
380
387
|
|
|
381
|
-
expect(result.
|
|
382
|
-
expect(result.
|
|
388
|
+
expect(result.ok).toBeUndefined();
|
|
389
|
+
expect(result.refusal).toEqual({
|
|
390
|
+
reason: 'unresolvable-target-path',
|
|
391
|
+
targetNames: ['Example'],
|
|
392
|
+
});
|
|
383
393
|
expect(fs.existsSync(path.join(outDir, 'expo-source', 'TestModule', 'Package.swift'))).toBe(
|
|
384
394
|
false
|
|
385
395
|
);
|
|
@@ -391,7 +401,7 @@ describe('implicit target source paths', () => {
|
|
|
391
401
|
manifest: {
|
|
392
402
|
name: 'TestModule',
|
|
393
403
|
products: [{ name: 'TestModule', targets: ['Example'] }],
|
|
394
|
-
targets: [{ name: 'Example', path: null, publicHeadersPath: null,
|
|
404
|
+
targets: [{ name: 'Example', path: null, publicHeadersPath: null, dependencies: [] }],
|
|
395
405
|
},
|
|
396
406
|
frameworkSearchPath: '/abs/interfaces',
|
|
397
407
|
})
|
|
@@ -399,9 +409,9 @@ describe('implicit target source paths', () => {
|
|
|
399
409
|
});
|
|
400
410
|
});
|
|
401
411
|
|
|
402
|
-
describe('
|
|
412
|
+
describe('pure-Swift manifest excludes', () => {
|
|
403
413
|
it('excludes the directories classification ignores, in the given order', () => {
|
|
404
|
-
const out =
|
|
414
|
+
const out = renderPureSwift({
|
|
405
415
|
product: 'ExpoClipboard',
|
|
406
416
|
srcRel: 'ios',
|
|
407
417
|
frameworkSearchPath: '/abs/interfaces',
|
|
@@ -412,7 +422,7 @@ describe('renderPureSwiftManifest excludes', () => {
|
|
|
412
422
|
|
|
413
423
|
it('emits no exclude key when nothing is ignored', () => {
|
|
414
424
|
expect(
|
|
415
|
-
|
|
425
|
+
renderPureSwift({
|
|
416
426
|
product: 'ExpoAsset',
|
|
417
427
|
srcRel: 'ios',
|
|
418
428
|
frameworkSearchPath: '/abs/interfaces',
|
|
@@ -422,9 +432,9 @@ describe('renderPureSwiftManifest excludes', () => {
|
|
|
422
432
|
});
|
|
423
433
|
});
|
|
424
434
|
|
|
425
|
-
describe('
|
|
435
|
+
describe('pure-Swift manifest privacy manifest', () => {
|
|
426
436
|
it('copies the privacy manifest into the target resources, after the excludes', () => {
|
|
427
|
-
const out =
|
|
437
|
+
const out = renderPureSwift({
|
|
428
438
|
product: 'ExpoDevice',
|
|
429
439
|
srcRel: 'ios',
|
|
430
440
|
frameworkSearchPath: '/abs/interfaces',
|
|
@@ -438,7 +448,7 @@ describe('renderPureSwiftManifest privacy manifest', () => {
|
|
|
438
448
|
|
|
439
449
|
it('emits no resources key when the module ships no privacy manifest', () => {
|
|
440
450
|
expect(
|
|
441
|
-
|
|
451
|
+
renderPureSwift({
|
|
442
452
|
product: 'ExpoAsset',
|
|
443
453
|
srcRel: 'ios',
|
|
444
454
|
frameworkSearchPath: '/abs/interfaces',
|
|
@@ -446,7 +456,7 @@ describe('renderPureSwiftManifest privacy manifest', () => {
|
|
|
446
456
|
})
|
|
447
457
|
).not.toContain('resources:');
|
|
448
458
|
expect(
|
|
449
|
-
|
|
459
|
+
renderPureSwift({
|
|
450
460
|
product: 'ExpoAsset',
|
|
451
461
|
srcRel: 'ios',
|
|
452
462
|
frameworkSearchPath: '/abs/interfaces',
|
|
@@ -464,12 +474,10 @@ describe('emitPureSwiftSourcePackage', () => {
|
|
|
464
474
|
fs.mkdirSync(path.join(moduleRoot, 'ios', '__tests__'), { recursive: true });
|
|
465
475
|
fs.writeFileSync(path.join(moduleRoot, 'ios', 'A.swift'), '// swift\n');
|
|
466
476
|
|
|
467
|
-
emitPureSwiftSourcePackage(
|
|
468
|
-
moduleRoot,
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
outDir,
|
|
472
|
-
});
|
|
477
|
+
emitPureSwiftSourcePackage(
|
|
478
|
+
{ moduleRoot, product: 'ExpoAsset' },
|
|
479
|
+
{ frameworkSearchPath: '/abs/interfaces', outDir }
|
|
480
|
+
);
|
|
473
481
|
const manifest = fs.readFileSync(
|
|
474
482
|
path.join(outDir, 'expo-source', 'ExpoAsset', 'Package.swift'),
|
|
475
483
|
'utf8'
|
|
@@ -487,12 +495,10 @@ describe('emitPureSwiftSourcePackage', () => {
|
|
|
487
495
|
if (withPrivacyManifest) {
|
|
488
496
|
fs.writeFileSync(path.join(moduleRoot, 'ios', 'PrivacyInfo.xcprivacy'), '<plist/>\n');
|
|
489
497
|
}
|
|
490
|
-
emitPureSwiftSourcePackage(
|
|
491
|
-
moduleRoot,
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
outDir,
|
|
495
|
-
});
|
|
498
|
+
emitPureSwiftSourcePackage(
|
|
499
|
+
{ moduleRoot, product: 'ExpoDevice' },
|
|
500
|
+
{ frameworkSearchPath: '/abs/interfaces', outDir }
|
|
501
|
+
);
|
|
496
502
|
return fs.readFileSync(
|
|
497
503
|
path.join(outDir, 'expo-source', 'ExpoDevice', 'Package.swift'),
|
|
498
504
|
'utf8'
|
|
@@ -534,13 +540,13 @@ describe('single-target packages with sources directly in a predefined directory
|
|
|
534
540
|
fs.writeFileSync(target, content);
|
|
535
541
|
};
|
|
536
542
|
const emit = () =>
|
|
537
|
-
emitSourceManifestPackage(
|
|
543
|
+
emitSourceManifestPackage(moduleRoot, { frameworkSearchPath: '/abs/interfaces', outDir });
|
|
538
544
|
|
|
539
545
|
it('resolves the only target to the bare predefined directory holding its sources', () => {
|
|
540
546
|
write('Sources/File.swift');
|
|
541
547
|
runDumpPackage.mockReturnValue(dumpTargets(['RootSrc']));
|
|
542
548
|
|
|
543
|
-
expect(emit().
|
|
549
|
+
expect(emit().refusal).toBeUndefined();
|
|
544
550
|
expect(
|
|
545
551
|
fs.readFileSync(path.join(outDir, 'expo-source', 'TestModule', 'Package.swift'), 'utf8')
|
|
546
552
|
).toContain('path: "root/Sources"');
|
|
@@ -561,14 +567,14 @@ describe('single-target packages with sources directly in a predefined directory
|
|
|
561
567
|
write('Sources/File.swift');
|
|
562
568
|
runDumpPackage.mockReturnValue(dumpTargets(['A', 'B']));
|
|
563
569
|
|
|
564
|
-
expect(emit().
|
|
570
|
+
expect(emit().refusal).toEqual({ reason: 'unresolvable-target-path', targetNames: ['A', 'B'] });
|
|
565
571
|
});
|
|
566
572
|
|
|
567
573
|
it('accepts a predefined directory whose sources are nested below it', () => {
|
|
568
574
|
write('Sources/Nested/File.swift');
|
|
569
575
|
runDumpPackage.mockReturnValue(dumpTargets(['RootSrc']));
|
|
570
576
|
|
|
571
|
-
expect(emit().
|
|
577
|
+
expect(emit().refusal).toBeUndefined();
|
|
572
578
|
expect(
|
|
573
579
|
fs.readFileSync(path.join(outDir, 'expo-source', 'TestModule', 'Package.swift'), 'utf8')
|
|
574
580
|
).toContain('path: "root/Sources"');
|
|
@@ -578,7 +584,10 @@ describe('single-target packages with sources directly in a predefined directory
|
|
|
578
584
|
write('Sources/Nested/README.md', '# docs\n');
|
|
579
585
|
runDumpPackage.mockReturnValue(dumpTargets(['RootSrc']));
|
|
580
586
|
|
|
581
|
-
expect(emit().
|
|
587
|
+
expect(emit().refusal).toEqual({
|
|
588
|
+
reason: 'unresolvable-target-path',
|
|
589
|
+
targetNames: ['RootSrc'],
|
|
590
|
+
});
|
|
582
591
|
});
|
|
583
592
|
});
|
|
584
593
|
|
|
@@ -605,7 +614,7 @@ describe('sibling dependencies on non-regular targets', () => {
|
|
|
605
614
|
],
|
|
606
615
|
})
|
|
607
616
|
).targets;
|
|
608
|
-
expect(main.
|
|
617
|
+
expect(main.dependencies).toEqual(['Helper']);
|
|
609
618
|
});
|
|
610
619
|
});
|
|
611
620
|
|
|
@@ -621,7 +630,7 @@ describe('unsupported platform conditions', () => {
|
|
|
621
630
|
name: 'Main',
|
|
622
631
|
path: 'Main',
|
|
623
632
|
publicHeadersPath: null,
|
|
624
|
-
|
|
633
|
+
dependencies: [{ name: 'Helper', platforms: ['freebsd'] }],
|
|
625
634
|
},
|
|
626
635
|
],
|
|
627
636
|
},
|
|
@@ -989,9 +998,9 @@ describe('deployment target', () => {
|
|
|
989
998
|
).toContain('platforms: [.iOS(.v15)],');
|
|
990
999
|
});
|
|
991
1000
|
|
|
992
|
-
it('takes the pure-Swift floor the plugin read from the
|
|
1001
|
+
it('takes the pure-Swift floor the plugin read from the prebuilt-metadata document', () => {
|
|
993
1002
|
expect(
|
|
994
|
-
|
|
1003
|
+
renderPureSwift({
|
|
995
1004
|
product: 'ExpoAsset',
|
|
996
1005
|
srcRel: 'ios',
|
|
997
1006
|
frameworkSearchPath: '/abs/interfaces',
|
|
@@ -999,7 +1008,7 @@ describe('deployment target', () => {
|
|
|
999
1008
|
})
|
|
1000
1009
|
).toContain('platforms: [.iOS("16.4")],');
|
|
1001
1010
|
expect(
|
|
1002
|
-
|
|
1011
|
+
renderPureSwift({
|
|
1003
1012
|
product: 'ExpoAsset',
|
|
1004
1013
|
srcRel: 'ios',
|
|
1005
1014
|
frameworkSearchPath: '/abs/interfaces',
|
|
@@ -1014,13 +1023,10 @@ describe('deployment target', () => {
|
|
|
1014
1023
|
fs.mkdirSync(path.join(moduleRoot, 'ios'), { recursive: true });
|
|
1015
1024
|
fs.writeFileSync(path.join(moduleRoot, 'ios', 'A.swift'), '// swift\n');
|
|
1016
1025
|
|
|
1017
|
-
emitPureSwiftSourcePackage(
|
|
1018
|
-
moduleRoot,
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
outDir,
|
|
1022
|
-
iosDeploymentTarget: '16.4',
|
|
1023
|
-
});
|
|
1026
|
+
emitPureSwiftSourcePackage(
|
|
1027
|
+
{ moduleRoot, product: 'ExpoAsset', iosDeploymentTarget: '16.4' },
|
|
1028
|
+
{ frameworkSearchPath: '/abs/interfaces', outDir }
|
|
1029
|
+
);
|
|
1024
1030
|
const manifest = fs.readFileSync(
|
|
1025
1031
|
path.join(outDir, 'expo-source', 'ExpoAsset', 'Package.swift'),
|
|
1026
1032
|
'utf8'
|
|
@@ -1084,8 +1090,7 @@ describe('the minimum floor a checked-in manifest is raised to', () => {
|
|
|
1084
1090
|
|
|
1085
1091
|
const emitted = (declared, minimum) => {
|
|
1086
1092
|
runDumpPackage.mockReturnValue(dumpWithIos(declared));
|
|
1087
|
-
emitSourceManifestPackage({
|
|
1088
|
-
moduleRoot,
|
|
1093
|
+
emitSourceManifestPackage(moduleRoot, {
|
|
1089
1094
|
frameworkSearchPath: '/abs/interfaces',
|
|
1090
1095
|
outDir,
|
|
1091
1096
|
minimumIosDeploymentTarget: minimum,
|
|
@@ -1184,10 +1189,12 @@ describe('dependencies on targets the generated package cannot declare', () => {
|
|
|
1184
1189
|
})
|
|
1185
1190
|
);
|
|
1186
1191
|
expect(unsupportedTargetDeps).toEqual([]);
|
|
1187
|
-
expect(targets[0].
|
|
1192
|
+
expect(targets[0].dependencies).toEqual(['EXConstantsObjC']);
|
|
1188
1193
|
});
|
|
1189
1194
|
|
|
1190
|
-
|
|
1195
|
+
// SwiftPM resolves it against the products of the packages the module declares, and
|
|
1196
|
+
// rendering it verbatim leaves that resolution where it belongs.
|
|
1197
|
+
it('renders a name that is no target of this package — an external product — verbatim', () => {
|
|
1191
1198
|
const { targets, unsupportedTargetDeps } = parseDumpedManifest(
|
|
1192
1199
|
JSON.stringify({
|
|
1193
1200
|
name: 'TestModule',
|
|
@@ -1203,7 +1210,7 @@ describe('dependencies on targets the generated package cannot declare', () => {
|
|
|
1203
1210
|
})
|
|
1204
1211
|
);
|
|
1205
1212
|
expect(unsupportedTargetDeps).toEqual([]);
|
|
1206
|
-
expect(targets[0].
|
|
1213
|
+
expect(targets[0].dependencies).toEqual(['SomeUpstreamProduct']);
|
|
1207
1214
|
});
|
|
1208
1215
|
|
|
1209
1216
|
it('skips the module instead of emitting a target whose dependency was dropped', () => {
|
|
@@ -1213,18 +1220,1022 @@ describe('dependencies on targets the generated package cannot declare', () => {
|
|
|
1213
1220
|
fs.mkdirSync(path.join(moduleRoot, 'ios', 'Src'), { recursive: true });
|
|
1214
1221
|
runDumpPackage.mockReturnValue(dumpWithBinaryTarget);
|
|
1215
1222
|
|
|
1216
|
-
const result = emitSourceManifestPackage({
|
|
1217
|
-
moduleRoot,
|
|
1223
|
+
const result = emitSourceManifestPackage(moduleRoot, {
|
|
1218
1224
|
frameworkSearchPath: '/abs/interfaces',
|
|
1219
1225
|
outDir,
|
|
1220
1226
|
});
|
|
1221
1227
|
|
|
1222
|
-
expect(result.
|
|
1223
|
-
expect(result.
|
|
1224
|
-
|
|
1225
|
-
|
|
1228
|
+
expect(result.ok).toBeUndefined();
|
|
1229
|
+
expect(result.refusal).toEqual({
|
|
1230
|
+
reason: 'unsupported-target-dependency',
|
|
1231
|
+
dependencies: [{ target: 'Src', dependsOn: 'Vendored', kind: 'binary' }],
|
|
1232
|
+
});
|
|
1226
1233
|
expect(fs.existsSync(path.join(outDir, 'expo-source', 'TestModule', 'Package.swift'))).toBe(
|
|
1227
1234
|
false
|
|
1228
1235
|
);
|
|
1229
1236
|
});
|
|
1230
1237
|
});
|
|
1238
|
+
|
|
1239
|
+
// A pure-Swift module's SwiftPM dependencies come from its spm.config.json, the
|
|
1240
|
+
// same coordinates CocoaPods resolves through the podspec. Without them
|
|
1241
|
+
// `import SDWebImage` names a package the generated manifest never declared.
|
|
1242
|
+
describe('SwiftPM package coordinates', () => {
|
|
1243
|
+
const sdWebImage = {
|
|
1244
|
+
url: 'https://github.com/SDWebImage/SDWebImage.git',
|
|
1245
|
+
productName: 'SDWebImage',
|
|
1246
|
+
version: { exact: '5.21.6' },
|
|
1247
|
+
};
|
|
1248
|
+
|
|
1249
|
+
describe('spmPackageIdentity', () => {
|
|
1250
|
+
it("takes the URL's last path component, without the .git suffix", () => {
|
|
1251
|
+
expect(spmPackageIdentity(sdWebImage)).toBe('SDWebImage');
|
|
1252
|
+
expect(
|
|
1253
|
+
spmPackageIdentity({ ...sdWebImage, url: 'https://github.com/SDWebImage/SDWebImage' })
|
|
1254
|
+
).toBe('SDWebImage');
|
|
1255
|
+
});
|
|
1256
|
+
|
|
1257
|
+
// libavif-Xcode ships the `libavif` product: the identity SwiftPM resolves is
|
|
1258
|
+
// the repository name, not the product name.
|
|
1259
|
+
it('reads the repository name, not the product it ships', () => {
|
|
1260
|
+
expect(
|
|
1261
|
+
spmPackageIdentity({
|
|
1262
|
+
url: 'https://github.com/SDWebImage/libavif-Xcode.git',
|
|
1263
|
+
productName: 'libavif',
|
|
1264
|
+
version: { exact: '1.0.0' },
|
|
1265
|
+
})
|
|
1266
|
+
).toBe('libavif-Xcode');
|
|
1267
|
+
});
|
|
1268
|
+
|
|
1269
|
+
// A URL ending in a slash has an empty last component, which would render
|
|
1270
|
+
// `package: ""` and fail the whole graph rather than the one declaration.
|
|
1271
|
+
it('ignores a trailing slash', () => {
|
|
1272
|
+
expect(
|
|
1273
|
+
spmPackageIdentity({ ...sdWebImage, url: 'https://github.com/SDWebImage/SDWebImage/' })
|
|
1274
|
+
).toBe('SDWebImage');
|
|
1275
|
+
expect(
|
|
1276
|
+
spmPackageIdentity({ ...sdWebImage, url: 'https://github.com/SDWebImage/SDWebImage.git/' })
|
|
1277
|
+
).toBe('SDWebImage');
|
|
1278
|
+
});
|
|
1279
|
+
});
|
|
1280
|
+
|
|
1281
|
+
describe('packageDeclaration of a documented package', () => {
|
|
1282
|
+
it('renders every version requirement PackageDescription declares', () => {
|
|
1283
|
+
const withVersion = (version) =>
|
|
1284
|
+
packageDeclaration(documentedPackage({ ...sdWebImage, version }));
|
|
1285
|
+
expect(withVersion({ exact: '5.21.6' })).toBe(
|
|
1286
|
+
'.package(url: "https://github.com/SDWebImage/SDWebImage.git", exact: "5.21.6")'
|
|
1287
|
+
);
|
|
1288
|
+
expect(withVersion({ from: '5.21.6' })).toBe(
|
|
1289
|
+
'.package(url: "https://github.com/SDWebImage/SDWebImage.git", from: "5.21.6")'
|
|
1290
|
+
);
|
|
1291
|
+
expect(withVersion({ branch: 'main' })).toBe(
|
|
1292
|
+
'.package(url: "https://github.com/SDWebImage/SDWebImage.git", branch: "main")'
|
|
1293
|
+
);
|
|
1294
|
+
expect(withVersion({ revision: 'c0ffee' })).toBe(
|
|
1295
|
+
'.package(url: "https://github.com/SDWebImage/SDWebImage.git", revision: "c0ffee")'
|
|
1296
|
+
);
|
|
1297
|
+
});
|
|
1298
|
+
});
|
|
1299
|
+
|
|
1300
|
+
describe('the target dependency on a documented package', () => {
|
|
1301
|
+
const rendered = (spmPackage) =>
|
|
1302
|
+
renderPureSwift({
|
|
1303
|
+
product: 'ExpoImage',
|
|
1304
|
+
srcRel: 'ios',
|
|
1305
|
+
frameworkSearchPath: '/abs/interfaces',
|
|
1306
|
+
packages: [documentedPackage(spmPackage)],
|
|
1307
|
+
});
|
|
1308
|
+
|
|
1309
|
+
it('names the product, resolved against its package identity', () => {
|
|
1310
|
+
expect(rendered(sdWebImage)).toContain('.product(name: "SDWebImage", package: "SDWebImage")');
|
|
1311
|
+
expect(
|
|
1312
|
+
rendered({
|
|
1313
|
+
url: 'https://github.com/SDWebImage/libavif-Xcode.git',
|
|
1314
|
+
productName: 'libavif',
|
|
1315
|
+
version: { exact: '1.0.0' },
|
|
1316
|
+
})
|
|
1317
|
+
).toContain('.product(name: "libavif", package: "libavif-Xcode")');
|
|
1318
|
+
});
|
|
1319
|
+
});
|
|
1320
|
+
|
|
1321
|
+
describe('the emitted manifest', () => {
|
|
1322
|
+
const emitWith = (spmPackages, { react = null, satisfiedDependencies } = {}) => {
|
|
1323
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'expo-spm-packages-emit-'));
|
|
1324
|
+
const moduleRoot = path.join(tmp, 'module');
|
|
1325
|
+
const outDir = path.join(tmp, 'out');
|
|
1326
|
+
fs.mkdirSync(path.join(moduleRoot, 'ios'), { recursive: true });
|
|
1327
|
+
fs.writeFileSync(path.join(moduleRoot, 'ios', 'A.swift'), '// swift\n');
|
|
1328
|
+
const result = emitPureSwiftSourcePackage(
|
|
1329
|
+
{ moduleRoot, product: 'ExpoImage', iosDeploymentTarget: '16.4', spmPackages },
|
|
1330
|
+
{ react, frameworkSearchPath: '/abs/interfaces', outDir, satisfiedDependencies }
|
|
1331
|
+
);
|
|
1332
|
+
const manifest = fs.readFileSync(
|
|
1333
|
+
path.join(outDir, 'expo-source', 'ExpoImage', 'Package.swift'),
|
|
1334
|
+
'utf8'
|
|
1335
|
+
);
|
|
1336
|
+
return { result, manifest };
|
|
1337
|
+
};
|
|
1338
|
+
const emit = (spmPackages, react = null) => emitWith(spmPackages, { react }).manifest;
|
|
1339
|
+
|
|
1340
|
+
// The precompiled framework is already in the app; a source copy would duplicate it.
|
|
1341
|
+
it('leaves out a package whose product a precompiled framework already provides', () => {
|
|
1342
|
+
const { result, manifest } = emitWith(
|
|
1343
|
+
[
|
|
1344
|
+
sdWebImage,
|
|
1345
|
+
{
|
|
1346
|
+
url: 'https://github.com/SDWebImage/libavif-Xcode.git',
|
|
1347
|
+
productName: 'libavif',
|
|
1348
|
+
version: { exact: '1.0.0' },
|
|
1349
|
+
},
|
|
1350
|
+
],
|
|
1351
|
+
{ satisfiedDependencies: new Set(['SDWebImage']) }
|
|
1352
|
+
);
|
|
1353
|
+
|
|
1354
|
+
expect(manifest).not.toContain(
|
|
1355
|
+
'.package(url: "https://github.com/SDWebImage/SDWebImage.git"'
|
|
1356
|
+
);
|
|
1357
|
+
expect(manifest).not.toContain('.product(name: "SDWebImage"');
|
|
1358
|
+
expect(manifest).toContain(
|
|
1359
|
+
'.package(url: "https://github.com/SDWebImage/libavif-Xcode.git", exact: "1.0.0"),'
|
|
1360
|
+
);
|
|
1361
|
+
expect(manifest).toContain('.product(name: "libavif", package: "libavif-Xcode"),');
|
|
1362
|
+
expect(result.ok.spmProductNames).toEqual(['SDWebImage', 'libavif']);
|
|
1363
|
+
expect(result.ok.partlyProvidedPackages).toEqual([]);
|
|
1364
|
+
});
|
|
1365
|
+
|
|
1366
|
+
it('declares each package and depends the target on its product', () => {
|
|
1367
|
+
const manifest = emit([
|
|
1368
|
+
sdWebImage,
|
|
1369
|
+
{
|
|
1370
|
+
url: 'https://github.com/SDWebImage/libavif-Xcode.git',
|
|
1371
|
+
productName: 'libavif',
|
|
1372
|
+
version: { exact: '1.0.0' },
|
|
1373
|
+
},
|
|
1374
|
+
]);
|
|
1375
|
+
expect(manifest).toContain(
|
|
1376
|
+
'dependencies: [\n' +
|
|
1377
|
+
' .package(url: "https://github.com/SDWebImage/SDWebImage.git", exact: "5.21.6"),\n' +
|
|
1378
|
+
' .package(url: "https://github.com/SDWebImage/libavif-Xcode.git", exact: "1.0.0"),\n' +
|
|
1379
|
+
' ],'
|
|
1380
|
+
);
|
|
1381
|
+
expect(manifest).toContain(
|
|
1382
|
+
'dependencies: [\n' +
|
|
1383
|
+
' .product(name: "SDWebImage", package: "SDWebImage"),\n' +
|
|
1384
|
+
' .product(name: "libavif", package: "libavif-Xcode"),\n' +
|
|
1385
|
+
' ],'
|
|
1386
|
+
);
|
|
1387
|
+
});
|
|
1388
|
+
|
|
1389
|
+
it('depends on its own package products before the React products', () => {
|
|
1390
|
+
const react = {
|
|
1391
|
+
packageRef: { name: 'ReactNative', path: '/abs/rn' },
|
|
1392
|
+
products: [{ name: 'React', package: 'ReactNative' }],
|
|
1393
|
+
};
|
|
1394
|
+
expect(emit([sdWebImage], react)).toContain(
|
|
1395
|
+
'dependencies: [\n' +
|
|
1396
|
+
' .product(name: "SDWebImage", package: "SDWebImage"),\n' +
|
|
1397
|
+
' .product(name: "React", package: "ReactNative"),\n' +
|
|
1398
|
+
' ],'
|
|
1399
|
+
);
|
|
1400
|
+
});
|
|
1401
|
+
|
|
1402
|
+
// A pure-Swift module renders in the format of a mirrored checked-in manifest:
|
|
1403
|
+
// no trailing comma after the last product or target.
|
|
1404
|
+
it('renders a module with no packages in the checked-in manifest format', () => {
|
|
1405
|
+
const expected =
|
|
1406
|
+
'// swift-tools-version: 6.0\n' +
|
|
1407
|
+
'// AUTO-GENERATED by expo/scripts/spm/plugin.js \u2014 do not edit.\n' +
|
|
1408
|
+
'// Pure-Swift source consumption package for "ExpoImage".\n' +
|
|
1409
|
+
'import PackageDescription\n' +
|
|
1410
|
+
'\n' +
|
|
1411
|
+
'let package = Package(\n' +
|
|
1412
|
+
' name: "ExpoImage",\n' +
|
|
1413
|
+
' platforms: [.iOS("16.4")],\n' +
|
|
1414
|
+
' products: [\n' +
|
|
1415
|
+
' .library(name: "ExpoImage", targets: ["ExpoImage"])\n' +
|
|
1416
|
+
' ],\n' +
|
|
1417
|
+
' dependencies: [],\n' +
|
|
1418
|
+
' targets: [\n' +
|
|
1419
|
+
' .target(\n' +
|
|
1420
|
+
' name: "ExpoImage",\n' +
|
|
1421
|
+
' dependencies: [],\n' +
|
|
1422
|
+
' path: "root/ios",\n' +
|
|
1423
|
+
' cSettings: [.unsafeFlags(["-F", "/abs/interfaces"])],\n' +
|
|
1424
|
+
' cxxSettings: [.unsafeFlags(["-F", "/abs/interfaces"])],\n' +
|
|
1425
|
+
' swiftSettings: [.unsafeFlags(["-F", "/abs/interfaces"])],\n' +
|
|
1426
|
+
' )\n' +
|
|
1427
|
+
' ],\n' +
|
|
1428
|
+
' swiftLanguageModes: [.v5],\n' +
|
|
1429
|
+
' cxxLanguageStandard: .cxx20\n' +
|
|
1430
|
+
')\n';
|
|
1431
|
+
expect(emit([])).toBe(expected);
|
|
1432
|
+
expect(emit(undefined)).toBe(expected);
|
|
1433
|
+
});
|
|
1434
|
+
});
|
|
1435
|
+
});
|
|
1436
|
+
|
|
1437
|
+
// A module that ships a checked-in Package.swift may declare third-party SwiftPM
|
|
1438
|
+
// packages of its own. The generated consumption package has to mirror them, or its
|
|
1439
|
+
// sources fail to compile with "no such module".
|
|
1440
|
+
describe('mirrored package dependencies', () => {
|
|
1441
|
+
// Verbatim shapes from `swift package dump-package` (SwiftPM 6.0).
|
|
1442
|
+
const remote = (identity, url, requirement, extra = {}) => ({
|
|
1443
|
+
sourceControl: [
|
|
1444
|
+
{
|
|
1445
|
+
identity,
|
|
1446
|
+
location: { remote: [{ urlString: url }] },
|
|
1447
|
+
productFilter: null,
|
|
1448
|
+
requirement,
|
|
1449
|
+
traits: [{ name: 'default' }],
|
|
1450
|
+
...extra,
|
|
1451
|
+
},
|
|
1452
|
+
],
|
|
1453
|
+
});
|
|
1454
|
+
|
|
1455
|
+
const SDWEB_IMAGE = remote('sdwebimage', 'https://github.com/SDWebImage/SDWebImage.git', {
|
|
1456
|
+
exact: ['5.21.6'],
|
|
1457
|
+
});
|
|
1458
|
+
// `.package(url:from:)` dumps as a range — the renderer never sees a `from` form.
|
|
1459
|
+
const LIBAVIF = remote('libavif-xcode', 'https://github.com/SDWebImage/libavif-Xcode.git', {
|
|
1460
|
+
range: [{ lowerBound: '0.11.0', upperBound: '1.0.0' }],
|
|
1461
|
+
});
|
|
1462
|
+
const ALL_REQUIREMENT_FORMS = [
|
|
1463
|
+
SDWEB_IMAGE,
|
|
1464
|
+
remote('branchy', 'https://github.com/acme/branchy.git', { branch: ['main'] }),
|
|
1465
|
+
remote('pinned', 'https://github.com/acme/pinned.git', { revision: ['0123456789abcdef'] }),
|
|
1466
|
+
LIBAVIF,
|
|
1467
|
+
];
|
|
1468
|
+
|
|
1469
|
+
const dumpWith = ({ dependencies = [], targetDeps = [] }) =>
|
|
1470
|
+
JSON.stringify({
|
|
1471
|
+
name: 'TestModule',
|
|
1472
|
+
dependencies,
|
|
1473
|
+
products: [{ name: 'TestModule', type: { library: ['automatic'] }, targets: ['Main'] }],
|
|
1474
|
+
targets: [
|
|
1475
|
+
{ name: 'Main', type: 'regular', path: 'ios/Main', dependencies: targetDeps },
|
|
1476
|
+
{ name: 'Helper', type: 'regular', path: 'ios/Helper', dependencies: [] },
|
|
1477
|
+
],
|
|
1478
|
+
});
|
|
1479
|
+
|
|
1480
|
+
const render = (dump, injectedNames = []) =>
|
|
1481
|
+
renderSourceManifest({
|
|
1482
|
+
manifest: parseDumpedManifest(dump, injectedNames),
|
|
1483
|
+
pkgDeps: ['.package(name: "ReactNative", path: "/abs/rn")'],
|
|
1484
|
+
injectedTargetDeps: ['.product(name: "React", package: "ReactNative")'],
|
|
1485
|
+
frameworkSearchPath: '/abs/interfaces',
|
|
1486
|
+
});
|
|
1487
|
+
|
|
1488
|
+
const unsupported = (dependencies, targetDeps) =>
|
|
1489
|
+
parseDumpedManifest(dumpWith({ dependencies, targetDeps })).unsupportedPackageDeps;
|
|
1490
|
+
|
|
1491
|
+
it('parses every requirement form the generated package can declare', () => {
|
|
1492
|
+
const { packageDeps, unsupportedPackageDeps } = parseDumpedManifest(
|
|
1493
|
+
dumpWith({ dependencies: ALL_REQUIREMENT_FORMS })
|
|
1494
|
+
);
|
|
1495
|
+
expect(unsupportedPackageDeps).toEqual([]);
|
|
1496
|
+
expect(packageDeps).toEqual([
|
|
1497
|
+
{
|
|
1498
|
+
identity: 'sdwebimage',
|
|
1499
|
+
url: 'https://github.com/SDWebImage/SDWebImage.git',
|
|
1500
|
+
requirement: { kind: 'exact', value: '5.21.6' },
|
|
1501
|
+
},
|
|
1502
|
+
{
|
|
1503
|
+
identity: 'branchy',
|
|
1504
|
+
url: 'https://github.com/acme/branchy.git',
|
|
1505
|
+
requirement: { kind: 'branch', value: 'main' },
|
|
1506
|
+
},
|
|
1507
|
+
{
|
|
1508
|
+
identity: 'pinned',
|
|
1509
|
+
url: 'https://github.com/acme/pinned.git',
|
|
1510
|
+
requirement: { kind: 'revision', value: '0123456789abcdef' },
|
|
1511
|
+
},
|
|
1512
|
+
{
|
|
1513
|
+
identity: 'libavif-xcode',
|
|
1514
|
+
url: 'https://github.com/SDWebImage/libavif-Xcode.git',
|
|
1515
|
+
requirement: { kind: 'range', lowerBound: '0.11.0', upperBound: '1.0.0' },
|
|
1516
|
+
},
|
|
1517
|
+
]);
|
|
1518
|
+
});
|
|
1519
|
+
|
|
1520
|
+
it('declares each requirement form the way PackageDescription spells it', () => {
|
|
1521
|
+
const out = render(dumpWith({ dependencies: ALL_REQUIREMENT_FORMS }));
|
|
1522
|
+
expect(out).toContain(
|
|
1523
|
+
'.package(url: "https://github.com/SDWebImage/SDWebImage.git", exact: "5.21.6"),'
|
|
1524
|
+
);
|
|
1525
|
+
expect(out).toContain('.package(url: "https://github.com/acme/branchy.git", branch: "main"),');
|
|
1526
|
+
expect(out).toContain(
|
|
1527
|
+
'.package(url: "https://github.com/acme/pinned.git", revision: "0123456789abcdef"),'
|
|
1528
|
+
);
|
|
1529
|
+
expect(out).toContain(
|
|
1530
|
+
'.package(url: "https://github.com/SDWebImage/libavif-Xcode.git", "0.11.0"..<"1.0.0"),'
|
|
1531
|
+
);
|
|
1532
|
+
});
|
|
1533
|
+
|
|
1534
|
+
it('declares the mirrored packages after the injected ones', () => {
|
|
1535
|
+
expect(render(dumpWith({ dependencies: [SDWEB_IMAGE] }))).toContain(
|
|
1536
|
+
'dependencies: [\n' +
|
|
1537
|
+
' .package(name: "ReactNative", path: "/abs/rn"),\n' +
|
|
1538
|
+
' .package(url: "https://github.com/SDWebImage/SDWebImage.git", exact: "5.21.6"),\n' +
|
|
1539
|
+
' ],'
|
|
1540
|
+
);
|
|
1541
|
+
});
|
|
1542
|
+
|
|
1543
|
+
it('keeps target dependencies in their declared order, siblings and products alike', () => {
|
|
1544
|
+
const dump = dumpWith({
|
|
1545
|
+
dependencies: [SDWEB_IMAGE, LIBAVIF],
|
|
1546
|
+
targetDeps: [
|
|
1547
|
+
{ product: ['SDWebImage', 'SDWebImage', null, null] },
|
|
1548
|
+
{ byName: ['Helper', null] },
|
|
1549
|
+
{ product: ['SDWebImageAVIFCoder', 'libavif-Xcode', null, { platformNames: ['ios'] }] },
|
|
1550
|
+
],
|
|
1551
|
+
});
|
|
1552
|
+
expect(parseDumpedManifest(dump).targets[0].dependencies).toEqual([
|
|
1553
|
+
{ product: 'SDWebImage', package: 'SDWebImage', platforms: [] },
|
|
1554
|
+
'Helper',
|
|
1555
|
+
{ product: 'SDWebImageAVIFCoder', package: 'libavif-Xcode', platforms: ['ios'] },
|
|
1556
|
+
]);
|
|
1557
|
+
expect(render(dump)).toContain(
|
|
1558
|
+
[
|
|
1559
|
+
' .product(name: "SDWebImage", package: "SDWebImage"),',
|
|
1560
|
+
' "Helper",',
|
|
1561
|
+
' .product(name: "SDWebImageAVIFCoder", package: "libavif-Xcode", condition: .when(platforms: [.iOS])),',
|
|
1562
|
+
' .product(name: "React", package: "ReactNative"),',
|
|
1563
|
+
].join('\n')
|
|
1564
|
+
);
|
|
1565
|
+
});
|
|
1566
|
+
|
|
1567
|
+
it('keeps a byName dependency that names a declared package', () => {
|
|
1568
|
+
const dump = dumpWith({
|
|
1569
|
+
dependencies: [
|
|
1570
|
+
remote('branchy', 'https://github.com/acme/branchy.git', { branch: ['main'] }),
|
|
1571
|
+
],
|
|
1572
|
+
targetDeps: [
|
|
1573
|
+
{ byName: ['branchy', null] },
|
|
1574
|
+
{ byName: ['Branchy', { platformNames: ['ios'] }] },
|
|
1575
|
+
],
|
|
1576
|
+
});
|
|
1577
|
+
const { targets, unsupportedPackageDeps } = parseDumpedManifest(dump);
|
|
1578
|
+
expect(unsupportedPackageDeps).toEqual([]);
|
|
1579
|
+
expect(targets[0].dependencies).toEqual(['branchy', { byName: 'Branchy', platforms: ['ios'] }]);
|
|
1580
|
+
expect(render(dump)).toContain(
|
|
1581
|
+
' "branchy",\n' +
|
|
1582
|
+
' .byName(name: "Branchy", condition: .when(platforms: [.iOS])),'
|
|
1583
|
+
);
|
|
1584
|
+
});
|
|
1585
|
+
|
|
1586
|
+
const vendored = { fileSystem: [{ identity: 'vendored', path: '/abs/vendored' }] };
|
|
1587
|
+
const SDWEB_PRODUCT = ['SDWebImage', 'SDWebImage'];
|
|
1588
|
+
|
|
1589
|
+
it.each([
|
|
1590
|
+
{
|
|
1591
|
+
title: 'reports a local path dependency instead of dropping it',
|
|
1592
|
+
dependencies: [
|
|
1593
|
+
{ fileSystem: [{ identity: 'local-thing', path: '/abs/path', productFilter: null }] },
|
|
1594
|
+
],
|
|
1595
|
+
expected: [{ form: 'local-path', identity: 'local-thing', target: null }],
|
|
1596
|
+
},
|
|
1597
|
+
{
|
|
1598
|
+
title: 'reports a registry dependency',
|
|
1599
|
+
dependencies: [
|
|
1600
|
+
{ registry: [{ identity: 'acme.widgets', requirement: { exact: ['1.0.0'] } }] },
|
|
1601
|
+
],
|
|
1602
|
+
expected: [{ form: 'registry', identity: 'acme.widgets', target: null }],
|
|
1603
|
+
},
|
|
1604
|
+
{
|
|
1605
|
+
title: 'reports a source-control dependency that is not a remote URL',
|
|
1606
|
+
dependencies: [
|
|
1607
|
+
{
|
|
1608
|
+
sourceControl: [
|
|
1609
|
+
{
|
|
1610
|
+
identity: 'local-scm',
|
|
1611
|
+
location: { local: [{ path: '/abs/checkout' }] },
|
|
1612
|
+
requirement: { branch: ['main'] },
|
|
1613
|
+
},
|
|
1614
|
+
],
|
|
1615
|
+
},
|
|
1616
|
+
],
|
|
1617
|
+
expected: [{ form: 'unsupported-location', identity: 'local-scm', target: null }],
|
|
1618
|
+
},
|
|
1619
|
+
{
|
|
1620
|
+
title: 'reports a requirement form it cannot render',
|
|
1621
|
+
dependencies: [
|
|
1622
|
+
remote('futured', 'https://github.com/acme/futured.git', { upToNextMajor: ['1.0.0'] }),
|
|
1623
|
+
],
|
|
1624
|
+
expected: [{ form: 'unsupported-requirement', identity: 'futured', target: null }],
|
|
1625
|
+
},
|
|
1626
|
+
{
|
|
1627
|
+
title: 'reports a dependency form it does not recognize',
|
|
1628
|
+
dependencies: [{ sourceArchive: [{ identity: 'zipped' }] }],
|
|
1629
|
+
expected: [{ form: 'unknown-form', identity: 'zipped', target: null }],
|
|
1630
|
+
},
|
|
1631
|
+
{
|
|
1632
|
+
title: 'reports a product whose package the manifest never declared, naming the target',
|
|
1633
|
+
targetDeps: [{ product: [...SDWEB_PRODUCT, null, null] }],
|
|
1634
|
+
expected: [{ form: 'undeclared-package', identity: 'SDWebImage', target: 'Main' }],
|
|
1635
|
+
},
|
|
1636
|
+
{
|
|
1637
|
+
title: 'reports a product that names no package at all',
|
|
1638
|
+
targetDeps: [{ product: ['Vendored', null, null, null] }],
|
|
1639
|
+
expected: [{ form: 'undeclared-package', identity: null, target: 'Main' }],
|
|
1640
|
+
},
|
|
1641
|
+
{
|
|
1642
|
+
title: 'does not also call a product of an unmirrorable, declared package undeclared',
|
|
1643
|
+
dependencies: [vendored],
|
|
1644
|
+
targetDeps: [{ product: ['Vendored', 'vendored', null, null] }],
|
|
1645
|
+
expected: [{ form: 'local-path', identity: 'vendored', target: 'Main' }],
|
|
1646
|
+
},
|
|
1647
|
+
{
|
|
1648
|
+
title: 'attributes a product to an unmirrorable package declared under another name',
|
|
1649
|
+
dependencies: [
|
|
1650
|
+
{
|
|
1651
|
+
fileSystem: [
|
|
1652
|
+
{
|
|
1653
|
+
identity: 'libavif-xcode',
|
|
1654
|
+
nameForTargetDependencyResolutionOnly: 'Avif',
|
|
1655
|
+
path: '/abs/libavif-Xcode',
|
|
1656
|
+
},
|
|
1657
|
+
],
|
|
1658
|
+
},
|
|
1659
|
+
],
|
|
1660
|
+
targetDeps: [{ product: ['Avif', 'Avif', null, null] }],
|
|
1661
|
+
expected: [{ form: 'local-path', identity: 'libavif-xcode', target: 'Main' }],
|
|
1662
|
+
},
|
|
1663
|
+
{
|
|
1664
|
+
title: 'still reports a product whose package nothing declares',
|
|
1665
|
+
dependencies: [vendored],
|
|
1666
|
+
targetDeps: [{ product: ['Elsewhere', 'elsewhere', null, null] }],
|
|
1667
|
+
expected: [
|
|
1668
|
+
{ form: 'local-path', identity: 'vendored', target: null },
|
|
1669
|
+
{ form: 'undeclared-package', identity: 'elsewhere', target: 'Main' },
|
|
1670
|
+
],
|
|
1671
|
+
},
|
|
1672
|
+
{
|
|
1673
|
+
title: 'reports two declared packages that answer to one name',
|
|
1674
|
+
dependencies: [
|
|
1675
|
+
remote('libavif', 'https://github.com/acme/libavif.git', { exact: ['2.0.0'] }),
|
|
1676
|
+
remote(
|
|
1677
|
+
'libavif-xcode',
|
|
1678
|
+
'https://github.com/SDWebImage/libavif-Xcode.git',
|
|
1679
|
+
{ exact: ['1.0.0'] },
|
|
1680
|
+
{ nameForTargetDependencyResolutionOnly: 'libavif' }
|
|
1681
|
+
),
|
|
1682
|
+
],
|
|
1683
|
+
expected: [{ form: 'ambiguous-package-name', identity: 'libavif', target: null }],
|
|
1684
|
+
},
|
|
1685
|
+
{
|
|
1686
|
+
title: 'reports a product dependency that renames modules with moduleAliases',
|
|
1687
|
+
dependencies: [SDWEB_IMAGE],
|
|
1688
|
+
targetDeps: [{ product: [...SDWEB_PRODUCT, { SD: 'SDWeb' }, null] }],
|
|
1689
|
+
expected: [{ form: 'module-aliases', identity: 'SDWebImage', target: 'Main' }],
|
|
1690
|
+
},
|
|
1691
|
+
{
|
|
1692
|
+
title: 'says nothing about an empty moduleAliases map',
|
|
1693
|
+
dependencies: [SDWEB_IMAGE],
|
|
1694
|
+
targetDeps: [{ product: [...SDWEB_PRODUCT, {}, null] }],
|
|
1695
|
+
expected: [],
|
|
1696
|
+
},
|
|
1697
|
+
{
|
|
1698
|
+
title: 'reports a product dependency conditioned on something other than platforms',
|
|
1699
|
+
dependencies: [SDWEB_IMAGE],
|
|
1700
|
+
targetDeps: [
|
|
1701
|
+
{ product: [...SDWEB_PRODUCT, null, { platformNames: ['ios'], traits: ['x'] }] },
|
|
1702
|
+
],
|
|
1703
|
+
expected: [{ form: 'unsupported-condition', identity: 'SDWebImage', target: 'Main' }],
|
|
1704
|
+
},
|
|
1705
|
+
{
|
|
1706
|
+
title: 'reports a sibling dependency so conditioned as a dependency, not a package',
|
|
1707
|
+
targetDeps: [{ byName: ['Helper', { traits: ['x'] }] }],
|
|
1708
|
+
expected: [{ form: 'unsupported-target-condition', identity: 'Helper', target: 'Main' }],
|
|
1709
|
+
},
|
|
1710
|
+
{
|
|
1711
|
+
title: 'says nothing about a condition whose only set key is the platform list',
|
|
1712
|
+
dependencies: [SDWEB_IMAGE],
|
|
1713
|
+
targetDeps: [
|
|
1714
|
+
{
|
|
1715
|
+
product: [...SDWEB_PRODUCT, null, { platformNames: ['ios'], traits: null, config: null }],
|
|
1716
|
+
},
|
|
1717
|
+
],
|
|
1718
|
+
expected: [],
|
|
1719
|
+
},
|
|
1720
|
+
{
|
|
1721
|
+
title: 'reports a package declared with a trait set that is not the default',
|
|
1722
|
+
dependencies: [
|
|
1723
|
+
remote(
|
|
1724
|
+
'traited',
|
|
1725
|
+
'https://github.com/acme/traited.git',
|
|
1726
|
+
{ exact: ['1.0.0'] },
|
|
1727
|
+
{ traits: [{ name: 'default' }, { name: 'extras' }] }
|
|
1728
|
+
),
|
|
1729
|
+
],
|
|
1730
|
+
expected: [{ form: 'unsupported-traits', identity: 'traited', target: null }],
|
|
1731
|
+
},
|
|
1732
|
+
])('$title', ({ dependencies = [], targetDeps = [], expected }) => {
|
|
1733
|
+
expect(unsupported(dependencies, targetDeps)).toEqual(expected);
|
|
1734
|
+
});
|
|
1735
|
+
|
|
1736
|
+
it('reports a package whose identity collides with one the injected set occupies', () => {
|
|
1737
|
+
const { unsupportedPackageDeps } = parseDumpedManifest(
|
|
1738
|
+
dumpWith({
|
|
1739
|
+
dependencies: [
|
|
1740
|
+
remote('reactnative', 'https://github.com/acme/ReactNative.git', {
|
|
1741
|
+
exact: ['1.0.0'],
|
|
1742
|
+
}),
|
|
1743
|
+
],
|
|
1744
|
+
}),
|
|
1745
|
+
['ReactNative', 'React-GeneratedCode']
|
|
1746
|
+
);
|
|
1747
|
+
expect(unsupportedPackageDeps).toEqual([
|
|
1748
|
+
{ form: 'collides-with-injected', identity: 'reactnative', target: null },
|
|
1749
|
+
]);
|
|
1750
|
+
});
|
|
1751
|
+
|
|
1752
|
+
it('renders a manifest without dependencies byte for byte', () => {
|
|
1753
|
+
const dump = JSON.stringify({
|
|
1754
|
+
name: 'expo-constants',
|
|
1755
|
+
dependencies: [],
|
|
1756
|
+
platforms: [{ platformName: 'ios', version: '15.1' }],
|
|
1757
|
+
products: [
|
|
1758
|
+
{
|
|
1759
|
+
name: 'EXConstants',
|
|
1760
|
+
type: { library: ['automatic'] },
|
|
1761
|
+
targets: ['EXConstants', 'EXConstantsObjC'],
|
|
1762
|
+
},
|
|
1763
|
+
],
|
|
1764
|
+
targets: [
|
|
1765
|
+
{
|
|
1766
|
+
name: 'EXConstants',
|
|
1767
|
+
type: 'regular',
|
|
1768
|
+
path: 'ios/EXConstants',
|
|
1769
|
+
dependencies: [{ byName: ['EXConstantsObjC', null] }],
|
|
1770
|
+
},
|
|
1771
|
+
{
|
|
1772
|
+
name: 'EXConstantsObjC',
|
|
1773
|
+
type: 'regular',
|
|
1774
|
+
path: 'ios/EXConstantsObjC',
|
|
1775
|
+
publicHeadersPath: 'include',
|
|
1776
|
+
dependencies: [],
|
|
1777
|
+
},
|
|
1778
|
+
],
|
|
1779
|
+
});
|
|
1780
|
+
expect(render(dump)).toBe(`// swift-tools-version: 6.0
|
|
1781
|
+
// AUTO-GENERATED by expo/scripts/spm/plugin.js — do not edit.
|
|
1782
|
+
// Source consumption package for "expo-constants": mirrors the module's checked-in
|
|
1783
|
+
// Package.swift targets and injects invariant React compile dependencies.
|
|
1784
|
+
import PackageDescription
|
|
1785
|
+
|
|
1786
|
+
let package = Package(
|
|
1787
|
+
name: "expo-constants",
|
|
1788
|
+
platforms: [.iOS("15.1")],
|
|
1789
|
+
products: [
|
|
1790
|
+
.library(name: "EXConstants", targets: ["EXConstants", "EXConstantsObjC"])
|
|
1791
|
+
],
|
|
1792
|
+
dependencies: [
|
|
1793
|
+
.package(name: "ReactNative", path: "/abs/rn"),
|
|
1794
|
+
],
|
|
1795
|
+
targets: [
|
|
1796
|
+
.target(
|
|
1797
|
+
name: "EXConstants",
|
|
1798
|
+
dependencies: [
|
|
1799
|
+
"EXConstantsObjC",
|
|
1800
|
+
.product(name: "React", package: "ReactNative"),
|
|
1801
|
+
],
|
|
1802
|
+
path: "root/ios/EXConstants",
|
|
1803
|
+
cSettings: [.unsafeFlags(["-F", "/abs/interfaces"])],
|
|
1804
|
+
cxxSettings: [.unsafeFlags(["-F", "/abs/interfaces"])],
|
|
1805
|
+
swiftSettings: [.unsafeFlags(["-F", "/abs/interfaces"])],
|
|
1806
|
+
),
|
|
1807
|
+
.target(
|
|
1808
|
+
name: "EXConstantsObjC",
|
|
1809
|
+
dependencies: [
|
|
1810
|
+
.product(name: "React", package: "ReactNative"),
|
|
1811
|
+
],
|
|
1812
|
+
path: "root/ios/EXConstantsObjC",
|
|
1813
|
+
publicHeadersPath: "include",
|
|
1814
|
+
cSettings: [.unsafeFlags(["-F", "/abs/interfaces"])],
|
|
1815
|
+
cxxSettings: [.unsafeFlags(["-F", "/abs/interfaces"])],
|
|
1816
|
+
swiftSettings: [.unsafeFlags(["-F", "/abs/interfaces"])],
|
|
1817
|
+
)
|
|
1818
|
+
],
|
|
1819
|
+
swiftLanguageModes: [.v5],
|
|
1820
|
+
cxxLanguageStandard: .cxx20
|
|
1821
|
+
)
|
|
1822
|
+
`);
|
|
1823
|
+
});
|
|
1824
|
+
|
|
1825
|
+
// SwiftPM resolves a `.byName` that is no target of this package against the products
|
|
1826
|
+
// of the packages it declares, which a dumped manifest does not enumerate.
|
|
1827
|
+
it('renders a byName that names no target verbatim rather than dropping it', () => {
|
|
1828
|
+
const dump = dumpWith({
|
|
1829
|
+
dependencies: [LIBAVIF],
|
|
1830
|
+
targetDeps: [
|
|
1831
|
+
{ byName: ['libavif', null] },
|
|
1832
|
+
{ byName: ['SVGKit', { platformNames: ['ios'] }] },
|
|
1833
|
+
],
|
|
1834
|
+
});
|
|
1835
|
+
const { targets, unsupportedPackageDeps } = parseDumpedManifest(dump);
|
|
1836
|
+
expect(unsupportedPackageDeps).toEqual([]);
|
|
1837
|
+
expect(targets[0].dependencies).toEqual(['libavif', { byName: 'SVGKit', platforms: ['ios'] }]);
|
|
1838
|
+
expect(render(dump)).toContain(
|
|
1839
|
+
' "libavif",\n' +
|
|
1840
|
+
' .byName(name: "SVGKit", condition: .when(platforms: [.iOS])),'
|
|
1841
|
+
);
|
|
1842
|
+
});
|
|
1843
|
+
|
|
1844
|
+
// `.package(name:url:)` is deprecated but legal, and the manifest then names the
|
|
1845
|
+
// package by that name rather than by the identity SwiftPM derives from the URL.
|
|
1846
|
+
it('matches a product against the name the manifest gave the package', () => {
|
|
1847
|
+
const named = remote(
|
|
1848
|
+
'libavif-xcode',
|
|
1849
|
+
'https://github.com/SDWebImage/libavif-Xcode.git',
|
|
1850
|
+
{ range: [{ lowerBound: '1.0.0', upperBound: '2.0.0' }] },
|
|
1851
|
+
{ nameForTargetDependencyResolutionOnly: 'libavif' }
|
|
1852
|
+
);
|
|
1853
|
+
const dump = dumpWith({
|
|
1854
|
+
dependencies: [named],
|
|
1855
|
+
targetDeps: [{ product: ['libavif', 'libavif', null, null] }],
|
|
1856
|
+
});
|
|
1857
|
+
expect(parseDumpedManifest(dump).unsupportedPackageDeps).toEqual([]);
|
|
1858
|
+
// The mirrored declaration carries no `name:`, so the product has to name the identity.
|
|
1859
|
+
expect(render(dump)).toContain('.product(name: "libavif", package: "libavif-xcode"),');
|
|
1860
|
+
});
|
|
1861
|
+
|
|
1862
|
+
it('escapes a conditioned sibling target name like every other dependency', () => {
|
|
1863
|
+
const out = renderSourceManifest({
|
|
1864
|
+
manifest: {
|
|
1865
|
+
name: 'TestModule',
|
|
1866
|
+
products: [{ name: 'TestModule', targets: ['Main'] }],
|
|
1867
|
+
targets: [
|
|
1868
|
+
{
|
|
1869
|
+
name: 'Main',
|
|
1870
|
+
path: 'Main',
|
|
1871
|
+
publicHeadersPath: null,
|
|
1872
|
+
dependencies: [{ name: 'We"ird', platforms: ['ios'] }],
|
|
1873
|
+
},
|
|
1874
|
+
],
|
|
1875
|
+
},
|
|
1876
|
+
frameworkSearchPath: '/abs/interfaces',
|
|
1877
|
+
});
|
|
1878
|
+
expect(out).toContain('.target(name: "We\\"ird", condition: .when(platforms: [.iOS]))');
|
|
1879
|
+
});
|
|
1880
|
+
|
|
1881
|
+
describe('emitting a module that declares packages', () => {
|
|
1882
|
+
let moduleRoot;
|
|
1883
|
+
let outDir;
|
|
1884
|
+
|
|
1885
|
+
beforeEach(() => {
|
|
1886
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'expo-spm-pkg-deps-'));
|
|
1887
|
+
moduleRoot = path.join(tmp, 'module');
|
|
1888
|
+
outDir = path.join(tmp, 'out');
|
|
1889
|
+
fs.mkdirSync(path.join(moduleRoot, 'ios', 'Main'), { recursive: true });
|
|
1890
|
+
fs.mkdirSync(path.join(moduleRoot, 'ios', 'Helper'), { recursive: true });
|
|
1891
|
+
});
|
|
1892
|
+
|
|
1893
|
+
const emittedManifestPath = () =>
|
|
1894
|
+
path.join(outDir, 'expo-source', 'TestModule', 'Package.swift');
|
|
1895
|
+
const emittedManifest = () => fs.readFileSync(emittedManifestPath(), 'utf8');
|
|
1896
|
+
const emit = (dump, react, satisfiedDependencies) => {
|
|
1897
|
+
runDumpPackage.mockReturnValue(dump);
|
|
1898
|
+
return emitSourceManifestPackage(moduleRoot, {
|
|
1899
|
+
react,
|
|
1900
|
+
frameworkSearchPath: '/abs/interfaces',
|
|
1901
|
+
outDir,
|
|
1902
|
+
satisfiedDependencies,
|
|
1903
|
+
});
|
|
1904
|
+
};
|
|
1905
|
+
|
|
1906
|
+
// A package can export several products; only the ones a precompiled framework
|
|
1907
|
+
// provides go, and the package stays while anything still depends on it.
|
|
1908
|
+
it('leaves out the products a precompiled framework already provides', () => {
|
|
1909
|
+
const result = emit(
|
|
1910
|
+
dumpWith({
|
|
1911
|
+
dependencies: [SDWEB_IMAGE, LIBAVIF],
|
|
1912
|
+
targetDeps: [
|
|
1913
|
+
{ product: ['SDWebImage', 'SDWebImage', null, null] },
|
|
1914
|
+
{ product: ['SDWebImageMapKit', 'SDWebImage', null, null] },
|
|
1915
|
+
{ product: ['libavif', 'libavif-Xcode', null, null] },
|
|
1916
|
+
],
|
|
1917
|
+
}),
|
|
1918
|
+
null,
|
|
1919
|
+
new Set(['SDWebImage', 'libavif'])
|
|
1920
|
+
);
|
|
1921
|
+
|
|
1922
|
+
expect(result.refusal).toBeUndefined();
|
|
1923
|
+
const manifest = emittedManifest();
|
|
1924
|
+
expect(manifest).not.toContain('.product(name: "SDWebImage"');
|
|
1925
|
+
expect(manifest).toContain('.product(name: "SDWebImageMapKit", package: "SDWebImage"),');
|
|
1926
|
+
expect(manifest).toContain(
|
|
1927
|
+
'.package(url: "https://github.com/SDWebImage/SDWebImage.git", exact: "5.21.6"),'
|
|
1928
|
+
);
|
|
1929
|
+
expect(manifest).not.toContain('.product(name: "libavif"');
|
|
1930
|
+
expect(manifest).not.toContain('libavif-Xcode.git');
|
|
1931
|
+
expect(result.ok.spmProductNames).toEqual(['SDWebImage', 'SDWebImageMapKit', 'libavif']);
|
|
1932
|
+
expect(result.ok.partlyProvidedPackages).toEqual([
|
|
1933
|
+
{
|
|
1934
|
+
url: 'https://github.com/SDWebImage/SDWebImage.git',
|
|
1935
|
+
providedProducts: ['SDWebImage'],
|
|
1936
|
+
keptProducts: ['SDWebImageMapKit'],
|
|
1937
|
+
},
|
|
1938
|
+
]);
|
|
1939
|
+
});
|
|
1940
|
+
|
|
1941
|
+
it('leaves out a provided product in every target, keeping the package another uses', () => {
|
|
1942
|
+
const result = emit(
|
|
1943
|
+
JSON.stringify({
|
|
1944
|
+
name: 'TestModule',
|
|
1945
|
+
dependencies: [SDWEB_IMAGE],
|
|
1946
|
+
products: [{ name: 'TestModule', type: { library: ['automatic'] }, targets: ['Main'] }],
|
|
1947
|
+
targets: [
|
|
1948
|
+
{
|
|
1949
|
+
name: 'Main',
|
|
1950
|
+
type: 'regular',
|
|
1951
|
+
path: 'ios/Main',
|
|
1952
|
+
dependencies: [{ product: ['SDWebImage', 'SDWebImage', null, null] }],
|
|
1953
|
+
},
|
|
1954
|
+
{
|
|
1955
|
+
name: 'Helper',
|
|
1956
|
+
type: 'regular',
|
|
1957
|
+
path: 'ios/Helper',
|
|
1958
|
+
dependencies: [
|
|
1959
|
+
{ product: ['SDWebImage', 'SDWebImage', null, null] },
|
|
1960
|
+
{ product: ['SDWebImageMapKit', 'SDWebImage', null, null] },
|
|
1961
|
+
],
|
|
1962
|
+
},
|
|
1963
|
+
],
|
|
1964
|
+
}),
|
|
1965
|
+
null,
|
|
1966
|
+
new Set(['SDWebImage'])
|
|
1967
|
+
);
|
|
1968
|
+
|
|
1969
|
+
const manifest = emittedManifest();
|
|
1970
|
+
expect(manifest).not.toContain('.product(name: "SDWebImage"');
|
|
1971
|
+
expect(manifest).toContain('.product(name: "SDWebImageMapKit", package: "SDWebImage"),');
|
|
1972
|
+
expect(manifest).toContain(
|
|
1973
|
+
'.package(url: "https://github.com/SDWebImage/SDWebImage.git", exact: "5.21.6"),'
|
|
1974
|
+
);
|
|
1975
|
+
expect(result.ok.partlyProvidedPackages).toEqual([
|
|
1976
|
+
{
|
|
1977
|
+
url: 'https://github.com/SDWebImage/SDWebImage.git',
|
|
1978
|
+
providedProducts: ['SDWebImage'],
|
|
1979
|
+
keptProducts: ['SDWebImageMapKit'],
|
|
1980
|
+
},
|
|
1981
|
+
]);
|
|
1982
|
+
});
|
|
1983
|
+
|
|
1984
|
+
it('leaves out a package once every product taken from it is provided', () => {
|
|
1985
|
+
const result = emit(
|
|
1986
|
+
dumpWith({
|
|
1987
|
+
dependencies: [SDWEB_IMAGE],
|
|
1988
|
+
targetDeps: [{ product: ['SDWebImage', 'SDWebImage', null, null] }],
|
|
1989
|
+
}),
|
|
1990
|
+
null,
|
|
1991
|
+
new Set(['SDWebImage'])
|
|
1992
|
+
);
|
|
1993
|
+
|
|
1994
|
+
expect(emittedManifest()).not.toContain('SDWebImage.git');
|
|
1995
|
+
expect(emittedManifest()).not.toContain('.product(name: "SDWebImage"');
|
|
1996
|
+
expect(result.ok.partlyProvidedPackages).toEqual([]);
|
|
1997
|
+
});
|
|
1998
|
+
|
|
1999
|
+
it('leaves out a byName dependency on a product a precompiled framework provides', () => {
|
|
2000
|
+
const result = emit(
|
|
2001
|
+
dumpWith({
|
|
2002
|
+
dependencies: [SDWEB_IMAGE],
|
|
2003
|
+
targetDeps: [
|
|
2004
|
+
{ byName: ['SDWebImage', null] },
|
|
2005
|
+
{ byName: ['SDWebImage', { platformNames: ['ios'] }] },
|
|
2006
|
+
],
|
|
2007
|
+
}),
|
|
2008
|
+
null,
|
|
2009
|
+
new Set(['SDWebImage'])
|
|
2010
|
+
);
|
|
2011
|
+
|
|
2012
|
+
expect(emittedManifest()).not.toContain('"SDWebImage"');
|
|
2013
|
+
expect(emittedManifest()).not.toContain('SDWebImage.git');
|
|
2014
|
+
expect(result.ok.spmProductNames).toEqual(['SDWebImage']);
|
|
2015
|
+
expect(result.ok.partlyProvidedPackages).toEqual([]);
|
|
2016
|
+
});
|
|
2017
|
+
|
|
2018
|
+
// Which package a bare name comes from is unknown, so its loss names no package.
|
|
2019
|
+
it('reports a skipped byName dependency once, with every package still declared', () => {
|
|
2020
|
+
const result = emit(
|
|
2021
|
+
dumpWith({
|
|
2022
|
+
dependencies: [SDWEB_IMAGE, LIBAVIF],
|
|
2023
|
+
targetDeps: [
|
|
2024
|
+
{ byName: ['SDWebImage', null] },
|
|
2025
|
+
{ product: ['libavif', 'libavif-Xcode', null, null] },
|
|
2026
|
+
],
|
|
2027
|
+
}),
|
|
2028
|
+
null,
|
|
2029
|
+
new Set(['SDWebImage'])
|
|
2030
|
+
);
|
|
2031
|
+
|
|
2032
|
+
expect(emittedManifest()).not.toContain('"SDWebImage"');
|
|
2033
|
+
expect(emittedManifest()).not.toContain('SDWebImage.git');
|
|
2034
|
+
expect(emittedManifest()).toContain('libavif-Xcode.git');
|
|
2035
|
+
expect(result.ok.partlyProvidedPackages).toEqual([
|
|
2036
|
+
{
|
|
2037
|
+
providedProducts: ['SDWebImage'],
|
|
2038
|
+
keptPackages: ['https://github.com/SDWebImage/libavif-Xcode.git'],
|
|
2039
|
+
},
|
|
2040
|
+
]);
|
|
2041
|
+
});
|
|
2042
|
+
|
|
2043
|
+
// A bare name does not say which package it comes from, so it keeps them all.
|
|
2044
|
+
it('keeps a package a remaining byName dependency may take a product from', () => {
|
|
2045
|
+
const result = emit(
|
|
2046
|
+
dumpWith({
|
|
2047
|
+
dependencies: [SDWEB_IMAGE],
|
|
2048
|
+
targetDeps: [
|
|
2049
|
+
{ product: ['SDWebImage', 'SDWebImage', null, null] },
|
|
2050
|
+
{ byName: ['SDWebImageMapKit', null] },
|
|
2051
|
+
],
|
|
2052
|
+
}),
|
|
2053
|
+
null,
|
|
2054
|
+
new Set(['SDWebImage'])
|
|
2055
|
+
);
|
|
2056
|
+
|
|
2057
|
+
expect(emittedManifest()).not.toContain('.product(name: "SDWebImage"');
|
|
2058
|
+
expect(emittedManifest()).toContain('"SDWebImageMapKit",');
|
|
2059
|
+
expect(emittedManifest()).toContain(
|
|
2060
|
+
'.package(url: "https://github.com/SDWebImage/SDWebImage.git", exact: "5.21.6"),'
|
|
2061
|
+
);
|
|
2062
|
+
expect(result.ok.partlyProvidedPackages).toEqual([
|
|
2063
|
+
{
|
|
2064
|
+
url: 'https://github.com/SDWebImage/SDWebImage.git',
|
|
2065
|
+
providedProducts: ['SDWebImage'],
|
|
2066
|
+
keptProducts: [],
|
|
2067
|
+
unattributedNames: ['SDWebImageMapKit'],
|
|
2068
|
+
},
|
|
2069
|
+
]);
|
|
2070
|
+
});
|
|
2071
|
+
|
|
2072
|
+
it('does not attribute a remaining byName dependency to a package that lost a product', () => {
|
|
2073
|
+
const LOTTIE = remote('lottie-spm', 'https://github.com/airbnb/lottie-spm.git', {
|
|
2074
|
+
exact: ['4.5.0'],
|
|
2075
|
+
});
|
|
2076
|
+
const result = emit(
|
|
2077
|
+
dumpWith({
|
|
2078
|
+
dependencies: [SDWEB_IMAGE, LOTTIE],
|
|
2079
|
+
targetDeps: [
|
|
2080
|
+
{ product: ['SDWebImage', 'SDWebImage', null, null] },
|
|
2081
|
+
{ byName: ['Lottie', null] },
|
|
2082
|
+
],
|
|
2083
|
+
}),
|
|
2084
|
+
null,
|
|
2085
|
+
new Set(['SDWebImage'])
|
|
2086
|
+
);
|
|
2087
|
+
|
|
2088
|
+
expect(emittedManifest()).toContain('SDWebImage.git');
|
|
2089
|
+
expect(emittedManifest()).toContain('lottie-spm.git');
|
|
2090
|
+
expect(result.ok.partlyProvidedPackages).toEqual([
|
|
2091
|
+
{
|
|
2092
|
+
url: 'https://github.com/SDWebImage/SDWebImage.git',
|
|
2093
|
+
providedProducts: ['SDWebImage'],
|
|
2094
|
+
keptProducts: [],
|
|
2095
|
+
unattributedNames: ['Lottie'],
|
|
2096
|
+
},
|
|
2097
|
+
]);
|
|
2098
|
+
});
|
|
2099
|
+
|
|
2100
|
+
it('keeps the packages for a remaining byName dependency with a condition', () => {
|
|
2101
|
+
emit(
|
|
2102
|
+
dumpWith({
|
|
2103
|
+
dependencies: [SDWEB_IMAGE],
|
|
2104
|
+
targetDeps: [
|
|
2105
|
+
{ product: ['SDWebImage', 'SDWebImage', null, null] },
|
|
2106
|
+
{ byName: ['SDWebImageMapKit', { platformNames: ['ios'] }] },
|
|
2107
|
+
],
|
|
2108
|
+
}),
|
|
2109
|
+
null,
|
|
2110
|
+
new Set(['SDWebImage'])
|
|
2111
|
+
);
|
|
2112
|
+
|
|
2113
|
+
expect(emittedManifest()).not.toContain('.product(name: "SDWebImage"');
|
|
2114
|
+
expect(emittedManifest()).toContain('.byName(name: "SDWebImageMapKit", condition:');
|
|
2115
|
+
expect(emittedManifest()).toContain(
|
|
2116
|
+
'.package(url: "https://github.com/SDWebImage/SDWebImage.git", exact: "5.21.6"),'
|
|
2117
|
+
);
|
|
2118
|
+
});
|
|
2119
|
+
|
|
2120
|
+
it('keeps a dependency on a sibling target named like a provided product', () => {
|
|
2121
|
+
emit(dumpWith({ targetDeps: [{ byName: ['Helper', null] }] }), null, new Set(['Helper']));
|
|
2122
|
+
|
|
2123
|
+
expect(emittedManifest()).toContain(
|
|
2124
|
+
'dependencies: [\n "Helper",\n ],'
|
|
2125
|
+
);
|
|
2126
|
+
});
|
|
2127
|
+
|
|
2128
|
+
it('carries the module packages and their products into the emitted manifest', () => {
|
|
2129
|
+
const result = emit(
|
|
2130
|
+
dumpWith({
|
|
2131
|
+
dependencies: [SDWEB_IMAGE],
|
|
2132
|
+
targetDeps: [{ product: ['SDWebImage', 'SDWebImage', null, null] }],
|
|
2133
|
+
})
|
|
2134
|
+
);
|
|
2135
|
+
|
|
2136
|
+
expect(result.refusal).toBeUndefined();
|
|
2137
|
+
expect(emittedManifest()).toContain(
|
|
2138
|
+
'.package(url: "https://github.com/SDWebImage/SDWebImage.git", exact: "5.21.6"),'
|
|
2139
|
+
);
|
|
2140
|
+
expect(emittedManifest()).toContain('.product(name: "SDWebImage", package: "SDWebImage"),');
|
|
2141
|
+
expect(result.ok.partlyProvidedPackages).toEqual([]);
|
|
2142
|
+
});
|
|
2143
|
+
|
|
2144
|
+
it('skips the module instead of emitting a manifest missing a package it declares', () => {
|
|
2145
|
+
const result = emit(
|
|
2146
|
+
dumpWith({ dependencies: [{ fileSystem: [{ identity: 'local-thing', path: '/abs' }] }] })
|
|
2147
|
+
);
|
|
2148
|
+
|
|
2149
|
+
expect(result.ok).toBeUndefined();
|
|
2150
|
+
expect(result.refusal).toEqual({
|
|
2151
|
+
reason: 'unsupported-package-dependency',
|
|
2152
|
+
dependencies: [{ form: 'local-path', identity: 'local-thing', target: null }],
|
|
2153
|
+
});
|
|
2154
|
+
expect(fs.existsSync(emittedManifestPath())).toBe(false);
|
|
2155
|
+
});
|
|
2156
|
+
|
|
2157
|
+
// `unmappedPodDependencies` subtracts these from the pods the module's podspec
|
|
2158
|
+
// names, matching a pod against the PRODUCT name, not the package identity.
|
|
2159
|
+
it('names the third-party products it mirrored, and no sibling target', () => {
|
|
2160
|
+
const result = emit(
|
|
2161
|
+
JSON.stringify({
|
|
2162
|
+
name: 'TestModule',
|
|
2163
|
+
dependencies: [
|
|
2164
|
+
SDWEB_IMAGE,
|
|
2165
|
+
LIBAVIF,
|
|
2166
|
+
remote('branchy', 'https://github.com/acme/branchy.git', { branch: ['main'] }),
|
|
2167
|
+
],
|
|
2168
|
+
products: [{ name: 'TestModule', type: { library: ['automatic'] }, targets: ['Main'] }],
|
|
2169
|
+
targets: [
|
|
2170
|
+
{
|
|
2171
|
+
name: 'Main',
|
|
2172
|
+
type: 'regular',
|
|
2173
|
+
path: 'ios/Main',
|
|
2174
|
+
dependencies: [
|
|
2175
|
+
{ byName: ['Helper', null] },
|
|
2176
|
+
{ product: ['SDWebImage', 'SDWebImage', null, null] },
|
|
2177
|
+
{ byName: ['branchy', null] },
|
|
2178
|
+
],
|
|
2179
|
+
},
|
|
2180
|
+
{
|
|
2181
|
+
name: 'Helper',
|
|
2182
|
+
type: 'regular',
|
|
2183
|
+
path: 'ios/Helper',
|
|
2184
|
+
dependencies: [
|
|
2185
|
+
{ product: ['libavif', 'libavif-Xcode', null, { platformNames: ['ios'] }] },
|
|
2186
|
+
{ product: ['SDWebImage', 'SDWebImage', null, null] },
|
|
2187
|
+
],
|
|
2188
|
+
},
|
|
2189
|
+
],
|
|
2190
|
+
})
|
|
2191
|
+
);
|
|
2192
|
+
|
|
2193
|
+
expect(result.ok.spmProductNames).toEqual(['SDWebImage', 'branchy', 'libavif']);
|
|
2194
|
+
});
|
|
2195
|
+
|
|
2196
|
+
it('counts a byName that names no target as a product it mirrored', () => {
|
|
2197
|
+
const result = emit(
|
|
2198
|
+
dumpWith({
|
|
2199
|
+
dependencies: [LIBAVIF],
|
|
2200
|
+
targetDeps: [{ byName: ['Helper', null] }, { byName: ['libavif', null] }],
|
|
2201
|
+
})
|
|
2202
|
+
);
|
|
2203
|
+
|
|
2204
|
+
expect(result.ok.spmProductNames).toEqual(['libavif']);
|
|
2205
|
+
});
|
|
2206
|
+
|
|
2207
|
+
// A path package's SwiftPM identity is its directory name, whatever `name:` calls it.
|
|
2208
|
+
it('occupies the identity of a path-based React package, not only its name', () => {
|
|
2209
|
+
const result = emit(
|
|
2210
|
+
dumpWith({
|
|
2211
|
+
dependencies: [remote('rn', 'https://github.com/acme/rn.git', { exact: ['1.0.0'] })],
|
|
2212
|
+
}),
|
|
2213
|
+
{ packageRef: { name: 'ReactNative', path: '/abs/checkout/rn' }, products: [] }
|
|
2214
|
+
);
|
|
2215
|
+
|
|
2216
|
+
expect(result.refusal).toEqual({
|
|
2217
|
+
reason: 'unsupported-package-dependency',
|
|
2218
|
+
dependencies: [{ form: 'collides-with-injected', identity: 'rn', target: null }],
|
|
2219
|
+
});
|
|
2220
|
+
});
|
|
2221
|
+
|
|
2222
|
+
it('takes the identities the injected set occupies from the React descriptor', () => {
|
|
2223
|
+
const result = emit(
|
|
2224
|
+
dumpWith({
|
|
2225
|
+
dependencies: [
|
|
2226
|
+
remote('reactnative', 'https://github.com/acme/ReactNative.git', { exact: ['1.0.0'] }),
|
|
2227
|
+
],
|
|
2228
|
+
}),
|
|
2229
|
+
{
|
|
2230
|
+
packageRef: { name: 'ReactNative', path: '/abs/rn' },
|
|
2231
|
+
products: [{ name: 'React', package: 'ReactNative' }],
|
|
2232
|
+
}
|
|
2233
|
+
);
|
|
2234
|
+
|
|
2235
|
+
expect(result.refusal).toEqual({
|
|
2236
|
+
reason: 'unsupported-package-dependency',
|
|
2237
|
+
dependencies: [{ form: 'collides-with-injected', identity: 'reactnative', target: null }],
|
|
2238
|
+
});
|
|
2239
|
+
});
|
|
2240
|
+
});
|
|
2241
|
+
});
|