({
root,
tempRoot,
bundleId,
urlScheme,
log = () => {},
})
| 7 | const minimumIosVersion = "15.0"; |
| 8 | |
| 9 | export function buildCachedFixtureApp({ |
| 10 | root, |
| 11 | tempRoot, |
| 12 | bundleId, |
| 13 | urlScheme, |
| 14 | log = () => {}, |
| 15 | }) { |
| 16 | const targetArch = process.arch === "arm64" ? "arm64" : "x86_64"; |
| 17 | const sdkVersion = commandOutput("xcrun", [ |
| 18 | "--sdk", |
| 19 | "iphonesimulator", |
| 20 | "--show-sdk-version", |
| 21 | ]); |
| 22 | const clangVersion = commandOutput("xcrun", [ |
| 23 | "--sdk", |
| 24 | "iphonesimulator", |
| 25 | "clang", |
| 26 | "--version", |
| 27 | ]); |
| 28 | const plist = fixtureInfoPlist(bundleId, urlScheme); |
| 29 | const source = fixtureSource(); |
| 30 | const fingerprint = crypto |
| 31 | .createHash("sha256") |
| 32 | .update( |
| 33 | JSON.stringify({ targetArch, sdkVersion, clangVersion, plist, source }), |
| 34 | ) |
| 35 | .digest("hex") |
| 36 | .slice(0, 16); |
| 37 | const cacheRoot = path.join( |
| 38 | root, |
| 39 | ".cache", |
| 40 | "simdeck", |
| 41 | "fixture", |
| 42 | `${targetArch}-iphonesimulator-${fingerprint}`, |
| 43 | ); |
| 44 | const cachedAppPath = path.join(cacheRoot, `${executable}.app`); |
| 45 | const appPath = path.join(tempRoot, `${executable}.app`); |
| 46 | |
| 47 | if (!isUsableApp(cachedAppPath)) { |
| 48 | log(`building cached UIKit fixture ${fingerprint}`); |
| 49 | buildFixtureIntoCache({ |
| 50 | cacheRoot, |
| 51 | cachedAppPath, |
| 52 | plist, |
| 53 | source, |
| 54 | targetArch, |
| 55 | }); |
| 56 | } else { |
| 57 | log(`using cached UIKit fixture ${fingerprint}`); |
| 58 | } |
| 59 | |
| 60 | fs.rmSync(appPath, { recursive: true, force: true }); |
| 61 | fs.cpSync(cachedAppPath, appPath, { recursive: true }); |
| 62 | return { appPath }; |
| 63 | } |
| 64 | |
| 65 | function buildFixtureIntoCache({ |
| 66 | cacheRoot, |
no test coverage detected