@kmlckj/licos-ai-cli 0.0.23 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -37,7 +37,7 @@ while [ $# -gt 0 ]; do
|
|
|
37
37
|
esac
|
|
38
38
|
done
|
|
39
39
|
is_port_free() {
|
|
40
|
-
!
|
|
40
|
+
! nc -z -w 1 127.0.0.1 "$1" >/dev/null 2>&1
|
|
41
41
|
}
|
|
42
42
|
choose_next_free_port() {
|
|
43
43
|
local start=$1
|
|
@@ -72,27 +72,18 @@ ensure_port() {
|
|
|
72
72
|
return 0
|
|
73
73
|
fi
|
|
74
74
|
local choice
|
|
75
|
-
if [ "$
|
|
75
|
+
if [ "${LICOS_DEV_KILL_PORTS:-0}" = "1" ]; then
|
|
76
|
+
if [ "$ASSUME_YES" = "1" ]; then choice="Y"; else read -r -p "是否关闭该端口的进程?[Y/n] " choice || choice="Y"; fi
|
|
77
|
+
else
|
|
78
|
+
choice="n"
|
|
79
|
+
fi
|
|
76
80
|
if [ -z "$choice" ] || [ "$choice" = "y" ] || [ "$choice" = "Y" ]; then
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
pids=$(lsof -t -i tcp:"$port_val" -sTCP:LISTEN 2>/dev/null || true)
|
|
80
|
-
if [ -n "$pids" ]; then
|
|
81
|
-
echo "正在关闭进程:$pids"
|
|
82
|
-
kill -9 $pids 2>/dev/null || echo "关闭进程失败:$pids"
|
|
83
|
-
eval "$var_name=$port_val"
|
|
84
|
-
else
|
|
85
|
-
echo "未获取到占用该端口的进程"
|
|
86
|
-
eval "$var_name=$port_val"
|
|
87
|
-
fi
|
|
88
|
-
else
|
|
89
|
-
echo "缺少 lsof,无法自动关闭进程"
|
|
90
|
-
eval "$var_name=$port_val"
|
|
91
|
-
fi
|
|
81
|
+
fuser -k "${port_val}/tcp" 2>/dev/null || echo "关闭端口进程失败或端口未找到:$port_val"
|
|
82
|
+
eval "$var_name=$port_val"
|
|
92
83
|
else
|
|
93
84
|
local new_port
|
|
94
|
-
new_port=$(choose_next_free_port "$port_val")
|
|
95
|
-
|
|
85
|
+
new_port=$(choose_next_free_port "$((port_val+1))")
|
|
86
|
+
echo "使用新的端口:$new_port"
|
|
96
87
|
eval "$var_name=$new_port"
|
|
97
88
|
fi
|
|
98
89
|
fi
|
|
@@ -185,7 +176,7 @@ echo "正在检查依赖命令和目录是否存在..."
|
|
|
185
176
|
# 检查核心命令
|
|
186
177
|
check_command "npm"
|
|
187
178
|
check_command "pnpm"
|
|
188
|
-
check_command "
|
|
179
|
+
check_command "nc"
|
|
189
180
|
check_command "bash"
|
|
190
181
|
|
|
191
182
|
# 端口占用预检查与处理
|
|
@@ -24,20 +24,21 @@ pipe_to_log() {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
kill_old_server() {
|
|
27
|
-
if
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return 0
|
|
35
|
-
fi
|
|
36
|
-
done
|
|
37
|
-
echo "正在关闭旧的 server 进程:$pids"
|
|
38
|
-
kill -9 $pids 2>/dev/null || echo "关闭进程失败:$pids"
|
|
39
|
-
sleep 1
|
|
27
|
+
if ! nc -z -w 1 127.0.0.1 "$SERVER_PORT" >/dev/null 2>&1; then
|
|
28
|
+
return 0
|
|
29
|
+
fi
|
|
30
|
+
for protected in $PROTECTED_PORTS; do
|
|
31
|
+
if [ "$protected" = "$SERVER_PORT" ]; then
|
|
32
|
+
echo "端口 $SERVER_PORT 是平台保护端口,不会关闭占用进程"
|
|
33
|
+
return 0
|
|
40
34
|
fi
|
|
35
|
+
done
|
|
36
|
+
if [ "${LICOS_DEV_KILL_PORTS:-0}" = "1" ]; then
|
|
37
|
+
echo "正在关闭旧的 server 端口:$SERVER_PORT"
|
|
38
|
+
fuser -k "${SERVER_PORT}/tcp" 2>/dev/null || echo "关闭端口进程失败或端口未找到:$SERVER_PORT"
|
|
39
|
+
sleep 1
|
|
40
|
+
else
|
|
41
|
+
echo "端口 $SERVER_PORT 已占用,未启用 LICOS_DEV_KILL_PORTS,跳过自动关闭"
|
|
41
42
|
fi
|
|
42
43
|
}
|
|
43
44
|
|
package/lib/cli.js
CHANGED
|
@@ -2107,7 +2107,7 @@ const EventBuilder = {
|
|
|
2107
2107
|
};
|
|
2108
2108
|
|
|
2109
2109
|
var name = "@kmlckj/licos-ai-cli";
|
|
2110
|
-
var version = "0.0.
|
|
2110
|
+
var version = "0.0.24";
|
|
2111
2111
|
var description = "LICOS AI coding workspace CLI - project template engine and dev tools";
|
|
2112
2112
|
var license = "MIT";
|
|
2113
2113
|
var author = "kmlckj";
|