@coze-arch/cli 0.0.1-alpha.f5dbe4 → 0.0.1-alpha.f62945
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/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +13 -12
- package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +9 -8
- package/lib/__templates__/expo/README.md +3 -5
- package/lib/__templates__/expo/client/app/+not-found.tsx +19 -4
- package/lib/__templates__/expo/client/app/_layout.tsx +17 -16
- package/lib/__templates__/expo/client/components/ThemedText.tsx +33 -0
- package/lib/__templates__/expo/client/components/ThemedView.tsx +37 -0
- package/lib/__templates__/expo/client/constants/theme.ts +177 -0
- package/lib/__templates__/expo/client/hooks/useColorScheme.tsx +48 -0
- package/lib/__templates__/expo/client/hooks/useTheme.ts +33 -0
- package/lib/__templates__/expo/client/metro.config.js +4 -8
- package/lib/__templates__/expo/client/package.json +29 -31
- package/lib/__templates__/expo/client/screens/demo/index.tsx +13 -7
- package/lib/__templates__/expo/package.json +1 -1
- package/lib/__templates__/expo/patches/{expo@54.0.32.patch → expo@54.0.33.patch} +3 -2
- package/lib/__templates__/expo/pnpm-lock.yaml +340 -1736
- package/lib/__templates__/expo/server/package.json +9 -7
- package/lib/__templates__/expo/server/src/index.ts +1 -0
- package/lib/__templates__/expo/template.config.js +56 -0
- package/lib/__templates__/native-static/.coze +11 -0
- package/lib/__templates__/native-static/index.html +33 -0
- package/lib/__templates__/native-static/styles/main.css +136 -0
- package/lib/__templates__/native-static/template.config.js +22 -0
- package/lib/__templates__/nextjs/package.json +3 -1
- package/lib/__templates__/nextjs/pnpm-lock.yaml +119 -106
- package/lib/__templates__/nextjs/src/app/page.tsx +18 -60
- package/lib/__templates__/nextjs/template.config.js +49 -14
- package/lib/__templates__/taro/.coze +14 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +151 -0
- package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
- package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -0
- package/lib/__templates__/taro/README.md +751 -0
- package/lib/__templates__/taro/_gitignore +40 -0
- package/lib/__templates__/taro/_npmrc +18 -0
- package/lib/__templates__/taro/babel.config.js +12 -0
- package/lib/__templates__/taro/config/dev.ts +9 -0
- package/lib/__templates__/taro/config/index.ts +223 -0
- package/lib/__templates__/taro/config/prod.ts +34 -0
- package/lib/__templates__/taro/eslint.config.mjs +80 -0
- package/lib/__templates__/taro/key/private.appid.key +0 -0
- package/lib/__templates__/taro/package.json +107 -0
- package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
- package/lib/__templates__/taro/pnpm-lock.yaml +23100 -0
- package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
- package/lib/__templates__/taro/project.config.json +15 -0
- package/lib/__templates__/taro/server/nest-cli.json +10 -0
- package/lib/__templates__/taro/server/package.json +40 -0
- package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
- package/lib/__templates__/taro/server/src/app.module.ts +10 -0
- package/lib/__templates__/taro/server/src/app.service.ts +8 -0
- package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
- package/lib/__templates__/taro/server/src/main.ts +49 -0
- package/lib/__templates__/taro/server/tsconfig.json +24 -0
- package/lib/__templates__/taro/src/app.config.ts +11 -0
- package/lib/__templates__/taro/src/app.css +52 -0
- package/lib/__templates__/taro/src/app.tsx +9 -0
- package/lib/__templates__/taro/src/index.html +39 -0
- package/lib/__templates__/taro/src/network.ts +39 -0
- package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
- package/lib/__templates__/taro/src/pages/index/index.css +1 -0
- package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
- package/lib/__templates__/taro/src/presets/dev-debug.ts +23 -0
- package/lib/__templates__/taro/src/presets/h5-container.tsx +15 -0
- package/lib/__templates__/taro/src/presets/h5-navbar.tsx +201 -0
- package/lib/__templates__/taro/src/presets/h5-styles.ts +142 -0
- package/lib/__templates__/taro/src/presets/index.tsx +18 -0
- package/lib/__templates__/taro/stylelint.config.mjs +4 -0
- package/lib/__templates__/taro/template.config.js +68 -0
- package/lib/__templates__/taro/tsconfig.json +29 -0
- package/lib/__templates__/taro/types/global.d.ts +32 -0
- package/lib/__templates__/templates.json +75 -0
- package/lib/__templates__/vite/package.json +5 -1
- package/lib/__templates__/vite/pnpm-lock.yaml +146 -1659
- package/lib/__templates__/vite/src/main.ts +17 -47
- package/lib/__templates__/vite/template.config.js +49 -14
- package/lib/__templates__/vite/vite.config.ts +1 -0
- package/lib/cli.js +62 -68
- package/package.json +2 -1
- package/lib/__templates__/expo/client/global.css +0 -76
- package/lib/__templates__/expo/client/uniwind-types.d.ts +0 -10
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -Eeuo pipefail
|
|
3
|
+
|
|
4
|
+
start_service() {
|
|
5
|
+
cd "${COZE_WORKSPACE_PATH}/server/dist"
|
|
6
|
+
|
|
7
|
+
local port="${DEPLOY_RUN_PORT:-3000}"
|
|
8
|
+
echo "Starting Static File Server on port ${port} for deploy..."
|
|
9
|
+
|
|
10
|
+
node ./main.js -p "${port}"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
echo "Starting HTTP service for deploy..."
|
|
14
|
+
start_service
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
echo "⚙️ dev_run.sh 开始运行"
|
|
3
|
+
set -Eeuo pipefail
|
|
4
|
+
|
|
5
|
+
cd "${COZE_WORKSPACE_PATH}"
|
|
6
|
+
|
|
7
|
+
# ---------------------------------------------------------
|
|
8
|
+
# PID 文件,用于追踪上一次启动的进程树
|
|
9
|
+
# ---------------------------------------------------------
|
|
10
|
+
PID_FILE="/tmp/coze-dev-run.pid"
|
|
11
|
+
|
|
12
|
+
# ---------------------------------------------------------
|
|
13
|
+
# 工具函数
|
|
14
|
+
# ---------------------------------------------------------
|
|
15
|
+
kill_process_tree() {
|
|
16
|
+
local pid=$1
|
|
17
|
+
local children
|
|
18
|
+
children=$(pgrep -P "${pid}" 2>/dev/null || true)
|
|
19
|
+
for child in ${children}; do
|
|
20
|
+
kill_process_tree "${child}"
|
|
21
|
+
done
|
|
22
|
+
if kill -0 "${pid}" 2>/dev/null; then
|
|
23
|
+
echo "Killing PID ${pid}"
|
|
24
|
+
kill -9 "${pid}" 2>/dev/null || true
|
|
25
|
+
fi
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
kill_port_if_listening() {
|
|
29
|
+
local port=$1
|
|
30
|
+
local pids
|
|
31
|
+
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)
|
|
32
|
+
if [[ -z "${pids}" ]]; then
|
|
33
|
+
echo "Port ${port} is free."
|
|
34
|
+
return
|
|
35
|
+
fi
|
|
36
|
+
echo "Port ${port} in use by PIDs: ${pids}"
|
|
37
|
+
for pid in ${pids}; do
|
|
38
|
+
kill_process_tree "${pid}"
|
|
39
|
+
done
|
|
40
|
+
sleep 1
|
|
41
|
+
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)
|
|
42
|
+
if [[ -n "${pids}" ]]; then
|
|
43
|
+
echo "Warning: port ${port} still busy after cleanup, PIDs: ${pids}"
|
|
44
|
+
else
|
|
45
|
+
echo "Port ${port} cleared."
|
|
46
|
+
fi
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# ---------------------------------------------------------
|
|
50
|
+
# 1. 清理上一次运行残留的整棵进程树
|
|
51
|
+
# ---------------------------------------------------------
|
|
52
|
+
cleanup_previous_run() {
|
|
53
|
+
# 1a. 通过 PID 文件清理上次的进程树
|
|
54
|
+
if [[ -f "${PID_FILE}" ]]; then
|
|
55
|
+
local old_pid
|
|
56
|
+
old_pid=$(cat "${PID_FILE}" 2>/dev/null || true)
|
|
57
|
+
if [[ -n "${old_pid}" ]] && kill -0 "${old_pid}" 2>/dev/null; then
|
|
58
|
+
echo "🧹 Killing previous dev process tree (root PID: ${old_pid})..."
|
|
59
|
+
kill_process_tree "${old_pid}"
|
|
60
|
+
fi
|
|
61
|
+
rm -f "${PID_FILE}"
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
# 1b. 兜底:按特征匹配清理所有残留的相关进程(排除自身)
|
|
65
|
+
echo "🧹 Cleaning up any orphaned dev processes..."
|
|
66
|
+
local patterns=(
|
|
67
|
+
"pnpm dev"
|
|
68
|
+
"concurrently.*dev:web.*dev:server"
|
|
69
|
+
"nest start --watch"
|
|
70
|
+
"taro build --type h5 --watch"
|
|
71
|
+
"node --enable-source-maps.*/workspace/projects/server/dist/main"
|
|
72
|
+
"esbuild --service.*--ping"
|
|
73
|
+
)
|
|
74
|
+
for pattern in "${patterns[@]}"; do
|
|
75
|
+
local pids
|
|
76
|
+
pids=$(pgrep -f "${pattern}" 2>/dev/null || true)
|
|
77
|
+
for pid in ${pids}; do
|
|
78
|
+
# 不杀自己和自己的父进程链
|
|
79
|
+
if [[ "${pid}" != "$$" ]] && [[ "${pid}" != "${PPID}" ]]; then
|
|
80
|
+
echo " Killing orphan PID ${pid} matching '${pattern}'"
|
|
81
|
+
kill -9 "${pid}" 2>/dev/null || true
|
|
82
|
+
fi
|
|
83
|
+
done
|
|
84
|
+
done
|
|
85
|
+
sleep 1
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
# ---------------------------------------------------------
|
|
89
|
+
# 2. 安装依赖
|
|
90
|
+
# ---------------------------------------------------------
|
|
91
|
+
echo "📦 Installing dependencies..."
|
|
92
|
+
pnpm install
|
|
93
|
+
echo "✅ Dependencies installed successfully!"
|
|
94
|
+
|
|
95
|
+
# ---------------------------------------------------------
|
|
96
|
+
# 3. 清理旧进程 + 端口
|
|
97
|
+
# ---------------------------------------------------------
|
|
98
|
+
SERVER_PORT=3000
|
|
99
|
+
|
|
100
|
+
cleanup_previous_run
|
|
101
|
+
|
|
102
|
+
echo "Clearing port ${DEPLOY_RUN_PORT} (web) before start."
|
|
103
|
+
kill_port_if_listening "${DEPLOY_RUN_PORT}"
|
|
104
|
+
echo "Clearing port ${SERVER_PORT} (server) before start."
|
|
105
|
+
kill_port_if_listening "${SERVER_PORT}"
|
|
106
|
+
|
|
107
|
+
# ---------------------------------------------------------
|
|
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. 启动服务
|
|
121
|
+
# ---------------------------------------------------------
|
|
122
|
+
start_service() {
|
|
123
|
+
cd "${COZE_WORKSPACE_PATH}"
|
|
124
|
+
|
|
125
|
+
# 动态注入环境变量
|
|
126
|
+
if [ -n "${COZE_PROJECT_DOMAIN_DEFAULT:-}" ]; then
|
|
127
|
+
export PROJECT_DOMAIN="$COZE_PROJECT_DOMAIN_DEFAULT"
|
|
128
|
+
echo "✅ 环境变量已动态注入: PROJECT_DOMAIN=$PROJECT_DOMAIN"
|
|
129
|
+
else
|
|
130
|
+
echo "⚠️ 警告: COZE_PROJECT_DOMAIN_DEFAULT 未设置,使用 .env.local 中的配置"
|
|
131
|
+
fi
|
|
132
|
+
|
|
133
|
+
# 启动 Taro H5 和 NestJS Server
|
|
134
|
+
echo "Starting Taro H5 Dev Server and NestJS Server..."
|
|
135
|
+
|
|
136
|
+
export PORT=${DEPLOY_RUN_PORT}
|
|
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
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
echo "Starting HTTP services on port ${DEPLOY_RUN_PORT} (web) and ${SERVER_PORT} (server)..."
|
|
151
|
+
start_service
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# build_weapp.sh - 通过 PID 文件精确杀掉自己上次的构建进程
|
|
2
|
+
export OUTPUT_ROOT=dist
|
|
3
|
+
PID_FILE="/tmp/coze-build_weapp.pid"
|
|
4
|
+
|
|
5
|
+
# 杀掉上次的构建进程组
|
|
6
|
+
if [ -f "$PID_FILE" ]; then
|
|
7
|
+
OLD_PID=$(cat "$PID_FILE")
|
|
8
|
+
if kill -0 "$OLD_PID" 2>/dev/null; then
|
|
9
|
+
echo "正在终止上次的构建进程组 (PID: $OLD_PID)..."
|
|
10
|
+
# 关键:kill 负数 PID = 杀掉整个进程组
|
|
11
|
+
kill -9 -"$OLD_PID" 2>/dev/null
|
|
12
|
+
sleep 1
|
|
13
|
+
fi
|
|
14
|
+
rm -f "$PID_FILE"
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
# 用 setsid 创建新的进程组,方便下次整组杀掉
|
|
18
|
+
setsid pnpm build:weapp &
|
|
19
|
+
echo $! > "$PID_FILE"
|
|
20
|
+
|
|
21
|
+
echo "构建已启动 (PID: $(cat $PID_FILE))"
|
|
22
|
+
|
|
23
|
+
wait $!
|
|
24
|
+
rm -f "$PID_FILE"
|