diff options
| author | William Boman <william@redwill.se> | 2023-10-11 15:33:10 +0200 |
|---|---|---|
| committer | William Boman <william@redwill.se> | 2025-02-16 09:49:17 +0100 |
| commit | 40bb6ddfa84b91f58a53f9d92ce7a3ce0c57b9aa (patch) | |
| tree | 1c092b13b2c40c693db87f040410411977990cef /lua/mason-core/installer | |
| parent | fix(package): support older receipt structures (#1520) (diff) | |
| download | mason-40bb6ddfa84b91f58a53f9d92ce7a3ce0c57b9aa.tar mason-40bb6ddfa84b91f58a53f9d92ce7a3ce0c57b9aa.tar.gz mason-40bb6ddfa84b91f58a53f9d92ce7a3ce0c57b9aa.tar.bz2 mason-40bb6ddfa84b91f58a53f9d92ce7a3ce0c57b9aa.tar.lz mason-40bb6ddfa84b91f58a53f9d92ce7a3ce0c57b9aa.tar.xz mason-40bb6ddfa84b91f58a53f9d92ce7a3ce0c57b9aa.tar.zst mason-40bb6ddfa84b91f58a53f9d92ce7a3ce0c57b9aa.zip | |
refactor(receipt): change receipt structure and remove old builder APIs (#1521)
Diffstat (limited to 'lua/mason-core/installer')
| -rw-r--r-- | lua/mason-core/installer/init.lua | 6 | ||||
| -rw-r--r-- | lua/mason-core/installer/linker.lua | 6 | ||||
| -rw-r--r-- | lua/mason-core/installer/registry/init.lua | 3 |
3 files changed, 6 insertions, 9 deletions
diff --git a/lua/mason-core/installer/init.lua b/lua/mason-core/installer/init.lua index 961c5c47..45bba46b 100644 --- a/lua/mason-core/installer/init.lua +++ b/lua/mason-core/installer/init.lua @@ -37,11 +37,7 @@ end local function build_receipt(context) return Result.pcall(function() log.fmt_debug("Building receipt for %s", context.package) - return context.receipt - :with_name(context.package.name) - :with_schema_version("1.1") - :with_completion_time(vim.loop.gettimeofday()) - :build() + return context.receipt:with_name(context.package.name):with_completion_time(vim.loop.gettimeofday()):build() end) end diff --git a/lua/mason-core/installer/linker.lua b/lua/mason-core/installer/linker.lua index 7a1098fb..83b1f4a5 100644 --- a/lua/mason-core/installer/linker.lua +++ b/lua/mason-core/installer/linker.lua @@ -21,12 +21,12 @@ local LinkContext = { ---@param link_context LinkContext local function unlink(receipt, link_context) return Result.pcall(function() - local links = receipt.links[link_context.type] + local links = receipt:get_links()[link_context.type] if not links then return end for linked_file in pairs(links) do - if receipt.schema_version == "1.0" and link_context == LinkContext.BIN and platform.is.win then + if receipt:get_schema_version() == "1.0" and link_context == LinkContext.BIN and platform.is.win then linked_file = linked_file .. ".cmd" end local share_path = link_context.prefix(linked_file) @@ -39,7 +39,7 @@ end ---@param receipt InstallReceipt ---@nodiscard function M.unlink(pkg, receipt) - log.fmt_debug("Unlinking %s", pkg, receipt.links) + log.fmt_debug("Unlinking %s", pkg, receipt:get_links()) return Result.try(function(try) try(unlink(receipt, LinkContext.BIN)) try(unlink(receipt, LinkContext.SHARE)) diff --git a/lua/mason-core/installer/registry/init.lua b/lua/mason-core/installer/registry/init.lua index c700715e..7376db86 100644 --- a/lua/mason-core/installer/registry/init.lua +++ b/lua/mason-core/installer/registry/init.lua @@ -10,6 +10,7 @@ local util = require "mason-core.installer.registry.util" local M = {} +---@type table<RegistryPackageSpecSchema, boolean> M.SCHEMA_CAP = _.set_of { "registry+v1", } @@ -204,7 +205,7 @@ function M.compile(spec, opts) try(link.opt(ctx, spec, parsed.purl, parsed.source)) end - ctx.receipt:with_primary_source { + ctx.receipt:with_source { type = ctx.package.spec.schema, id = Purl.compile(parsed.purl), } |
