dlw-machine-setup 0.14.1 → 0.15.0-test.1
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/installer.js +5 -2
- package/package.json +1 -1
package/bin/installer.js
CHANGED
|
@@ -278,6 +278,9 @@ var import_path2 = require("path");
|
|
|
278
278
|
var import_child_process2 = require("child_process");
|
|
279
279
|
var MIN_FILE_SIZE = 1024;
|
|
280
280
|
async function downloadAndExtractAsset(token, asset, projectPath, tempDirName) {
|
|
281
|
+
return downloadAndExtractTgz(token, asset.url, asset.name, projectPath, tempDirName);
|
|
282
|
+
}
|
|
283
|
+
async function downloadAndExtractTgz(token, url, archiveName, projectPath, tempDirName) {
|
|
281
284
|
const tarCheck = (0, import_child_process2.spawnSync)("tar", ["--version"], { stdio: "ignore" });
|
|
282
285
|
if (tarCheck.status !== 0) {
|
|
283
286
|
throw new Error("tar command not found. Please ensure tar is installed and available in your PATH.");
|
|
@@ -294,13 +297,13 @@ async function downloadAndExtractAsset(token, asset, projectPath, tempDirName) {
|
|
|
294
297
|
}
|
|
295
298
|
};
|
|
296
299
|
try {
|
|
297
|
-
const dlRes = await fetchWithRetry(
|
|
300
|
+
const dlRes = await fetchWithRetry(url, {
|
|
298
301
|
headers: { "Accept": "application/octet-stream", "Authorization": `Bearer ${token}` }
|
|
299
302
|
});
|
|
300
303
|
if (!dlRes.ok) {
|
|
301
304
|
throw new Error(`Download failed: ${getReadableError(dlRes.status)}`);
|
|
302
305
|
}
|
|
303
|
-
const archivePath = (0, import_path2.join)(tempDir,
|
|
306
|
+
const archivePath = (0, import_path2.join)(tempDir, archiveName);
|
|
304
307
|
(0, import_fs2.writeFileSync)(archivePath, Buffer.from(await dlRes.arrayBuffer()));
|
|
305
308
|
if ((0, import_fs2.statSync)(archivePath).size < MIN_FILE_SIZE) {
|
|
306
309
|
throw new Error("File corrupted");
|