feat(integration): add universal merkwerk binary detection

- Check development binary (./bin/merkwerk)
- Check installed binary (/usr/local/bin/merkwerk)
- Fallback to PATH lookup (command -v merkwerk)
- Proper error handling for missing binary

Related to DAW/furt#94
This commit is contained in:
michael 2025-08-28 17:34:36 +02:00
parent 6b2da02429
commit 95dcdbaebb

View file

@ -10,10 +10,51 @@ local cache = {
ttl = 300 -- 5 minutes default TTL ttl = 300 -- 5 minutes default TTL
} }
-- Find merkwerk binary using universal detection pattern
local function find_merkwerk_binary()
-- Check development binary
local dev_handle = io.popen("test -x './bin/merkwerk' && echo './bin/merkwerk' 2>/dev/null")
if dev_handle then
local dev_result = dev_handle:read("*line")
dev_handle:close()
if dev_result and dev_result ~= "" then
return dev_result
end
end
-- Check installed binary
local inst_handle = io.popen("test -x '/usr/local/bin/merkwerk' && echo '/usr/local/bin/merkwerk' 2>/dev/null")
if inst_handle then
local inst_result = inst_handle:read("*line")
inst_handle:close()
if inst_result and inst_result ~= "" then
return inst_result
end
end
-- Check PATH
local path_handle = io.popen("command -v merkwerk 2>/dev/null")
if path_handle then
local path_result = path_handle:read("*line")
path_handle:close()
if path_result and path_result ~= "" then
return "merkwerk"
end
end
return nil
end
-- Execute merkwerk command and return result -- Execute merkwerk command and return result
local function execute_merkwerk(args) local function execute_merkwerk(args)
args = args or "info --json" args = args or "info --json"
local command = "./tools/merkwerk/bin/merkwerk " .. args .. " 2>/dev/null"
local merkwerk_cmd = find_merkwerk_binary()
if not merkwerk_cmd then
return nil, "merkwerk binary not found"
end
local command = merkwerk_cmd .. " " .. args .. " 2>/dev/null"
local handle = io.popen(command) local handle = io.popen(command)
if not handle then if not handle then