()
| 70 | } |
| 71 | |
| 72 | async function listVersions(): Promise<void> { |
| 73 | const [versions, publishTimes] = await Promise.all([ |
| 74 | getVersionHistory(DEFAULT_VERSION_HISTORY_LIMIT), |
| 75 | getVersionPublishTimes(), |
| 76 | ]) |
| 77 | |
| 78 | if (versions.length === 0) { |
| 79 | writeToStderr('No published versions found.\n') |
| 80 | await gracefulShutdown(1) |
| 81 | return |
| 82 | } |
| 83 | |
| 84 | const versionWidth = Math.max(...versions.map(version => version.length)) |
| 85 | |
| 86 | writeToStdout(`Current version: ${MACRO.VERSION}\n\n`) |
| 87 | versions.forEach((version, index) => { |
| 88 | const age = formatAge(publishTimes[version]) |
| 89 | const current = version === MACRO.VERSION ? ' (current)' : '' |
| 90 | writeToStdout( |
| 91 | `${String(index).padStart(2)} ${version.padEnd(versionWidth)} ${age}${current}\n`, |
| 92 | ) |
| 93 | }) |
| 94 | |
| 95 | await gracefulShutdown(0) |
| 96 | } |
| 97 | |
| 98 | async function resolveRollbackTarget( |
| 99 | target: string | undefined, |
no test coverage detected