@coze-arch/cli 0.0.1-alpha.d85d9d → 0.0.1-alpha.dee5d9
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/patches/expo@54.0.32.patch +3 -2
- package/lib/__templates__/expo/pnpm-lock.yaml +165 -1734
- package/lib/__templates__/expo/server/package.json +1 -1
- package/lib/__templates__/nextjs/src/app/page.tsx +17 -61
- package/lib/__templates__/taro/.coze +1 -1
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +3 -4
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +5 -8
- package/lib/__templates__/taro/_gitignore +40 -0
- package/lib/__templates__/taro/_npmrc +18 -0
- package/lib/__templates__/taro/config/index.ts +3 -2
- package/lib/__templates__/taro/eslint.config.mjs +57 -0
- package/lib/__templates__/taro/package.json +29 -32
- package/lib/__templates__/taro/pnpm-lock.yaml +353 -564
- package/lib/__templates__/taro/server/package.json +7 -6
- package/lib/__templates__/taro/src/app.ts +11 -25
- package/lib/__templates__/taro/src/pages/index/index.tsx +14 -11
- package/lib/__templates__/taro/src/utils/wx-debug.ts +23 -0
- package/lib/__templates__/templates.json +37 -0
- package/lib/__templates__/vite/src/main.ts +17 -47
- package/lib/cli.js +1 -1
- package/package.json +1 -1
- package/lib/__templates__/taro/.eslintrc +0 -40
- package/lib/__templates__/taro/commitlint.config.mjs +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
2
2
|
PREVIEW_DIR="${COZE_PREVIEW_DIR:-/source/preview}"
|
|
3
3
|
LOG_DIR="${COZE_LOG_DIR:-$ROOT_DIR/logs}"
|
|
4
|
-
|
|
4
|
+
LOG_CLIENT_FILE="$LOG_DIR/client.log"
|
|
5
5
|
mkdir -p "$LOG_DIR"
|
|
6
6
|
|
|
7
7
|
# ==================== 配置项 ====================
|
|
@@ -89,14 +89,17 @@ ensure_port() {
|
|
|
89
89
|
pipe_to_log() {
|
|
90
90
|
local source="${1:-CLIENT}"
|
|
91
91
|
local raw_log="${2:-}"
|
|
92
|
-
local line timestamp
|
|
92
|
+
local line clean_line timestamp
|
|
93
93
|
while IFS= read -r line || [ -n "$line" ]; do
|
|
94
|
+
clean_line=$(printf '%s' "$line" | sed 's/\x1b\[[0-9;]*[mA-Za-z]//g')
|
|
95
|
+
if echo "$clean_line" | grep -qE '(^(Web|iOS|Android) node_modules/.*expo-router.*entry\.js.*%|^(Web|iOS|Android) Bundled [0-9]+ms node_modules/.*expo-router.*entry\.js|Logs will appear in the browser)'; then
|
|
96
|
+
continue
|
|
97
|
+
fi
|
|
94
98
|
if [ -n "$raw_log" ]; then
|
|
95
|
-
|
|
99
|
+
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
|
100
|
+
echo "[$timestamp] $clean_line" >> "$raw_log"
|
|
96
101
|
fi
|
|
97
|
-
|
|
98
|
-
msg="${line}"
|
|
99
|
-
echo "$msg"
|
|
102
|
+
printf '[%s] %s\n' "$source" "$clean_line"
|
|
100
103
|
done
|
|
101
104
|
}
|
|
102
105
|
|
|
@@ -116,10 +119,10 @@ start_expo() {
|
|
|
116
119
|
|
|
117
120
|
if [ "$offline" = "1" ]; then
|
|
118
121
|
( EXPO_OFFLINE=1 EXPO_NO_DEPENDENCY_VALIDATION=1 EXPO_PUBLIC_BACKEND_BASE_URL="$EXPO_PUBLIC_BACKEND_BASE_URL" EXPO_PACKAGER_PROXY_URL="$EXPO_PACKAGER_PROXY_URL" EXPO_PUBLIC_COZE_PROJECT_ID="$EXPO_PUBLIC_COZE_PROJECT_ID" \
|
|
119
|
-
nohup npx expo start --clear --port "$EXPO_PORT" 2>&1 | pipe_to_log "CLIENT" "$
|
|
122
|
+
nohup npx expo start --clear --port "$EXPO_PORT" 2>&1 | pipe_to_log "CLIENT" "$LOG_CLIENT_FILE" ) &
|
|
120
123
|
else
|
|
121
124
|
( EXPO_NO_DEPENDENCY_VALIDATION=1 EXPO_PUBLIC_BACKEND_BASE_URL="$EXPO_PUBLIC_BACKEND_BASE_URL" EXPO_PACKAGER_PROXY_URL="$EXPO_PACKAGER_PROXY_URL" EXPO_PUBLIC_COZE_PROJECT_ID="$EXPO_PUBLIC_COZE_PROJECT_ID" \
|
|
122
|
-
nohup npx expo start --clear --port "$EXPO_PORT" 2>&1 | pipe_to_log "CLIENT" "$
|
|
125
|
+
nohup npx expo start --clear --port "$EXPO_PORT" 2>&1 | pipe_to_log "CLIENT" "$LOG_CLIENT_FILE" ) &
|
|
123
126
|
fi
|
|
124
127
|
EXPO_PID=$!
|
|
125
128
|
disown $EXPO_PID 2>/dev/null || true
|
|
@@ -130,9 +133,9 @@ start_expo() {
|
|
|
130
133
|
detect_expo_fetch_failed() {
|
|
131
134
|
local timeout="${1:-8}"
|
|
132
135
|
local waited=0
|
|
133
|
-
local log_file="$
|
|
136
|
+
local log_file="$LOG_CLIENT_FILE"
|
|
134
137
|
while [ "$waited" -lt "$timeout" ]; do
|
|
135
|
-
if [ -f "$log_file" ] &&
|
|
138
|
+
if [ -f "$log_file" ] && tail -n 100 "$log_file" 2>/dev/null | grep -q "TypeError: fetch failed"; then
|
|
136
139
|
return 0
|
|
137
140
|
fi
|
|
138
141
|
sleep 1
|
|
@@ -166,8 +169,6 @@ check_command "pnpm"
|
|
|
166
169
|
check_command "lsof"
|
|
167
170
|
check_command "bash"
|
|
168
171
|
|
|
169
|
-
echo "准备日志目录:$ROOT_DIR/logs"
|
|
170
|
-
mkdir -p "$ROOT_DIR/logs"
|
|
171
172
|
# 端口占用预检查与处理
|
|
172
173
|
ensure_port SERVER_PORT "$SERVER_PORT"
|
|
173
174
|
ensure_port EXPO_PORT "$EXPO_PORT"
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
4
4
|
SERVER_DIR="$ROOT_DIR/server"
|
|
5
|
-
LOG_DIR="$ROOT_DIR/logs"
|
|
6
|
-
|
|
5
|
+
LOG_DIR="${COZE_LOG_DIR:-$ROOT_DIR/logs}"
|
|
6
|
+
LOG_SERVER_FILE="$LOG_DIR/server.log"
|
|
7
7
|
SERVER_PORT="${SERVER_PORT:-9091}"
|
|
8
8
|
|
|
9
9
|
mkdir -p "$LOG_DIR"
|
|
@@ -11,13 +11,14 @@ mkdir -p "$LOG_DIR"
|
|
|
11
11
|
pipe_to_log() {
|
|
12
12
|
local source="${1:-SERVER}"
|
|
13
13
|
local raw_log="${2:-}"
|
|
14
|
-
local line
|
|
14
|
+
local line clean_line timestamp
|
|
15
15
|
while IFS= read -r line || [ -n "$line" ]; do
|
|
16
|
+
clean_line=$(printf '%s' "$line" | sed 's/\x1b\[[0-9;]*[mA-Za-z]//g')
|
|
16
17
|
if [ -n "$raw_log" ]; then
|
|
17
|
-
|
|
18
|
+
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
|
19
|
+
echo "[$timestamp] $clean_line" >> "$raw_log"
|
|
18
20
|
fi
|
|
19
|
-
|
|
20
|
-
echo "$line"
|
|
21
|
+
printf '[%s] %s\n' "$source" "$clean_line"
|
|
21
22
|
done
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -36,10 +37,10 @@ kill_old_server() {
|
|
|
36
37
|
echo "==================== Server Dev Run ===================="
|
|
37
38
|
echo "Server 目录:$SERVER_DIR"
|
|
38
39
|
echo "Server 端口:$SERVER_PORT"
|
|
39
|
-
echo "日志文件:$
|
|
40
|
+
echo "日志文件:$LOG_SERVER_FILE"
|
|
40
41
|
|
|
41
42
|
kill_old_server
|
|
42
43
|
|
|
43
44
|
echo "启动 server 服务..."
|
|
44
45
|
cd "$SERVER_DIR"
|
|
45
|
-
NODE_ENV=development PORT="$SERVER_PORT" npx tsx ./src/index.ts 2>&1 | pipe_to_log "SERVER" "$
|
|
46
|
+
NODE_ENV=development PORT="$SERVER_PORT" npx tsx ./src/index.ts 2>&1 | pipe_to_log "SERVER" "$LOG_SERVER_FILE"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
diff --git a/src/async-require/hmr.ts b/src/async-require/hmr.ts
|
|
2
|
-
index 33ce50ee2950c40d2b0553b148710f1e24e44f3d..
|
|
2
|
+
index 33ce50ee2950c40d2b0553b148710f1e24e44f3d..3d78cb02dd7e96ac9727a2935d8178f2c7e95982 100644
|
|
3
3
|
--- a/src/async-require/hmr.ts
|
|
4
4
|
+++ b/src/async-require/hmr.ts
|
|
5
|
-
@@ -216,6 +216,
|
|
5
|
+
@@ -216,6 +216,40 @@ const HMRClient: HMRClientNativeInterface = {
|
|
6
6
|
|
|
7
7
|
client.on('update-done', () => {
|
|
8
8
|
hideLoading();
|
|
@@ -39,6 +39,7 @@ index 33ce50ee2950c40d2b0553b148710f1e24e44f3d..a13d6f2da10dea858019cc991c21753f
|
|
|
39
39
|
+ checkServerAndReload(6);
|
|
40
40
|
+ }, 35_000);
|
|
41
41
|
+ }
|
|
42
|
+
+ console.log('[HMR] Update done.');
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
client.on('error', (data: { type: string; message: string }) => {
|