@stim-cli/expo-build-cache 1.3.0 → 1.4.0
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/dist/index.mjs +8 -47
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { buildCacheKey, buildCacheRoot, registerCache } from "@stim-cli/core";
|
|
3
|
+
import { artifactIn, buildCacheKey, buildCacheRoot, registerCache, resolveArtifact, storeArtifact } from "@stim-cli/core";
|
|
4
4
|
import { execFileSync } from "node:child_process";
|
|
5
5
|
//#region index.ts
|
|
6
6
|
let registeredDir = null;
|
|
@@ -13,16 +13,6 @@ function entryDir(platform, key) {
|
|
|
13
13
|
function shortKey(key, fingerprintHash) {
|
|
14
14
|
return `${String(fingerprintHash).slice(0, 12)}${key.slice(String(fingerprintHash).length)}`;
|
|
15
15
|
}
|
|
16
|
-
function artifactIn(dir) {
|
|
17
|
-
if (!fs.existsSync(dir)) return null;
|
|
18
|
-
let found;
|
|
19
|
-
try {
|
|
20
|
-
found = fs.readdirSync(dir).find((f) => f.endsWith(".app") || f.endsWith(".apk"));
|
|
21
|
-
} catch {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
return found ? path.join(dir, found) : null;
|
|
25
|
-
}
|
|
26
16
|
function registerOnce() {
|
|
27
17
|
const root = cacheRoot();
|
|
28
18
|
if (registeredDir === root) return;
|
|
@@ -38,12 +28,9 @@ function registerOnce() {
|
|
|
38
28
|
async function resolveBuildCache({ platform, fingerprintHash, runOptions }) {
|
|
39
29
|
registerOnce();
|
|
40
30
|
const key = buildCacheKey(platform, fingerprintHash, runOptions);
|
|
41
|
-
const hit =
|
|
31
|
+
const hit = resolveArtifact(entryDir(platform, key));
|
|
42
32
|
if (hit) {
|
|
43
33
|
console.log(`[build-cache] hit ${platform} ${shortKey(key, fingerprintHash)}`);
|
|
44
|
-
try {
|
|
45
|
-
fs.utimesSync(path.dirname(hit), /* @__PURE__ */ new Date(), /* @__PURE__ */ new Date());
|
|
46
|
-
} catch {}
|
|
47
34
|
return hit;
|
|
48
35
|
}
|
|
49
36
|
console.log(`[build-cache] miss ${platform} ${shortKey(key, fingerprintHash)}`);
|
|
@@ -55,41 +42,15 @@ async function uploadBuildCache({ platform, fingerprintHash, buildPath, runOptio
|
|
|
55
42
|
const key = buildCacheKey(platform, fingerprintHash, runOptions);
|
|
56
43
|
const dest = entryDir(platform, key);
|
|
57
44
|
if (artifactIn(dest)) return artifactIn(dest);
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
force: true
|
|
62
|
-
});
|
|
63
|
-
fs.mkdirSync(staging, { recursive: true });
|
|
64
|
-
try {
|
|
65
|
-
execFileSync("cp", [
|
|
66
|
-
"-c",
|
|
67
|
-
"-R",
|
|
68
|
-
buildPath,
|
|
69
|
-
path.join(staging, path.basename(buildPath))
|
|
70
|
-
]);
|
|
71
|
-
} catch {
|
|
72
|
-
execFileSync("cp", [
|
|
73
|
-
"-R",
|
|
74
|
-
buildPath,
|
|
75
|
-
path.join(staging, path.basename(buildPath))
|
|
76
|
-
]);
|
|
77
|
-
}
|
|
78
|
-
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
79
|
-
fs.rmSync(dest, {
|
|
80
|
-
recursive: true,
|
|
81
|
-
force: true
|
|
82
|
-
});
|
|
83
|
-
try {
|
|
84
|
-
fs.renameSync(staging, dest);
|
|
85
|
-
} catch {
|
|
86
|
-
fs.rmSync(staging, {
|
|
45
|
+
const stored = storeArtifact(dest, buildPath, {
|
|
46
|
+
runFile: execFileSync,
|
|
47
|
+
onRenameError: (staging) => fs.rmSync(staging, {
|
|
87
48
|
recursive: true,
|
|
88
49
|
force: true
|
|
89
|
-
})
|
|
90
|
-
}
|
|
50
|
+
})
|
|
51
|
+
});
|
|
91
52
|
console.log(`[build-cache] stored ${platform} ${shortKey(key, fingerprintHash)}`);
|
|
92
|
-
return
|
|
53
|
+
return stored;
|
|
93
54
|
}
|
|
94
55
|
//#endregion
|
|
95
56
|
export { buildCacheKey, cacheRoot, resolveBuildCache, uploadBuildCache };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stim-cli/expo-build-cache",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Local Expo build cache provider: installs a cached .app/.apk instead of compiling when no native input changed.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@stim-cli/core": "^1.
|
|
27
|
+
"@stim-cli/core": "^1.4.0"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|
|
30
30
|
"node": "^20.19.4 || >=22.12.0"
|