Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kentcdodds/lineage

src/version-shape.ts

28 lines · 607 B · TypeScript
export type AppVersion = {
	sha: string
	shortSha: string
	message: string
	committedAt: string
	publishedAt: string
}

export function emptyVersion(): AppVersion {
	return {
		sha: '',
		shortSha: '',
		message: '',
		committedAt: '',
		publishedAt: '',
	}
}

export function normalizeVersion(input: Partial<AppVersion> & { sha?: string }): AppVersion {
	const sha = String(input.sha ?? '').trim()
	return {
		sha,
		shortSha: sha.slice(0, 7),
		message: String(input.message ?? '').split('\n')[0] ?? '',
		committedAt: String(input.committedAt ?? ''),
		publishedAt: String(input.publishedAt ?? ''),
	}
}