also looking at this
docs: align update acceptance with protected preparation
#48
27 files
+1676
-74
| @@ -0,0 +1,21 @@ | ||
| 1 | import { defineCommand } from '@stacksjs/cli' | |
| 2 | import { printAsync, printErrorAsync } from '../../resources/functions/cli/output' | |
| 3 | import { storeCommandReference, storeReferenceFlags } from '../../resources/functions/drone/updates/command' | |
| 4 | import { prepareRuntimeFirmwareUpdate } from '../../resources/functions/drone/updates/store' | |
| 5 | ||
| 6 | export default defineCommand({ | |
| 7 | name: 'updates:prepare <directory>', | |
| 8 | description: 'Authenticate a signed image under protected metadata into a new candidate without installing firmware', | |
| 9 | options: { ...storeReferenceFlags, '--repository <path>': 'Bounded offline signed-image repository', '--output <path>': 'New exclusive candidate directory', '--trusted-system-clock-source <name>': 'Audit label for the independently managed trusted system clock, not an attestation' }, | |
| 10 | async handle(options, directory) { | |
| 11 | try { | |
| 12 | if (typeof options.repository !== 'string' || typeof options.output !== 'string' || typeof options.trustedSystemClockSource !== 'string') throw new Error('Explicit repository, output and independently trusted system-clock source required') | |
| 13 | await printAsync(JSON.stringify(await prepareRuntimeFirmwareUpdate({ ...storeCommandReference(options, directory), repository: options.repository, output: options.output, clock: { source: options.trustedSystemClockSource, read: () => new Date() } }))) | |
| 14 | } | |
| 15 | catch { | |
| 16 | process.exitCode = 1 | |
| 17 | try { await printErrorAsync('Runtime image preparation unavailable: invalid trust, clock, rejected image or output failure') } | |
| 18 | catch { /* Preserve failure when the diagnostic pipe also fails. */ } | |
| 19 | } | |
| 20 | }, | |
| 21 | }) | |