import { getAppVersion, setAppVersion, type AppVersion } from './version.ts' /** * Persist publish metadata in this app's packageStorage for About + update checks. * * Do not re-export the kit's ./record-version: that writes the kit's storage and * fails packageStorage provenance when called as kody:@scope/app/record-version. * * @param input.sha - Full git commit SHA (required) * @param input.message - First-line commit message * @param input.committedAt - Commit author/committer ISO time * @param input.publishedAt - Publish time (defaults to now) * @returns Normalized AppVersion stored in packageStorage * * @example * import recordVersion from 'kody:@kentcdodds/pocket-piano/record-version' * await recordVersion({ sha: 'abc123', message: 'Ship' }) */ export default async function recordVersion(input: { sha: string message?: string committedAt?: string publishedAt?: string }): Promise { if (!input?.sha) throw new Error('sha is required') return await setAppVersion(input) } /** * Read the recorded version without writing. * Prefer this (or a relative import) for About / update-check server routes. * * @example * import { readRecordedVersion } from './record-version.ts' * const version = await readRecordedVersion() */ export async function readRecordedVersion(): Promise { return await getAppVersion() } export type { AppVersion }