Skip to content

Commit

Permalink
refactor!: remove old managers (#1497)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamboman committed Feb 25, 2024
1 parent 3b5068f commit a3e39ce
Show file tree
Hide file tree
Showing 34 changed files with 20 additions and 3,731 deletions.
2 changes: 1 addition & 1 deletion lua/mason-core/fetch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local a = require "mason-core.async"
local async_uv = require "mason-core.async.uv"
local log = require "mason-core.log"
local platform = require "mason-core.platform"
local powershell = require "mason-core.managers.powershell"
local powershell = require "mason-core.installer.managers.powershell"
local spawn = require "mason-core.spawn"
local version = require "mason.version"

Expand Down
9 changes: 4 additions & 5 deletions lua/mason-core/installer/context.lua
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ end
---@param new_executable_rel_path string Relative path to the executable file to create.
---@param module string The python module to call.
function InstallContext:write_pyvenv_exec_wrapper(new_executable_rel_path, module)
local pip3 = require "mason-core.managers.pip3"
local pypi = require "mason-core.installer.managers.pypi"
local module_exists, module_err = pcall(function()
local result =
self.spawn.python { "-c", ("import %s"):format(module), with_paths = { pip3.venv_path(self.cwd:get()) } }
self.spawn.python { "-c", ("import %s"):format(module), with_paths = { pypi.venv_path(self.cwd:get()) } }
if not self.spawn.strict_mode then
result:get_or_throw()
end
Expand All @@ -319,7 +319,7 @@ function InstallContext:write_pyvenv_exec_wrapper(new_executable_rel_path, modul
new_executable_rel_path,
("%q -m %s"):format(
path.concat {
pip3.venv_path(self.package:get_install_path()),
pypi.venv_path(self.package:get_install_path()),
"python",
},
module
Expand Down Expand Up @@ -367,14 +367,13 @@ function InstallContext:write_shell_exec_wrapper(new_executable_rel_path, comman
end
return platform.when {
unix = function()
local std = require "mason-core.managers.std"
local formatted_envs = _.map(function(pair)
local var, value = pair[1], pair[2]
return ("export %s=%q"):format(var, value)
end, _.to_pairs(env or {}))

self.fs:write_file(new_executable_rel_path, BASH_TEMPLATE:format(_.join("\n", formatted_envs), command))
std.chmod("+x", { new_executable_rel_path })
self.fs:chmod_exec(new_executable_rel_path)
return new_executable_rel_path
end,
win = function()
Expand Down
2 changes: 1 addition & 1 deletion lua/mason-core/installer/managers/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local async_uv = require "mason-core.async.uv"
local installer = require "mason-core.installer"
local log = require "mason-core.log"
local platform = require "mason-core.platform"
local powershell = require "mason-core.managers.powershell"
local powershell = require "mason-core.installer.managers.powershell"
local std = require "mason-core.installer.managers.std"

local M = {}
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions lua/mason-core/installer/managers/pypi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ local VENV_DIR = "venv"

local is_executable = _.compose(_.equals(1), vim.fn.executable)

function M.venv_path(dir)
return path.concat {
dir,
VENV_DIR,
platform.is.win and "Scripts" or "bin",
}
end

---@async
---@param candidates string[]
local function resolve_python3(candidates)
Expand Down
2 changes: 1 addition & 1 deletion lua/mason-core/installer/managers/std.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local installer = require "mason-core.installer"
local log = require "mason-core.log"
local path = require "mason-core.path"
local platform = require "mason-core.platform"
local powershell = require "mason-core.managers.powershell"
local powershell = require "mason-core.installer.managers.powershell"

local M = {}

Expand Down
18 changes: 0 additions & 18 deletions lua/mason-core/managers/cargo/client.lua

This file was deleted.

199 changes: 0 additions & 199 deletions lua/mason-core/managers/cargo/init.lua

This file was deleted.

Loading

0 comments on commit a3e39ce

Please sign in to comment.