(type: VersionType)
| 30 | type VersionType = "date" | "tag"; |
| 31 | |
| 32 | async function getVersion(type: VersionType) { |
| 33 | if (type === "date") { |
| 34 | const data = (await (await fetch(FETCH_COMMIT_URL)).json()) as { |
| 35 | commit: { |
| 36 | author: { name: string; date: string }; |
| 37 | }; |
| 38 | sha: string; |
| 39 | }[]; |
| 40 | const remoteCommitTime = data[0].commit.author.date; |
| 41 | const remoteId = new Date(remoteCommitTime).getTime().toString(); |
| 42 | return remoteId; |
| 43 | } else if (type === "tag") { |
| 44 | const data = (await (await fetch(FETCH_TAG_URL)).json()) as { |
| 45 | commit: { sha: string; url: string }; |
| 46 | name: string; |
| 47 | }[]; |
| 48 | return data.at(0)?.name; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | export const useUpdateStore = createPersistStore( |
| 53 | { |
no test coverage detected