summaryrefslogtreecommitdiff
path: root/xmake/actions
diff options
context:
space:
mode:
authorruki <[email protected]>2026-08-14 23:42:13 +0800
committerruki <[email protected]>2026-08-14 23:42:13 +0800
commit46141dbac176444bd1ed114ea419d4bb8e6d2e13 (patch)
tree5bb62ecf325bd4d42bcedd2440a35dddada97c57 /xmake/actions
parenta79cf74f920c088528d66a67a59b3d8eaa1d4f7a (diff)
update lock and version
Diffstat (limited to 'xmake/actions')
-rw-r--r--xmake/actions/addon/main.lua50
-rw-r--r--xmake/actions/addon/xmake.lua5
2 files changed, 43 insertions, 12 deletions
diff --git a/xmake/actions/addon/main.lua b/xmake/actions/addon/main.lua
index 7af106c05..6a4bd06ca 100644
--- a/xmake/actions/addon/main.lua
+++ b/xmake/actions/addon/main.lua
@@ -226,10 +226,36 @@ end
-- remove the given installed addons
function _remove()
- local names = assert(option.get("addons"), "please specify the addon name to be removed!")
+ local names = option.get("addons")
+
+ -- remove all the installed addons? e.g. xmake addon --remove --all
+ --
+ -- @note we remove them one by one, so we can also remove the symlinks safely,
+ -- and the dependencies between them do not matter, they are all removed
+ --
+ if option.get("all") then
+ names = table.keys(addon.addons())
+ if #names == 0 then
+ cprint("${color.warning}no installed addons!")
+ return
+ end
+ for _, name in ipairs(names) do
+ addon.remove(name, {force = true})
+ cprint("${color.success}remove ${bright}%s${clear} ok!", name)
+ end
+ return
+ end
+
+ assert(names, "please specify the addon name to be removed!")
_xrepo("remove", names)
end
+-- upgrade the addons which the current project declares in its `xmake-addons.lua`
+function _upgrade()
+ import("private.addons", {alias = "install_addons"})
+ install_addons(os.projectdir(), {upgrade = true})
+end
+
-- search the addons from the repositories
function _search()
local patterns = assert(option.get("addons"), "please specify the addon name pattern to be searched!")
@@ -243,8 +269,12 @@ end
--
function _collect_installed_addons()
local entries = {}
- for name, addoninfo in pairs(addon.rescan()) do
+ for name, addoninfo in pairs(addon.addons()) do
+ -- an addon can be installed with several versions, we show the active one,
+ -- the projects can lock the other ones, @see core/project/addons.lua
+ local versions = addon.versions(name)
table.insert(entries, {name = name, version = addoninfo.version,
+ versions = #versions > 1 and versions or nil,
description = addoninfo.description, payloads = addoninfo.payloads})
end
table.sort(entries, function (a, b) return a.name < b.name end)
@@ -285,7 +315,11 @@ function _list()
if #installed > 0 then
for _, entry in ipairs(installed) do
exclude[entry.name] = true
- _print_addon(entry, string.format(" ${dim}(%s)${clear}", table.concat(entry.payloads, ", ")))
+ local suffix = string.format(" ${dim}(%s)${clear}", table.concat(entry.payloads, ", "))
+ if entry.versions then
+ suffix = suffix .. string.format(" ${dim}[installed: %s]${clear}", table.concat(entry.versions, ", "))
+ end
+ _print_addon(entry, suffix)
end
else
print(" (none)")
@@ -308,22 +342,16 @@ function _list()
end
end
--- clear all installed addons
-function _clear()
- addon.clear()
- cprint("${color.success}clear all installed addons ok!")
-end
-
function main()
if option.get("install") then
_install()
elseif option.get("remove") then
_remove()
+ elseif option.get("upgrade") then
+ _upgrade()
elseif option.get("list") then
_list()
elseif option.get("search") then
_search()
- elseif option.get("clear") then
- _clear()
end
end
diff --git a/xmake/actions/addon/xmake.lua b/xmake/actions/addon/xmake.lua
index 3c814cc6d..a0266aa4f 100644
--- a/xmake/actions/addon/xmake.lua
+++ b/xmake/actions/addon/xmake.lua
@@ -29,7 +29,8 @@ task("addon")
{'r', "remove", "k", nil, "Remove the given installed addons."},
{'s', "search", "k", nil, "Search the addons from the repositories."},
{'l', "list", "k", nil, "List all installed addons."},
- {'c', "clear", "k", nil, "Clear all installed addons."},
+ {'u', "upgrade", "k", nil, "Upgrade the addons which the current project declares."},
+ {nil, "all", "k", nil, "Remove all installed addons, e.g. xmake addon --remove --all"},
{'f', "force", "k", nil, "Force to remove the addons, even if they are depended on by the others."},
{nil, "addons", "vs", nil, "The addon paths, urls or names.",
"e.g.",
@@ -40,6 +41,8 @@ task("addon")
" $ xmake addon --install xmake-repo@serial-monitor",
" $ xmake addon --install serial-monitor",
" $ xmake addon --remove serial-monitor",
+ " $ xmake addon --remove --all",
+ " $ xmake addon --upgrade",
" $ xmake addon --search serial",
" $ xmake addon --list"}
}