@coze-arch/cli 0.0.36-alpha.fd6b86 → 0.0.36
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.
- package/README.md +0 -11
- package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +18 -73
- package/lib/__templates__/expo/pnpm-lock.yaml +5 -5
- package/lib/__templates__/expo/server/package.json +1 -1
- package/lib/__templates__/nextjs/package.json +2 -2
- package/lib/__templates__/nextjs/pnpm-lock.yaml +258 -197
- package/lib/__templates__/nextjs/scripts/dev.sh +1 -82
- package/lib/__templates__/nextjs/template.config.js +1 -3
- package/lib/__templates__/nuxt-vue/scripts/dev.sh +1 -82
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +26 -63
- package/lib/__templates__/taro/pnpm-lock.yaml +5 -5
- package/lib/__templates__/taro/server/package.json +1 -1
- package/lib/__templates__/templates.json +0 -25
- package/lib/__templates__/vite/scripts/dev.sh +1 -82
- package/lib/__templates__/vite/template.config.js +1 -3
- package/lib/cli.js +199 -3446
- package/package.json +3 -5
- package/docs/deploy.md +0 -171
- package/lib/__templates__/phaser/.coze +0 -13
- package/lib/__templates__/phaser/README.md +0 -37
- package/lib/__templates__/phaser/_gitignore +0 -23
- package/lib/__templates__/phaser/_npmrc +0 -14
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0001.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0002.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0003.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0004.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0005.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0006.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0007.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0008.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0009.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0010.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0011.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0012.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0013.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0014.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0015.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0016.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0017.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0018.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0019.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0020.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0021.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0022.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0023.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0024.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/manifest.json +0 -11
- package/lib/__templates__/phaser/debug-runtime/flow-graph.json +0 -20
- package/lib/__templates__/phaser/index.html +0 -12
- package/lib/__templates__/phaser/package.json +0 -31
- package/lib/__templates__/phaser/pnpm-lock.yaml +0 -661
- package/lib/__templates__/phaser/scripts/build.sh +0 -8
- package/lib/__templates__/phaser/scripts/dev.sh +0 -82
- package/lib/__templates__/phaser/scripts/prepare.sh +0 -7
- package/lib/__templates__/phaser/scripts/spawn-detached.cjs +0 -29
- package/lib/__templates__/phaser/scripts/start.sh +0 -82
- package/lib/__templates__/phaser/scripts/validate.sh +0 -7
- package/lib/__templates__/phaser/src/assets.ts +0 -15
- package/lib/__templates__/phaser/src/global.d.ts +0 -36
- package/lib/__templates__/phaser/src/main.ts +0 -28
- package/lib/__templates__/phaser/src/scene/BootScene.ts +0 -209
- package/lib/__templates__/phaser/src/scene/DevLoadingScene.ts +0 -66
- package/lib/__templates__/phaser/src/style.css +0 -28
- package/lib/__templates__/phaser/src/types.ts +0 -32
- package/lib/__templates__/phaser/src/utils/asset-loader.ts +0 -319
- package/lib/__templates__/phaser/src/utils/index.ts +0 -2
- package/lib/__templates__/phaser/src/utils/mark-editable.ts +0 -6
- package/lib/__templates__/phaser/template.config.js +0 -43
- package/lib/__templates__/phaser/tsconfig.json +0 -23
- package/lib/__templates__/phaser/vite.config.ts +0 -96
- package/lib/deploy/package-project.js +0 -226
- package/lib/deploy/package-project.py +0 -168
|
@@ -32,89 +32,8 @@ kill_port_if_listening() {
|
|
|
32
32
|
fi
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
<% if (process.env.NODE_ENV === 'test') { %>
|
|
36
|
-
echo "Clearing port ${DEPLOY_RUN_PORT} before start."
|
|
37
|
-
kill_port_if_listening
|
|
38
|
-
echo "Starting HTTP service on port ${DEPLOY_RUN_PORT} for dev..."
|
|
39
|
-
|
|
40
|
-
# 测试环境保持服务为前台进程,便于 e2e 收集输出并停止进程。
|
|
41
|
-
exec env PORT="${DEPLOY_RUN_PORT}" pnpm tsx watch src/server.ts
|
|
42
|
-
<% } else { %>
|
|
43
|
-
LOG_DIR="${COZE_LOG_DIR:-${COZE_WORKSPACE_PATH}/logs}"
|
|
44
|
-
LOG_FILE="${LOG_DIR}/server.log"
|
|
45
|
-
PID_FILE="${LOG_DIR}/server.pid"
|
|
46
|
-
|
|
47
|
-
# coze-daemon 会在 runtime shell 退出时清理原进程组。
|
|
48
|
-
# 通过 Node detached spawn 创建独立 session/进程组,并将 stdio 直接写入日志。
|
|
49
|
-
spawn_detached() {
|
|
50
|
-
local cwd="$1"
|
|
51
|
-
local log_file="$2"
|
|
52
|
-
shift 2
|
|
53
|
-
|
|
54
|
-
node - "$cwd" "$log_file" "$@" <<'NODE'
|
|
55
|
-
const fs = require('node:fs');
|
|
56
|
-
const { spawn } = require('node:child_process');
|
|
57
|
-
|
|
58
|
-
const [cwd, logFile, command, ...args] = process.argv.slice(2);
|
|
59
|
-
if (!cwd || !logFile || !command) {
|
|
60
|
-
throw new Error('spawn_detached 缺少 cwd、log_file 或 command');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const logFd = fs.openSync(logFile, 'a');
|
|
64
|
-
try {
|
|
65
|
-
const child = spawn(command, args, {
|
|
66
|
-
cwd,
|
|
67
|
-
detached: true,
|
|
68
|
-
env: process.env,
|
|
69
|
-
stdio: ['ignore', logFd, logFd],
|
|
70
|
-
});
|
|
71
|
-
child.unref();
|
|
72
|
-
process.stdout.write(String(child.pid));
|
|
73
|
-
} finally {
|
|
74
|
-
fs.closeSync(logFd);
|
|
75
|
-
}
|
|
76
|
-
NODE
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
stop_detached() {
|
|
80
|
-
local pid="${1:-}"
|
|
81
|
-
if [[ -z "${pid}" ]]; then
|
|
82
|
-
return
|
|
83
|
-
fi
|
|
84
|
-
|
|
85
|
-
kill -TERM -- "-${pid}" 2>/dev/null || kill -TERM "${pid}" 2>/dev/null || true
|
|
86
|
-
sleep 1
|
|
87
|
-
kill -KILL -- "-${pid}" 2>/dev/null || true
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
# 监听端口的是孙进程(pnpm -> tsx -> node),只清端口会漏掉上层 pnpm/tsx,
|
|
91
|
-
# 所以先按上次记录的 PID 把整个进程组回收掉。
|
|
92
|
-
if [[ -f "${PID_FILE}" ]]; then
|
|
93
|
-
stop_detached "$(cat "${PID_FILE}" 2>/dev/null || true)"
|
|
94
|
-
rm -f "${PID_FILE}"
|
|
95
|
-
fi
|
|
96
|
-
|
|
97
35
|
echo "Clearing port ${DEPLOY_RUN_PORT} before start."
|
|
98
36
|
kill_port_if_listening
|
|
99
37
|
echo "Starting HTTP service on port ${DEPLOY_RUN_PORT} for dev..."
|
|
100
38
|
|
|
101
|
-
|
|
102
|
-
: > "${LOG_FILE}"
|
|
103
|
-
|
|
104
|
-
export PORT="${DEPLOY_RUN_PORT}"
|
|
105
|
-
server_pid="$(spawn_detached "${COZE_WORKSPACE_PATH}" "${LOG_FILE}" \
|
|
106
|
-
"$(command -v pnpm)" tsx watch src/server.ts)"
|
|
107
|
-
echo "${server_pid}" > "${PID_FILE}"
|
|
108
|
-
|
|
109
|
-
sleep 1
|
|
110
|
-
if [[ -z "${server_pid}" ]] || ! kill -0 "${server_pid}" 2>/dev/null; then
|
|
111
|
-
echo "Dev server failed to start. See ${LOG_FILE}." >&2
|
|
112
|
-
tail -n 20 "${LOG_FILE}" >&2 || true
|
|
113
|
-
rm -f "${PID_FILE}"
|
|
114
|
-
exit 1
|
|
115
|
-
fi
|
|
116
|
-
|
|
117
|
-
echo "Dev server started (PID: ${server_pid})."
|
|
118
|
-
echo "Log file: ${LOG_FILE}"
|
|
119
|
-
echo "PID file: ${PID_FILE}"
|
|
120
|
-
<% } %>
|
|
39
|
+
PORT=${DEPLOY_RUN_PORT} pnpm tsx watch src/server.ts
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { spawn } from 'child_process';
|
|
4
4
|
import { resolve, join, basename } from 'path';
|
|
5
5
|
import { appendFileSync, openSync, closeSync, mkdirSync } from 'fs';
|
|
6
|
-
import { homedir } from 'os';
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
|
|
@@ -75,8 +74,7 @@ const config = {
|
|
|
75
74
|
const projectRoot = resolve(outputPath);
|
|
76
75
|
|
|
77
76
|
// Determine log directory
|
|
78
|
-
const
|
|
79
|
-
const logDir = process.env.COZE_LOG_DIR || join(cozeHome, 'logs');
|
|
77
|
+
const logDir = process.env.COZE_LOG_DIR || resolve(__dirname, '../.log');
|
|
80
78
|
mkdirSync(logDir, { recursive: true });
|
|
81
79
|
|
|
82
80
|
// Use project name in log file to avoid conflicts
|
|
@@ -32,89 +32,8 @@ kill_port_if_listening() {
|
|
|
32
32
|
fi
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
<% if (process.env.NODE_ENV === 'test') { %>
|
|
36
|
-
echo "Clearing port ${DEPLOY_RUN_PORT} before start."
|
|
37
|
-
kill_port_if_listening
|
|
38
|
-
echo "Starting Nuxt dev server on port ${DEPLOY_RUN_PORT}..."
|
|
39
|
-
|
|
40
|
-
# 测试环境保持服务为前台进程,便于 e2e 收集输出并停止进程。
|
|
41
|
-
exec env PORT="${DEPLOY_RUN_PORT}" pnpm nuxt dev
|
|
42
|
-
<% } else { %>
|
|
43
|
-
LOG_DIR="${COZE_LOG_DIR:-${COZE_WORKSPACE_PATH}/logs}"
|
|
44
|
-
LOG_FILE="${LOG_DIR}/server.log"
|
|
45
|
-
PID_FILE="${LOG_DIR}/server.pid"
|
|
46
|
-
|
|
47
|
-
# coze-daemon 会在 runtime shell 退出时清理原进程组。
|
|
48
|
-
# 通过 Node detached spawn 创建独立 session/进程组,并将 stdio 直接写入日志。
|
|
49
|
-
spawn_detached() {
|
|
50
|
-
local cwd="$1"
|
|
51
|
-
local log_file="$2"
|
|
52
|
-
shift 2
|
|
53
|
-
|
|
54
|
-
node - "$cwd" "$log_file" "$@" <<'NODE'
|
|
55
|
-
const fs = require('node:fs');
|
|
56
|
-
const { spawn } = require('node:child_process');
|
|
57
|
-
|
|
58
|
-
const [cwd, logFile, command, ...args] = process.argv.slice(2);
|
|
59
|
-
if (!cwd || !logFile || !command) {
|
|
60
|
-
throw new Error('spawn_detached 缺少 cwd、log_file 或 command');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const logFd = fs.openSync(logFile, 'a');
|
|
64
|
-
try {
|
|
65
|
-
const child = spawn(command, args, {
|
|
66
|
-
cwd,
|
|
67
|
-
detached: true,
|
|
68
|
-
env: process.env,
|
|
69
|
-
stdio: ['ignore', logFd, logFd],
|
|
70
|
-
});
|
|
71
|
-
child.unref();
|
|
72
|
-
process.stdout.write(String(child.pid));
|
|
73
|
-
} finally {
|
|
74
|
-
fs.closeSync(logFd);
|
|
75
|
-
}
|
|
76
|
-
NODE
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
stop_detached() {
|
|
80
|
-
local pid="${1:-}"
|
|
81
|
-
if [[ -z "${pid}" ]]; then
|
|
82
|
-
return
|
|
83
|
-
fi
|
|
84
|
-
|
|
85
|
-
kill -TERM -- "-${pid}" 2>/dev/null || kill -TERM "${pid}" 2>/dev/null || true
|
|
86
|
-
sleep 1
|
|
87
|
-
kill -KILL -- "-${pid}" 2>/dev/null || true
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
# 监听端口的是孙进程(pnpm -> nuxt -> node),只清端口会漏掉上层 pnpm/nuxt,
|
|
91
|
-
# 所以先按上次记录的 PID 把整个进程组回收掉。
|
|
92
|
-
if [[ -f "${PID_FILE}" ]]; then
|
|
93
|
-
stop_detached "$(cat "${PID_FILE}" 2>/dev/null || true)"
|
|
94
|
-
rm -f "${PID_FILE}"
|
|
95
|
-
fi
|
|
96
|
-
|
|
97
35
|
echo "Clearing port ${DEPLOY_RUN_PORT} before start."
|
|
98
36
|
kill_port_if_listening
|
|
99
37
|
echo "Starting Nuxt dev server on port ${DEPLOY_RUN_PORT}..."
|
|
100
38
|
|
|
101
|
-
|
|
102
|
-
: > "${LOG_FILE}"
|
|
103
|
-
|
|
104
|
-
export PORT="${DEPLOY_RUN_PORT}"
|
|
105
|
-
server_pid="$(spawn_detached "${COZE_WORKSPACE_PATH}" "${LOG_FILE}" \
|
|
106
|
-
"$(command -v pnpm)" nuxt dev)"
|
|
107
|
-
echo "${server_pid}" > "${PID_FILE}"
|
|
108
|
-
|
|
109
|
-
sleep 1
|
|
110
|
-
if [[ -z "${server_pid}" ]] || ! kill -0 "${server_pid}" 2>/dev/null; then
|
|
111
|
-
echo "Dev server failed to start. See ${LOG_FILE}." >&2
|
|
112
|
-
tail -n 20 "${LOG_FILE}" >&2 || true
|
|
113
|
-
rm -f "${PID_FILE}"
|
|
114
|
-
exit 1
|
|
115
|
-
fi
|
|
116
|
-
|
|
117
|
-
echo "Dev server started (PID: ${server_pid})."
|
|
118
|
-
echo "Log file: ${LOG_FILE}"
|
|
119
|
-
echo "PID file: ${PID_FILE}"
|
|
120
|
-
<% } %>
|
|
39
|
+
PORT=${DEPLOY_RUN_PORT} pnpm nuxt dev
|
|
@@ -8,9 +8,6 @@ cd "${COZE_WORKSPACE_PATH}"
|
|
|
8
8
|
# PID 文件,用于追踪上一次启动的进程树
|
|
9
9
|
# ---------------------------------------------------------
|
|
10
10
|
PID_FILE="/tmp/coze-dev-run.pid"
|
|
11
|
-
LOG_DIR="/tmp/coze-logs"
|
|
12
|
-
LOG_FILE="${LOG_DIR}/dev.log"
|
|
13
|
-
DEV_PID=""
|
|
14
11
|
|
|
15
12
|
# ---------------------------------------------------------
|
|
16
13
|
# 工具函数
|
|
@@ -28,49 +25,6 @@ kill_process_tree() {
|
|
|
28
25
|
fi
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
# coze-daemon 会在 runtime shell 退出时清理原进程组。
|
|
32
|
-
# 通过 Node detached spawn 创建独立 session/进程组,并将 stdio 直接写入日志。
|
|
33
|
-
spawn_detached() {
|
|
34
|
-
local cwd="$1"
|
|
35
|
-
local log_file="$2"
|
|
36
|
-
shift 2
|
|
37
|
-
|
|
38
|
-
node - "$cwd" "$log_file" "$@" <<'NODE'
|
|
39
|
-
const fs = require('node:fs');
|
|
40
|
-
const { spawn } = require('node:child_process');
|
|
41
|
-
|
|
42
|
-
const [cwd, logFile, command, ...args] = process.argv.slice(2);
|
|
43
|
-
if (!cwd || !logFile || !command) {
|
|
44
|
-
throw new Error('spawn_detached 缺少 cwd、log_file 或 command');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const logFd = fs.openSync(logFile, 'a');
|
|
48
|
-
try {
|
|
49
|
-
const child = spawn(command, args, {
|
|
50
|
-
cwd,
|
|
51
|
-
detached: true,
|
|
52
|
-
env: process.env,
|
|
53
|
-
stdio: ['ignore', logFd, logFd],
|
|
54
|
-
});
|
|
55
|
-
child.unref();
|
|
56
|
-
process.stdout.write(String(child.pid));
|
|
57
|
-
} finally {
|
|
58
|
-
fs.closeSync(logFd);
|
|
59
|
-
}
|
|
60
|
-
NODE
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
stop_detached() {
|
|
64
|
-
local pid="${1:-}"
|
|
65
|
-
if [[ -z "${pid}" ]]; then
|
|
66
|
-
return
|
|
67
|
-
fi
|
|
68
|
-
|
|
69
|
-
kill -TERM -- "-${pid}" 2>/dev/null || kill -TERM "${pid}" 2>/dev/null || true
|
|
70
|
-
sleep 1
|
|
71
|
-
kill -KILL -- "-${pid}" 2>/dev/null || true
|
|
72
|
-
}
|
|
73
|
-
|
|
74
28
|
kill_port_if_listening() {
|
|
75
29
|
local port=$1
|
|
76
30
|
local pids
|
|
@@ -102,7 +56,7 @@ cleanup_previous_run() {
|
|
|
102
56
|
old_pid=$(cat "${PID_FILE}" 2>/dev/null || true)
|
|
103
57
|
if [[ -n "${old_pid}" ]] && kill -0 "${old_pid}" 2>/dev/null; then
|
|
104
58
|
echo "🧹 Killing previous dev process tree (root PID: ${old_pid})..."
|
|
105
|
-
|
|
59
|
+
kill_process_tree "${old_pid}"
|
|
106
60
|
fi
|
|
107
61
|
rm -f "${PID_FILE}"
|
|
108
62
|
fi
|
|
@@ -135,8 +89,7 @@ cleanup_previous_run() {
|
|
|
135
89
|
# 2. 安装依赖
|
|
136
90
|
# ---------------------------------------------------------
|
|
137
91
|
echo "📦 Installing dependencies..."
|
|
138
|
-
|
|
139
|
-
"${PNPM_BIN}" install
|
|
92
|
+
pnpm install
|
|
140
93
|
echo "✅ Dependencies installed successfully!"
|
|
141
94
|
|
|
142
95
|
# ---------------------------------------------------------
|
|
@@ -152,7 +105,19 @@ echo "Clearing port ${SERVER_PORT} (server) before start."
|
|
|
152
105
|
kill_port_if_listening "${SERVER_PORT}"
|
|
153
106
|
|
|
154
107
|
# ---------------------------------------------------------
|
|
155
|
-
# 4.
|
|
108
|
+
# 4. 退出时自动清理子进程(信号 trap)
|
|
109
|
+
# ---------------------------------------------------------
|
|
110
|
+
cleanup_on_exit() {
|
|
111
|
+
echo "🛑 dev_run.sh exiting, cleaning up child processes..."
|
|
112
|
+
# 杀掉当前脚本的所有子进程
|
|
113
|
+
kill -- -$$ 2>/dev/null || true
|
|
114
|
+
rm -f "${PID_FILE}"
|
|
115
|
+
exit 0
|
|
116
|
+
}
|
|
117
|
+
trap cleanup_on_exit EXIT INT TERM HUP
|
|
118
|
+
|
|
119
|
+
# ---------------------------------------------------------
|
|
120
|
+
# 5. 启动服务
|
|
156
121
|
# ---------------------------------------------------------
|
|
157
122
|
start_service() {
|
|
158
123
|
cd "${COZE_WORKSPACE_PATH}"
|
|
@@ -169,19 +134,17 @@ start_service() {
|
|
|
169
134
|
echo "Starting Taro H5 Dev Server and NestJS Server..."
|
|
170
135
|
|
|
171
136
|
export PORT=${DEPLOY_RUN_PORT}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
echo "${DEV_PID}" > "${PID_FILE}"
|
|
184
|
-
echo "📝 Dev process started with PID: ${DEV_PID} (saved to ${PID_FILE})"
|
|
137
|
+
rm -f /tmp/coze-logs/dev.log
|
|
138
|
+
mkdir -p /tmp/coze-logs
|
|
139
|
+
|
|
140
|
+
# 后台启动并记录 PID
|
|
141
|
+
pnpm dev 2>&1 | tee /tmp/coze-logs/dev.log &
|
|
142
|
+
local dev_pid=$!
|
|
143
|
+
echo "${dev_pid}" > "${PID_FILE}"
|
|
144
|
+
echo "📝 Dev process started with PID: ${dev_pid} (saved to ${PID_FILE})"
|
|
145
|
+
|
|
146
|
+
# 前台等待,保证 trap 能正常捕获信号
|
|
147
|
+
wait "${dev_pid}" || true
|
|
185
148
|
}
|
|
186
149
|
|
|
187
150
|
echo "Starting HTTP services on port ${DEPLOY_RUN_PORT} (web) and ${SERVER_PORT} (server)..."
|
|
@@ -204,8 +204,8 @@ importers:
|
|
|
204
204
|
specifier: 2.95.3
|
|
205
205
|
version: 2.95.3
|
|
206
206
|
coze-coding-dev-sdk:
|
|
207
|
-
specifier: ^0.7.
|
|
208
|
-
version: 0.7.
|
|
207
|
+
specifier: ^0.7.24
|
|
208
|
+
version: 0.7.24(openai@6.16.0(ws@8.19.0)(zod@4.3.5))(ws@8.19.0)
|
|
209
209
|
dotenv:
|
|
210
210
|
specifier: ^17.2.3
|
|
211
211
|
version: 17.2.3
|
|
@@ -5416,8 +5416,8 @@ packages:
|
|
|
5416
5416
|
typescript:
|
|
5417
5417
|
optional: true
|
|
5418
5418
|
|
|
5419
|
-
coze-coding-dev-sdk@0.7.
|
|
5420
|
-
resolution: {integrity: sha512
|
|
5419
|
+
coze-coding-dev-sdk@0.7.24:
|
|
5420
|
+
resolution: {integrity: sha512-oL9Tg5PwxP6iMixonzzMO4aBjOKWcFUMVM+iz5dPyaqQkG84HP1y9DqK5DJVmtdfJuYdAW7pzOatDqLvgvZiXg==}
|
|
5421
5421
|
engines: {node: '>=18.0.0'}
|
|
5422
5422
|
hasBin: true
|
|
5423
5423
|
|
|
@@ -17159,7 +17159,7 @@ snapshots:
|
|
|
17159
17159
|
optionalDependencies:
|
|
17160
17160
|
typescript: 5.9.3
|
|
17161
17161
|
|
|
17162
|
-
coze-coding-dev-sdk@0.7.
|
|
17162
|
+
coze-coding-dev-sdk@0.7.24(openai@6.16.0(ws@8.19.0)(zod@4.3.5))(ws@8.19.0):
|
|
17163
17163
|
dependencies:
|
|
17164
17164
|
'@langchain/core': 1.1.16(openai@6.16.0(ws@8.19.0)(zod@4.3.5))
|
|
17165
17165
|
'@langchain/openai': 1.2.3(@langchain/core@1.1.16(openai@6.16.0(ws@8.19.0)(zod@4.3.5)))(ws@8.19.0)
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@nestjs/core": "^10.4.15",
|
|
18
18
|
"@nestjs/platform-express": "^10.4.15",
|
|
19
19
|
"@supabase/supabase-js": "2.95.3",
|
|
20
|
-
"coze-coding-dev-sdk": "^0.7.
|
|
20
|
+
"coze-coding-dev-sdk": "^0.7.24",
|
|
21
21
|
"dotenv": "^17.2.3",
|
|
22
22
|
"drizzle-kit": "^0.31.8",
|
|
23
23
|
"drizzle-orm": "^0.45.1",
|
|
@@ -94,31 +94,6 @@
|
|
|
94
94
|
"additionalProperties": false
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
|
-
{
|
|
98
|
-
"name": "phaser",
|
|
99
|
-
"description": "Phaser(2D 游戏):`coze-dev init ${COZE_WORKSPACE_PATH} --template phaser`\n- 适用:基于 Phaser 3、Vite 和 TypeScript 的 2D Web 游戏。",
|
|
100
|
-
"location": "./phaser",
|
|
101
|
-
"paramsSchema": {
|
|
102
|
-
"type": "object",
|
|
103
|
-
"properties": {
|
|
104
|
-
"appName": {
|
|
105
|
-
"type": "string",
|
|
106
|
-
"minLength": 1,
|
|
107
|
-
"pattern": "^[a-z0-9-]+$",
|
|
108
|
-
"description": "Application name (lowercase, alphanumeric and hyphens only)"
|
|
109
|
-
},
|
|
110
|
-
"port": {
|
|
111
|
-
"type": "number",
|
|
112
|
-
"default": 5000,
|
|
113
|
-
"minimum": 1024,
|
|
114
|
-
"maximum": 65535,
|
|
115
|
-
"description": "Development and preview server port"
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
"required": [],
|
|
119
|
-
"additionalProperties": false
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
97
|
{
|
|
123
98
|
"name": "pi-agent",
|
|
124
99
|
"description": "Pi Agent:`coze-dev init ${COZE_WORKSPACE_PATH} --template pi-agent`\n- 适用:基于 pi-agent-core 的 AI Agent 应用\n- 支持飞书、微信等多渠道接入\n- 内置 Dashboard 管理面板\n- 使用 TypeScript + Express + Vite",
|
|
@@ -32,89 +32,8 @@ kill_port_if_listening() {
|
|
|
32
32
|
fi
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
<% if (process.env.NODE_ENV === 'test') { %>
|
|
36
|
-
echo "Clearing port ${DEPLOY_RUN_PORT} before start."
|
|
37
|
-
kill_port_if_listening
|
|
38
|
-
echo "Starting express + Vite dev server on port ${DEPLOY_RUN_PORT}..."
|
|
39
|
-
|
|
40
|
-
# 测试环境保持服务为前台进程,便于 e2e 收集输出并停止进程。
|
|
41
|
-
exec env PORT="${DEPLOY_RUN_PORT}" pnpm tsx watch server/server.ts
|
|
42
|
-
<% } else { %>
|
|
43
|
-
LOG_DIR="${COZE_LOG_DIR:-${COZE_WORKSPACE_PATH}/logs}"
|
|
44
|
-
LOG_FILE="${LOG_DIR}/server.log"
|
|
45
|
-
PID_FILE="${LOG_DIR}/server.pid"
|
|
46
|
-
|
|
47
|
-
# coze-daemon 会在 runtime shell 退出时清理原进程组。
|
|
48
|
-
# 通过 Node detached spawn 创建独立 session/进程组,并将 stdio 直接写入日志。
|
|
49
|
-
spawn_detached() {
|
|
50
|
-
local cwd="$1"
|
|
51
|
-
local log_file="$2"
|
|
52
|
-
shift 2
|
|
53
|
-
|
|
54
|
-
node - "$cwd" "$log_file" "$@" <<'NODE'
|
|
55
|
-
const fs = require('node:fs');
|
|
56
|
-
const { spawn } = require('node:child_process');
|
|
57
|
-
|
|
58
|
-
const [cwd, logFile, command, ...args] = process.argv.slice(2);
|
|
59
|
-
if (!cwd || !logFile || !command) {
|
|
60
|
-
throw new Error('spawn_detached 缺少 cwd、log_file 或 command');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const logFd = fs.openSync(logFile, 'a');
|
|
64
|
-
try {
|
|
65
|
-
const child = spawn(command, args, {
|
|
66
|
-
cwd,
|
|
67
|
-
detached: true,
|
|
68
|
-
env: process.env,
|
|
69
|
-
stdio: ['ignore', logFd, logFd],
|
|
70
|
-
});
|
|
71
|
-
child.unref();
|
|
72
|
-
process.stdout.write(String(child.pid));
|
|
73
|
-
} finally {
|
|
74
|
-
fs.closeSync(logFd);
|
|
75
|
-
}
|
|
76
|
-
NODE
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
stop_detached() {
|
|
80
|
-
local pid="${1:-}"
|
|
81
|
-
if [[ -z "${pid}" ]]; then
|
|
82
|
-
return
|
|
83
|
-
fi
|
|
84
|
-
|
|
85
|
-
kill -TERM -- "-${pid}" 2>/dev/null || kill -TERM "${pid}" 2>/dev/null || true
|
|
86
|
-
sleep 1
|
|
87
|
-
kill -KILL -- "-${pid}" 2>/dev/null || true
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
# 监听端口的是孙进程(pnpm -> tsx -> node),只清端口会漏掉上层 pnpm/tsx,
|
|
91
|
-
# 所以先按上次记录的 PID 把整个进程组回收掉。
|
|
92
|
-
if [[ -f "${PID_FILE}" ]]; then
|
|
93
|
-
stop_detached "$(cat "${PID_FILE}" 2>/dev/null || true)"
|
|
94
|
-
rm -f "${PID_FILE}"
|
|
95
|
-
fi
|
|
96
|
-
|
|
97
35
|
echo "Clearing port ${DEPLOY_RUN_PORT} before start."
|
|
98
36
|
kill_port_if_listening
|
|
99
37
|
echo "Starting express + Vite dev server on port ${DEPLOY_RUN_PORT}..."
|
|
100
38
|
|
|
101
|
-
|
|
102
|
-
: > "${LOG_FILE}"
|
|
103
|
-
|
|
104
|
-
export PORT="${DEPLOY_RUN_PORT}"
|
|
105
|
-
server_pid="$(spawn_detached "${COZE_WORKSPACE_PATH}" "${LOG_FILE}" \
|
|
106
|
-
"$(command -v pnpm)" tsx watch server/server.ts)"
|
|
107
|
-
echo "${server_pid}" > "${PID_FILE}"
|
|
108
|
-
|
|
109
|
-
sleep 1
|
|
110
|
-
if [[ -z "${server_pid}" ]] || ! kill -0 "${server_pid}" 2>/dev/null; then
|
|
111
|
-
echo "Dev server failed to start. See ${LOG_FILE}." >&2
|
|
112
|
-
tail -n 20 "${LOG_FILE}" >&2 || true
|
|
113
|
-
rm -f "${PID_FILE}"
|
|
114
|
-
exit 1
|
|
115
|
-
fi
|
|
116
|
-
|
|
117
|
-
echo "Dev server started (PID: ${server_pid})."
|
|
118
|
-
echo "Log file: ${LOG_FILE}"
|
|
119
|
-
echo "PID file: ${PID_FILE}"
|
|
120
|
-
<% } %>
|
|
39
|
+
PORT=${DEPLOY_RUN_PORT} pnpm tsx watch server/server.ts
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { spawn } from 'child_process';
|
|
3
3
|
import { resolve, join, basename } from 'path';
|
|
4
4
|
import { appendFileSync, openSync, closeSync, mkdirSync } from 'fs';
|
|
5
|
-
import { homedir } from 'os';
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
|
|
@@ -82,8 +81,7 @@ const config = {
|
|
|
82
81
|
const projectRoot = resolve(outputPath);
|
|
83
82
|
|
|
84
83
|
// Determine log directory
|
|
85
|
-
const
|
|
86
|
-
const logDir = process.env.COZE_LOG_DIR || join(cozeHome, 'logs');
|
|
84
|
+
const logDir = process.env.COZE_LOG_DIR || resolve(__dirname, '../.log');
|
|
87
85
|
mkdirSync(logDir, { recursive: true });
|
|
88
86
|
|
|
89
87
|
// Use project name in log file to avoid conflicts
|