@frumu/tandem 0.4.5 → 0.4.7

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 +21 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frumu/tandem",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "Tandem Engine binary distribution",
5
5
  "homepage": "https://tandem.frumu.ai",
6
6
  "bin": {
@@ -48,6 +48,24 @@ const { artifactName, binaryName, isWindows } = getArtifactInfo();
48
48
  const binDir = path.join(__dirname, '..', 'bin', 'native');
49
49
  const destPath = path.join(binDir, binaryName);
50
50
 
51
+ function buildHeaders(userAgent) {
52
+ const headers = { 'User-Agent': userAgent };
53
+ const token = process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
54
+ if (token) {
55
+ headers.Authorization = `Bearer ${token}`;
56
+ }
57
+ return headers;
58
+ }
59
+
60
+ function warnAndExit(err) {
61
+ const detail = err && err.message ? err.message : String(err);
62
+ console.warn(`Warning: tandem-engine binary download skipped: ${detail}`);
63
+ console.warn(
64
+ "Install completed without a bundled binary. Runtime commands will require a later reinstall or a preinstalled tandem-engine binary."
65
+ );
66
+ process.exit(0);
67
+ }
68
+
51
69
  if (!fs.existsSync(binDir)) {
52
70
  fs.mkdirSync(binDir, { recursive: true });
53
71
  }
@@ -60,7 +78,7 @@ if (fs.existsSync(destPath)) {
60
78
  // Helper to fetch JSON from GitHub API
61
79
  function fetchJson(url) {
62
80
  return new Promise((resolve, reject) => {
63
- https.get(url, { headers: { 'User-Agent': 'tandem-engine-installer' } }, (res) => {
81
+ https.get(url, { headers: buildHeaders('tandem-engine-installer') }, (res) => {
64
82
  if (res.statusCode !== 200) {
65
83
  if (res.statusCode === 302 || res.statusCode === 301) {
66
84
  return fetchJson(res.headers.location).then(resolve).catch(reject);
@@ -114,7 +132,7 @@ async function download() {
114
132
  const downloadUrl = asset.browser_download_url;
115
133
 
116
134
  const request = (url) => {
117
- https.get(url, { headers: { 'User-Agent': 'tandem-installer' } }, (res) => {
135
+ https.get(url, { headers: buildHeaders('tandem-installer') }, (res) => {
118
136
  if (res.statusCode === 302 || res.statusCode === 301) {
119
137
  return request(res.headers.location);
120
138
  }
@@ -172,7 +190,4 @@ async function extract(archivePath) {
172
190
  }
173
191
  }
174
192
 
175
- download().then(extract).catch(err => {
176
- console.error("Install failed:", err);
177
- process.exit(1);
178
- });
193
+ download().then(extract).catch(warnAndExit);