Skip to content

Commit 505f6e5

Browse files
committed
Fix all scripts
1 parent d6a0f30 commit 505f6e5

File tree

9 files changed

+92
-168
lines changed

9 files changed

+92
-168
lines changed

.gitignore

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
# Temporary files
21
*.tmp
32
*.temp
43
.DS_Store
54
Thumbs.db
6-
7-
# Test artifacts
85
test/tmp/
96
test/output/
10-
11-
# IDE/editor files
127
.vscode/
138
.idea/
149
*.swp
1510
*.swo
16-
17-
# OS files
1811
*.log

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ECA (Editor Code Assistant) is an AI-powered pair-programming tool that works wi
1717

1818
```bash
1919
# Install the plugin
20-
mise plugin install eca https://github.com/USERNAME/mise-eca-plugin
20+
mise plugin install eca https://github.com/CsBigDataHub/mise-eca-plugin
2121

2222
# Install ECA
2323
mise install eca@latest

hooks/available.lua

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,17 @@
11
-- hooks/available.lua
22
function PLUGIN:Available(ctx)
3-
local http = require("http")
4-
local json = require("json")
5-
6-
-- Fetch releases from GitHub API
7-
local resp, err = http.get({
8-
url = "https://api.github.com/repos/editor-code-assistant/eca/releases"
9-
})
10-
11-
if err ~= nil then
12-
error("Failed to fetch releases from GitHub API: " .. err)
13-
end
14-
15-
if resp.status_code ~= 200 then
16-
error("GitHub API returned status " .. resp.status_code .. ": " .. resp.body)
17-
end
18-
19-
local releases = json.decode(resp.body)
20-
local result = {}
21-
22-
for i, release in ipairs(releases) do
23-
local version = release.tag_name
24-
-- Remove 'v' prefix if present
25-
version = version:gsub("^v", "")
26-
27-
local note = nil
28-
if release.prerelease then
29-
note = "Pre-release"
30-
elseif i == 1 then
31-
note = "Latest"
3+
local http = require("http")
4+
local json = require("json")
5+
local resp, err = http.get({url = "https://api.github.com/repos/editor-code-assistant/eca/releases"})
6+
if err or resp.status_code ~= 200 then
7+
error("Failed to fetch releases: " .. (err or resp.status_code))
328
end
33-
34-
table.insert(result, {
35-
version = version,
36-
note = note
37-
})
38-
end
39-
40-
return result
9+
local releases = json.decode(resp.body)
10+
local result = {}
11+
for i, r in ipairs(releases) do
12+
local v = r.tag_name:gsub("^v", "")
13+
local note = r.prerelease and "Pre" or (i == 1 and "Latest" or nil)
14+
table.insert(result, {version = v, note = note})
15+
end
16+
return result
4117
end

hooks/env_keys.lua

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
-- hooks/env_keys.lua
22
function PLUGIN:EnvKeys(ctx)
3-
local mainPath = ctx.path
4-
5-
return {
6-
{
7-
key = "PATH",
8-
value = mainPath
9-
}
10-
}
3+
return {{key = "PATH", value = ctx.path}}
114
end

hooks/post_install.lua

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
-- hooks/post_install.lua
22
function PLUGIN:PostInstall(ctx)
3-
local sdkInfo = ctx.sdkInfo['eca']
4-
local path = sdkInfo.path
3+
local sdkInfo = ctx.sdkInfo["eca"]
4+
local path = sdkInfo.path
55

6-
-- Set executable permissions on Unix systems
7-
if RUNTIME.osType ~= "Windows" then
8-
local result = os.execute("chmod +x " .. path .. "/eca")
9-
if result ~= 0 then
10-
error("Failed to set executable permissions on eca binary")
6+
-- Set executable permissions on Unix
7+
local os_lower = RUNTIME.osType:lower()
8+
if not os_lower:find("windows") then
9+
local cmd = string.format("chmod +x %s/eca", path)
10+
if os.execute(cmd) ~= 0 then
11+
error("Failed to set executable permissions")
12+
end
1113
end
12-
end
1314

14-
-- Verify installation by checking if binary exists and is executable
15-
local binary_path
16-
if RUNTIME.osType == "Windows" then
17-
binary_path = path .. "/eca.exe"
18-
else
19-
binary_path = path .. "/eca"
20-
end
21-
22-
-- Test that the binary works
23-
local test_cmd = binary_path .. " --version"
24-
local test_result = os.execute(test_cmd .. " > /dev/null 2>&1")
25-
if test_result ~= 0 then
26-
error("ECA binary installation verification failed")
27-
end
15+
-- Verify binary
16+
local bin = os_lower:find("windows") and (path .. "/eca.exe") or (path .. "/eca")
17+
if os.execute(bin .. " --version > /dev/null 2>&1") ~= 0 then
18+
error("ECA binary verification failed")
19+
end
2820
end

hooks/pre_install.lua

Lines changed: 34 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,44 @@
11
-- hooks/pre_install.lua
22
function PLUGIN:PreInstall(ctx)
3-
local version = ctx.version
4-
local http = require("http")
3+
local version = ctx.version
4+
local http = require("http")
55

6-
-- Determine platform using RUNTIME object
7-
local arch_token
8-
if RUNTIME.archType == "amd64" then
9-
arch_token = "amd64"
10-
elseif RUNTIME.archType == "arm64" then
11-
arch_token = "aarch64"
12-
else
13-
error("Unsupported architecture: " .. RUNTIME.archType)
14-
end
15-
16-
local os_token
17-
if RUNTIME.osType == "Windows" then
18-
os_token = "windows"
19-
elseif RUNTIME.osType == "Darwin" then
20-
os_token = "macos"
21-
elseif RUNTIME.osType == "Linux" then
22-
os_token = "linux"
23-
else
24-
error("Unsupported operating system: " .. RUNTIME.osType)
25-
end
26-
27-
-- Build filename based on platform
28-
local filename
29-
if os_token == "linux" then
30-
-- Use static build for better compatibility
31-
if arch_token == "amd64" then
32-
filename = "eca-native-static-linux-amd64.zip"
6+
-- Normalize architecture
7+
local arch = RUNTIME.archType:lower()
8+
local arch_token
9+
if arch == "amd64" or arch == "x86_64" then
10+
arch_token = "amd64"
11+
elseif arch == "arm64" or arch == "aarch64" then
12+
arch_token = "aarch64"
3313
else
34-
filename = "eca-native-linux-" .. arch_token .. ".zip"
14+
error("Unsupported architecture: " .. RUNTIME.archType)
3515
end
36-
else
37-
filename = "eca-native-" .. os_token .. "-" .. arch_token .. ".zip"
38-
end
3916

40-
-- Build download URL
41-
local url = "https://github.com/editor-code-assistant/eca/releases/download/v" .. version .. "/" .. filename
17+
-- Normalize OS
18+
local os_l = RUNTIME.osType:lower()
19+
local os_token
20+
if os_l:find("windows") then
21+
os_token = "windows"
22+
elseif os_l:find("darwin") then
23+
os_token = "macos"
24+
elseif os_l:find("linux") then
25+
os_token = "linux"
26+
else
27+
error("Unsupported OS: " .. RUNTIME.osType)
28+
end
4229

43-
-- Fetch SHA256 checksum
44-
local sha256 = nil
45-
local checksum_url = url .. ".sha256"
46-
local checksum_resp, checksum_err = http.get({ url = checksum_url })
30+
-- Construct filename (dynamic builds)
31+
local filename = string.format("eca-native-%s-%s.zip", os_token, arch_token)
32+
local url = string.format("https://github.com/editor-code-assistant/eca/releases/download/%s/%s", version, filename)
4733

48-
if checksum_err == nil and checksum_resp.status_code == 200 then
49-
-- Extract SHA256 from checksum file
50-
sha256 = checksum_resp.body:match("^(%w+)")
51-
end
34+
-- Fetch checksum
35+
local sha256
36+
do
37+
local resp, err = http.get({url = url .. ".sha256"})
38+
if not err and resp.status_code == 200 then
39+
sha256 = resp.body:match("^(%w+)")
40+
end
41+
end
5242

53-
return {
54-
version = version,
55-
url = url,
56-
sha256 = sha256,
57-
note = "Installing ECA " .. version .. " (" .. os_token .. "-" .. arch_token .. ")"
58-
}
43+
return {version = version, url = url, sha256 = sha256, note = "Installing ECA " .. version}
5944
end

lib/helper.lua

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
-- lib/helper.lua
22
local M = {}
3-
43
function M.get_arch()
5-
local arch = RUNTIME.archType
6-
if arch == "amd64" then
7-
return "amd64"
8-
elseif arch == "arm64" then
9-
return "aarch64"
10-
else
11-
return arch
12-
end
4+
local arch = RUNTIME.archType:lower()
5+
if arch == "amd64" then
6+
return "amd64"
7+
elseif arch == "arm64" then
8+
return "aarch64"
9+
else
10+
return arch
11+
end
1312
end
14-
1513
function M.get_os()
16-
local os = RUNTIME.osType
17-
if os == "Windows" then
18-
return "windows"
19-
elseif os == "Darwin" then
20-
return "macos"
21-
else
22-
return "linux"
23-
end
14+
local os_l = RUNTIME.osType:lower()
15+
if os_l:find("windows") then
16+
return "windows"
17+
elseif os_l:find("darwin") then
18+
return "macos"
19+
elseif os_l:find("linux") then
20+
return "linux"
21+
else
22+
return os_l
23+
end
2424
end
25-
2625
function M.get_platform()
27-
return M.get_os() .. "-" .. M.get_arch()
26+
return M.get_os() .. "-" .. M.get_arch()
2827
end
29-
3028
return M

metadata.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
-- metadata.lua
22
PLUGIN = {
3-
name = "eca",
4-
version = "1.0.0",
5-
description = "Editor Code Assistant (ECA) mise tool plugin",
6-
author = "YOUR_NAME",
7-
homepage = "https://eca.dev",
8-
repository = "https://github.com/editor-code-assistant/eca",
3+
name = "eca",
4+
version = "1.0.2",
5+
description = "Editor Code Assistant (ECA) mise tool plugin",
6+
author = "YOUR_NAME",
7+
homepage = "https://eca.dev",
8+
repository = "https://github.com/editor-code-assistant/eca"
99
}

test/test.sh

100644100755
Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
#!/bin/bash
2-
# test/test.sh
32
set -e
4-
53
echo "Testing ECA mise tool plugin..."
6-
7-
# Install the plugin locally
8-
mise plugin link eca . || true
9-
10-
# Test basic functionality
4+
MISE_VERBOSE=1 mise plugin link eca . || true
115
mise install eca@latest
12-
mise use eca@latest
13-
14-
# Verify installation
6+
mise use -g eca@latest
157
eca --version
16-
17-
# Test that eca server can start (basic check)
18-
timeout 5s eca server --help || echo "Server help command works"
19-
8+
timeout 5s eca server --help || true
209
echo "All tests passed!"
21-
22-
# Clean up
23-
mise plugin remove eca
10+
mise plugin uninstall -p eca

0 commit comments

Comments
 (0)