aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/bash-debug-adapter/init.lua
blob: c77abb81dbe62fab5dbbe61550d2986c2abf7b31 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local Pkg = require "mason-core.package"
local github = require "mason-core.managers.github"
local github_client = require "mason-core.managers.github.client"
local _ = require "mason-core.functional"
local path = require "mason-core.path"
local Optional = require "mason-core.optional"

return Pkg.new {
    name = "bash-debug-adapter",
    desc = [[Bash shell debugger, based on bashdb.]],
    homepage = "https://github.com/rogalmic/vscode-bash-debug",
    languages = { Pkg.Lang.Bash },
    categories = { Pkg.Cat.DAP },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        local repo = "rogalmic/vscode-bash-debug"
        ---@type GitHubRelease
        local release = ctx.requested_version
            :map(function(version)
                return github_client.fetch_release(repo, version)
            end)
            :or_else_get(function()
                return github_client.fetch_latest_release(repo)
            end)
            :get_or_throw()

        ---@type GitHubReleaseAsset
        local release_asset = _.find_first(_.prop_satisfies(_.matches "%.vsix$", "name"), release.assets)

        github
            .unzip_release_file({
                repo = repo,
                asset_file = release_asset.name,
                version = Optional.of(release.tag_name),
            })
            .with_receipt()

        ctx.fs:rmrf(path.concat { "extension", "images" })
        ctx:link_bin(
            "bash-debug-adapter",
            ctx:write_node_exec_wrapper("bash-debug-adapter", path.concat { "extension", "out", "bashDebug.js" })
        )
    end,
}