argonctl 1.0.0 → 1.0.2
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 +20 -3
- package/package.json +2 -2
package/install.js
CHANGED
|
@@ -6,7 +6,7 @@ const https = require('https');
|
|
|
6
6
|
const { execSync } = require('child_process');
|
|
7
7
|
|
|
8
8
|
const GITHUB_REPO = 'argon-lab/argon';
|
|
9
|
-
const VERSION =
|
|
9
|
+
const VERSION = '1.0.0'; // Use fixed version since that's where binaries are
|
|
10
10
|
|
|
11
11
|
function getPlatform() {
|
|
12
12
|
const platform = process.platform;
|
|
@@ -61,7 +61,22 @@ function downloadBinary() {
|
|
|
61
61
|
return new Promise((resolve, reject) => {
|
|
62
62
|
const file = fs.createWriteStream(binaryPath);
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
function handleResponse(response) {
|
|
65
|
+
// Handle redirects
|
|
66
|
+
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
67
|
+
const redirectUrl = response.headers.location;
|
|
68
|
+
console.log(`Following redirect to: ${redirectUrl}`);
|
|
69
|
+
const url = require('url');
|
|
70
|
+
const parsed = url.parse(redirectUrl);
|
|
71
|
+
const client = parsed.protocol === 'https:' ? https : require('http');
|
|
72
|
+
|
|
73
|
+
client.get(redirectUrl, handleResponse).on('error', (err) => {
|
|
74
|
+
fs.unlink(binaryPath, () => {}); // Delete partial file
|
|
75
|
+
reject(err);
|
|
76
|
+
});
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
65
80
|
if (response.statusCode !== 200) {
|
|
66
81
|
reject(new Error(`Failed to download binary: HTTP ${response.statusCode}`));
|
|
67
82
|
return;
|
|
@@ -85,7 +100,9 @@ function downloadBinary() {
|
|
|
85
100
|
console.log('Run "argon --version" to verify installation.');
|
|
86
101
|
resolve();
|
|
87
102
|
});
|
|
88
|
-
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
https.get(downloadUrl, handleResponse).on('error', (err) => {
|
|
89
106
|
fs.unlink(binaryPath, () => {}); // Delete partial file
|
|
90
107
|
reject(err);
|
|
91
108
|
});
|
package/package.json
CHANGED