This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c40506
commit 9e96686
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const user = "ArchiDog1998"; | ||
const repos = [ | ||
"RotationSolver", | ||
]; | ||
|
||
const clearText = (str) => { | ||
return str | ||
.replace(/\p{Extended_Pictographic}/gu, "") // remove emojis | ||
.replace(/\*\*(.*)\*\*/g, "$1") // extract markdown bold text | ||
.replace(/\[([^\)]+)\]\([^\)]+\)/g, "$1") // extract markdown link label | ||
.split(/\r?\n/g) | ||
.map(line => line.replace(/^#+\s+/g, "")) | ||
.join("\n"); | ||
}; | ||
|
||
const output = await Promise.all(repos.map(async (repo) => { | ||
const res = await fetch(`https://api.github.com/repos/${user}/${repo}/releases/latest`); | ||
const data = await res.json(); | ||
const base = { | ||
AssemblyVersion: data.tag_name.replace(/^v/, ""), | ||
Changelog: clearText(data.body), | ||
DownloadCount: data.assets[0].download_count, | ||
LastUpdate: new Date(data.published_at).valueOf() / 1000, | ||
DownloadLinkInstall: data.assets[0].browser_download_url, | ||
DownloadLinkUpdate: data.assets[0].browser_download_url, | ||
}; | ||
|
||
const manifestAsset = data.assets.find(asset => asset.name == "manifest.json"); | ||
if (!manifestAsset) { | ||
return Object.assign({ | ||
Author: user, | ||
Name: repo, | ||
InternalName: repo, | ||
RepoUrl: `https://github.com/${user}/${repo}`, | ||
ApplicableVersion: "any", | ||
DalamudApiLevel: 6, | ||
}, base); | ||
} | ||
|
||
const manifestRes = await fetch(manifestAsset.browser_download_url); | ||
const manifest = await manifestRes.json(); | ||
return Object.assign(manifest, base); | ||
})); | ||
|
||
await Deno.writeTextFile("repo.json", JSON.stringify(output, null, 2)); |