@kmlckj/licos-ai-cli 0.0.21 → 0.0.23

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.
@@ -7,18 +7,14 @@ mkdir -p "$LOG_DIR"
7
7
  # ==================== 配置项 ====================
8
8
  # Server 服务配置
9
9
  SERVER_HOST="0.0.0.0"
10
- SERVER_PORT="9091"
10
+ SERVER_PORT="${LICOS_BACKEND_PORT:-${SERVER_PORT:-5001}}"
11
11
  # Expo 项目配置
12
12
  EXPO_HOST="0.0.0.0"
13
13
  EXPO_DIR="expo"
14
- EXPO_PORT="5000"
15
- WEB_URL="${LICOS_PROJECT_DOMAIN_DEFAULT:-http://127.0.0.1:${SERVER_PORT}}"
14
+ EXPO_PORT="${LICOS_RUN_PORT:-${PORT:-5000}}"
16
15
  ASSUME_YES="1"
17
- EXPO_PUBLIC_BACKEND_BASE_URL="${EXPO_PUBLIC_BACKEND_BASE_URL:-$WEB_URL}"
18
- EXPO_PUBLIC_LICOS_PROJECT_ID="${LICOS_PROJECT_ID:-}"
16
+ PROTECTED_PORTS="${LICOS_DEV_PROTECTED_PORTS:-8080 8081 9091}"
19
17
 
20
- EXPO_PACKAGER_PROXY_URL="${EXPO_PUBLIC_BACKEND_BASE_URL}"
21
- export EXPO_PUBLIC_BACKEND_BASE_URL EXPO_PACKAGER_PROXY_URL EXPO_PUBLIC_LICOS_PROJECT_ID
22
18
  # 运行时变量(为避免 set -u 的未绑定错误,预置为空)
23
19
  SERVER_PID=""
24
20
  EXPO_PID=""
@@ -51,6 +47,15 @@ choose_next_free_port() {
51
47
  done
52
48
  echo "$p"
53
49
  }
50
+ is_protected_port() {
51
+ local port_val=$1
52
+ for protected in $PROTECTED_PORTS; do
53
+ if [ "$protected" = "$port_val" ]; then
54
+ return 0
55
+ fi
56
+ done
57
+ return 1
58
+ }
54
59
  ensure_port() {
55
60
  local var_name=$1
56
61
  local port_val=$2
@@ -59,6 +64,13 @@ ensure_port() {
59
64
  eval "$var_name=$port_val"
60
65
  else
61
66
  echo "端口已占用:$port_val"
67
+ if is_protected_port "$port_val"; then
68
+ local new_port
69
+ new_port=$(choose_next_free_port "$((port_val+1))")
70
+ echo "端口 $port_val 是平台保护端口,改用新的端口:$new_port"
71
+ eval "$var_name=$new_port"
72
+ return 0
73
+ fi
62
74
  local choice
63
75
  if [ "$ASSUME_YES" = "1" ]; then choice="Y"; else read -r -p "是否关闭该端口的进程?[Y/n] " choice || choice="Y"; fi
64
76
  if [ -z "$choice" ] || [ "$choice" = "y" ] || [ "$choice" = "Y" ]; then
@@ -85,6 +97,13 @@ ensure_port() {
85
97
  fi
86
98
  fi
87
99
  }
100
+ configure_expo_env() {
101
+ local web_url="${LICOS_PROJECT_DOMAIN_DEFAULT:-http://127.0.0.1:${SERVER_PORT}}"
102
+ EXPO_PUBLIC_BACKEND_BASE_URL="${EXPO_PUBLIC_BACKEND_BASE_URL:-$web_url}"
103
+ EXPO_PUBLIC_LICOS_PROJECT_ID="${LICOS_PROJECT_ID:-}"
104
+ EXPO_PACKAGER_PROXY_URL="${EXPO_PACKAGER_PROXY_URL:-$EXPO_PUBLIC_BACKEND_BASE_URL}"
105
+ export EXPO_PUBLIC_BACKEND_BASE_URL EXPO_PACKAGER_PROXY_URL EXPO_PUBLIC_LICOS_PROJECT_ID
106
+ }
88
107
 
89
108
  pipe_to_log() {
90
109
  local source="${1:-CLIENT}"
@@ -172,6 +191,7 @@ check_command "bash"
172
191
  # 端口占用预检查与处理
173
192
  ensure_port SERVER_PORT "$SERVER_PORT"
174
193
  ensure_port EXPO_PORT "$EXPO_PORT"
194
+ configure_expo_env
175
195
 
176
196
  echo "==================== 启动 server 服务 ===================="
177
197
  echo "正在执行:pnpm run dev (server)"
@@ -4,7 +4,8 @@ ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
4
4
  SERVER_DIR="$ROOT_DIR/server"
5
5
  LOG_DIR="${LICOS_LOG_DIR:-$ROOT_DIR/logs}"
6
6
  LOG_SERVER_FILE="$LOG_DIR/server.log"
7
- SERVER_PORT="${SERVER_PORT:-9091}"
7
+ SERVER_PORT="${LICOS_BACKEND_PORT:-${SERVER_PORT:-5001}}"
8
+ PROTECTED_PORTS="${LICOS_DEV_PROTECTED_PORTS:-8080 8081 9091}"
8
9
 
9
10
  mkdir -p "$LOG_DIR"
10
11
 
@@ -27,6 +28,12 @@ kill_old_server() {
27
28
  local pids
28
29
  pids=$(lsof -t -i tcp:"$SERVER_PORT" -sTCP:LISTEN 2>/dev/null || true)
29
30
  if [ -n "$pids" ]; then
31
+ for protected in $PROTECTED_PORTS; do
32
+ if [ "$protected" = "$SERVER_PORT" ]; then
33
+ echo "端口 $SERVER_PORT 是平台保护端口,不会关闭占用进程"
34
+ return 0
35
+ fi
36
+ done
30
37
  echo "正在关闭旧的 server 进程:$pids"
31
38
  kill -9 $pids 2>/dev/null || echo "关闭进程失败:$pids"
32
39
  sleep 1
@@ -1,4 +1,4 @@
1
- loglevel=error
1
+ loglevel=warn
2
2
  registry=https://registry.npmmirror.com/
3
3
  @kmlckj:registry=https://registry.npmmirror.com/
4
4
 
@@ -32,7 +32,7 @@ config.resolver.blockList = [
32
32
  /.*node_modules\/\.pnpm\/.*_tmp_\d+.*/,
33
33
  ];
34
34
 
35
- const BACKEND_TARGET = 'http://localhost:9091';
35
+ const BACKEND_TARGET = process.env.EXPO_PUBLIC_BACKEND_BASE_URL || 'http://localhost:5001';
36
36
 
37
37
  const apiProxy = createProxyMiddleware({
38
38
  target: BACKEND_TARGET,
@@ -1322,7 +1322,7 @@ packages:
1322
1322
  resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
1323
1323
 
1324
1324
  '@kmlckj/licos-platform-sdk@0.6.1':
1325
- resolution: {integrity: sha512-eADWtycsGKxO37QZKsHNNI91XDmHZrrbQGZUrR576v8rxASZBLV8X3j/02W8nIwIkfcKK7XC63DOE2IIDDsuuQ==}
1325
+ resolution: {integrity: sha512-8i+MCc7RYLK42NhT+JGF7wG0ddUQtSfcT05WqUtNnEn7SdHewoNLi/JqK4ZJM3DQB+/azOxqqM/To72B9DkIsA==}
1326
1326
 
1327
1327
  '@langchain/core@1.1.17':
1328
1328
  resolution: {integrity: sha512-g7/kcKbKEwNZSyyT7aT0utxn7wTOtKErqz0cL6VjrV4v/aOb9g+dKcfj17YkSm42YQmJp/rB2IXGc17vQPEBqA==}
@@ -2,7 +2,7 @@ import express from "express";
2
2
  import cors from "cors";
3
3
 
4
4
  const app = express();
5
- const port = process.env.PORT || 9091;
5
+ const port = process.env.PORT || 5001;
6
6
 
7
7
  // Middleware
8
8
  app.use(cors());
@@ -1,4 +1,4 @@
1
- loglevel=error
1
+ loglevel=warn
2
2
  registry=https://registry.npmmirror.com/
3
3
  @kmlckj:registry=https://registry.npmmirror.com/
4
4
 
@@ -1335,7 +1335,7 @@ packages:
1335
1335
  resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
1336
1336
 
1337
1337
  '@kmlckj/licos-platform-sdk@0.6.1':
1338
- resolution: {integrity: sha512-eADWtycsGKxO37QZKsHNNI91XDmHZrrbQGZUrR576v8rxASZBLV8X3j/02W8nIwIkfcKK7XC63DOE2IIDDsuuQ==}
1338
+ resolution: {integrity: sha512-8i+MCc7RYLK42NhT+JGF7wG0ddUQtSfcT05WqUtNnEn7SdHewoNLi/JqK4ZJM3DQB+/azOxqqM/To72B9DkIsA==}
1339
1339
 
1340
1340
  '@langchain/core@1.1.17':
1341
1341
  resolution: {integrity: sha512-g7/kcKbKEwNZSyyT7aT0utxn7wTOtKErqz0cL6VjrV4v/aOb9g+dKcfj17YkSm42YQmJp/rB2IXGc17vQPEBqA==}
@@ -1,4 +1,4 @@
1
- loglevel=error
1
+ loglevel=warn
2
2
  registry=https://registry.npmmirror.com/
3
3
  @kmlckj:registry=https://registry.npmmirror.com/
4
4
 
@@ -418,7 +418,7 @@ packages:
418
418
  resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
419
419
 
420
420
  '@kmlckj/licos-platform-sdk@0.6.1':
421
- resolution: {integrity: sha512-eADWtycsGKxO37QZKsHNNI91XDmHZrrbQGZUrR576v8rxASZBLV8X3j/02W8nIwIkfcKK7XC63DOE2IIDDsuuQ==}
421
+ resolution: {integrity: sha512-8i+MCc7RYLK42NhT+JGF7wG0ddUQtSfcT05WqUtNnEn7SdHewoNLi/JqK4ZJM3DQB+/azOxqqM/To72B9DkIsA==}
422
422
 
423
423
  '@koa/router@12.0.2':
424
424
  resolution: {integrity: sha512-sYcHglGKTxGF+hQ6x67xDfkE9o+NhVlRHBqq6gLywaMc6CojK/5vFZByphdonKinYlMLkEkacm+HEse9HzwgTA==}
@@ -1,4 +1,4 @@
1
- loglevel=error
1
+ loglevel=warn
2
2
  registry=https://registry.npmmirror.com/
3
3
  @kmlckj:registry=https://registry.npmmirror.com/
4
4
 
@@ -3090,7 +3090,7 @@ packages:
3090
3090
  resolution: {integrity: sha512-dXn3FZhPv0US+7dtJsIi2R+c7qWYiReoEh5zUntWCf4oSpMNib8FDhSoed6m3QyZdx5hK7iLFkYk3rNxwt8vTA==}
3091
3091
 
3092
3092
  '@kmlckj/licos-platform-sdk@0.6.1':
3093
- resolution: {integrity: sha512-eADWtycsGKxO37QZKsHNNI91XDmHZrrbQGZUrR576v8rxASZBLV8X3j/02W8nIwIkfcKK7XC63DOE2IIDDsuuQ==}
3093
+ resolution: {integrity: sha512-8i+MCc7RYLK42NhT+JGF7wG0ddUQtSfcT05WqUtNnEn7SdHewoNLi/JqK4ZJM3DQB+/azOxqqM/To72B9DkIsA==}
3094
3094
 
3095
3095
  '@langchain/core@1.1.16':
3096
3096
  resolution: {integrity: sha512-2XKQKxvQdeQiuIo0tacAmDVojhSVAci8D2WDdmmyN+6CqDusLHEHyIDaOt4o+UBvpkyHXbCdrljzDTQY/AKeqg==}
@@ -1,4 +1,4 @@
1
- loglevel=error
1
+ loglevel=warn
2
2
  registry=https://registry.npmmirror.com/
3
3
  @kmlckj:registry=https://registry.npmmirror.com/
4
4
 
@@ -295,7 +295,7 @@ packages:
295
295
  resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
296
296
 
297
297
  '@kmlckj/licos-platform-sdk@0.6.1':
298
- resolution: {integrity: sha512-eADWtycsGKxO37QZKsHNNI91XDmHZrrbQGZUrR576v8rxASZBLV8X3j/02W8nIwIkfcKK7XC63DOE2IIDDsuuQ==}
298
+ resolution: {integrity: sha512-8i+MCc7RYLK42NhT+JGF7wG0ddUQtSfcT05WqUtNnEn7SdHewoNLi/JqK4ZJM3DQB+/azOxqqM/To72B9DkIsA==}
299
299
 
300
300
  '@langchain/core@1.1.16':
301
301
  resolution: {integrity: sha512-2XKQKxvQdeQiuIo0tacAmDVojhSVAci8D2WDdmmyN+6CqDusLHEHyIDaOt4o+UBvpkyHXbCdrljzDTQY/AKeqg==}
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.21";
2110
+ var version = "0.0.23";
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";
@@ -7002,7 +7002,24 @@ const executeRun = async (
7002
7002
  const logFilePath = resolveLogFilePath(options.logFile);
7003
7003
  const logStream = createLogStream(logFilePath);
7004
7004
 
7005
- // 4. 执行命令
7005
+ // 4. 开发预览先执行 dev.build,例如 pnpm install / framework prepare。
7006
+ if (commandName === 'dev') {
7007
+ const devBuildArgs = _optionalChain$4([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.build]);
7008
+ if (Array.isArray(devBuildArgs) && devBuildArgs.length > 0) {
7009
+ const devBuildCommand = devBuildArgs.join(' ');
7010
+ logger.info(`Executing dev build step: ${devBuildCommand}`);
7011
+ logger.info(`Working directory: ${process.cwd()}`);
7012
+ const buildResult = shelljs.exec(devBuildCommand, {
7013
+ silent: false,
7014
+ env: buildProjectProgramEnv(),
7015
+ });
7016
+ if (buildResult.code !== 0) {
7017
+ throw new Error(`Dev build step exited with code ${buildResult.code}`);
7018
+ }
7019
+ }
7020
+ }
7021
+
7022
+ // 5. 执行命令
7006
7023
  const commandString = commandArgs.join(' ');
7007
7024
 
7008
7025
  logger.info(`Executing: ${commandString}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmlckj/licos-ai-cli",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "LICOS AI coding workspace CLI - project template engine and dev tools",
5
5
  "license": "MIT",
6
6
  "author": "kmlckj",