• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nightconcept / almandine / 14846535458

05 May 2025 09:22PM UTC coverage: 32.421% (-35.5%) from 67.965%
14846535458

push

github

web-flow
fix: Change init module to be e2e testable (#17)

91 of 420 new or added lines in 11 files covered. (21.67%)

462 of 1425 relevant lines covered (32.42%)

1.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.2
/src/modules/list.lua
1
--[[
2
  List Command Module
3

4
  Provides functionality to list all installed dependencies and their versions as recorded in the lockfile
5
  (almd-lock.lua) or manifest (project.lua).
6
]]
7
--
8

9
---TODO: remove this once we have a pass over this file
10
-- luacheck: ignore
11
local lockfile_utils = require("utils.lockfile")
2✔
12

13
--- Lists installed dependencies and their versions.
14
---@param load_manifest function Function to load the manifest.
15
---@param deps table Dependency table containing `printer`.
16
---@return boolean success True if successful, false otherwise.
17
---@return string|nil message Formatted list for stdout.
18
---@return string|nil error_message Error message for stderr.
19
local function list_dependencies(load_manifest, deps)
NEW
20
  local lockfile = lockfile_utils.load_lockfile()
×
NEW
21
  local lockfile_exists = (lockfile ~= nil)
×
22

23
  local dependencies = {}
×
NEW
24
  local source_description = ""
×
25

26
  if lockfile_exists and type(lockfile) == "table" and lockfile.dependencies then
×
27
    dependencies = lockfile.dependencies
×
NEW
28
    source_description = " (from almd-lock.lua)"
×
29
  else
NEW
30
    local manifest, manifest_err = load_manifest()
×
NEW
31
    if manifest_err then
×
NEW
32
      return false, nil, "Error loading project.lua: " .. tostring(manifest_err)
×
NEW
33
    elseif not manifest then
×
NEW
34
      return false, nil, "Could not find or load project.lua."
×
35
    end
36
    if type(manifest) == "table" and manifest.dependencies then
×
37
      dependencies = manifest.dependencies
×
NEW
38
      source_description = " (from project.lua)"
×
39
    end
40
  end
41

NEW
42
  local output = {}
×
43
  if next(dependencies) == nil then
×
NEW
44
    table.insert(output, "No dependencies found.")
×
45
  else
NEW
46
    table.insert(output, "Installed dependencies" .. source_description .. ":")
×
47
    -- Sort dependencies by name for consistent output
NEW
48
    local sorted_names = {}
×
NEW
49
    for name, _ in pairs(dependencies) do
×
NEW
50
      table.insert(sorted_names, name)
×
51
    end
NEW
52
    table.sort(sorted_names)
×
53

NEW
54
    for _, name in ipairs(sorted_names) do
×
NEW
55
      local dep = dependencies[name]
×
56
      local version
NEW
57
      if type(dep) == "table" then
×
NEW
58
        version = dep.version or (dep.tag and "tag:" .. dep.tag) or (dep.branch and "branch:" .. dep.branch) or (dep.hash and "#" .. dep.hash)
×
NEW
59
        if not version or version == "" then
×
NEW
60
          version = "(unknown source)"
×
61
        end
NEW
62
      elseif type(dep) == "string" then
×
NEW
63
        version = dep
×
64
      else
NEW
65
        version = "(unknown type)"
×
66
      end
NEW
67
      table.insert(output, string.format("  %s\t%s", name, version))
×
68
    end
69
  end
NEW
70
  return true, table.concat(output, "\n")
×
71
end
72

73
---
74
-- Prints usage/help information for the `list` command.
75
-- Usage: almd list
76
-- Lists all installed dependencies and their versions.
77
local function help_info()
NEW
78
  return [[Usage: almd list
×
79

80
Lists all installed dependencies and their versions.
81
Prioritizes almd-lock.lua if it exists, otherwise uses project.lua.
NEW
82
]]
×
83
end
84

85
return {
2✔
86
  list_dependencies = list_dependencies,
2✔
87
  help_info = help_info,
2✔
88
}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc