apteva 0.8.1 → 0.8.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/install.js +28 -1
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -47,10 +47,29 @@ async function main() {
|
|
|
47
47
|
process.exit(1);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
// Cache binaries in ~/.apteva/bin/<version>/ so repeated npx runs are instant
|
|
51
|
+
const cacheDir = path.join(os.homedir(), ".apteva", "bin", VERSION);
|
|
52
|
+
const ext = platform === "windows" ? ".exe" : "";
|
|
53
|
+
const cachedBin = path.join(cacheDir, `apteva${ext}`);
|
|
54
|
+
|
|
55
|
+
if (fs.existsSync(cachedBin)) {
|
|
56
|
+
// Copy from cache to install dir
|
|
57
|
+
for (const name of ["apteva", "apteva-server", "apteva-core"]) {
|
|
58
|
+
const src = path.join(cacheDir, `${name}${ext}`);
|
|
59
|
+
const dst = path.join(DIR, `${name}${ext}`);
|
|
60
|
+
if (fs.existsSync(src)) {
|
|
61
|
+
fs.copyFileSync(src, dst);
|
|
62
|
+
if (platform !== "windows") fs.chmodSync(dst, 0o755);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
console.log(`apteva: v${VERSION} loaded from cache.`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
50
69
|
const tarName = `apteva-${VERSION}-${platform}-${arch}.tar.gz`;
|
|
51
70
|
const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${tarName}`;
|
|
52
71
|
|
|
53
|
-
console.log(`apteva: downloading ${platform}-${arch}
|
|
72
|
+
console.log(`apteva: downloading v${VERSION} for ${platform}-${arch}...`);
|
|
54
73
|
|
|
55
74
|
try {
|
|
56
75
|
const buffer = await download(url);
|
|
@@ -69,6 +88,14 @@ async function main() {
|
|
|
69
88
|
}
|
|
70
89
|
}
|
|
71
90
|
|
|
91
|
+
// Save to cache for next run
|
|
92
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
93
|
+
for (const name of ["apteva", "apteva-server", "apteva-core"]) {
|
|
94
|
+
const src = path.join(DIR, `${name}${ext}`);
|
|
95
|
+
const dst = path.join(cacheDir, `${name}${ext}`);
|
|
96
|
+
if (fs.existsSync(src)) fs.copyFileSync(src, dst);
|
|
97
|
+
}
|
|
98
|
+
|
|
72
99
|
console.log("apteva: installed successfully.");
|
|
73
100
|
} catch (err) {
|
|
74
101
|
console.error(`apteva: binary download failed: ${err.message}`);
|