@rikipurpur/puru-ai 6.2.1 → 6.3.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/package.json +1 -1
- package/scripts/install.js +28 -12
package/package.json
CHANGED
package/scripts/install.js
CHANGED
|
@@ -16,7 +16,15 @@ function pkgVersion() {
|
|
|
16
16
|
|
|
17
17
|
function resolveTag() {
|
|
18
18
|
const v = (process.env.PURU_AI_VERSION || pkgVersion()).trim();
|
|
19
|
-
return
|
|
19
|
+
return /^[vV]/.test(v) ? v : `v${v}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// GitHub release tags are case sensitive, so a repo that publishes V6.3.0 (or a
|
|
23
|
+
// user who passes 6.3.0 while only V6.3.0 exists) must try both spellings.
|
|
24
|
+
function tagVariants(tag) {
|
|
25
|
+
if (tag.startsWith('v')) return [tag, `V${tag.slice(1)}`];
|
|
26
|
+
if (tag.startsWith('V')) return [tag, `v${tag.slice(1)}`];
|
|
27
|
+
return [tag];
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
function fetch(url, dest, redirects = 5) {
|
|
@@ -48,21 +56,29 @@ async function main() {
|
|
|
48
56
|
return;
|
|
49
57
|
}
|
|
50
58
|
const repo = process.env.PURU_AI_REPO || 'purujawa06-bot/PURU-AI';
|
|
51
|
-
const
|
|
59
|
+
const tags = tagVariants(resolveTag());
|
|
52
60
|
const goos = mapOS();
|
|
53
61
|
const goarch = mapArch();
|
|
54
|
-
const url = downloadURL({ repo, tag, goos, goarch });
|
|
55
62
|
const dest = binaryPath();
|
|
56
63
|
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
let lastErr = null;
|
|
65
|
+
for (const tag of tags) {
|
|
66
|
+
const url = downloadURL({ repo, tag, goos, goarch });
|
|
67
|
+
console.log(`[puru-ai] downloading ${assetName(goos, goarch)} ${tag} from ${repo}...`);
|
|
68
|
+
try {
|
|
69
|
+
await fetch(url, dest);
|
|
70
|
+
lastErr = null;
|
|
71
|
+
break;
|
|
72
|
+
} catch (err) {
|
|
73
|
+
lastErr = err;
|
|
74
|
+
try { fs.unlinkSync(dest); } catch (_) {}
|
|
75
|
+
console.error(`[puru-ai] FAILED: ${err.message}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (lastErr) {
|
|
79
|
+
console.error(`[puru-ai] Check the release at https://github.com/${repo}/releases/tag/${tags[0]}`);
|
|
64
80
|
console.error(`[puru-ai] Or set PURU_AI_BINARY=/path/to/puru and reinstall.`);
|
|
65
|
-
throw
|
|
81
|
+
throw lastErr;
|
|
66
82
|
}
|
|
67
83
|
if (goos !== 'windows') {
|
|
68
84
|
try { fs.chmodSync(dest, 0o755); } catch (_) {}
|
|
@@ -78,4 +94,4 @@ if (require.main === module) {
|
|
|
78
94
|
});
|
|
79
95
|
}
|
|
80
96
|
|
|
81
|
-
module.exports = { resolveTag, fetch };
|
|
97
|
+
module.exports = { resolveTag, tagVariants, fetch };
|