argonctl 1.0.1 → 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 +10 -27
- package/package.json +1 -1
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,35 +61,16 @@ function downloadBinary() {
|
|
|
61
61
|
return new Promise((resolve, reject) => {
|
|
62
62
|
const file = fs.createWriteStream(binaryPath);
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
function handleResponse(response) {
|
|
65
65
|
// Handle redirects
|
|
66
66
|
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
67
67
|
const redirectUrl = response.headers.location;
|
|
68
68
|
console.log(`Following redirect to: ${redirectUrl}`);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
redirectResponse.pipe(file);
|
|
75
|
-
|
|
76
|
-
file.on('finish', () => {
|
|
77
|
-
file.close();
|
|
78
|
-
|
|
79
|
-
// Make binary executable on Unix systems
|
|
80
|
-
if (process.platform !== 'win32') {
|
|
81
|
-
try {
|
|
82
|
-
fs.chmodSync(binaryPath, '755');
|
|
83
|
-
} catch (err) {
|
|
84
|
-
console.warn('Warning: Could not make binary executable:', err.message);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
console.log('Argon CLI installed successfully!');
|
|
89
|
-
console.log('Run "argon --version" to verify installation.');
|
|
90
|
-
resolve();
|
|
91
|
-
});
|
|
92
|
-
}).on('error', (err) => {
|
|
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) => {
|
|
93
74
|
fs.unlink(binaryPath, () => {}); // Delete partial file
|
|
94
75
|
reject(err);
|
|
95
76
|
});
|
|
@@ -119,7 +100,9 @@ function downloadBinary() {
|
|
|
119
100
|
console.log('Run "argon --version" to verify installation.');
|
|
120
101
|
resolve();
|
|
121
102
|
});
|
|
122
|
-
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
https.get(downloadUrl, handleResponse).on('error', (err) => {
|
|
123
106
|
fs.unlink(binaryPath, () => {}); // Delete partial file
|
|
124
107
|
reject(err);
|
|
125
108
|
});
|