chore: update public repo

This commit is contained in:
desu-bot 2025-01-14 02:38:00 +00:00
parent e0109980c0
commit e7c9507247
No known key found for this signature in database
25 changed files with 5364 additions and 0 deletions

View file

@ -0,0 +1,51 @@
import { readFile } from 'node:fs/promises'
import { join } from 'node:path'
import plist from 'plist'
import { z } from 'zod'
import { $ } from 'zx'
import { ffetch } from '../../utils/fetch.ts'
const latestVerInfo = await ffetch('https://api.github.com/repos/forkgram/tdesktop/releases/latest').parsedJson(
z.object({
tag_name: z.string().transform(v => v.replace(/^v/, '')),
assets: z.array(z.object({
name: z.string(),
browser_download_url: z.string(),
})),
}),
)
const INSTALL_PATH = '/Applications/Forkgram.app'
console.log('latest version:', latestVerInfo.tag_name)
const installedPlist = await readFile(join(INSTALL_PATH, 'Contents/Info.plist'), 'utf8')
const installedPlistParsed = z.object({
CFBundleShortVersionString: z.string(),
}).parse(plist.parse(installedPlist))
console.log('installed version:', installedPlistParsed.CFBundleShortVersionString)
if (installedPlistParsed.CFBundleShortVersionString === latestVerInfo.tag_name) {
console.log('✅ no update needed')
process.exit(0)
}
const arm64Asset = latestVerInfo.assets.find(asset => asset.name === 'Forkgram.macOS.no.auto-update_arm64.zip')
if (!arm64Asset) {
console.error('❌ no arm64 asset found')
process.exit(1)
}
console.log('installing new version...')
await $`curl -L ${arm64Asset.browser_download_url} -o /tmp/forkgram.zip`
await $`unzip -o /tmp/forkgram.zip -d /tmp/forkgram`
await $`kill -9 $(pgrep -f /Applications/Forkgram.app/Contents/MacOS/Telegram)`
await $`rm -rf ${INSTALL_PATH}`
await $`mv /tmp/forkgram/Telegram.app ${INSTALL_PATH}`
await $`rm -rf /tmp/forkgram`
await $`xattr -cr ${INSTALL_PATH}`
await $`open ${INSTALL_PATH}`
console.log('✅ done')