1
0

Merge branch 'main' of github.com:silverbulletmd/silverbullet

This commit is contained in:
Zef Hemel
2022-07-25 14:11:40 +02:00
14 changed files with 286 additions and 157 deletions
+4 -1
View File
@@ -280,7 +280,10 @@ functions:
path: "./plugmanager.ts:getPlugGithub"
events:
- get-plug:github
getPlugGithubRelease:
path: "./plugmanager.ts:getPlugGithubRelease"
events:
- get-plug:ghr
# Debug commands
parseCommand:
path: ./debug.ts:parsePageCommand
+15
View File
@@ -92,3 +92,18 @@ export async function getPlugGithub(identifier: string): Promise<Manifest> {
`//raw.githubusercontent.com/${owner}/${repoClean}/${branch}/${path}`
);
}
export async function getPlugGithubRelease(identifier: string): Promise<Manifest> {
let [owner, repo, version] = identifier.split("/");
if (!version || version === "latest") {
console.log('fetching the latest version');
const req = await fetch(`https://api.github.com/repos/${owner}/${repo}/releases/latest`);
if (req.status !== 200) {
throw new Error(`Could not fetch latest relase manifest from ${identifier}}`);
}
const result = await req.json();
version = result.name;
}
const finalUrl = `//github.com/${owner}/${repo}/releases/download/${version}/${repo}.plug.json`;
return getPlugHTTPS(finalUrl);
}