← Public packages
@kentcdodds/package-app-kit
Design tokens, PWA install/update, About/version, cache helpers, and optional realtime notes sync for Kody package apps.
src/record-version.ts
48 lines · 1.5 KB · TypeScriptimport {
getAppVersion,
setAppVersion,
type AppVersion,
} from './version.ts'
/**
* Persist publish metadata in packageStorage for About + update checks.
* Mirror of `@kentcdodds/court-projector` `./record-version`. Call after a successful publish
* with the published commit SHA (and optional message / commit date).
*
* @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/package-app-kit/record-version'
* const version = await recordVersion({
* sha: 'abc1234deadbeef',
* message: 'Ship package-app-kit',
* committedAt: '2026-09-13T06:00:00.000Z',
* })
*/
export default async function recordVersion(input: {
sha: string
message?: string
committedAt?: string
publishedAt?: string
}): Promise<AppVersion> {
if (!input?.sha) throw new Error('sha is required')
return await setAppVersion(input)
}
/**
* Read the recorded version without writing.
* Prefer this for About / update-check server routes.
*
* @example
* import { readRecordedVersion } from 'kody:@kentcdodds/package-app-kit/record-version'
* const version = await readRecordedVersion()
*/
export async function readRecordedVersion(): Promise<AppVersion> {
return await getAppVersion()
}
export type { AppVersion }