@kmlckj/licos-ai-cli 1.1.28 → 1.1.29

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.
@@ -88,6 +88,26 @@ ensure_port() {
88
88
  fi
89
89
  fi
90
90
  }
91
+ ensure_fixed_preview_port() {
92
+ local port_val=$1
93
+ if is_port_free "$port_val"; then
94
+ echo "预览端口未占用:$port_val"
95
+ return 0
96
+ fi
97
+
98
+ echo "预览端口已占用:$port_val,正在清理旧进程"
99
+ if ! command -v fuser >/dev/null 2>&1; then
100
+ echo "无法清理预览端口 $port_val:缺少 fuser。LICOS 预览不会切换到其他端口。"
101
+ exit 1
102
+ fi
103
+ fuser -k "${port_val}/tcp" 2>/dev/null || true
104
+ sleep 1
105
+ if ! is_port_free "$port_val"; then
106
+ echo "预览端口 $port_val 清理失败。LICOS 预览不会切换到其他端口。"
107
+ exit 1
108
+ fi
109
+ echo "预览端口已清理:$port_val"
110
+ }
91
111
  configure_expo_env() {
92
112
  local web_url="${LICOS_PROJECT_DOMAIN_DEFAULT:-http://127.0.0.1:${SERVER_PORT}}"
93
113
  EXPO_PUBLIC_BACKEND_BASE_URL="${EXPO_PUBLIC_BACKEND_BASE_URL:-$web_url}"
@@ -181,7 +201,7 @@ check_command "bash"
181
201
 
182
202
  # 端口占用预检查与处理
183
203
  ensure_port SERVER_PORT "$SERVER_PORT"
184
- ensure_port EXPO_PORT "$EXPO_PORT"
204
+ ensure_fixed_preview_port "$EXPO_PORT"
185
205
  configure_expo_env
186
206
 
187
207
  echo "==================== 启动 server 服务 ===================="
@@ -1,16 +1,13 @@
1
1
  #!/bin/bash
2
2
  set -Eeuo pipefail
3
3
 
4
- <% if (process.env.NODE_ENV === 'test') { %>
5
- # 测试环境:支持环境变量覆盖端口
6
- PORT="${PORT:-<%= port %>}"
4
+ if [[ -n "${LICOS_RUN_PORT:-}" ]]; then
5
+ PORT="${LICOS_RUN_PORT}"
6
+ elif [[ -z "${PORT:-}" ]]; then
7
+ PORT=<%= port %>
8
+ fi
7
9
  PROJECT_DIR="${LICOS_PROJECT_PATH:-${LICOS_WORKSPACE_PATH:-$(pwd)}}"
8
- DEPLOY_RUN_PORT="${DEPLOY_RUN_PORT:-${PORT}}"
9
- <% } else { %>
10
- PORT=<%= port %>
11
- PROJECT_DIR="${LICOS_PROJECT_PATH:-${LICOS_WORKSPACE_PATH:-$(pwd)}}"
12
- DEPLOY_RUN_PORT=<%= port %>
13
- <% } %>
10
+ DEPLOY_RUN_PORT="${PORT}"
14
11
 
15
12
  cd "${PROJECT_DIR}"
16
13
 
@@ -26,7 +23,8 @@ kill_port_if_listening() {
26
23
  sleep 1
27
24
  pids=$(ss -H -lntp 2>/dev/null | awk -v port="${DEPLOY_RUN_PORT}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
28
25
  if [[ -n "${pids}" ]]; then
29
- echo "Warning: port ${DEPLOY_RUN_PORT} still busy after SIGKILL, PIDs: ${pids}"
26
+ echo "Preview port ${DEPLOY_RUN_PORT} is still busy after cleanup, PIDs: ${pids}. Refusing to use another port."
27
+ exit 1
30
28
  else
31
29
  echo "Port ${DEPLOY_RUN_PORT} cleared."
32
30
  fi
@@ -130,10 +130,11 @@ export default defineNuxtConfig({
130
130
  },
131
131
 
132
132
  // Vite configuration (similar to Next.js allowedDevOrigins)
133
- vite: {
134
- server: {
135
- host: '0.0.0.0',
136
- cors: {
133
+ vite: {
134
+ server: {
135
+ host: '0.0.0.0',
136
+ strictPort: true,
137
+ cors: {
137
138
  origin: ['*.dev.licos.local'],
138
139
  credentials: true,
139
140
  },
@@ -1,16 +1,13 @@
1
1
  #!/bin/bash
2
2
  set -Eeuo pipefail
3
3
 
4
- <% if (process.env.NODE_ENV === 'test') { %>
5
- # 测试环境:支持环境变量覆盖端口
6
- PORT="${PORT:-<%= port %>}"
4
+ if [[ -n "${LICOS_RUN_PORT:-}" ]]; then
5
+ PORT="${LICOS_RUN_PORT}"
6
+ elif [[ -z "${PORT:-}" ]]; then
7
+ PORT=<%= port %>
8
+ fi
7
9
  PROJECT_DIR="${LICOS_PROJECT_PATH:-${LICOS_WORKSPACE_PATH:-$(pwd)}}"
8
- DEPLOY_RUN_PORT="${DEPLOY_RUN_PORT:-${PORT}}"
9
- <% } else { %>
10
- PORT=<%= port %>
11
- PROJECT_DIR="${LICOS_PROJECT_PATH:-${LICOS_WORKSPACE_PATH:-$(pwd)}}"
12
- DEPLOY_RUN_PORT=<%= port %>
13
- <% } %>
10
+ DEPLOY_RUN_PORT="${PORT}"
14
11
 
15
12
  cd "${PROJECT_DIR}"
16
13
 
@@ -26,7 +23,8 @@ kill_port_if_listening() {
26
23
  sleep 1
27
24
  pids=$(ss -H -lntp 2>/dev/null | awk -v port="${DEPLOY_RUN_PORT}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
28
25
  if [[ -n "${pids}" ]]; then
29
- echo "Warning: port ${DEPLOY_RUN_PORT} still busy after SIGKILL, PIDs: ${pids}"
26
+ echo "Preview port ${DEPLOY_RUN_PORT} is still busy after cleanup, PIDs: ${pids}. Refusing to use another port."
27
+ exit 1
30
28
  else
31
29
  echo "Port ${DEPLOY_RUN_PORT} cleared."
32
30
  fi
@@ -43,7 +43,8 @@ kill_port_if_listening() {
43
43
  sleep 1
44
44
  pids=$(ss -H -lntp 2>/dev/null | awk -v port="${port}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | sort -u | paste -sd' ' - || true)
45
45
  if [[ -n "${pids}" ]]; then
46
- echo "Warning: port ${port} still busy after cleanup, PIDs: ${pids}"
46
+ echo "Preview port ${port} is still busy after cleanup, PIDs: ${pids}. Refusing to use another port."
47
+ exit 1
47
48
  else
48
49
  echo "Port ${port} cleared."
49
50
  fi
@@ -1,16 +1,13 @@
1
1
  #!/bin/bash
2
2
  set -Eeuo pipefail
3
3
 
4
- <% if (process.env.NODE_ENV === 'test') { %>
5
- # 测试环境:支持环境变量覆盖端口
6
- PORT="${PORT:-<%= port %>}"
4
+ if [[ -n "${LICOS_RUN_PORT:-}" ]]; then
5
+ PORT="${LICOS_RUN_PORT}"
6
+ elif [[ -z "${PORT:-}" ]]; then
7
+ PORT=<%= port %>
8
+ fi
7
9
  PROJECT_DIR="${LICOS_PROJECT_PATH:-${LICOS_WORKSPACE_PATH:-$(pwd)}}"
8
- DEPLOY_RUN_PORT="${DEPLOY_RUN_PORT:-${PORT}}"
9
- <% } else { %>
10
- PORT=<%= port %>
11
- PROJECT_DIR="${LICOS_PROJECT_PATH:-${LICOS_WORKSPACE_PATH:-$(pwd)}}"
12
- DEPLOY_RUN_PORT=<%= port %>
13
- <% } %>
10
+ DEPLOY_RUN_PORT="${PORT}"
14
11
 
15
12
  cd "${PROJECT_DIR}"
16
13
 
@@ -26,7 +23,8 @@ kill_port_if_listening() {
26
23
  sleep 1
27
24
  pids=$(ss -H -lntp 2>/dev/null | awk -v port="${DEPLOY_RUN_PORT}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
28
25
  if [[ -n "${pids}" ]]; then
29
- echo "Warning: port ${DEPLOY_RUN_PORT} still busy after SIGKILL, PIDs: ${pids}"
26
+ echo "Preview port ${DEPLOY_RUN_PORT} is still busy after cleanup, PIDs: ${pids}. Refusing to use another port."
27
+ exit 1
30
28
  else
31
29
  echo "Port ${DEPLOY_RUN_PORT} cleared."
32
30
  fi
@@ -45,9 +45,10 @@ const previewHmrConfig = createPreviewHmrConfig();
45
45
 
46
46
  export default defineConfig({
47
47
  base: shouldUseBasePath ? normalizeBasePath(deployBasePath) : '/',
48
- server: {
49
- port: <%= port %>,
50
- host: '0.0.0.0',
48
+ server: {
49
+ port: parsePort(process.env.LICOS_RUN_PORT) || parsePort(process.env.PORT) || <%= port %>,
50
+ strictPort: true,
51
+ host: '0.0.0.0',
51
52
  allowedHosts: true,
52
53
  hmr: previewHmrConfig || {
53
54
  overlay: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmlckj/licos-ai-cli",
3
- "version": "1.1.28",
3
+ "version": "1.1.29",
4
4
  "description": "LICOS AI coding workspace CLI - project template engine and dev tools",
5
5
  "license": "MIT",
6
6
  "author": "kmlckj",