MCPcopy Index your code
hub / github.com/NativeScript/SimDeck / buildCachedFixtureApp

Function buildCachedFixtureApp

scripts/integration/fixture.mjs:9–63  ·  view source on GitHub ↗
({
  root,
  tempRoot,
  bundleId,
  urlScheme,
  log = () => {},
})

Source from the content-addressed store, hash-verified

7const minimumIosVersion = "15.0";
8
9export 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
65function buildFixtureIntoCache({
66 cacheRoot,

Callers 4

buildFixtureAppFunction · 0.90
mainFunction · 0.90
buildFixtureAppFunction · 0.90

Calls 7

commandOutputFunction · 0.85
isUsableAppFunction · 0.85
logFunction · 0.85
buildFixtureIntoCacheFunction · 0.85
fixtureInfoPlistFunction · 0.70
fixtureSourceFunction · 0.70
updateMethod · 0.65

Tested by

no test coverage detected