diff --git a/dist/index.js b/dist/index.js index c08d5c7..098c9a8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2748,10 +2748,10 @@ var BuildInformationRepository = /** @class */ (function () { BuildInformationRepository.prototype.push = function (buildInformation, overwriteMode) { if (overwriteMode === void 0) { overwriteMode = overwriteMode_1.OverwriteMode.FailIfExists; } return __awaiter(this, void 0, void 0, function () { - var tasks, _a, _b, pkg; - var e_1, _c; - return __generator(this, function (_d) { - switch (_d.label) { + var tasks, _a, _b, pkg, rejectedTasks, completedTasks, completedTasks_1, completedTasks_1_1, t, errors, rejectedTasks_1, rejectedTasks_1_1, e, error; + var e_1, _c, e_2, _d, e_3, _e; + return __generator(this, function (_f) { + switch (_f.label) { case 0: tasks = []; try { @@ -2781,9 +2781,48 @@ var BuildInformationRepository = /** @class */ (function () { } finally { if (e_1) throw e_1.error; } } + rejectedTasks = []; return [4 /*yield*/, Promise.allSettled(tasks)]; case 1: - _d.sent(); + completedTasks = _f.sent(); + try { + for (completedTasks_1 = __values(completedTasks), completedTasks_1_1 = completedTasks_1.next(); !completedTasks_1_1.done; completedTasks_1_1 = completedTasks_1.next()) { + t = completedTasks_1_1.value; + if (t.status === "rejected") { + rejectedTasks.push(t.reason); + } + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (completedTasks_1_1 && !completedTasks_1_1.done && (_d = completedTasks_1.return)) _d.call(completedTasks_1); + } + finally { if (e_2) throw e_2.error; } + } + errors = []; + try { + for (rejectedTasks_1 = __values(rejectedTasks), rejectedTasks_1_1 = rejectedTasks_1.next(); !rejectedTasks_1_1.done; rejectedTasks_1_1 = rejectedTasks_1.next()) { + e = rejectedTasks_1_1.value; + if (e instanceof Error) { + errors.push(e); + } + else { + errors.push(new Error("unexpected error: ".concat(e))); + } + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (rejectedTasks_1_1 && !rejectedTasks_1_1.done && (_e = rejectedTasks_1.return)) _e.call(rejectedTasks_1); + } + finally { if (e_3) throw e_3.error; } + } + if (errors.length > 0) { + error = errors.map(function (e) { return "".concat(e); }); + throw new Error(error.join("\n")); + } return [2 /*return*/]; } }); @@ -3858,12 +3897,12 @@ var globp = (0, util_1.promisify)(glob_1.glob); * @param {boolean} overwrite Whether to overwrite the Zip file if it already exists. Defaults to true if not specified. */ function doZip(basePath, inputFilePatterns, outputFolder, zipFilename, logger, compressionLevel, overwrite) { - var _a, _b, _c; + var _a, _b, _c, _d; return __awaiter(this, void 0, void 0, function () { var archivePath, initialWorkingDirectory, zip, files, files_1, files_1_1, file, dirName; - var e_1, _d; - return __generator(this, function (_e) { - switch (_e.label) { + var e_1, _e; + return __generator(this, function (_f) { + switch (_f.label) { case 0: archivePath = path_1.default.resolve(outputFolder, zipFilename); (_a = logger.info) === null || _a === void 0 ? void 0 : _a.call(logger, "Writing to package: ".concat(archivePath, "...")); @@ -3872,7 +3911,7 @@ function doZip(basePath, inputFilePatterns, outputFolder, zipFilename, logger, c zip = new adm_zip_1.default(); return [4 /*yield*/, expandGlobs(inputFilePatterns)]; case 1: - files = _e.sent(); + files = _f.sent(); try { for (files_1 = __values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) { file = files_1_1.value; @@ -3889,7 +3928,7 @@ function doZip(basePath, inputFilePatterns, outputFolder, zipFilename, logger, c catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (files_1_1 && !files_1_1.done && (_d = files_1.return)) _d.call(files_1); + if (files_1_1 && !files_1_1.done && (_e = files_1.return)) _e.call(files_1); } finally { if (e_1) throw e_1.error; } } @@ -3898,10 +3937,11 @@ function doZip(basePath, inputFilePatterns, outputFolder, zipFilename, logger, c } setCompressionLevel(zip, compressionLevel || 8); process.chdir(initialWorkingDirectory); - return [4 /*yield*/, zip.writeZipPromise(archivePath, { overwrite: overwrite || true })]; - case 2: - _e.sent(); - return [2 /*return*/]; + if (fs_1.default.existsSync(archivePath) && overwrite === false) { + (_d = logger.info) === null || _d === void 0 ? void 0 : _d.call(logger, "Found an existing archive at ".concat(archivePath, " and overwrite is disabled. The existing archive will not be overwritten.")); + return [2 /*return*/]; + } + return [2 /*return*/, zip.writeZip(archivePath, function () { })]; } }); }); @@ -6160,30 +6200,31 @@ var ServerTaskWaiter = /** @class */ (function () { stop = true; }, timeout); completedTasks = []; + _a.label = 1; + case 1: + _a.trys.push([1, , 5, 6]); _loop_1 = function () { - var tasks_2, unknownTaskIds, nowCompletedTaskIds_1, tasks_1, tasks_1_1, task; + var tasks, unknownTaskIds, nowCompletedTaskIds, tasks_1, tasks_1_1, task; var e_1, _b; return __generator(this, function (_c) { switch (_c.label) { - case 0: - _c.trys.push([0, , 2, 3]); - return [4 /*yield*/, spaceServerTaskRepository.getByIds(serverTaskIds)]; + case 0: return [4 /*yield*/, spaceServerTaskRepository.getByIds(serverTaskIds)]; case 1: - tasks_2 = _c.sent(); - unknownTaskIds = serverTaskIds.filter(function (id) { return tasks_2.filter(function (t) { return t.Id === id; }).length == 0; }); + tasks = _c.sent(); + unknownTaskIds = serverTaskIds.filter(function (id) { return tasks.filter(function (t) { return t.Id === id; }).length == 0; }); if (unknownTaskIds.length) { throw new Error("Unknown task Id(s) ".concat(unknownTaskIds.join(", "))); } - nowCompletedTaskIds_1 = []; + nowCompletedTaskIds = []; try { - for (tasks_1 = (e_1 = void 0, __values(tasks_2)), tasks_1_1 = tasks_1.next(); !tasks_1_1.done; tasks_1_1 = tasks_1.next()) { + for (tasks_1 = (e_1 = void 0, __values(tasks)), tasks_1_1 = tasks_1.next(); !tasks_1_1.done; tasks_1_1 = tasks_1.next()) { task = tasks_1_1.value; if (pollingCallback) { pollingCallback(task); } // once the task is complete if (task.IsCompleted) { - nowCompletedTaskIds_1.push(task.Id); + nowCompletedTaskIds.push(task.Id); completedTasks.push(task); } } @@ -6196,30 +6237,31 @@ var ServerTaskWaiter = /** @class */ (function () { finally { if (e_1) throw e_1.error; } } // filter down the ids to only those that haven't completed for the next time around the loop - serverTaskIds = serverTaskIds.filter(function (id) { return nowCompletedTaskIds_1.indexOf(id) < 0; }); + serverTaskIds = serverTaskIds.filter(function (id) { return nowCompletedTaskIds.indexOf(id) < 0; }); // once all tasks have completed we can stop the loop - if (serverTaskIds.length === 0 || tasks_2.length === 0) { + if (serverTaskIds.length === 0 || tasks.length === 0) { stop = true; + clearTimeout(t); } - return [3 /*break*/, 3]; + return [4 /*yield*/, sleep(statusCheckSleepCycle)]; case 2: - clearTimeout(t); - return [7 /*endfinally*/]; - case 3: return [4 /*yield*/, sleep(statusCheckSleepCycle)]; - case 4: _c.sent(); return [2 /*return*/]; } }); }; - _a.label = 1; - case 1: - if (!!stop) return [3 /*break*/, 3]; - return [5 /*yield**/, _loop_1()]; + _a.label = 2; case 2: + if (!!stop) return [3 /*break*/, 4]; + return [5 /*yield**/, _loop_1()]; + case 3: _a.sent(); - return [3 /*break*/, 1]; - case 3: return [2 /*return*/, completedTasks]; + return [3 /*break*/, 2]; + case 4: return [3 /*break*/, 6]; + case 5: + clearTimeout(t); + return [7 /*endfinally*/]; + case 6: return [2 /*return*/, completedTasks]; } }); }); diff --git a/package-lock.json b/package-lock.json index 1a800e5..6c80119 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@actions/core": "1.10.1", - "@octopusdeploy/api-client": "3.2.0" + "@octopusdeploy/api-client": "3.4.1" }, "devDependencies": { "@octopusdeploy/runtime-inputs": "0.16.0", @@ -1359,9 +1359,9 @@ } }, "node_modules/@octopusdeploy/api-client": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/@octopusdeploy/api-client/-/api-client-3.2.0.tgz", - "integrity": "sha512-0TrbsXaFc/Xi3yfsEEAvf5mOveZx4K347LmBRwCuLd2pLl8tj3NJYJn7nRzz3kr4j6o46oUv1RukemEXqu91Dg==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/@octopusdeploy/api-client/-/api-client-3.4.1.tgz", + "integrity": "sha512-j6FRgDNzc6AQoT3CAguYLWxoMR4W5TKCT1BCPpqjEN9mknmdMSKfYORs3djn/Yj/BhqtITTydDpBoREbzKY5+g==", "dependencies": { "adm-zip": "^0.5.9", "axios": "^1.2.1", @@ -7809,9 +7809,9 @@ } }, "@octopusdeploy/api-client": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/@octopusdeploy/api-client/-/api-client-3.2.0.tgz", - "integrity": "sha512-0TrbsXaFc/Xi3yfsEEAvf5mOveZx4K347LmBRwCuLd2pLl8tj3NJYJn7nRzz3kr4j6o46oUv1RukemEXqu91Dg==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/@octopusdeploy/api-client/-/api-client-3.4.1.tgz", + "integrity": "sha512-j6FRgDNzc6AQoT3CAguYLWxoMR4W5TKCT1BCPpqjEN9mknmdMSKfYORs3djn/Yj/BhqtITTydDpBoREbzKY5+g==", "requires": { "adm-zip": "^0.5.9", "axios": "^1.2.1", diff --git a/package.json b/package.json index 9cf88a6..78f4ace 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@actions/core": "1.10.1", - "@octopusdeploy/api-client": "3.2.0" + "@octopusdeploy/api-client": "3.4.1" }, "description": "GitHub Action to Create a Release in Octopus Deploy", "devDependencies": {