Cleanup and @lezer/lr upgrade

This commit is contained in:
Zef Hemel
2022-06-29 15:03:06 +02:00
parent db82ade33b
commit bcff45e7ad
19 changed files with 80 additions and 2352 deletions
+8
View File
@@ -172,6 +172,14 @@ functions:
updatePlugs:
path: ./plugmanager.ts:updatePlugs
env: server
getPlugHTTPS:
path: "./plugmanager.ts:getPlugHTTPS"
events:
- get-plug:https
getPlugGithub:
path: "./plugmanager.ts:getPlugGithub"
events:
- get-plug:github
# Debug commands
parseServerCommand:
+29 -1
View File
@@ -1,6 +1,10 @@
import { dispatch } from "@plugos/plugos-syscall/event";
import { Manifest } from "@silverbulletmd/common/manifest";
import { findNodeOfType } from "@silverbulletmd/common/tree";
import { flashNotification } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import {
flashNotification,
save,
} from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
import {
deletePage,
@@ -22,6 +26,7 @@ async function listPlugs(): Promise<string[]> {
}
export async function updatePlugsCommand() {
await save();
flashNotification("Updating plugs...");
await invokeFunction("server", "updatePlugs");
flashNotification("And... done!");
@@ -67,3 +72,26 @@ export async function updatePlugs() {
}
await reloadPlugs();
}
export async function getPlugHTTPS(url: string): Promise<Manifest> {
let fullUrl = `https:${url}`;
console.log("Now fetching plug manifest from", fullUrl);
let req = await fetch(fullUrl);
if (req.status !== 200) {
throw new Error(`Could not fetch plug manifest from ${fullUrl}`);
}
let json = await req.json();
return json;
}
export async function getPlugGithub(identifier: string): Promise<Manifest> {
let [owner, repo, path] = identifier.split("/");
let [repoClean, branch] = repo.split("@");
if (!branch) {
branch = "main"; // or "master"?
}
return getPlugHTTPS(
`//raw.githubusercontent.com/${owner}/${repoClean}/${branch}/${path}`
);
}