feat: signed releases, release feed, notification (read-only)

This commit is contained in:
fsylvain committed 2026-10-01 15:01:53 +02:00
1 parent a49eec909c
commit 834493a4f5
49 files changed
+4191 -18

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
import { formatAbsoluteDateFromIso } from '@/lib/relativeDate'
export const ENABLE_BROWSER_UPDATES_COMMAND = 'renewcms enable-browser-updates'
export const AUTO_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000
export function displayVersion(tag: string) {
return tag.replace(/^v/, '')
}
function isSameLocalDay(a: Date, b: Date) {
return (
a.getFullYear() === b.getFullYear() &&
a.getMonth() === b.getMonth() &&
a.getDate() === b.getDate()
)
}
function formatClock(date: Date) {
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
return `${hours}:${minutes}`
}
export function formatLastChecked(iso: string, now: Date = new Date()) {
const date = new Date(iso)
const yesterday = new Date(now)
yesterday.setDate(now.getDate() - 1)
if (isSameLocalDay(date, now)) {
return `Last checked today at ${formatClock(date)}`
}
if (isSameLocalDay(date, yesterday)) {
return `Last checked yesterday at ${formatClock(date)}`
}
return `Last checked ${formatAbsoluteDateFromIso(iso)} at ${formatClock(date)}`
}
export function isCheckDue(checkedAt: string | null, now: number = Date.now()) {
if (checkedAt === null) {
return true
}
return now - new Date(checkedAt).getTime() > AUTO_CHECK_INTERVAL_MS
}
export function formatReleased(iso: string) {
return `Released ${formatAbsoluteDateFromIso(iso)}`
}