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

nightconcept / almandine / 14740114043

29 Apr 2025 07:54PM UTC coverage: 82.069% (-0.7%) from 82.759%
14740114043

push

github

web-flow
fix: Lock file generation and Mac/Linux installs (#9)

84 of 96 new or added lines in 5 files covered. (87.5%)

4 existing lines in 2 files now uncovered.

1579 of 1924 relevant lines covered (82.07%)

2.38 hits per line

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

22.0
/src/utils/manifest.lua
1
--[[
2
  Manifest Loader Utility
3

4
  Provides functions to safely load the project manifest (project.lua) with validation.
5
]]
6
--
7

8
local manifest = {}
3✔
9

10
--- Safely load the project manifest.
11
-- @param path string Path to the manifest file (default: "project.lua").
12
-- @return table|nil, string|nil Manifest table or nil and error message.
13
function manifest.safe_load_project_manifest(path)
3✔
14
  path = path or "project.lua"
9✔
15
  local chunk, err = loadfile(path)
9✔
16
  if not chunk then
9✔
UNCOV
17
    return nil, err
×
18
  end
19
  local ok, result = pcall(chunk)
9✔
20
  if not ok then
9✔
UNCOV
21
    return nil, result
×
22
  end
23
  if type(result) ~= "table" then
9✔
UNCOV
24
    return nil, "Manifest must return a table"
×
25
  end
26
  return result, nil
9✔
27
end
28

29
--- Pretty-print a Lua table representing dependencies for manifest output
30
local function pretty_print_dependencies(dependencies, indent)
31
  indent = indent or "  "
×
32
  local lines = { indent .. "dependencies = {" }
×
33
  local dep_keys = {}
×
34
  for k in pairs(dependencies or {}) do
×
35
    table.insert(dep_keys, k)
×
36
  end
37
  table.sort(dep_keys)
×
38
  for _, k in ipairs(dep_keys) do
×
39
    local v = dependencies[k]
×
40
    if type(v) == "table" then
×
41
      local url = v.url or ""
×
42
      local path = v.path or ""
×
43
      path = path:gsub("\\", "\\\\")
×
44
      table.insert(lines, string.format('%s  ["%s"] = {', indent, k))
×
45
      table.insert(lines, string.format('%s    url = "%s",', indent, url))
×
46
      table.insert(lines, string.format('%s    path = "%s"', indent, path))
×
47
      table.insert(lines, indent .. "  },")
×
48
    else
49
      table.insert(lines, string.format('%s  ["%s"] = "%s",', indent, k, tostring(v)))
×
50
    end
51
  end
52
  table.insert(lines, indent .. "},")
×
53
  return table.concat(lines, "\n")
×
54
end
55

56
--- Saves the project manifest to project.lua.
57
-- @param manifest_table table Manifest table to save.
58
-- @return boolean, string True on success, false and error message on failure.
59
-- @usage
60
--   local ok, err = manifest.save_manifest(tbl)
61
function manifest.save_manifest(manifest_table)
3✔
62
  local file, err = io.open("project.lua", "w")
×
63
  if not file then
×
64
    return false, "Could not write project.lua: " .. tostring(err)
×
65
  end
66
  file:write("return {\n")
×
67
  file:write(string.format('  name = "%s",\n', manifest_table.name or ""))
×
68
  file:write(string.format('  type = "%s",\n', manifest_table.type or ""))
×
69
  file:write(string.format('  version = "%s",\n', manifest_table.version or ""))
×
70
  file:write(string.format('  license = "%s",\n', manifest_table.license or ""))
×
71
  file:write(string.format('  description = "%s",\n', manifest_table.description or ""))
×
72
  file:write("  scripts = {\n")
×
73
  for k, v in pairs(manifest_table.scripts or {}) do
×
74
    file:write(string.format('    ["%s"] = "%s",\n', k, v))
×
75
  end
76
  file:write("  },\n")
×
77
  -- Use pretty printer for dependencies
78
  file:write(pretty_print_dependencies(manifest_table.dependencies or {}, "  ") .. "\n")
×
79
  file:write("}\n")
×
80
  file:close()
×
81
  return true, nil
×
82
end
83

84
return manifest
3✔
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