Skip to content

Commit

Permalink
chore: latest releases change check method
Browse files Browse the repository at this point in the history
  • Loading branch information
hywax committed Mar 17, 2024
1 parent fd06fc0 commit 9762d64
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/server/api/update.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import currentPackage from '~~/package.json'

export default defineEventHandler(async () => {
const latestPackage = await $fetch<typeof currentPackage>('https://raw.githubusercontent.com/hywax/mafl/main/package.json', {
const latestReleases = await $fetch<typeof currentPackage>('https://api.github.com/repos/hywax/mafl/releases/latest', {
parseResponse: (json) => JSON.parse(json),
})
const latestVersion = latestReleases.tag_name.replace('v', '')

Check failure on line 7 in src/server/api/update.ts

View workflow job for this annotation

GitHub Actions / ubuntu-latest

Property 'tag_name' does not exist on type '{ type: string; version: string; private: boolean; scripts: { build: string; dev: string; "dev:pwa": string; release: string; generate: string; preview: string; postinstall: string; lint: string; typecheck: string; prepare: string; "docs:dev": string; "docs:build": string; "docs:preview": string; }; dependencies: { ...'.

const parseVersion = (version: string): number => Number.parseInt(version.replace(/\./g, ''), 10)
const difference = parseVersion(latestPackage.version) - parseVersion(currentPackage.version)
const difference = parseVersion(latestVersion) - parseVersion(currentPackage.version)

return {
available: difference > 0,
version: latestPackage.version,
version: latestVersion,
}
})

0 comments on commit 9762d64

Please sign in to comment.