From 3289cf7a0b96ef3d3af9737af58daa5fb5eebc20 Mon Sep 17 00:00:00 2001 From: Sunrise Date: Sun, 30 Jun 2024 00:45:26 +0800 Subject: [PATCH] Remove hardcoded Clang versions --- lib/util.lua | 69 ++++++++++++++++++---------------------------------- metadata.lua | 2 +- 2 files changed, 24 insertions(+), 47 deletions(-) diff --git a/lib/util.lua b/lib/util.lua index 4f45878..69e1bcf 100644 --- a/lib/util.lua +++ b/lib/util.lua @@ -1,49 +1,26 @@ -local ClangVersions = { - "18.1.8", - "18.1.7", - "18.1.6", - "18.1.5", - "18.1.4", - "18.1.3", - "18.1.2", - "18.1.1", - "17.0.6", - "17.0.5", - "17.0.4", - "17.0.3", - "17.0.2", - "17.0.1", - "16.0.6", - "16.0.5", - "16.0.4", - "16.0.3", - "16.0.2", - "16.0.1", - "16.0.0", - "15.0.7", - "15.0.6", - "15.0.5", - "15.0.4", - "15.0.3", - "15.0.2", - "15.0.1", - "15.0.0", - "14.0.6", - "14.0.5", - "14.0.4", - "14.0.3", - "14.0.0", - "13.0.1", - "13.0.0", - "12.0.1", - "12.0.0", - "11.1.0", - "11.0.1", - "11.0.0", - "10.0.1", - "10.0.0", - "9.0.1", -} +local http = require("http") +local json = require("json") + +function fetchVersions() + local versionList + local githubURL = os.getenv("GITHUB_URL") or "https://github.com/" + local resp, err = http.get({ + url = githubURL:gsub("/$", "") .. "/version-fox/vfox-clang/releases/manifest", + }) + if err ~= nil then + error("Failed to request: " .. err) + end + if resp.status_code ~= 200 then + error("Failed to get versions: " .. err .. "\nstatus_code => " .. resp.status_code) + end + + versionList = resp.body:match("(.-)") + versionList = json.decode(versionList)["conda-forge"] + + return versionList +end + +local ClangVersions = fetchVersions() function fetchAvailable(noCache) local result = {} diff --git a/metadata.lua b/metadata.lua index 2e1ba1c..efcff02 100644 --- a/metadata.lua +++ b/metadata.lua @@ -5,7 +5,7 @@ PLUGIN = {} --- Plugin name PLUGIN.name = "clang" --- Plugin version -PLUGIN.version = "0.1.1" +PLUGIN.version = "0.1.2" --- Plugin homepage PLUGIN.homepage = "https://github.com/version-fox/vfox-clang" --- Plugin license, please choose a correct license according to your needs.