mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
905 B
25 lines
905 B
export async function task(): Promise<void> {
|
|
WIKI.logger.info('Checking for latest version...')
|
|
|
|
try {
|
|
const resp: { tag_name: string; published_at: string } = await fetch(
|
|
'https://api.github.com/repos/requarks/wiki/releases/latest'
|
|
).then((r) => r.json() as Promise<{ tag_name: string; published_at: string }>)
|
|
const strictVersion =
|
|
resp.tag_name.indexOf('v') === 0 ? resp.tag_name.substring(1) : resp.tag_name
|
|
WIKI.logger.info(`Latest version is ${resp.tag_name}.`)
|
|
WIKI.config.update = {
|
|
lastCheckedAt: new Date().toISOString(),
|
|
version: strictVersion,
|
|
versionDate: resp.published_at
|
|
}
|
|
await WIKI.configSvc.saveToDb(['update'])
|
|
|
|
WIKI.logger.info('Checked for latest version: [ COMPLETED ]')
|
|
} catch (err: any) {
|
|
WIKI.logger.error('Checking for latest version: [ FAILED ]')
|
|
WIKI.logger.error(err.message)
|
|
throw err
|
|
}
|
|
}
|