stacktape 2.24.0-rc.3 → 2.24.0-rc.4
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/bin/stacktape.js +15 -23
- package/package.json +1 -1
package/bin/stacktape.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/* eslint-disable */
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Stacktape CLI launcher
|
|
6
5
|
* Downloads and caches the platform-specific binary on first run
|
|
7
6
|
*/
|
|
7
|
+
|
|
8
8
|
const { spawnSync, execSync } = require('node:child_process');
|
|
9
9
|
const { createWriteStream, existsSync, chmodSync, mkdirSync } = require('node:fs');
|
|
10
10
|
const { get: httpsGet } = require('node:https');
|
|
@@ -24,7 +24,7 @@ const PLATFORM_MAP = {
|
|
|
24
24
|
'linux-x64-musl': { fileName: 'alpine.tar.gz', extract: extractTarGz }
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
function detectPlatform() {
|
|
28
28
|
const currentPlatform = platform();
|
|
29
29
|
const currentArch = arch();
|
|
30
30
|
|
|
@@ -52,9 +52,9 @@ const detectPlatform = () => {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
return platformKey;
|
|
55
|
-
}
|
|
55
|
+
}
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
async function downloadFile(url, destPath, retries = 3) {
|
|
58
58
|
for (let i = 0; i < retries; i++) {
|
|
59
59
|
try {
|
|
60
60
|
await new Promise((resolve, reject) => {
|
|
@@ -119,27 +119,25 @@ const downloadFile = async (url, destPath, retries = 3) => {
|
|
|
119
119
|
console.info(`\nRetrying download (${i + 1}/${retries})...`);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
}
|
|
122
|
+
}
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
const extractTarGz = async (archivePath, destDir) => {
|
|
124
|
+
async function extractTarGz(archivePath, destDir) {
|
|
126
125
|
const tar = require('tar');
|
|
127
126
|
await tar.x({
|
|
128
127
|
file: archivePath,
|
|
129
128
|
cwd: destDir
|
|
130
129
|
});
|
|
131
|
-
}
|
|
130
|
+
}
|
|
132
131
|
|
|
133
|
-
|
|
134
|
-
const extractZip = async (archivePath, destDir) => {
|
|
132
|
+
async function extractZip(archivePath, destDir) {
|
|
135
133
|
const AdmZip = require('adm-zip');
|
|
136
134
|
const zip = new AdmZip(archivePath);
|
|
137
135
|
zip.extractAllTo(destDir, true);
|
|
138
|
-
}
|
|
136
|
+
}
|
|
139
137
|
|
|
140
|
-
|
|
138
|
+
function setExecutablePermissions(binDir) {
|
|
141
139
|
if (platform() === 'win32') {
|
|
142
|
-
return;
|
|
140
|
+
return;
|
|
143
141
|
}
|
|
144
142
|
|
|
145
143
|
const executables = [
|
|
@@ -159,9 +157,9 @@ const setExecutablePermissions = (binDir) => {
|
|
|
159
157
|
}
|
|
160
158
|
}
|
|
161
159
|
}
|
|
162
|
-
}
|
|
160
|
+
}
|
|
163
161
|
|
|
164
|
-
|
|
162
|
+
async function ensureBinary() {
|
|
165
163
|
const platformKey = detectPlatform();
|
|
166
164
|
const platformInfo = PLATFORM_MAP[platformKey];
|
|
167
165
|
const version = PACKAGE_VERSION;
|
|
@@ -174,7 +172,7 @@ const ensureBinary = async () => {
|
|
|
174
172
|
return binaryPath;
|
|
175
173
|
}
|
|
176
174
|
|
|
177
|
-
console.info(`Stacktape binary not found. Installing
|
|
175
|
+
console.info(`Stacktape binary not found. Installing version ${version} for ${platformKey}...`);
|
|
178
176
|
|
|
179
177
|
if (!existsSync(cacheDir)) {
|
|
180
178
|
mkdirSync(cacheDir, { recursive: true });
|
|
@@ -211,11 +209,8 @@ You can also install Stacktape directly using:
|
|
|
211
209
|
${getManualInstallCommand(platformKey)}`);
|
|
212
210
|
process.exit(1);
|
|
213
211
|
}
|
|
214
|
-
}
|
|
212
|
+
}
|
|
215
213
|
|
|
216
|
-
/**
|
|
217
|
-
* Gets the manual installation command for the platform
|
|
218
|
-
*/
|
|
219
214
|
function getManualInstallCommand(platformKey) {
|
|
220
215
|
const commands = {
|
|
221
216
|
'win32-x64': 'iwr https://installs.stacktape.com/windows.ps1 -useb | iex',
|
|
@@ -228,9 +223,6 @@ function getManualInstallCommand(platformKey) {
|
|
|
228
223
|
return commands[platformKey] || 'See https://docs.stacktape.com for installation instructions';
|
|
229
224
|
}
|
|
230
225
|
|
|
231
|
-
/**
|
|
232
|
-
* Main execution
|
|
233
|
-
*/
|
|
234
226
|
async function main() {
|
|
235
227
|
try {
|
|
236
228
|
const binaryPath = await ensureBinary();
|