@rikipurpur/puru-ai 6.2.0 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/install.js +28 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rikipurpur/puru-ai",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "description": "PURU-AI CLI — setup wizard and Telegram bot gateway (no web server). Self-contained Go binary distributed via npm.",
5
5
  "license": "MIT",
6
6
  "author": "Ricky",
@@ -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 v.startsWith('v') ? v : `v${v}`;
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 tag = resolveTag();
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
- console.log(`[puru-ai] downloading ${assetName(goos, goarch)} ${tag} from ${repo}...`);
58
- try {
59
- await fetch(url, dest);
60
- } catch (err) {
61
- try { fs.unlinkSync(dest); } catch (_) {}
62
- console.error(`[puru-ai] FAILED: ${err.message}`);
63
- console.error(`[puru-ai] Check the release at https://github.com/${repo}/releases/tag/${tag}`);
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 err;
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 };