aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/sources/github.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/mason-registry/sources/github.lua')
-rw-r--r--lua/mason-registry/sources/github.lua20
1 files changed, 8 insertions, 12 deletions
diff --git a/lua/mason-registry/sources/github.lua b/lua/mason-registry/sources/github.lua
index b314d690..ceb503dc 100644
--- a/lua/mason-registry/sources/github.lua
+++ b/lua/mason-registry/sources/github.lua
@@ -15,7 +15,6 @@ local parse_checksums = _.compose(_.from_pairs, _.map(_.compose(_.reverse, _.spl
---@class GitHubRegistrySourceSpec
---@field id string
----@field repo string
---@field namespace string
---@field name string
---@field version string?
@@ -38,6 +37,7 @@ function GitHubRegistrySource:new(spec)
local root_dir = InstallLocation.global():registry(path.concat { "github", spec.namespace, spec.name })
instance.id = spec.id
instance.spec = spec
+ instance.repo = ("%s/%s"):format(spec.namespace, spec.name)
instance.root_dir = root_dir
instance.data_file = path.concat { root_dir, "registry.json" }
instance.info_file = path.concat { root_dir, "info.json" }
@@ -81,10 +81,6 @@ function GitHubRegistrySource:get_all_package_names()
return _.map(_.prop "name", self:get_all_package_specs())
end
-function GitHubRegistrySource:get_installer()
- return Optional.of(_.partial(self.install, self))
-end
-
---@async
function GitHubRegistrySource:install()
local zzlib = require "mason-vendor.zzlib"
@@ -106,7 +102,7 @@ function GitHubRegistrySource:install()
---@type GitHubRelease
local release = try(
providers.github
- .get_latest_release(self.spec.repo)
+ .get_latest_release(self.repo)
:map_err(_.always "Failed to fetch latest registry version from GitHub API.")
)
version = release.tag_name
@@ -114,7 +110,7 @@ function GitHubRegistrySource:install()
end
local zip_file = path.concat { self.root_dir, "registry.json.zip" }
- try(fetch(settings.current.github.download_url_template:format(self.spec.repo, version, "registry.json.zip"), {
+ try(fetch(settings.current.github.download_url_template:format(self.repo, version, "registry.json.zip"), {
out_file = zip_file,
}):map_err(_.always "Failed to download registry archive."))
local zip_buffer = fs.async.read_file(zip_file)
@@ -126,7 +122,7 @@ function GitHubRegistrySource:install()
pcall(fs.async.unlink, zip_file)
local checksums = try(
- fetch(settings.current.github.download_url_template:format(self.spec.repo, version, "checksums.txt")):map_err(
+ fetch(settings.current.github.download_url_template:format(self.repo, version, "checksums.txt")):map_err(
_.always "Failed to download checksums.txt."
)
)
@@ -158,17 +154,17 @@ end
function GitHubRegistrySource:get_display_name()
if self:is_installed() then
local info = self:get_info()
- return ("github.com/%s version: %s"):format(self.spec.repo, info.version)
+ return ("github.com/%s version: %s"):format(self.repo, info.version)
else
- return ("github.com/%s [uninstalled]"):format(self.spec.repo)
+ return ("github.com/%s [uninstalled]"):format(self.repo)
end
end
function GitHubRegistrySource:__tostring()
if self.spec.version then
- return ("GitHubRegistrySource(repo=%s, version=%s)"):format(self.spec.repo, self.spec.version)
+ return ("GitHubRegistrySource(repo=%s, version=%s)"):format(self.repo, self.spec.version)
else
- return ("GitHubRegistrySource(repo=%s)"):format(self.spec.repo)
+ return ("GitHubRegistrySource(repo=%s)"):format(self.repo)
end
end