diff options
author | Adam Harrison <adamdharrison@gmail.com> | 2023-05-20 13:09:41 -0400 |
---|---|---|
committer | Adam Harrison <adamdharrison@gmail.com> | 2023-05-20 13:09:41 -0400 |
commit | 9cd48d16ffb1682327426428f8f8f5f98f2958db (patch) | |
tree | e520f10f0315543c8303efdde1a86bb07c38c7b7 | |
parent | 5cb8c16aa3ee62fe751b51dd57de8299dee4b7f5 (diff) | |
download | lite-xl-plugin-manager-9cd48d16ffb1682327426428f8f8f5f98f2958db.tar.gz lite-xl-plugin-manager-9cd48d16ffb1682327426428f8f8f5f98f2958db.zip |
Made it so you can specify repo urls in run for transient plugin running, made it so plugins sort properly, and made it so that if you try to unstub a plugin and the repo behind it is inaccessible, it is flagged, and only reported on if you try to do anything with it.
-rw-r--r-- | src/lpm.lua | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/lpm.lua b/src/lpm.lua index 9e37dfb..2ad058e 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -625,14 +625,18 @@ end function Addon:is_stub() return self.remote end function Addon:unstub() - if not self:is_stub() then return end - local repo = Repository.url(self.remote):fetch() - local manifest = repo:parse_manifest(self.id) - local remote_entry = common.grep(manifest['addons'] or manifest['plugins'], function(e) return e.id == self.id end)[1] - if not remote_entry then error("can't find " .. self.type .. " on " .. self.remote) end - local addon = Addon.new(repo, remote_entry) - -- merge in attribtues that are probably more accurate than the stub - for k,v in pairs(addon) do self[k] = v end + if not self:is_stub() or self.inaccessible then return end + local repo + local status, err = pcall(function() + repo = Repository.url(self.remote):fetch() + local manifest = repo:parse_manifest(self.id) + local remote_entry = common.grep(manifest['addons'] or manifest['plugins'], function(e) return e.id == self.id end)[1] + if not remote_entry then error("can't find " .. self.type .. " on " .. self.remote) end + local addon = Addon.new(repo, remote_entry) + -- merge in attribtues that are probably more accurate than the stub + for k,v in pairs(addon) do self[k] = v end + end) + if not status then self.inaccessible = err end return repo end @@ -720,6 +724,7 @@ end function Addon:install(bottle, installing) if self:is_installed(bottle) then error("addon " .. self.id .. " is already installed") return end if self:is_stub() then self:unstub() end + if self.inaccessible then error("addon " .. self.id .. " is inacessible: " .. self.inaccessible) end local install_path = self:get_install_path(bottle) local temporary_install_path = TMPDIR .. PATHSEP .. install_path:sub(#USERDIR + 2) local status, err = pcall(function() @@ -1342,7 +1347,7 @@ function Bottle:get_addon(id, version, filter) end end return table.unpack(common.sort(common.uniq(candidates), function (a,b) - return (a.replaces == id and b.replaces ~= id) or (a.version < b.version) + return (a.replaces == id and b.replaces ~= id) or (a.version > b.version) end)) end @@ -1363,6 +1368,7 @@ local function lpm_repo_save() end + local DEFAULT_REPOS local function lpm_repo_init(repos) DEFAULT_REPOS = { Repository.url("https://github.com/adamharrison/lite-xl-plugin-manager.git:latest") } @@ -1542,10 +1548,14 @@ local function lpm_lite_xl_run(version, ...) while i <= #arguments do if arguments[i] == "--" then break end local str = arguments[i] - local id, version = common.split(":", str) - local addon = system_bottle:get_addon(id, version, { mod_version = lite_xl.mod_version }) - if not addon then error("can't find addon " .. str) end - table.insert(addons, addon) + if str:find("^http") then + table.insert(repositories, 1, Repository.url(str):add()) + else + local id, version = common.split(":", str) + local addon = system_bottle:get_addon(id, version, { mod_version = lite_xl.mod_version }) + if not addon then error("can't find addon " .. str) end + table.insert(addons, addon) + end i = i + 1 end local bottle = Bottle.new(lite_xl, addons) |