1
0

Merge pull request #48 from Willyfrog/github-releases-protocol

Add GHR protocol to plug manager
This commit is contained in:
Zef Hemel 2022-07-24 09:15:10 +02:00 committed by GitHub
commit 1816925e37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View File

@ -280,7 +280,10 @@ functions:
path: "./plugmanager.ts:getPlugGithub" path: "./plugmanager.ts:getPlugGithub"
events: events:
- get-plug:github - get-plug:github
getPlugGithubRelease:
path: "./plugmanager.ts:getPlugGithubRelease"
events:
- get-plug:ghr
# Debug commands # Debug commands
parseCommand: parseCommand:
path: ./debug.ts:parsePageCommand path: ./debug.ts:parsePageCommand

View File

@ -92,3 +92,18 @@ export async function getPlugGithub(identifier: string): Promise<Manifest> {
`//raw.githubusercontent.com/${owner}/${repoClean}/${branch}/${path}` `//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);
}

View File

@ -52,6 +52,7 @@ Reload your list of plugs via the `Plugs: Update` command (`Cmd-Shift-p` on Mac,
Once youre happy with your plug, you can distribute it in various ways: Once youre happy with your plug, you can distribute it in various ways:
* You can put it on github by simply committing the resulting `.plug.json` file there and instructing users to point to by adding `- github:yourgithubuser/yourrepo/yourplugname.plug.json` to their `PLUGS` file * You can put it on github by simply committing the resulting `.plug.json` file there and instructing users to point to by adding `- github:yourgithubuser/yourrepo/yourplugname.plug.json` to their `PLUGS` file
* Add a release in your github repo and instruct users to add the release as `- ghr:yourgithubuser/yourrepo` or if they need a spcecific release `- ghr:yourgithubuser/yourrepo/release-name`
* You can put it on any other web server, and tell people to load it via https, e.g. `- https://mydomain.com/mypugname.plug.json`. * You can put it on any other web server, and tell people to load it via https, e.g. `- https://mydomain.com/mypugname.plug.json`.
### Recommended development workflow ### Recommended development workflow