Merge pull request #48 from Willyfrog/github-releases-protocol
Add GHR protocol to plug manager
This commit is contained in:
commit
1816925e37
@ -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
|
||||
|
@ -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);
|
||||
}
|
@ -52,6 +52,7 @@ Reload your list of plugs via the `Plugs: Update` command (`Cmd-Shift-p` on Mac,
|
||||
Once you’re 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
|
||||
* 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`.
|
||||
|
||||
### Recommended development workflow
|
||||
|
Loading…
Reference in New Issue
Block a user