generated from version-fox/vfox-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
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
111 additions
and
95 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,9 @@ | ||
# vfox-plugin-template | ||
# vfox-erlang plugin | ||
|
||
This is a [vfox plugin](https://vfox.lhan.me/plugins/create/howto.html) template with CI that package and publish the plugin. | ||
Erlang/OTP [vfox](https://github.com/version-fox) plugin. Use the vfox to manage multiple Erlang/OTP versions in Linux/Darwin. | ||
|
||
## 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). | ||
```shell | ||
vfox add erlang | ||
``` |
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,20 +1,8 @@ | ||
local util = require("util") | ||
local erlangUtils = require("erlang_utils") | ||
|
||
--- 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() | ||
return { | ||
{ | ||
version = "xxxx", | ||
note = "LTS", | ||
addition = { | ||
{ | ||
name = "npm", | ||
version = "8.8.8", | ||
} | ||
} | ||
} | ||
} | ||
return erlangUtils.get_erlang_release_verions() | ||
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,39 +1,24 @@ | ||
local erlangUtils = require("erlang_utils") | ||
|
||
--- 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 | ||
|
||
erlangUtils.check_platform() | ||
|
||
local erlang_version = ctx.version | ||
if erlang_version == nil then | ||
print("You will install the Erlang/OTP version is" .. erlang_version) | ||
error("You must provide a version number for Erlang/OTP, eg: vfox install erlang@24.1") | ||
end | ||
erlangUtils.check_version_existence("https://github.com/erlang/otp/releases/tag/OTP-" .. erlang_version) | ||
|
||
local download_url = "https://github.com/erlang/otp/archive/refs/tags/OTP-" .. erlang_version .. ".tar.gz" | ||
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 = erlang_version, | ||
url = download_url | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
local http = require("http") | ||
|
||
local erlang_utils = {} | ||
|
||
local function peek_lua_table(o, indent) | ||
indent = indent or 0 | ||
|
||
local function handle_table(t, currentIndent) | ||
local result = {} | ||
for k, v in pairs(t) do | ||
local key = type(k) ~= 'number' and ('[' .. peek_lua_table(k, currentIndent + 1) .. ']') or '' | ||
local value = type(v) == 'table' and handle_table(v, currentIndent + 1) or peek_lua_table(v, currentIndent + 1) | ||
table.insert(result, key .. (key ~= '' and ' = ' or '') .. value) | ||
end | ||
return '{\n' .. table.concat(result, ',\n') .. '\n' .. string.rep(' ', currentIndent) .. '}' | ||
end | ||
|
||
if type(o) == 'table' then | ||
return handle_table(o, indent) | ||
else | ||
return tostring(o) | ||
end | ||
end | ||
|
||
function erlang_utils.check_platform() | ||
if RUNTIME.OS_TYPE == "windows" then | ||
error("Windows is not supported. Please direct use the offcial installer to setup Erlang/OTP. visit: https://www.erlang.org/downloads") | ||
end | ||
end | ||
|
||
function erlang_utils.check_version_existence(url) | ||
local resp, err = http.get({ | ||
url = url | ||
}) | ||
if err ~= nil or resp.status_code ~= 200 then | ||
error("Please confirm whether the corresponding Erlang/OTP release version exists! visit: https://github.com/erlang/otp/releases") | ||
end | ||
end | ||
|
||
function erlang_utils.get_erlang_release_verions() | ||
local resp, err = http.get({ | ||
url = "https://github.com/raw/yeshan333/vfox-erlang/main/.github/workflows/versions.txt" | ||
}) | ||
local result = {} | ||
-- print("resp.body: " .. resp.body) | ||
print(type(resp.body)) | ||
for version in string.gmatch(resp.body, '([^\n]+)') do | ||
table.insert(result, { | ||
version = version | ||
}) | ||
end | ||
-- print(peek_lua_table(result)) | ||
return result | ||
end | ||
|
||
return erlang_utils |
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