@@ -10,13 +10,10 @@ if GITHUB_ACTION_PATH then
1010 vim .opt .rtp :prepend (GITHUB_ACTION_PATH .. " /mason.nvim" )
1111end
1212
13- local Pkg = require " mason-core.package"
14- local spawn = require " mason-core.spawn"
13+ local registry = require " mason-registry"
1514local _ = require " mason-core.functional"
16- local fs = require " mason-core.fs"
17- local path = require " mason-core.path"
1815local a = require " mason-core.async"
19- local registry_installer = require " mason-core.installer.registry "
16+ local compiler = require " mason-core.installer.compiler "
2017local Result = require " mason-core.result"
2118local platform = require " mason-core.platform"
2219local Purl = require " mason-core.purl"
@@ -45,30 +42,14 @@ local log = setmetatable({}, {
4542
4643require (" mason" ).setup {
4744 log_level = vim .log .levels [DEBUG and " DEBUG" or " INFO" ],
45+ registries = {
46+ " file:" .. vim .env .REGISTRY
47+ }
4848}
49+ registry .refresh ()
4950
5051local yq = vim .fn .exepath " yq"
5152
52- --- @param pkg_path string
53- local function parse_package_spec (pkg_path )
54- return Result .try (function (try )
55- local raw_yaml = fs .async .read_file (path .concat { vim .loop .cwd (), pkg_path })
56- local raw_spec = try (spawn [yq ] {
57- " -o" ,
58- " json" ,
59- on_spawn = function (_ , stdio )
60- local stdin = stdio [1 ]
61- stdin :write (raw_yaml , function ()
62- stdin :shutdown ()
63- end )
64- end ,
65- })
66- local spec = vim .json .decode (raw_spec .stdout )
67- spec .schema = " registry+v1"
68- return Pkg .new (spec )
69- end )
70- end
71-
7253local is_not_empty = _ .complement (_ .equals " " )
7354
7455--- @param pkg Package
@@ -102,7 +83,7 @@ local function get_targets(pkg)
10283
10384 if VERSION then
10485 for _ , target in ipairs (targets ) do
105- if registry_installer .parse (pkg .spec , { target = target , version = VERSION }):is_success () then
86+ if compiler .parse (pkg .spec , { target = target , version = VERSION }):is_success () then
10687 return Result .success { { target = target , version = VERSION } }
10788 else
10889 return Result .failure ((" Unsupported platform (version=%s)." ):format (VERSION ))
@@ -117,7 +98,7 @@ local function get_targets(pkg)
11798 if
11899 Purl .parse (source .id )
119100 :and_then (function (purl )
120- return registry_installer
101+ return compiler
121102 .parse (pkg .spec , { target = target , version = purl .version })
122103 :on_success (function ()
123104 table.insert (resolved_targets , { target = target , version = purl .version })
@@ -143,7 +124,9 @@ local ok, err = pcall(a.run_blocking, function()
143124 log .info (" Testing packages" , packages )
144125
145126 for __ , pkg_path in ipairs (packages ) do
146- local pkg = try (parse_package_spec (pkg_path ))
127+ -- Turns "packages/rust-analyzer/package.yaml" into "rust-analyzer"
128+ local pkg_name = vim .fn .fnamemodify (pkg_path , " :h:t" )
129+ local pkg = registry .get_package (pkg_name )
147130 a .scheduler ()
148131 get_targets (pkg )
149132 :on_success (function (targets )
0 commit comments