@frumu/tandem-tui 0.4.5 → 0.4.6

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-tui",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "Tandem TUI binary distribution",
5
5
  "homepage": "https://tandem.frumu.ai",
6
6
  "bin": {
@@ -45,6 +45,24 @@ const { artifactName, binaryName, isWindows } = getArtifactInfo();
45
45
  const binDir = path.join(__dirname, '..', 'bin', 'native');
46
46
  const destPath = path.join(binDir, binaryName);
47
47
 
48
+ function buildHeaders(userAgent) {
49
+ const headers = { 'User-Agent': userAgent };
50
+ const token = process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
51
+ if (token) {
52
+ headers.Authorization = `Bearer ${token}`;
53
+ }
54
+ return headers;
55
+ }
56
+
57
+ function warnAndExit(err) {
58
+ const detail = err && err.message ? err.message : String(err);
59
+ console.warn(`Warning: tandem-tui binary download skipped: ${detail}`);
60
+ console.warn(
61
+ "Install completed without a bundled binary. Runtime commands will require a later reinstall or a preinstalled tandem-tui binary."
62
+ );
63
+ process.exit(0);
64
+ }
65
+
48
66
  if (!fs.existsSync(binDir)) {
49
67
  fs.mkdirSync(binDir, { recursive: true });
50
68
  }
@@ -56,7 +74,7 @@ if (fs.existsSync(destPath)) {
56
74
 
57
75
  function fetchJson(url) {
58
76
  return new Promise((resolve, reject) => {
59
- https.get(url, { headers: { 'User-Agent': 'tandem-tui-installer' } }, (res) => {
77
+ https.get(url, { headers: buildHeaders('tandem-tui-installer') }, (res) => {
60
78
  if (res.statusCode !== 200) {
61
79
  if (res.statusCode === 302 || res.statusCode === 301) {
62
80
  return fetchJson(res.headers.location).then(resolve).catch(reject);
@@ -102,7 +120,7 @@ async function download() {
102
120
  const downloadUrl = asset.browser_download_url;
103
121
 
104
122
  const request = (url) => {
105
- https.get(url, { headers: { 'User-Agent': 'tandem-tui-installer' } }, (res) => {
123
+ https.get(url, { headers: buildHeaders('tandem-tui-installer') }, (res) => {
106
124
  if (res.statusCode === 302 || res.statusCode === 301) {
107
125
  return request(res.headers.location);
108
126
  }
@@ -145,7 +163,4 @@ async function extract(archivePath) {
145
163
  }
146
164
  }
147
165
 
148
- download().then(extract).catch(err => {
149
- console.error("Install failed:", err);
150
- process.exit(1);
151
- });
166
+ download().then(extract).catch(warnAndExit);