@tutti-os/nexight-devops 0.5.1 → 0.5.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/dist/cli.js +26 -11
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -5093,10 +5093,23 @@ var SINGAPORE_TIME = new Intl.DateTimeFormat("sv-SE", {
|
|
|
5093
5093
|
dateStyle: "short",
|
|
5094
5094
|
timeStyle: "medium"
|
|
5095
5095
|
});
|
|
5096
|
+
var SINGAPORE_CHOICE_TIME = new Intl.DateTimeFormat("sv-SE", {
|
|
5097
|
+
timeZone: "Asia/Singapore",
|
|
5098
|
+
dateStyle: "short",
|
|
5099
|
+
timeStyle: "short"
|
|
5100
|
+
});
|
|
5096
5101
|
var displayTime = (raw) => {
|
|
5097
5102
|
const date = new Date(raw);
|
|
5098
5103
|
return Number.isNaN(date.getTime()) ? raw : `${SINGAPORE_TIME.format(date)} SGT`;
|
|
5099
5104
|
};
|
|
5105
|
+
var displayChoiceTime = (raw) => {
|
|
5106
|
+
const date = new Date(raw);
|
|
5107
|
+
return Number.isNaN(date.getTime()) ? raw : SINGAPORE_CHOICE_TIME.format(date);
|
|
5108
|
+
};
|
|
5109
|
+
var buildRollbackChoices = (catalog) => catalog.candidates.filter((candidate) => !candidate.current).sort((left, right) => Date.parse(right.deployedAt) - Date.parse(left.deployedAt)).map((candidate) => ({
|
|
5110
|
+
name: `${displayChoiceTime(candidate.deployedAt)} SGT #${candidate.revision} ${candidate.version}`,
|
|
5111
|
+
value: candidate.revision
|
|
5112
|
+
}));
|
|
5100
5113
|
var gh = async (args) => {
|
|
5101
5114
|
const result = await runCommand("gh", args);
|
|
5102
5115
|
if (result.exitCode !== 0) {
|
|
@@ -5186,29 +5199,31 @@ var runTuttiRollback = async (options) => {
|
|
|
5186
5199
|
await ensureNoActiveDeployment();
|
|
5187
5200
|
const listRun = await dispatch("list");
|
|
5188
5201
|
const catalog = await fetchCatalog(listRun.runId);
|
|
5189
|
-
const choices = catalog
|
|
5190
|
-
|
|
5191
|
-
value: candidate.revision,
|
|
5192
|
-
disabled: candidate.current ? "currently deployed" : false
|
|
5193
|
-
}));
|
|
5194
|
-
logger.info("Production deployments, newest first:");
|
|
5195
|
-
choices.forEach((choice) => logger.info(choice.name));
|
|
5196
|
-
if (catalog.candidates.every((candidate) => candidate.current)) {
|
|
5202
|
+
const choices = buildRollbackChoices(catalog);
|
|
5203
|
+
if (choices.length === 0) {
|
|
5197
5204
|
throw new CliError("No previous retained production image is available to restore", 1);
|
|
5198
5205
|
}
|
|
5199
5206
|
let revision;
|
|
5200
5207
|
if (options.revision) {
|
|
5201
5208
|
revision = Number(options.revision);
|
|
5202
5209
|
} else {
|
|
5203
|
-
|
|
5210
|
+
const current = catalog.candidates.find((candidate) => candidate.current);
|
|
5211
|
+
logger.info(`Currently deployed: #${catalog.currentRevision} ${current?.version ?? catalog.currentDigest.slice(0, 19)}${current?.workflowSucceeded === false ? " [checks failed]" : ""}`);
|
|
5212
|
+
revision = await ui.select({
|
|
5213
|
+
message: "Select a production image to restore (newest first)",
|
|
5214
|
+
choices,
|
|
5215
|
+
pageSize: choices.length
|
|
5216
|
+
});
|
|
5204
5217
|
}
|
|
5205
5218
|
const selected = catalog.candidates.find((candidate) => candidate.revision === revision && !candidate.current);
|
|
5206
5219
|
if (!selected) {
|
|
5207
5220
|
throw new CliError(`Revision ${revision} is not an eligible recent deployment`, 1);
|
|
5208
5221
|
}
|
|
5209
5222
|
logger.info(`Environment: production`);
|
|
5210
|
-
logger.info(`Current: Helm revision ${catalog.currentRevision}
|
|
5211
|
-
logger.info(`
|
|
5223
|
+
logger.info(`Current: Helm revision ${catalog.currentRevision}`);
|
|
5224
|
+
logger.info(` ${catalog.currentDigest}`);
|
|
5225
|
+
logger.info(`Target: Helm revision ${selected.revision} / ${displayTime(selected.deployedAt)} / ${selected.version}`);
|
|
5226
|
+
logger.info(` ${selected.digest}`);
|
|
5212
5227
|
if (!options.yes && !await ui.confirm({ message: "Restore this image to production?", default: false })) {
|
|
5213
5228
|
logger.warn("Rollback cancelled");
|
|
5214
5229
|
return;
|