aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helpers
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2023-09-11 00:37:05 +0200
committerWilliam Boman <william@redwill.se>2025-02-16 09:48:59 +0100
commitd0119c18adff184c5c75f7ec59b6f12b301d268d (patch)
tree3f196ef7cdde464392c0680edcd57fc6fe47825a /tests/helpers
parentrefactor!: remove old managers (#1497) (diff)
downloadmason-d0119c18adff184c5c75f7ec59b6f12b301d268d.tar
mason-d0119c18adff184c5c75f7ec59b6f12b301d268d.tar.gz
mason-d0119c18adff184c5c75f7ec59b6f12b301d268d.tar.bz2
mason-d0119c18adff184c5c75f7ec59b6f12b301d268d.tar.lz
mason-d0119c18adff184c5c75f7ec59b6f12b301d268d.tar.xz
mason-d0119c18adff184c5c75f7ec59b6f12b301d268d.tar.zst
mason-d0119c18adff184c5c75f7ec59b6f12b301d268d.zip
refactor!: consolidate Lua registry sources and the Package API (#1498)
**This removes the following APIs:** - `Package:check_new_version()`. Instead use the new `Package:get_latest_version()`. **This has a breaking change in the following APIs:** - `Package:get_installed_version()` now no longer takes a callback but instead returns the installed version or `nil` if not installed. <details> <summary>To handle these breaking changes in plugins, leverage the `mason.version` module, for example:</summary> ```lua local mason_version = require("mason.version") local registry = require("mason-registry") local pkg = registry.get_package("rust-analyzer") if mason_version.MAJOR_VERSION < 2 then -- before pkg:check_new_version(function (success, new_version) -- … end) pkg:get_installed_version(function (success, installed_version) -- … end) else -- after local new_version = pkg:get_latest_version() local installed_version = pkg:get_installed_version() fi ``` </details> --- <details> <summary>This change also introduces breaking changes for Lua registry sources, by consolidating the package schema with the registry.</summary> The following is an example of a package defined in a Lua registry, following the new schema: ```lua local Pkg = require("mason-core.package") return Pkg.new { schema = "registry+v1", name = "ripgrep", description = "ripgrep recursively searches directories for a regex pattern while respecting your gitignore.", homepage = "https://github.com/BurntSushi/ripgrep", licenses = { Pkg.License.MIT }, languages = {}, categories = {}, source = { id = "pkg:mason/ripgrep@13.0.0", ---@param ctx InstallContext ---@param purl Purl install = function(ctx, purl) -- Arbitrary installation code. end, }, bin = { rg = "./bin/rg", }, } ``` </details>
Diffstat (limited to 'tests/helpers')
-rw-r--r--tests/helpers/lua/dummy-registry/dummy2_package.lua19
-rw-r--r--tests/helpers/lua/dummy-registry/dummy_package.lua19
2 files changed, 22 insertions, 16 deletions
diff --git a/tests/helpers/lua/dummy-registry/dummy2_package.lua b/tests/helpers/lua/dummy-registry/dummy2_package.lua
index 424e47d7..793404ea 100644
--- a/tests/helpers/lua/dummy-registry/dummy2_package.lua
+++ b/tests/helpers/lua/dummy-registry/dummy2_package.lua
@@ -1,14 +1,17 @@
local Pkg = require "mason-core.package"
return Pkg.new {
+ schema = "registry+v1",
name = "dummy2",
- desc = [[This is a dummy2 package.]],
- categories = { Pkg.Cat.LSP },
- languages = { Pkg.Lang.Dummy2Lang },
+ description = [[This is a dummy2 package.]],
homepage = "https://example.com",
- ---@async
- ---@param ctx InstallContext
- install = function(ctx)
- ctx.receipt:with_primary_source { type = "dummy2" }
- end,
+ licenses = { Pkg.License.MIT },
+ languages = { Pkg.Lang.Dummy2Lang },
+ categories = { Pkg.Cat.LSP },
+ source = {
+ id = "pkg:mason/dummy2@1.0.0",
+ ---@async
+ ---@param ctx InstallContext
+ install = function(ctx) end,
+ },
}
diff --git a/tests/helpers/lua/dummy-registry/dummy_package.lua b/tests/helpers/lua/dummy-registry/dummy_package.lua
index b38d1cd8..52a709ad 100644
--- a/tests/helpers/lua/dummy-registry/dummy_package.lua
+++ b/tests/helpers/lua/dummy-registry/dummy_package.lua
@@ -1,14 +1,17 @@
local Pkg = require "mason-core.package"
return Pkg.new {
+ schema = "registry+v1",
name = "dummy",
- desc = [[This is a dummy package.]],
- categories = { Pkg.Cat.LSP },
- languages = { Pkg.Lang.DummyLang },
+ description = [[This is a dummy package.]],
homepage = "https://example.com",
- ---@async
- ---@param ctx InstallContext
- install = function(ctx)
- ctx.receipt:with_primary_source { type = "dummy" }
- end,
+ licenses = { Pkg.License.MIT },
+ languages = { Pkg.Lang.DummyLang },
+ categories = { Pkg.Cat.LSP },
+ source = {
+ id = "pkg:mason/dummy@1.0.0",
+ ---@async
+ ---@param ctx InstallContext
+ install = function(ctx) end,
+ },
}