expo 58.0.17 → 58.0.19
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/bundledNativeModules.json +15 -15
- package/package.json +11 -11
- package/scripts/spm/README.md +43 -3
- package/scripts/spm/__tests__/cli.test.js +17 -2
- package/scripts/spm/__tests__/commands.test.js +61 -0
- package/scripts/spm/__tests__/diagnostics.test.js +210 -9
- package/scripts/spm/__tests__/direct.test.js +387 -0
- package/scripts/spm/__tests__/flavored-frameworks.test.js +127 -0
- package/scripts/spm/__tests__/helpers.js +9 -0
- package/scripts/spm/__tests__/manifests.test.js +38 -50
- package/scripts/spm/__tests__/plugin.test.js +1238 -53
- package/scripts/spm/__tests__/precompiled-sources.test.js +139 -0
- package/scripts/spm/classify.js +8 -6
- package/scripts/spm/cli.js +11 -4
- package/scripts/spm/commands.js +18 -1
- package/scripts/spm/diagnostics.js +112 -8
- package/scripts/spm/direct.js +215 -0
- package/scripts/spm/flavored-frameworks.js +125 -40
- package/scripts/spm/manifests.js +4 -3
- package/scripts/spm/plugin.js +432 -82
- package/template.tgz +0 -0
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
jest.mock('../cli', () => ({
|
|
8
|
+
runDumpPackage: jest.fn(() =>
|
|
9
|
+
JSON.stringify({ name: 'ExpoHaptics', products: [{ name: 'ExpoHaptics' }] })
|
|
10
|
+
),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
const { runDumpPackage } = require('../cli');
|
|
14
|
+
const {
|
|
15
|
+
dependsOnCoreHeaders,
|
|
16
|
+
dumpModuleManifest,
|
|
17
|
+
emitDirectPackage,
|
|
18
|
+
prepareDirectWatchPaths,
|
|
19
|
+
} = require('../direct');
|
|
20
|
+
const { rerunSpmUpdate, thrownBy } = require('./helpers');
|
|
21
|
+
|
|
22
|
+
const hapticsManifest = {
|
|
23
|
+
name: 'expo-haptics',
|
|
24
|
+
products: [{ name: 'ExpoHaptics' }, { name: 'ExpoHapticsExtras' }],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** A dumped manifest whose one target depends on `dependencies`. */
|
|
28
|
+
const manifestDependingOn = (...dependencies) => ({
|
|
29
|
+
name: 'expo-haptics',
|
|
30
|
+
products: [{ name: 'ExpoHaptics' }],
|
|
31
|
+
targets: [{ name: 'ExpoHaptics', type: 'regular', dependencies }],
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('dependsOnCoreHeaders', () => {
|
|
35
|
+
// Verbatim shape from `swift package dump-package` (Swift 6.4) of a manifest with
|
|
36
|
+
// `.product(name: "ExpoModulesCoreHeaders", package: "ExpoModulesCoreHeaders")`.
|
|
37
|
+
const coreHeadersProduct = {
|
|
38
|
+
product: ['ExpoModulesCoreHeaders', 'ExpoModulesCoreHeaders', null, null],
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
it('is true when a target depends on the ExpoModulesCoreHeaders product', () => {
|
|
42
|
+
expect(
|
|
43
|
+
dependsOnCoreHeaders({
|
|
44
|
+
...manifestDependingOn(),
|
|
45
|
+
targets: [
|
|
46
|
+
{ name: 'ExpoHapticsObjC', type: 'regular', dependencies: [] },
|
|
47
|
+
{ name: 'ExpoHaptics', type: 'regular', dependencies: [coreHeadersProduct] },
|
|
48
|
+
],
|
|
49
|
+
})
|
|
50
|
+
).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// `.byName(name:)` and a bare string both dump as `byName`; SwiftPM resolves the name to
|
|
54
|
+
// a product of a package dependency when no target has it.
|
|
55
|
+
it.each([
|
|
56
|
+
['without a condition', { byName: ['ExpoModulesCoreHeaders', null] }],
|
|
57
|
+
['with a condition', { byName: ['ExpoModulesCoreHeaders', { platformNames: ['ios'] }] }],
|
|
58
|
+
])('is true for a dependency by name %s', (_, dependency) => {
|
|
59
|
+
expect(dependsOnCoreHeaders(manifestDependingOn(dependency))).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it.each([
|
|
63
|
+
['no target dependencies', manifestDependingOn()],
|
|
64
|
+
['a dependency on another name', manifestDependingOn({ byName: ['ExpoModulesCore', null] })],
|
|
65
|
+
[
|
|
66
|
+
'another product',
|
|
67
|
+
manifestDependingOn({ product: ['ExpoModulesCore', 'ExpoModulesCore', null, null] }),
|
|
68
|
+
],
|
|
69
|
+
['a target of that name', manifestDependingOn({ target: ['ExpoModulesCoreHeaders', null] })],
|
|
70
|
+
[
|
|
71
|
+
'only a package dependency',
|
|
72
|
+
{
|
|
73
|
+
...manifestDependingOn(),
|
|
74
|
+
dependencies: [{ fileSystem: [{ identity: 'expomodulescoreheaders' }] }],
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
['no targets', { name: 'expo-haptics', products: [] }],
|
|
78
|
+
])('is false for a manifest with %s', (_, manifest) => {
|
|
79
|
+
expect(dependsOnCoreHeaders(manifest)).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('dumpModuleManifest', () => {
|
|
84
|
+
const moduleRoot = path.join(os.tmpdir(), 'expo-haptics');
|
|
85
|
+
const dump = () => dumpModuleManifest(moduleRoot, 'expo-haptics');
|
|
86
|
+
|
|
87
|
+
it('returns the JSON the tool printed and its parse', () => {
|
|
88
|
+
const json = JSON.stringify(hapticsManifest);
|
|
89
|
+
runDumpPackage.mockReturnValueOnce(json);
|
|
90
|
+
expect(dump()).toEqual({ json, manifest: hapticsManifest });
|
|
91
|
+
expect(runDumpPackage).toHaveBeenLastCalledWith(moduleRoot);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('when the Package.swift cannot be evaluated', () => {
|
|
95
|
+
const failWith = (error) =>
|
|
96
|
+
runDumpPackage.mockImplementationOnce(() => {
|
|
97
|
+
throw error;
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('names the package, the first line the tool printed, and how to fix it', () => {
|
|
101
|
+
const error = Object.assign(new Error('Command failed: swift package dump-package'), {
|
|
102
|
+
status: 1,
|
|
103
|
+
stderr: '\nerror: Invalid manifest\nPackage.swift:3:1: error: expected expression\n',
|
|
104
|
+
});
|
|
105
|
+
failWith(error);
|
|
106
|
+
const thrown = thrownBy(dump);
|
|
107
|
+
expect(thrown.message).toContain(
|
|
108
|
+
"expo-haptics's Package.swift could not be evaluated: error: Invalid manifest."
|
|
109
|
+
);
|
|
110
|
+
expect(thrown.message).toContain('`swift package dump-package`');
|
|
111
|
+
expect(thrown.message).toContain(moduleRoot);
|
|
112
|
+
expect(thrown.message).toContain('xcode-select');
|
|
113
|
+
expect(thrown.message).toContain(rerunSpmUpdate);
|
|
114
|
+
expect(thrown.cause).toBe(error);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('says the swift command was not found when it is missing', () => {
|
|
118
|
+
failWith(Object.assign(new Error('spawnSync swift ENOENT'), { code: 'ENOENT' }));
|
|
119
|
+
expect(thrownBy(dump).message).toContain(
|
|
120
|
+
"expo-haptics's Package.swift could not be evaluated: the swift command was not found."
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('says what the tool printed is not a manifest', () => {
|
|
125
|
+
runDumpPackage.mockReturnValueOnce('warning: not JSON');
|
|
126
|
+
const thrown = thrownBy(dump);
|
|
127
|
+
expect(thrown.message).toContain("expo-haptics's Package.swift could not be evaluated:");
|
|
128
|
+
expect(thrown.cause).toBeInstanceOf(SyntaxError);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe('emitDirectPackage', () => {
|
|
134
|
+
const savedBuildDir = process.env.BUILD_DIR;
|
|
135
|
+
let root;
|
|
136
|
+
let outDir;
|
|
137
|
+
let pkgDir;
|
|
138
|
+
let coreHeadersXCFramework;
|
|
139
|
+
let jsiHeadersPkgPath;
|
|
140
|
+
|
|
141
|
+
const emit = () =>
|
|
142
|
+
emitDirectPackage({
|
|
143
|
+
moduleRoot: path.join(root, 'expo-haptics'),
|
|
144
|
+
packageName: 'expo-haptics',
|
|
145
|
+
outDir,
|
|
146
|
+
coreHeadersXCFramework,
|
|
147
|
+
jsiHeadersPkgPath,
|
|
148
|
+
macroTool: path.join(root, 'ExpoModulesMacros'),
|
|
149
|
+
manifest: hapticsManifest,
|
|
150
|
+
});
|
|
151
|
+
const manifest = () => fs.readFileSync(path.join(pkgDir, 'Package.swift'), 'utf8');
|
|
152
|
+
|
|
153
|
+
beforeEach(() => {
|
|
154
|
+
delete process.env.BUILD_DIR;
|
|
155
|
+
root = fs.mkdtempSync(path.join(os.tmpdir(), 'direct-emit-'));
|
|
156
|
+
outDir = path.join(root, 'out');
|
|
157
|
+
pkgDir = path.join(outDir, 'direct', 'ExpoModulesCoreHeaders');
|
|
158
|
+
jsiHeadersPkgPath = path.join(outDir, 'ExpoModulesJSIHeaders');
|
|
159
|
+
fs.mkdirSync(path.join(root, 'expo-haptics'));
|
|
160
|
+
coreHeadersXCFramework = path.join(
|
|
161
|
+
root,
|
|
162
|
+
'expo-modules-core',
|
|
163
|
+
'headers',
|
|
164
|
+
'ExpoModulesCoreHeaders.xcframework'
|
|
165
|
+
);
|
|
166
|
+
fs.mkdirSync(coreHeadersXCFramework, { recursive: true });
|
|
167
|
+
fs.writeFileSync(path.join(coreHeadersXCFramework, 'Info.plist'), '<plist/>');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
afterEach(() => {
|
|
171
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
172
|
+
if (savedBuildDir === undefined) {
|
|
173
|
+
delete process.env.BUILD_DIR;
|
|
174
|
+
} else {
|
|
175
|
+
process.env.BUILD_DIR = savedBuildDir;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('declares one product over the ExpoModulesCore headers binary target', () => {
|
|
180
|
+
emit();
|
|
181
|
+
expect(manifest().match(/\.binaryTarget\(/g)).toHaveLength(1);
|
|
182
|
+
expect(manifest()).toContain(
|
|
183
|
+
'.binaryTarget(name: "ExpoModulesCoreHeaders", path: "ExpoModulesCoreHeaders.xcframework")'
|
|
184
|
+
);
|
|
185
|
+
expect(manifest().match(/\.library\(/g)).toHaveLength(1);
|
|
186
|
+
expect(manifest()).toMatch(
|
|
187
|
+
/\.library\(name: "ExpoModulesCoreHeaders", targets: \["ExpoModulesCoreHeaders"/
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// The ExpoModulesJSI headers package declares that target too, and SwiftPM rejects a
|
|
192
|
+
// graph with two targets of one name.
|
|
193
|
+
it('declares no ExpoModulesJSIHeaders target, and depends on the JSI headers package by path', () => {
|
|
194
|
+
emit();
|
|
195
|
+
expect(manifest()).not.toMatch(/\.(binaryTarget|target)\(name: "ExpoModulesJSIHeaders"/);
|
|
196
|
+
expect(manifest()).toContain(
|
|
197
|
+
'.package(name: "ExpoModulesJSIHeaders", path: "../../ExpoModulesJSIHeaders")'
|
|
198
|
+
);
|
|
199
|
+
expect(manifest()).toContain(
|
|
200
|
+
'.product(name: "ExpoModulesJSIHeaders", package: "ExpoModulesJSIHeaders")'
|
|
201
|
+
);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('fails, writing no package, when there is no JSI headers package', () => {
|
|
205
|
+
jsiHeadersPkgPath = null;
|
|
206
|
+
expect(emit).toThrow(
|
|
207
|
+
'expo-haptics is built from its own Package.swift and needs the ExpoModulesJSI headers, but expo-modules-jsi is not autolinked.'
|
|
208
|
+
);
|
|
209
|
+
expect(emit).toThrow('re-export ExpoModulesJSI');
|
|
210
|
+
expect(emit).toThrow('"expo": { "autolinking": { "exclude": [...] } }');
|
|
211
|
+
expect(emit).toThrow(rerunSpmUpdate);
|
|
212
|
+
expect(fs.existsSync(path.join(outDir, 'direct'))).toBe(false);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('places the ExpoModulesCore headers xcframework in the package by link', () => {
|
|
216
|
+
emit();
|
|
217
|
+
const link = path.join(pkgDir, 'ExpoModulesCoreHeaders.xcframework');
|
|
218
|
+
expect(fs.lstatSync(link).isSymbolicLink()).toBe(true);
|
|
219
|
+
expect(fs.realpathSync(link)).toBe(fs.realpathSync(coreHeadersXCFramework));
|
|
220
|
+
expect(fs.existsSync(path.join(pkgDir, 'ExpoModulesJSIHeaders.xcframework'))).toBe(false);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it('replaces the xcframework an earlier plugin generated in the package', () => {
|
|
224
|
+
const generated = path.join(pkgDir, 'ExpoModulesCoreHeaders.xcframework');
|
|
225
|
+
fs.mkdirSync(path.join(generated, 'ios-arm64'), { recursive: true });
|
|
226
|
+
emit();
|
|
227
|
+
expect(fs.realpathSync(generated)).toBe(fs.realpathSync(coreHeadersXCFramework));
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it('removes the stubs directory an earlier plugin generated in the package', () => {
|
|
231
|
+
const stubs = path.join(pkgDir, '.stubs');
|
|
232
|
+
fs.mkdirSync(path.join(stubs, 'ExpoModulesCore'), { recursive: true });
|
|
233
|
+
emit();
|
|
234
|
+
expect(fs.existsSync(stubs)).toBe(false);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it('moves the xcframework link when the ExpoModulesCore headers come from another path', () => {
|
|
238
|
+
emit();
|
|
239
|
+
coreHeadersXCFramework = path.join(root, 'other', 'ExpoModulesCoreHeaders.xcframework');
|
|
240
|
+
fs.mkdirSync(coreHeadersXCFramework, { recursive: true });
|
|
241
|
+
emit();
|
|
242
|
+
const link = path.join(pkgDir, 'ExpoModulesCoreHeaders.xcframework');
|
|
243
|
+
expect(fs.realpathSync(link)).toBe(fs.realpathSync(coreHeadersXCFramework));
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('links a scoped package under its scope directory', () => {
|
|
247
|
+
const moduleRoot = path.join(root, 'node_modules', '@acme', 'widgets');
|
|
248
|
+
fs.mkdirSync(moduleRoot, { recursive: true });
|
|
249
|
+
const { ok } = emitDirectPackage({
|
|
250
|
+
moduleRoot,
|
|
251
|
+
packageName: '@acme/widgets',
|
|
252
|
+
outDir,
|
|
253
|
+
coreHeadersXCFramework,
|
|
254
|
+
jsiHeadersPkgPath,
|
|
255
|
+
macroTool: path.join(root, 'ExpoModulesMacros'),
|
|
256
|
+
manifest: hapticsManifest,
|
|
257
|
+
});
|
|
258
|
+
const link = path.join(outDir, 'direct', '@acme', 'widgets');
|
|
259
|
+
expect(ok.packageDep.path).toBe(link);
|
|
260
|
+
expect(fs.realpathSync(link)).toBe(fs.realpathSync(moduleRoot));
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// That package is written under its SwiftPM package name, which need not be the npm name.
|
|
264
|
+
it('removes the package an earlier sync generated from the manifest', () => {
|
|
265
|
+
const generated = path.join(outDir, 'expo-source', 'ExpoHapticsPackage');
|
|
266
|
+
fs.mkdirSync(generated, { recursive: true });
|
|
267
|
+
fs.writeFileSync(path.join(generated, 'Package.swift'), '// generated\n');
|
|
268
|
+
emitDirectPackage({
|
|
269
|
+
moduleRoot: path.join(root, 'expo-haptics'),
|
|
270
|
+
packageName: 'expo-haptics',
|
|
271
|
+
outDir,
|
|
272
|
+
coreHeadersXCFramework,
|
|
273
|
+
jsiHeadersPkgPath,
|
|
274
|
+
macroTool: path.join(root, 'ExpoModulesMacros'),
|
|
275
|
+
manifest: { ...hapticsManifest, name: 'ExpoHapticsPackage' },
|
|
276
|
+
});
|
|
277
|
+
expect(fs.existsSync(generated)).toBe(false);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
it('links the products of the manifest it is given, without dumping it again', () => {
|
|
281
|
+
runDumpPackage.mockClear();
|
|
282
|
+
const { ok } = emit();
|
|
283
|
+
expect(runDumpPackage).not.toHaveBeenCalled();
|
|
284
|
+
expect(ok.packageDep).toEqual({
|
|
285
|
+
name: 'expo-haptics',
|
|
286
|
+
path: path.join(outDir, 'direct', 'expo-haptics'),
|
|
287
|
+
});
|
|
288
|
+
expect(ok.productDeps).toEqual([
|
|
289
|
+
{ name: 'ExpoHaptics', package: 'expo-haptics' },
|
|
290
|
+
{ name: 'ExpoHapticsExtras', package: 'expo-haptics' },
|
|
291
|
+
]);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it('changes no file in the package when emitted again with the same inputs', () => {
|
|
295
|
+
emit();
|
|
296
|
+
const snapshot = () =>
|
|
297
|
+
fs
|
|
298
|
+
.readdirSync(pkgDir, { recursive: true })
|
|
299
|
+
.sort()
|
|
300
|
+
.map((entry) => {
|
|
301
|
+
const stat = fs.lstatSync(path.join(pkgDir, entry), { bigint: true });
|
|
302
|
+
return [entry, stat.ino, stat.mtimeNs];
|
|
303
|
+
});
|
|
304
|
+
const first = snapshot();
|
|
305
|
+
emit();
|
|
306
|
+
expect(snapshot()).toEqual(first);
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
describe('prepareDirectWatchPaths', () => {
|
|
311
|
+
const savedBuildDir = process.env.BUILD_DIR;
|
|
312
|
+
let outDir;
|
|
313
|
+
beforeEach(() => {
|
|
314
|
+
outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'direct-watch-'));
|
|
315
|
+
});
|
|
316
|
+
afterEach(() => {
|
|
317
|
+
fs.rmSync(outDir, { recursive: true, force: true });
|
|
318
|
+
if (savedBuildDir === undefined) {
|
|
319
|
+
delete process.env.BUILD_DIR;
|
|
320
|
+
} else {
|
|
321
|
+
process.env.BUILD_DIR = savedBuildDir;
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
// Clean Build Folder deletes the macro plugin link while RN's sync stamp survives.
|
|
326
|
+
// A watched path that has vanished makes RN re-sync then.
|
|
327
|
+
it('watches the macro plugin link when a direct module is emitted', () => {
|
|
328
|
+
process.env.BUILD_DIR = '/tmp/Build/Products';
|
|
329
|
+
expect(prepareDirectWatchPaths(['expo-haptics'], outDir)).toEqual([
|
|
330
|
+
path.join('/tmp/Build/Products', 'ExpoModulesMacros'),
|
|
331
|
+
]);
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it('watches nothing when no direct module is emitted', () => {
|
|
335
|
+
process.env.BUILD_DIR = '/tmp/Build/Products';
|
|
336
|
+
expect(prepareDirectWatchPaths([], outDir)).toEqual([]);
|
|
337
|
+
delete process.env.BUILD_DIR;
|
|
338
|
+
expect(prepareDirectWatchPaths([], outDir)).toEqual([]);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// A command-line sync has no BUILD_DIR, so it cannot create the link, yet it writes a
|
|
342
|
+
// fresh stamp. RN keeps only watched paths that exist and re-syncs when one is newer
|
|
343
|
+
// than the stamp, so the marker must exist and stay newer than any later stamp.
|
|
344
|
+
it('forces the next build to sync when sync runs outside a build', () => {
|
|
345
|
+
delete process.env.BUILD_DIR;
|
|
346
|
+
const watched = prepareDirectWatchPaths(['expo-haptics'], outDir);
|
|
347
|
+
expect(watched).toHaveLength(1);
|
|
348
|
+
expect(fs.existsSync(watched[0])).toBe(true);
|
|
349
|
+
expect(fs.statSync(watched[0]).mtimeMs).toBeGreaterThan(Date.now() + 365 * 24 * 3600 * 1000);
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
it('leaves the marker untouched when a later sync outside a build finds it in place', () => {
|
|
353
|
+
delete process.env.BUILD_DIR;
|
|
354
|
+
prepareDirectWatchPaths(['expo-haptics'], outDir);
|
|
355
|
+
const writes = [jest.spyOn(fs, 'writeFileSync'), jest.spyOn(fs, 'utimesSync')];
|
|
356
|
+
try {
|
|
357
|
+
prepareDirectWatchPaths(['expo-haptics'], outDir);
|
|
358
|
+
for (const write of writes) expect(write).not.toHaveBeenCalled();
|
|
359
|
+
} finally {
|
|
360
|
+
for (const write of writes) write.mockRestore();
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it('dates the marker in the future again when its date has changed', () => {
|
|
365
|
+
delete process.env.BUILD_DIR;
|
|
366
|
+
const [marker] = prepareDirectWatchPaths(['expo-haptics'], outDir);
|
|
367
|
+
const now = new Date();
|
|
368
|
+
fs.utimesSync(marker, now, now);
|
|
369
|
+
prepareDirectWatchPaths(['expo-haptics'], outDir);
|
|
370
|
+
expect(fs.statSync(marker).mtimeMs).toBeGreaterThan(Date.now() + 365 * 24 * 3600 * 1000);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it('removes the marker once no direct module is emitted', () => {
|
|
374
|
+
delete process.env.BUILD_DIR;
|
|
375
|
+
const [marker] = prepareDirectWatchPaths(['expo-haptics'], outDir);
|
|
376
|
+
prepareDirectWatchPaths([], outDir);
|
|
377
|
+
expect(fs.existsSync(marker)).toBe(false);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
it('removes the marker once a sync runs inside a build', () => {
|
|
381
|
+
delete process.env.BUILD_DIR;
|
|
382
|
+
const [marker] = prepareDirectWatchPaths(['expo-haptics'], outDir);
|
|
383
|
+
process.env.BUILD_DIR = '/tmp/Build/Products';
|
|
384
|
+
prepareDirectWatchPaths(['expo-haptics'], outDir);
|
|
385
|
+
expect(fs.existsSync(marker)).toBe(false);
|
|
386
|
+
});
|
|
387
|
+
});
|
|
@@ -9,10 +9,12 @@ const {
|
|
|
9
9
|
FLAVORS,
|
|
10
10
|
assertHeadersMatchSources,
|
|
11
11
|
byteOrder,
|
|
12
|
+
hasPrecompiledArtifact,
|
|
12
13
|
headersXCFrameworkDirs,
|
|
13
14
|
prepareCompileInterfaces,
|
|
14
15
|
resolveFlavoredFramework,
|
|
15
16
|
resolveHeadersXCFramework,
|
|
17
|
+
resolveHeadersXCFrameworkWithSource,
|
|
16
18
|
stableFrameworkId,
|
|
17
19
|
validateFlavoredFramework,
|
|
18
20
|
} = require('../flavored-frameworks');
|
|
@@ -59,6 +61,52 @@ function declaration(frameworkName, debug, release, overrides = {}) {
|
|
|
59
61
|
};
|
|
60
62
|
}
|
|
61
63
|
|
|
64
|
+
describe('hasPrecompiledArtifact', () => {
|
|
65
|
+
const savedEnvPath = process.env.EXPO_PRECOMPILED_MODULES_PATH;
|
|
66
|
+
let moduleRoot;
|
|
67
|
+
const lookup = () =>
|
|
68
|
+
hasPrecompiledArtifact({
|
|
69
|
+
packageName: '@expo-spm-test/no-monorepo-build',
|
|
70
|
+
moduleRoot,
|
|
71
|
+
frameworkName: 'ExpoProbe',
|
|
72
|
+
});
|
|
73
|
+
const xcframeworksDir = (flavor) =>
|
|
74
|
+
path.join(moduleRoot, 'prebuilds', 'output', flavor, 'xcframeworks');
|
|
75
|
+
|
|
76
|
+
beforeEach(() => {
|
|
77
|
+
delete process.env.EXPO_PRECOMPILED_MODULES_PATH;
|
|
78
|
+
moduleRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'has-artifact-'));
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
afterEach(() => {
|
|
82
|
+
fs.rmSync(moduleRoot, { recursive: true, force: true });
|
|
83
|
+
if (savedEnvPath === undefined) {
|
|
84
|
+
delete process.env.EXPO_PRECOMPILED_MODULES_PATH;
|
|
85
|
+
} else {
|
|
86
|
+
process.env.EXPO_PRECOMPILED_MODULES_PATH = savedEnvPath;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('is false when no flavor of the framework exists', () => {
|
|
91
|
+
expect(lookup()).toBe(false);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('is true for an xcframework of either flavor', () => {
|
|
95
|
+
fs.mkdirSync(path.join(xcframeworksDir('release'), 'ExpoProbe.xcframework'), {
|
|
96
|
+
recursive: true,
|
|
97
|
+
});
|
|
98
|
+
expect(lookup()).toBe(true);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// The pair is not validated or extracted: nothing is linked from it.
|
|
102
|
+
it('is true for a tarball, leaving it unextracted', () => {
|
|
103
|
+
fs.mkdirSync(xcframeworksDir('debug'), { recursive: true });
|
|
104
|
+
fs.writeFileSync(path.join(xcframeworksDir('debug'), 'ExpoProbe.tar.gz'), 'not a tarball');
|
|
105
|
+
expect(lookup()).toBe(true);
|
|
106
|
+
expect(fs.readdirSync(xcframeworksDir('debug'))).toEqual(['ExpoProbe.tar.gz']);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
62
110
|
describe('byteOrder', () => {
|
|
63
111
|
// The compile-interface merge and the declaration order both run through it,
|
|
64
112
|
// and a locale-aware comparison would order these the other way around.
|
|
@@ -330,6 +378,59 @@ describe('artifact preparation', () => {
|
|
|
330
378
|
).toThrow('is not part of an .xcframework');
|
|
331
379
|
});
|
|
332
380
|
|
|
381
|
+
it('returns a headers xcframework directory where it lies', () => {
|
|
382
|
+
const headers = path.join(root, 'expo-modules-core', 'output', 'headers', 'xcframeworks');
|
|
383
|
+
const xcframework = makeXcframework(headers, 'ExpoModulesCoreHeaders', '.');
|
|
384
|
+
|
|
385
|
+
expect(
|
|
386
|
+
resolveHeadersXCFrameworkWithSource({
|
|
387
|
+
packageName: 'expo-modules-core',
|
|
388
|
+
moduleRoot: path.join(root, 'module'),
|
|
389
|
+
productName: 'ExpoModulesCore',
|
|
390
|
+
cacheDir: path.join(root, 'cache'),
|
|
391
|
+
})
|
|
392
|
+
).toEqual({
|
|
393
|
+
xcframework,
|
|
394
|
+
source: { kind: 'env', dir: path.join(root, 'expo-modules-core', 'output') },
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
itNotWindows('expands a bundled headers tarball into the cache', () => {
|
|
399
|
+
const source = path.join(root, 'source');
|
|
400
|
+
makeXcframework(source, 'ExpoModulesCoreHeaders', 'headers');
|
|
401
|
+
const moduleRoot = path.join(root, 'module');
|
|
402
|
+
packTarball(
|
|
403
|
+
path.join(source, 'headers'),
|
|
404
|
+
path.join(
|
|
405
|
+
moduleRoot,
|
|
406
|
+
'prebuilds',
|
|
407
|
+
'output',
|
|
408
|
+
'headers',
|
|
409
|
+
'xcframeworks',
|
|
410
|
+
'ExpoModulesCoreHeaders.tar.gz'
|
|
411
|
+
),
|
|
412
|
+
['ExpoModulesCoreHeaders.xcframework']
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
const result = resolveHeadersXCFrameworkWithSource({
|
|
416
|
+
packageName: 'expo-spm-headers-fixture',
|
|
417
|
+
moduleRoot,
|
|
418
|
+
productName: 'ExpoModulesCore',
|
|
419
|
+
cacheDir: path.join(root, 'cache'),
|
|
420
|
+
});
|
|
421
|
+
expect(result).toEqual({
|
|
422
|
+
xcframework: path.join(
|
|
423
|
+
root,
|
|
424
|
+
'cache',
|
|
425
|
+
'expo-modules-core-headers',
|
|
426
|
+
'headers',
|
|
427
|
+
'ExpoModulesCoreHeaders.xcframework'
|
|
428
|
+
),
|
|
429
|
+
source: { kind: 'bundled', dir: path.join(moduleRoot, 'prebuilds', 'output') },
|
|
430
|
+
});
|
|
431
|
+
expect(fs.existsSync(path.join(result.xcframework, 'Info.plist'))).toBe(true);
|
|
432
|
+
});
|
|
433
|
+
|
|
333
434
|
it('produces byte-identical compile interfaces regardless of declaration order', () => {
|
|
334
435
|
const aDebug = makeXcframework(root, 'ExpoA', 'a-debug', 'a');
|
|
335
436
|
const aRelease = makeXcframework(root, 'ExpoA', 'a-release', 'a');
|
|
@@ -443,10 +544,36 @@ describe('resolveHeadersXCFramework', () => {
|
|
|
443
544
|
expect(fs.existsSync(path.join(resolved, 'Info.plist'))).toBe(true);
|
|
444
545
|
});
|
|
445
546
|
|
|
547
|
+
const rebuildHint =
|
|
548
|
+
'Reinstall test-package, or from the Expo repository root run `node tools/bin/expotools.js prebuild test-package`. Then run `node node_modules/react-native/scripts/setup-apple-spm.js update` from your app directory again.';
|
|
549
|
+
|
|
446
550
|
it('rejects an expanded XCFramework with no Info.plist', () => {
|
|
447
551
|
const shipped = headersIn(path.join(moduleRoot, 'prebuilds', 'output'));
|
|
448
552
|
fs.rmSync(path.join(shipped, 'Info.plist'));
|
|
449
553
|
expect(resolve).toThrow(`${shipped} has no Info.plist`);
|
|
554
|
+
expect(resolve).toThrow('its build or its extraction did not finish');
|
|
555
|
+
expect(resolve).toThrow(rebuildHint);
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
itNotWindows('rejects a tarball whose XCFramework has no Info.plist', () => {
|
|
559
|
+
const source = path.join(root, 'source');
|
|
560
|
+
fs.rmSync(path.join(headersIn(source), 'Info.plist'));
|
|
561
|
+
const tarball = packTarball(
|
|
562
|
+
path.join(source, 'headers', 'xcframeworks'),
|
|
563
|
+
path.join(
|
|
564
|
+
moduleRoot,
|
|
565
|
+
'prebuilds',
|
|
566
|
+
'output',
|
|
567
|
+
'headers',
|
|
568
|
+
'xcframeworks',
|
|
569
|
+
'ExpoPairHeaders.tar.gz'
|
|
570
|
+
),
|
|
571
|
+
['ExpoPairHeaders.xcframework']
|
|
572
|
+
);
|
|
573
|
+
|
|
574
|
+
expect(resolve).toThrow(`${tarball} holds ExpoPairHeaders.xcframework with no Info.plist`);
|
|
575
|
+
expect(resolve).toThrow('its build or its extraction did not finish');
|
|
576
|
+
expect(resolve).toThrow(rebuildHint);
|
|
450
577
|
});
|
|
451
578
|
});
|
|
452
579
|
|
|
@@ -4,6 +4,8 @@ const fs = require('fs');
|
|
|
4
4
|
const os = require('os');
|
|
5
5
|
const path = require('path');
|
|
6
6
|
|
|
7
|
+
const { spmUpdateCommand } = require('../commands');
|
|
8
|
+
|
|
7
9
|
/** A podspec with the given body lines. */
|
|
8
10
|
const spec = (...body) => ['Pod::Spec.new do |s|', ...body, 'end', ''].join('\n');
|
|
9
11
|
|
|
@@ -14,6 +16,9 @@ const metadataEntry = (packageRoot, productName, fields = {}) => ({
|
|
|
14
16
|
...fields,
|
|
15
17
|
});
|
|
16
18
|
|
|
19
|
+
/** How an error asks the user to update the app's packages; Expo apps have no `react-native` CLI. */
|
|
20
|
+
const rerunSpmUpdate = `Then run \`${spmUpdateCommand()}\` from your app directory again.`;
|
|
21
|
+
|
|
17
22
|
const tempDirs = [];
|
|
18
23
|
|
|
19
24
|
/** A new directory under the OS temp dir, removed by `removeTempDirs`. */
|
|
@@ -62,6 +67,9 @@ function runPlugin(tmp, context = {}) {
|
|
|
62
67
|
outputDir: path.join(tmp, 'out'),
|
|
63
68
|
appRoot: path.join(tmp, 'app', 'ios'),
|
|
64
69
|
projectRoot: path.join(tmp, 'app'),
|
|
70
|
+
// Fixtures that link real packages would otherwise resolve the repository's react-native, and
|
|
71
|
+
// the update command in every error would name that path.
|
|
72
|
+
reactNativeRoot: path.join(tmp, 'app', 'node_modules', 'react-native'),
|
|
65
73
|
...context,
|
|
66
74
|
});
|
|
67
75
|
}
|
|
@@ -82,6 +90,7 @@ module.exports = {
|
|
|
82
90
|
metadataEntry,
|
|
83
91
|
printed,
|
|
84
92
|
removeTempDirs,
|
|
93
|
+
rerunSpmUpdate,
|
|
85
94
|
runPlugin,
|
|
86
95
|
spec,
|
|
87
96
|
thrownBy,
|