generated from version-fox/vfox-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
9 changed files
with
81 additions
and
122 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 |
---|---|---|
@@ -1,15 +1,7 @@ | ||
# vfox-plugin-template | ||
|
||
This is a [vfox plugin](https://vfox.lhan.me/plugins/create/howto.html) template with CI that package and publish the plugin. | ||
|
||
## Usage | ||
|
||
1. [Generate](https://github.com/version-fox/vfox-plugin-template/generate) a new repository based on this template. | ||
2. Configure [metadata](https://github.com/version-fox/vfox-plugin-template/blob/main/metadata.lua) information | ||
3. To develop your plugin further, please read [the plugins create section of the docs](https://vfox.lhan.me/plugins/create/howto.html). | ||
|
||
|
||
## How to publish? | ||
|
||
1. Push a new tag to the repository which name is `vX.Y.Z` (X.Y.Z is the version number). | ||
2. The CI will automatically package, then publish [release](https://github.com/version-fox/vfox-plugin-template/releases/tag/v0.0.1) and publish [manifest](https://github.com/version-fox/vfox-plugin-template/releases/tag/manifest). | ||
# Introduction | ||
vfox-deno is a plugin for [vfox](https://vfox.lhan.me/). | ||
# Install | ||
After installing vfox, run the following command to add the plugin: | ||
```bash | ||
vfox add deno | ||
``` |
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 |
---|---|---|
@@ -1,21 +1,28 @@ | ||
local util = require("util") | ||
|
||
local http = require("http") | ||
--- Return all available versions provided by this plugin | ||
--- @param ctx table Empty table used as context, for future extension | ||
--- @return table Descriptions of available versions and accompanying tool descriptions | ||
function PLUGIN:Available(ctx) | ||
util:DoSomeThing() | ||
local runtimeVersion = ctx.runtimeVersion | ||
return { | ||
{ | ||
version = "xxxx", | ||
note = "LTS", | ||
addition = { | ||
{ | ||
name = "npm", | ||
version = "8.8.8", | ||
} | ||
} | ||
} | ||
} | ||
local resp, err = http.get({ | ||
url = util.ReleaseURL | ||
}) | ||
if err ~= nil or resp.status_code ~= 200 then | ||
return {} | ||
end | ||
local result = {} | ||
for line in string.gmatch(resp.body, '([^\n]*)\n?') do | ||
if string.match(line, "^###") then | ||
local start = string.sub(line, 5) | ||
local version = string.sub(start, 1, -14) | ||
if string.sub(version, 1, 1) == "v" then | ||
version = string.sub(version, 2) | ||
end | ||
table.insert(result, { | ||
version = version, | ||
note = "" | ||
}) | ||
end | ||
end | ||
return result | ||
end |
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
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
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 |
---|---|---|
@@ -1,40 +1,20 @@ | ||
local util = require("util") | ||
--- Returns some pre-installed information, such as version number, download address, local files, etc. | ||
--- If checksum is provided, vfox will automatically check it for you. | ||
--- @param ctx table | ||
--- @field ctx.version string User-input version | ||
--- @return table Version information | ||
function PLUGIN:PreInstall(ctx) | ||
local version = ctx.version | ||
local runtimeVersion = ctx.runtimeVersion | ||
|
||
local type = util:getOsTypeAndArch() | ||
if version == "latest" then | ||
local lists = self:Available({}) | ||
version = lists[1].version | ||
end | ||
local filename = "deno-" .. type.archType .. "-" .. type.osType .. ".zip" | ||
return { | ||
--- Version number | ||
version = "xxx", | ||
--- remote URL or local file path [optional] | ||
url = "xxx", | ||
--- SHA256 checksum [optional] | ||
sha256 = "xxx", | ||
--- md5 checksum [optional] | ||
md5 = "xxx", | ||
--- sha1 checksum [optional] | ||
sha1 = "xxx", | ||
--- sha512 checksum [optional] | ||
sha512 = "xx", | ||
--- additional need files [optional] | ||
addition = { | ||
{ | ||
--- additional file name ! | ||
name = "xxx", | ||
--- remote URL or local file path [optional] | ||
url = "xxx", | ||
--- SHA256 checksum [optional] | ||
sha256 = "xxx", | ||
--- md5 checksum [optional] | ||
md5 = "xxx", | ||
--- sha1 checksum [optional] | ||
sha1 = "xxx", | ||
--- sha512 checksum [optional] | ||
sha512 = "xx", | ||
} | ||
} | ||
version = version, | ||
url = util.DownloadURL:format(version, filename), | ||
} | ||
end |
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
This file was deleted.
Oops, something went wrong.
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,33 @@ | ||
|
||
local util = {} | ||
|
||
util.ReleaseURL = "https://raw.githubusercontent.com/denoland/deno/main/Releases.md" | ||
util.DownloadURL = "https://github.com/denoland/deno/releases/download/v%s/%s" | ||
|
||
function util:getOsTypeAndArch() | ||
local osType = RUNTIME.osType | ||
local archType = RUNTIME.archType | ||
if RUNTIME.osType == "darwin" then | ||
osType = "apple-darwin" | ||
elseif RUNTIME.osType == "windows" then | ||
osType = "pc-windows-msvc" | ||
elseif RUNTIME.osType == "linux" then | ||
osType = "unknown-linux-gnu" | ||
else | ||
error("Deno does not support " .. RUNTIME.osType .. " os") | ||
end | ||
if RUNTIME.archType == "amd64" then | ||
archType = "x86_64" | ||
elseif RUNTIME.archType == "arm64" then | ||
archType = "aarch64" | ||
else | ||
error("Deno does not support " .. RUNTIME.archType .. " architecture") | ||
end | ||
return { | ||
osType = osType, archType = archType | ||
} | ||
end | ||
|
||
|
||
|
||
return util |
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