@coze-arch/cli 0.0.1-alpha.77c1b0 → 0.0.1-alpha.77c276
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/.coze +7 -2
- package/lib/__templates__/expo/.cozeproj/scripts/{deploy_build.sh → dev_build.sh} +25 -25
- package/lib/__templates__/expo/.cozeproj/scripts/{deploy_run.sh → dev_run.sh} +45 -63
- package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +47 -0
- package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +34 -0
- package/lib/__templates__/expo/_gitignore +1 -1
- package/lib/__templates__/expo/_npmrc +3 -5
- package/lib/__templates__/expo/client/app.config.ts +71 -0
- package/lib/__templates__/expo/client/metro.config.js +51 -0
- package/lib/__templates__/expo/client/package.json +92 -0
- package/lib/__templates__/expo/client/scripts/install-missing-deps.js +36 -12
- package/lib/__templates__/expo/client/src/app/index.ts +1 -0
- package/lib/__templates__/expo/client/{constants → src/constants}/theme.ts +10 -0
- package/lib/__templates__/expo/client/src/contexts/AuthContext.tsx +49 -0
- package/lib/__templates__/expo/client/{hooks → src/hooks}/useTheme.ts +1 -1
- package/lib/__templates__/expo/client/{screens → src/screens}/home/index.tsx +1 -5
- package/lib/__templates__/expo/client/src/screens/home/styles.ts +60 -0
- package/lib/__templates__/expo/client/{utils → src/utils}/index.ts +1 -2
- package/lib/__templates__/expo/client/tsconfig.json +24 -0
- package/lib/__templates__/expo/package.json +27 -13
- package/lib/__templates__/expo/pnpm-lock.yaml +426 -514
- package/lib/__templates__/expo/pnpm-workspace.yaml +3 -0
- package/lib/__templates__/expo/server/package.json +17 -0
- package/lib/__templates__/expo/{src → server/src}/index.ts +2 -2
- package/lib/__templates__/expo/template.config.js +1 -1
- package/lib/__templates__/expo/tsconfig.json +1 -24
- package/lib/__templates__/nextjs/.coze +3 -3
- package/lib/__templates__/nextjs/README.md +341 -19
- package/lib/__templates__/nextjs/_npmrc +1 -1
- package/lib/__templates__/nextjs/components.json +21 -0
- package/lib/__templates__/nextjs/package.json +54 -1
- package/lib/__templates__/nextjs/pnpm-lock.yaml +7947 -1523
- package/lib/__templates__/nextjs/scripts/dev.sh +9 -27
- package/lib/__templates__/nextjs/src/app/globals.css +114 -11
- package/lib/__templates__/nextjs/src/app/layout.tsx +18 -18
- package/lib/__templates__/nextjs/src/components/ui/accordion.tsx +66 -0
- package/lib/__templates__/nextjs/src/components/ui/alert-dialog.tsx +157 -0
- package/lib/__templates__/nextjs/src/components/ui/alert.tsx +66 -0
- package/lib/__templates__/nextjs/src/components/ui/aspect-ratio.tsx +11 -0
- package/lib/__templates__/nextjs/src/components/ui/avatar.tsx +53 -0
- package/lib/__templates__/nextjs/src/components/ui/badge.tsx +46 -0
- package/lib/__templates__/nextjs/src/components/ui/breadcrumb.tsx +109 -0
- package/lib/__templates__/nextjs/src/components/ui/button-group.tsx +83 -0
- package/lib/__templates__/nextjs/src/components/ui/button.tsx +62 -0
- package/lib/__templates__/nextjs/src/components/ui/calendar.tsx +220 -0
- package/lib/__templates__/nextjs/src/components/ui/card.tsx +92 -0
- package/lib/__templates__/nextjs/src/components/ui/carousel.tsx +241 -0
- package/lib/__templates__/nextjs/src/components/ui/chart.tsx +357 -0
- package/lib/__templates__/nextjs/src/components/ui/checkbox.tsx +32 -0
- package/lib/__templates__/nextjs/src/components/ui/collapsible.tsx +33 -0
- package/lib/__templates__/nextjs/src/components/ui/command.tsx +184 -0
- package/lib/__templates__/nextjs/src/components/ui/context-menu.tsx +252 -0
- package/lib/__templates__/nextjs/src/components/ui/dialog.tsx +143 -0
- package/lib/__templates__/nextjs/src/components/ui/drawer.tsx +135 -0
- package/lib/__templates__/nextjs/src/components/ui/dropdown-menu.tsx +257 -0
- package/lib/__templates__/nextjs/src/components/ui/empty.tsx +104 -0
- package/lib/__templates__/nextjs/src/components/ui/field.tsx +248 -0
- package/lib/__templates__/nextjs/src/components/ui/form.tsx +167 -0
- package/lib/__templates__/nextjs/src/components/ui/hover-card.tsx +44 -0
- package/lib/__templates__/nextjs/src/components/ui/input-group.tsx +170 -0
- package/lib/__templates__/nextjs/src/components/ui/input-otp.tsx +77 -0
- package/lib/__templates__/nextjs/src/components/ui/input.tsx +21 -0
- package/lib/__templates__/nextjs/src/components/ui/item.tsx +193 -0
- package/lib/__templates__/nextjs/src/components/ui/kbd.tsx +28 -0
- package/lib/__templates__/nextjs/src/components/ui/label.tsx +24 -0
- package/lib/__templates__/nextjs/src/components/ui/menubar.tsx +276 -0
- package/lib/__templates__/nextjs/src/components/ui/navigation-menu.tsx +168 -0
- package/lib/__templates__/nextjs/src/components/ui/pagination.tsx +127 -0
- package/lib/__templates__/nextjs/src/components/ui/popover.tsx +48 -0
- package/lib/__templates__/nextjs/src/components/ui/progress.tsx +31 -0
- package/lib/__templates__/nextjs/src/components/ui/radio-group.tsx +45 -0
- package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +56 -0
- package/lib/__templates__/nextjs/src/components/ui/scroll-area.tsx +58 -0
- package/lib/__templates__/nextjs/src/components/ui/select.tsx +190 -0
- package/lib/__templates__/nextjs/src/components/ui/separator.tsx +28 -0
- package/lib/__templates__/nextjs/src/components/ui/sheet.tsx +139 -0
- package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +726 -0
- package/lib/__templates__/nextjs/src/components/ui/skeleton.tsx +13 -0
- package/lib/__templates__/nextjs/src/components/ui/slider.tsx +63 -0
- package/lib/__templates__/nextjs/src/components/ui/sonner.tsx +40 -0
- package/lib/__templates__/nextjs/src/components/ui/spinner.tsx +16 -0
- package/lib/__templates__/nextjs/src/components/ui/switch.tsx +31 -0
- package/lib/__templates__/nextjs/src/components/ui/table.tsx +116 -0
- package/lib/__templates__/nextjs/src/components/ui/tabs.tsx +66 -0
- package/lib/__templates__/nextjs/src/components/ui/textarea.tsx +18 -0
- package/lib/__templates__/nextjs/src/components/ui/toggle-group.tsx +83 -0
- package/lib/__templates__/nextjs/src/components/ui/toggle.tsx +47 -0
- package/lib/__templates__/nextjs/src/components/ui/tooltip.tsx +61 -0
- package/lib/__templates__/nextjs/src/hooks/use-mobile.ts +19 -0
- package/lib/__templates__/nextjs/src/lib/utils.ts +6 -0
- package/lib/__templates__/nextjs/template.config.js +2 -2
- package/lib/__templates__/templates.json +6 -37
- package/lib/__templates__/vite/.coze +3 -3
- package/lib/__templates__/vite/README.md +204 -26
- package/lib/__templates__/vite/_npmrc +1 -1
- package/lib/__templates__/vite/package.json +1 -1
- package/lib/__templates__/vite/pnpm-lock.yaml +120 -120
- package/lib/__templates__/vite/scripts/dev.sh +7 -26
- package/lib/__templates__/vite/template.config.js +11 -2
- package/lib/__templates__/vite/vite.config.ts +3 -3
- package/lib/cli.js +426 -249
- package/package.json +7 -4
- package/lib/__templates__/expo/app.json +0 -63
- package/lib/__templates__/expo/babel.config.js +0 -9
- package/lib/__templates__/expo/client/app/(tabs)/_layout.tsx +0 -43
- package/lib/__templates__/expo/client/app/(tabs)/home.tsx +0 -1
- package/lib/__templates__/expo/client/app/(tabs)/index.tsx +0 -7
- package/lib/__templates__/expo/client/app/+not-found.tsx +0 -79
- package/lib/__templates__/expo/client/contexts/AuthContext.tsx +0 -142
- package/lib/__templates__/expo/client/index.js +0 -12
- package/lib/__templates__/expo/client/screens/home/styles.ts +0 -332
- package/lib/__templates__/expo/metro.config.js +0 -53
- package/lib/__templates__/react-rsbuild/.coze +0 -11
- package/lib/__templates__/react-rsbuild/.vscode/settings.json +0 -121
- package/lib/__templates__/react-rsbuild/README.md +0 -61
- package/lib/__templates__/react-rsbuild/_gitignore +0 -97
- package/lib/__templates__/react-rsbuild/_npmrc +0 -22
- package/lib/__templates__/react-rsbuild/package.json +0 -31
- package/lib/__templates__/react-rsbuild/pnpm-lock.yaml +0 -997
- package/lib/__templates__/react-rsbuild/rsbuild.config.ts +0 -13
- package/lib/__templates__/react-rsbuild/scripts/build.sh +0 -14
- package/lib/__templates__/react-rsbuild/scripts/dev.sh +0 -51
- package/lib/__templates__/react-rsbuild/scripts/start.sh +0 -15
- package/lib/__templates__/react-rsbuild/src/App.tsx +0 -60
- package/lib/__templates__/react-rsbuild/src/index.css +0 -21
- package/lib/__templates__/react-rsbuild/src/index.html +0 -12
- package/lib/__templates__/react-rsbuild/src/index.tsx +0 -16
- package/lib/__templates__/react-rsbuild/tailwind.config.js +0 -9
- package/lib/__templates__/react-rsbuild/template.config.js +0 -54
- package/lib/__templates__/react-rsbuild/tsconfig.json +0 -17
- package/lib/__templates__/rsbuild/.coze +0 -11
- package/lib/__templates__/rsbuild/.vscode/settings.json +0 -7
- package/lib/__templates__/rsbuild/README.md +0 -61
- package/lib/__templates__/rsbuild/_gitignore +0 -97
- package/lib/__templates__/rsbuild/_npmrc +0 -22
- package/lib/__templates__/rsbuild/package.json +0 -24
- package/lib/__templates__/rsbuild/pnpm-lock.yaml +0 -888
- package/lib/__templates__/rsbuild/rsbuild.config.ts +0 -12
- package/lib/__templates__/rsbuild/scripts/build.sh +0 -14
- package/lib/__templates__/rsbuild/scripts/dev.sh +0 -51
- package/lib/__templates__/rsbuild/scripts/start.sh +0 -15
- package/lib/__templates__/rsbuild/src/index.css +0 -21
- package/lib/__templates__/rsbuild/src/index.html +0 -12
- package/lib/__templates__/rsbuild/src/index.ts +0 -5
- package/lib/__templates__/rsbuild/src/main.ts +0 -65
- package/lib/__templates__/rsbuild/tailwind.config.js +0 -9
- package/lib/__templates__/rsbuild/template.config.js +0 -56
- package/lib/__templates__/rsbuild/tsconfig.json +0 -16
- /package/lib/__templates__/expo/{eslint-formatter-simple.mjs → client/eslint-formatter-simple.mjs} +0 -0
- /package/lib/__templates__/expo/{eslint.config.mjs → client/eslint.config.mjs} +0 -0
- /package/lib/__templates__/expo/client/{app → src/app}/_layout.tsx +0 -0
- /package/lib/__templates__/expo/client/{assets → src/assets}/fonts/SpaceMono-Regular.ttf +0 -0
- /package/lib/__templates__/expo/client/{assets → src/assets}/images/adaptive-icon.png +0 -0
- /package/lib/__templates__/expo/client/{assets → src/assets}/images/default-avatar.png +0 -0
- /package/lib/__templates__/expo/client/{assets → src/assets}/images/favicon.png +0 -0
- /package/lib/__templates__/expo/client/{assets → src/assets}/images/icon.png +0 -0
- /package/lib/__templates__/expo/client/{assets → src/assets}/images/partial-react-logo.png +0 -0
- /package/lib/__templates__/expo/client/{assets → src/assets}/images/react-logo.png +0 -0
- /package/lib/__templates__/expo/client/{assets → src/assets}/images/react-logo@2x.png +0 -0
- /package/lib/__templates__/expo/client/{assets → src/assets}/images/react-logo@3x.png +0 -0
- /package/lib/__templates__/expo/client/{assets → src/assets}/images/splash-icon.png +0 -0
- /package/lib/__templates__/expo/client/{components → src/components}/Screen.tsx +0 -0
- /package/lib/__templates__/expo/client/{components → src/components}/SmartDateInput.tsx +0 -0
- /package/lib/__templates__/expo/client/{hooks → src/hooks}/useColorScheme.ts +0 -0
|
@@ -3,5 +3,10 @@ entrypoint = "server.js"
|
|
|
3
3
|
requires = ["nodejs-24"]
|
|
4
4
|
|
|
5
5
|
[dev]
|
|
6
|
-
build = ["bash", ".cozeproj/scripts/
|
|
7
|
-
run = ["bash", ".cozeproj/scripts/
|
|
6
|
+
build = ["bash", ".cozeproj/scripts/dev_build.sh"]
|
|
7
|
+
run = ["bash", ".cozeproj/scripts/dev_run.sh"]
|
|
8
|
+
|
|
9
|
+
[deploy]
|
|
10
|
+
build = ["bash", ".cozeproj/scripts/prod_build.sh"]
|
|
11
|
+
run = ["bash", ".cozeproj/scripts/prod_run.sh"]
|
|
12
|
+
build_app_dir = "."
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
if [ -z "${BASH_VERSION:-}" ]; then exec /usr/bin/env bash "$0" "$@"; fi
|
|
3
3
|
set -euo pipefail
|
|
4
4
|
ROOT_DIR="$(pwd)"
|
|
5
|
+
PREVIEW_DIR="${COZE_PREVIEW_DIR:-$ROOT_DIR}"
|
|
5
6
|
LOG_DIR="${COZE_LOG_DIR:-$ROOT_DIR/logs}"
|
|
6
7
|
LOG_FILE="$LOG_DIR/app.log"
|
|
7
8
|
mkdir -p "$LOG_DIR"
|
|
@@ -29,42 +30,41 @@ check_command() {
|
|
|
29
30
|
write_log() {
|
|
30
31
|
local level="${1:-INFO}"
|
|
31
32
|
local msg="${2:-}"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
esac
|
|
33
|
+
node -e '
|
|
34
|
+
const fs=require("fs");
|
|
35
|
+
const path=process.argv[1];
|
|
36
|
+
const level=(process.argv[2]||"").toUpperCase();
|
|
37
|
+
let msg=String(process.argv[3]||"");
|
|
38
|
+
const ts=Date.now();
|
|
39
|
+
const dt=new Date();
|
|
40
|
+
const parts=new Intl.DateTimeFormat("en-GB",{timeZone:"Asia/Shanghai",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:false}).formatToParts(dt);
|
|
41
|
+
const o={};
|
|
42
|
+
for(const p of parts){o[p.type]=p.value}
|
|
43
|
+
const dt_str=`${o.year}-${o.month}-${o.day} ${o.hour}:${o.minute}:${o.second}`;
|
|
44
|
+
msg=msg.replace(/\\n/g,"\n");
|
|
45
|
+
msg=`${dt_str} [${level}] ${msg}`;
|
|
46
|
+
const record=JSON.stringify({level, message: msg, timestamp: ts},null,0);
|
|
47
|
+
const fd=fs.openSync(path,"a");
|
|
48
|
+
fs.writeSync(fd, record+"\n", null, "utf8");
|
|
49
|
+
fs.fsyncSync(fd);
|
|
50
|
+
fs.closeSync(fd);
|
|
51
|
+
' "$LOG_FILE" "$level" "$msg"
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
# ==================== 前置检查 ====================
|
|
55
55
|
write_log "INFO" "==================== 开始构建 ===================="
|
|
56
56
|
|
|
57
57
|
write_log "INFO" "检查根目录 pre_install.py"
|
|
58
|
-
if [ -f "$
|
|
59
|
-
write_log "INFO" "执行:python $
|
|
60
|
-
python "$
|
|
58
|
+
if [ -f "$PREVIEW_DIR/pre_install.py" ]; then
|
|
59
|
+
write_log "INFO" "执行:python $PREVIEW_DIR/pre_install.py"
|
|
60
|
+
python "$PREVIEW_DIR/pre_install.py" || write_log "ERROR" "pre_install.py 执行失败"
|
|
61
61
|
fi
|
|
62
62
|
|
|
63
63
|
write_log "INFO" "开始执行构建脚本(build_dev.sh)..."
|
|
64
64
|
write_log "INFO" "正在检查依赖命令是否存在..."
|
|
65
65
|
# 检查核心命令
|
|
66
|
-
check_command "pip"
|
|
67
|
-
check_command "python"
|
|
66
|
+
# check_command "pip"
|
|
67
|
+
# check_command "python"
|
|
68
68
|
check_command "pnpm"
|
|
69
69
|
check_command "npm"
|
|
70
70
|
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
2
|
+
PREVIEW_DIR="${COZE_PREVIEW_DIR:-$ROOT_DIR}"
|
|
2
3
|
LOG_DIR="${COZE_LOG_DIR:-$ROOT_DIR/logs}"
|
|
3
4
|
LOG_FILE="$LOG_DIR/app.log"
|
|
4
5
|
mkdir -p "$LOG_DIR"
|
|
5
6
|
|
|
6
7
|
# ==================== 配置项 ====================
|
|
7
|
-
#
|
|
8
|
+
# Server 服务配置
|
|
8
9
|
SERVER_HOST="0.0.0.0"
|
|
9
10
|
SERVER_PORT="9091"
|
|
10
11
|
# Expo 项目配置
|
|
11
12
|
EXPO_HOST="0.0.0.0"
|
|
12
13
|
EXPO_DIR="expo"
|
|
13
|
-
EXPO_PORT="
|
|
14
|
+
EXPO_PORT="5000"
|
|
14
15
|
WEB_URL="${COZE_PROJECT_DOMAIN_DEFAULT:-http://127.0.0.1:${SERVER_PORT}}"
|
|
15
16
|
ASSUME_YES="1"
|
|
16
17
|
EXPO_PUBLIC_BACKEND_BASE_URL="${EXPO_PUBLIC_BACKEND_BASE_URL:-$WEB_URL}"
|
|
@@ -97,31 +98,31 @@ ensure_port() {
|
|
|
97
98
|
write_log() {
|
|
98
99
|
local level="${1:-INFO}"
|
|
99
100
|
local msg="${2:-}"
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
101
|
+
node -e '
|
|
102
|
+
const fs=require("fs");
|
|
103
|
+
const path=process.argv[1];
|
|
104
|
+
const level=(process.argv[2]||"").toUpperCase();
|
|
105
|
+
let msg=String(process.argv[3]||"");
|
|
106
|
+
const ts=Date.now();
|
|
107
|
+
msg=msg.replace(/\\n/g,"\n");
|
|
108
|
+
const dt=new Date();
|
|
109
|
+
const parts=new Intl.DateTimeFormat("en-GB",{timeZone:"Asia/Shanghai",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:false}).formatToParts(dt);
|
|
110
|
+
const o={};
|
|
111
|
+
for(const p of parts){o[p.type]=p.value}
|
|
112
|
+
const dt_str=`${o.year}-${o.month}-${o.day} ${o.hour}:${o.minute}:${o.second}`;
|
|
113
|
+
msg=`${dt_str} [${level}] ${msg}`;
|
|
114
|
+
const record=JSON.stringify({level, message: msg, timestamp: ts},null,0);
|
|
115
|
+
const fd=fs.openSync(path,"a");
|
|
116
|
+
fs.writeSync(fd, record+"\n", null, "utf8");
|
|
117
|
+
fs.fsyncSync(fd);
|
|
118
|
+
fs.closeSync(fd);
|
|
119
|
+
' "$LOG_FILE" "$level" "$msg"
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
wait_port_connectable() {
|
|
122
123
|
local host=$1 port=$2 retries=${3:-10}
|
|
123
124
|
for _ in $(seq 1 "$retries"); do
|
|
124
|
-
nc -z "$host" "$port" && return 0
|
|
125
|
+
nc -z -w 1 "$host" "$port" >/dev/null 2>&1 && return 0
|
|
125
126
|
sleep 1
|
|
126
127
|
done
|
|
127
128
|
return 1
|
|
@@ -129,13 +130,18 @@ wait_port_connectable() {
|
|
|
129
130
|
|
|
130
131
|
start_expo() {
|
|
131
132
|
local offline="${1:-0}"
|
|
133
|
+
|
|
134
|
+
pushd ./client
|
|
135
|
+
|
|
132
136
|
if [ "$offline" = "1" ]; then
|
|
133
|
-
EXPO_OFFLINE=1 EXPO_NO_DOCTOR=1 EXPO_PUBLIC_BACKEND_BASE_URL="$EXPO_PUBLIC_BACKEND_BASE_URL" EXPO_PACKAGER_PROXY_URL="$EXPO_PACKAGER_PROXY_URL" nohup npx expo start --port "$EXPO_PORT" > logs/expo.log 2>&1 &
|
|
137
|
+
EXPO_OFFLINE=1 EXPO_NO_DOCTOR=1 EXPO_PUBLIC_BACKEND_BASE_URL="$EXPO_PUBLIC_BACKEND_BASE_URL" EXPO_PACKAGER_PROXY_URL="$EXPO_PACKAGER_PROXY_URL" nohup npx expo start --port "$EXPO_PORT" > ../logs/expo.log 2>&1 &
|
|
134
138
|
else
|
|
135
|
-
EXPO_NO_DOCTOR=1 EXPO_PUBLIC_BACKEND_BASE_URL="$EXPO_PUBLIC_BACKEND_BASE_URL" EXPO_PACKAGER_PROXY_URL="$EXPO_PACKAGER_PROXY_URL" nohup npx expo start --port "$EXPO_PORT" > logs/expo.log 2>&1 &
|
|
139
|
+
EXPO_NO_DOCTOR=1 EXPO_PUBLIC_BACKEND_BASE_URL="$EXPO_PUBLIC_BACKEND_BASE_URL" EXPO_PACKAGER_PROXY_URL="$EXPO_PACKAGER_PROXY_URL" nohup npx expo start --port "$EXPO_PORT" > ../logs/expo.log 2>&1 &
|
|
136
140
|
fi
|
|
137
141
|
EXPO_PID=$!
|
|
138
142
|
echo "$EXPO_PID"
|
|
143
|
+
|
|
144
|
+
popd
|
|
139
145
|
}
|
|
140
146
|
|
|
141
147
|
detect_expo_fetch_failed() {
|
|
@@ -153,11 +159,20 @@ detect_expo_fetch_failed() {
|
|
|
153
159
|
}
|
|
154
160
|
|
|
155
161
|
# ==================== 前置检查 ====================
|
|
162
|
+
# 关掉nginx进程
|
|
163
|
+
ps -ef | grep nginx | grep -v grep | awk '{print $2}' | xargs -r kill -9
|
|
164
|
+
|
|
165
|
+
write_log "INFO" "检查根目录 pre_install.py"
|
|
166
|
+
if [ -f "$PREVIEW_DIR/pre_install.py" ]; then
|
|
167
|
+
write_log "INFO" "执行:python $PREVIEW_DIR/pre_install.py"
|
|
168
|
+
python "$PREVIEW_DIR/pre_install.py" || write_log "ERROR" "pre_install.py 执行失败"
|
|
169
|
+
fi
|
|
170
|
+
|
|
156
171
|
write_log "INFO" "==================== 开始启动 ===================="
|
|
157
172
|
write_log "INFO" "开始执行服务启动脚本(start_dev.sh)..."
|
|
158
173
|
write_log "INFO" "正在检查依赖命令和目录是否存在..."
|
|
159
174
|
# 检查核心命令
|
|
160
|
-
check_command "python"
|
|
175
|
+
# check_command "python"
|
|
161
176
|
check_command "npm"
|
|
162
177
|
check_command "pnpm"
|
|
163
178
|
check_command "lsof"
|
|
@@ -169,42 +184,10 @@ mkdir -p logs
|
|
|
169
184
|
ensure_port SERVER_PORT "$SERVER_PORT"
|
|
170
185
|
ensure_port EXPO_PORT "$EXPO_PORT"
|
|
171
186
|
|
|
172
|
-
# ====================
|
|
173
|
-
|
|
174
|
-
# ------------环境变量----------------------
|
|
175
|
-
export storage_type="s3"
|
|
176
|
-
export project_platform="app"
|
|
177
|
-
|
|
178
|
-
if [ -n "${COZE_WORKLOAD_IDENTITY_API_KEY:-}" ]; then
|
|
179
|
-
export OPENAI_API_KEY="$COZE_WORKLOAD_IDENTITY_API_KEY"
|
|
180
|
-
fi
|
|
181
|
-
if [ -n "${OPENAI_API_KEY:-}" ]; then
|
|
182
|
-
export ARK_API_KEY="$OPENAI_API_KEY"
|
|
183
|
-
fi
|
|
184
|
-
|
|
185
|
-
if [ -n "${COZE_INTEGRATION_BASE_URL:-}" ]; then
|
|
186
|
-
_base="${COZE_INTEGRATION_BASE_URL%/}"
|
|
187
|
-
export default_llm_base_url="${_base}/api/v3"
|
|
188
|
-
else
|
|
189
|
-
export default_llm_base_url="https://ark.cn-beijing.volces.com/api/v3"
|
|
190
|
-
fi
|
|
191
|
-
|
|
192
|
-
if [ -n "${PGDATABASE_URL:-}" ]; then
|
|
193
|
-
_pg="${PGDATABASE_URL}"
|
|
194
|
-
case "${_pg}" in
|
|
195
|
-
postgresql://*)
|
|
196
|
-
_pg="postgresql+asyncpg://${_pg#postgresql://}"
|
|
197
|
-
;;
|
|
198
|
-
esac
|
|
199
|
-
_pg="${_pg%%\?*}"
|
|
200
|
-
export DATABASE_URL="${_pg}"
|
|
201
|
-
fi
|
|
202
|
-
|
|
203
|
-
# ------------环境变量----------------------
|
|
204
|
-
|
|
187
|
+
# ==================== 启动 Server 服务 ====================
|
|
205
188
|
write_log "INFO" "==================== 启动 server 服务 ===================="
|
|
206
|
-
write_log "INFO" "正在执行:npm run
|
|
207
|
-
PORT="$SERVER_PORT" nohup npm run server > logs/app.log 2>&1 &
|
|
189
|
+
write_log "INFO" "正在执行:npm run dev"
|
|
190
|
+
PORT="$SERVER_PORT" nohup npm run dev --prefix ./server > logs/app.log 2>&1 &
|
|
208
191
|
SERVER_PID=$!
|
|
209
192
|
if [ -z "${SERVER_PID}" ]; then
|
|
210
193
|
write_log "ERROR" "无法获取 server 后台进程 PID"
|
|
@@ -212,8 +195,7 @@ fi
|
|
|
212
195
|
write_log "INFO" "server 服务已启动,进程 ID:${SERVER_PID:-unknown}"
|
|
213
196
|
|
|
214
197
|
write_log "INFO" "==================== 启动 Expo 项目 ===================="
|
|
215
|
-
write_log "INFO" "
|
|
216
|
-
write_log "INFO" "开始启动 Expo 服务"
|
|
198
|
+
write_log "INFO" "开始启动 Expo 服务,端口 ${EXPO_PORT}"
|
|
217
199
|
EXPO_PID=$(start_expo 0)
|
|
218
200
|
if detect_expo_fetch_failed 8; then
|
|
219
201
|
write_log "WARN" "Expo 启动检测到网络错误:TypeError: fetch failed,启用离线模式重试"
|
|
@@ -221,7 +203,7 @@ if detect_expo_fetch_failed 8; then
|
|
|
221
203
|
: > logs/expo.log
|
|
222
204
|
EXPO_PID=$(start_expo 1)
|
|
223
205
|
fi
|
|
224
|
-
# 输出以下环境变量,确保 Expo 项目能正确连接到
|
|
206
|
+
# 输出以下环境变量,确保 Expo 项目能正确连接到 Server 服务
|
|
225
207
|
write_log "INFO" "Expo 环境变量配置:"
|
|
226
208
|
write_log "INFO" "EXPO_PUBLIC_BACKEND_BASE_URL=${EXPO_PUBLIC_BACKEND_BASE_URL}"
|
|
227
209
|
write_log "INFO" "EXPO_PACKAGER_PROXY_URL=${EXPO_PACKAGER_PROXY_URL}"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
if [ -z "${BASH_VERSION:-}" ]; then exec /usr/bin/env bash "$0" "$@"; fi
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
ROOT_DIR="$(pwd)"
|
|
5
|
+
|
|
6
|
+
# ==================== 工具函数 ====================
|
|
7
|
+
info() {
|
|
8
|
+
echo "[INFO] $1"
|
|
9
|
+
}
|
|
10
|
+
warn() {
|
|
11
|
+
echo "[WARN] $1"
|
|
12
|
+
}
|
|
13
|
+
error() {
|
|
14
|
+
echo "[ERROR] $1"
|
|
15
|
+
exit 1
|
|
16
|
+
}
|
|
17
|
+
check_command() {
|
|
18
|
+
if ! command -v "$1" &> /dev/null; then
|
|
19
|
+
error "命令 $1 未找到,请先安装"
|
|
20
|
+
fi
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
info "==================== 开始构建 ===================="
|
|
24
|
+
info "开始执行构建脚本(build_prod.sh)..."
|
|
25
|
+
info "正在检查依赖命令是否存在..."
|
|
26
|
+
# 检查核心命令
|
|
27
|
+
check_command "pnpm"
|
|
28
|
+
check_command "npm"
|
|
29
|
+
|
|
30
|
+
# ==================== 安装 Node 依赖 ====================
|
|
31
|
+
info "==================== 安装 Node 依赖 ===================="
|
|
32
|
+
info "开始安装 Node 依赖"
|
|
33
|
+
if [ -f "$ROOT_DIR/package.json" ]; then
|
|
34
|
+
info "进入目录:$ROOT_DIR"
|
|
35
|
+
info "正在执行:pnpm install"
|
|
36
|
+
(cd "$ROOT_DIR" && pnpm install --registry=https://registry.npmmirror.com) || error "Node 依赖安装失败"
|
|
37
|
+
else
|
|
38
|
+
warn "未找到 $ROOT_DIR/package.json 文件,请检查路径是否正确"
|
|
39
|
+
fi
|
|
40
|
+
info "==================== 依赖安装完成!====================\n"
|
|
41
|
+
|
|
42
|
+
info "==================== dist打包 ===================="
|
|
43
|
+
info "开始执行:npm run build --prefix server"
|
|
44
|
+
(cd "$ROOT_DIR" && npm run build --prefix ./server) || error "dist打包失败"
|
|
45
|
+
info "==================== dist打包完成!====================\n"
|
|
46
|
+
|
|
47
|
+
info "下一步:执行 ./prod_run.sh 启动服务"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# 产物部署使用
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
ROOT_DIR="$(pwd)"
|
|
6
|
+
|
|
7
|
+
HOST="${HOST:-0.0.0.0}"
|
|
8
|
+
PORT="${PORT:-5000}"
|
|
9
|
+
|
|
10
|
+
# ==================== 工具函数 ====================
|
|
11
|
+
info() {
|
|
12
|
+
echo "[INFO] $1"
|
|
13
|
+
}
|
|
14
|
+
warn() {
|
|
15
|
+
echo "[WARN] $1"
|
|
16
|
+
}
|
|
17
|
+
error() {
|
|
18
|
+
echo "[ERROR] $1"
|
|
19
|
+
exit 1
|
|
20
|
+
}
|
|
21
|
+
check_command() {
|
|
22
|
+
if ! command -v "$1" &> /dev/null; then
|
|
23
|
+
error "命令 $1 未找到,请先安装"
|
|
24
|
+
fi
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# ============== 启动服务 ======================
|
|
28
|
+
# 检查核心命令
|
|
29
|
+
check_command "pnpm"
|
|
30
|
+
check_command "npm"
|
|
31
|
+
|
|
32
|
+
info "开始执行:npm run start"
|
|
33
|
+
(cd "$ROOT_DIR" && PORT="$PORT" npm run start --prefix ./server) || error "服务启动失败"
|
|
34
|
+
info "服务启动完成!\n"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
registry=https://registry.
|
|
1
|
+
registry=https://registry.npmmirror.com
|
|
2
2
|
|
|
3
3
|
strictStorePkgContentCheck=false
|
|
4
4
|
verifyStoreIntegrity=false
|
|
@@ -8,15 +8,13 @@ network-concurrency=16
|
|
|
8
8
|
fetch-retries=3
|
|
9
9
|
fetch-timeout=60000
|
|
10
10
|
|
|
11
|
-
#
|
|
11
|
+
# peerDependencies
|
|
12
12
|
strict-peer-dependencies=false
|
|
13
|
-
|
|
14
|
-
# 自动生成 lockfile
|
|
15
13
|
auto-install-peers=true
|
|
16
14
|
|
|
17
15
|
# lockfile 配置
|
|
18
16
|
lockfile=true
|
|
19
17
|
prefer-frozen-lockfile=true
|
|
20
18
|
|
|
21
|
-
#
|
|
19
|
+
# semver 选择最高版本
|
|
22
20
|
resolution-mode=highest
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ExpoConfig, ConfigContext } from 'expo/config';
|
|
2
|
+
|
|
3
|
+
export default ({ config }: ConfigContext): ExpoConfig => {
|
|
4
|
+
return {
|
|
5
|
+
...config,
|
|
6
|
+
"name": "${app_name}",
|
|
7
|
+
"slug": "${slug}",
|
|
8
|
+
"version": "1.0.0",
|
|
9
|
+
"orientation": "portrait",
|
|
10
|
+
"icon": "./assets/images/icon.png",
|
|
11
|
+
"scheme": "myapp",
|
|
12
|
+
"userInterfaceStyle": "automatic",
|
|
13
|
+
"newArchEnabled": true,
|
|
14
|
+
"ios": {
|
|
15
|
+
"supportsTablet": true
|
|
16
|
+
},
|
|
17
|
+
"android": {
|
|
18
|
+
"adaptiveIcon": {
|
|
19
|
+
"foregroundImage": "./assets/images/adaptive-icon.png",
|
|
20
|
+
"backgroundColor": "#ffffff"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"web": {
|
|
24
|
+
"bundler": "metro",
|
|
25
|
+
"output": "single",
|
|
26
|
+
"favicon": "./assets/images/favicon.png"
|
|
27
|
+
},
|
|
28
|
+
"plugins": [
|
|
29
|
+
process.env.EXPO_PUBLIC_BACKEND_BASE_URL ? [
|
|
30
|
+
"expo-router",
|
|
31
|
+
{
|
|
32
|
+
"origin": process.env.EXPO_PUBLIC_BACKEND_BASE_URL
|
|
33
|
+
}
|
|
34
|
+
] : 'expo-router',
|
|
35
|
+
[
|
|
36
|
+
"expo-splash-screen",
|
|
37
|
+
{
|
|
38
|
+
"image": "./assets/images/splash-icon.png",
|
|
39
|
+
"imageWidth": 200,
|
|
40
|
+
"resizeMode": "contain",
|
|
41
|
+
"backgroundColor": "#ffffff"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
"expo-image-picker",
|
|
46
|
+
{
|
|
47
|
+
"photosPermission": "允许${app_name}访问您的相册,以便您上传或保存图片。",
|
|
48
|
+
"cameraPermission": "允许${app_name}使用您的相机,以便您直接拍摄照片上传。",
|
|
49
|
+
"microphonePermission": "允许${app_name}访问您的麦克风,以便您拍摄带有声音的视频。"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
"expo-location",
|
|
54
|
+
{
|
|
55
|
+
"locationWhenInUsePermission": "${app_name}需要访问您的位置以提供周边服务及导航功能。"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
"expo-camera",
|
|
60
|
+
{
|
|
61
|
+
"cameraPermission": "${app_name}需要访问相机以拍摄照片和视频。",
|
|
62
|
+
"microphonePermission": "${app_name}需要访问麦克风以录制视频声音。",
|
|
63
|
+
"recordAudioAndroid": true
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
],
|
|
67
|
+
"experiments": {
|
|
68
|
+
"typedRoutes": true
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const { getDefaultConfig } = require('expo/metro-config');
|
|
2
|
+
const { createProxyMiddleware } = require('http-proxy-middleware');
|
|
3
|
+
const connect = require('connect');
|
|
4
|
+
|
|
5
|
+
const config = getDefaultConfig(__dirname);
|
|
6
|
+
|
|
7
|
+
// 安全地获取 Expo 的默认排除列表
|
|
8
|
+
const existingBlockList = [].concat(config.resolver.blockList || []);
|
|
9
|
+
|
|
10
|
+
config.resolver.blockList = [
|
|
11
|
+
...existingBlockList,
|
|
12
|
+
/.*\/\.expo\/.*/, // Expo 的缓存和构建产物目录
|
|
13
|
+
|
|
14
|
+
// 1. 原生代码 (Java/C++/Objective-C)
|
|
15
|
+
/.*\/react-native\/ReactAndroid\/.*/,
|
|
16
|
+
/.*\/react-native\/ReactCommon\/.*/,
|
|
17
|
+
|
|
18
|
+
// 2. 纯开发和调试工具
|
|
19
|
+
// 这些工具只在开发电脑上运行,不会被打包到应用中
|
|
20
|
+
/.*\/@typescript-eslint\/eslint-plugin\/.*/,
|
|
21
|
+
|
|
22
|
+
// 3. 构建时数据
|
|
23
|
+
// 这个数据库只在打包过程中使用,应用运行时不需要
|
|
24
|
+
/.*\/caniuse-lite\/data\/.*/,
|
|
25
|
+
|
|
26
|
+
// 4. 通用规则
|
|
27
|
+
/.*\/__tests__\/.*/, // 排除所有测试目录
|
|
28
|
+
/.*\.git\/.*/, // 排除 Git 目录
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const apiProxy = createProxyMiddleware({
|
|
32
|
+
target: 'http://localhost:9091',
|
|
33
|
+
logLevel: 'debug',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
config.server = {
|
|
37
|
+
...config.server,
|
|
38
|
+
enhanceMiddleware: (metroMiddleware, metroServer) => {
|
|
39
|
+
return connect()
|
|
40
|
+
.use((req, res, next) => {
|
|
41
|
+
if (req.url && req.url.startsWith('/api/v')) {
|
|
42
|
+
console.log(`[Metro Proxy] Forwarding ${req.method} ${req.url}`);
|
|
43
|
+
return apiProxy(req, res, next);
|
|
44
|
+
}
|
|
45
|
+
next();
|
|
46
|
+
})
|
|
47
|
+
.use(metroMiddleware);
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = config;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "expo-app",
|
|
3
|
+
"description": "<%= appName %>",
|
|
4
|
+
"main": "expo-router/entry",
|
|
5
|
+
"private": true,
|
|
6
|
+
"scripts": {
|
|
7
|
+
"check-deps": "npx depcheck",
|
|
8
|
+
"postinstall": "npm run install-missing",
|
|
9
|
+
"install-missing": "node ./scripts/install-missing-deps.js",
|
|
10
|
+
"lint": "expo lint",
|
|
11
|
+
"start": "expo start --web --clear",
|
|
12
|
+
"test": "jest --watchAll"
|
|
13
|
+
},
|
|
14
|
+
"jest": {
|
|
15
|
+
"preset": "jest-expo"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@expo/metro-runtime": "^6.1.2",
|
|
19
|
+
"@expo/vector-icons": "^15.0.0",
|
|
20
|
+
"@react-native-async-storage/async-storage": "^2.2.0",
|
|
21
|
+
"@react-native-community/datetimepicker": "^8.5.0",
|
|
22
|
+
"@react-native-community/slider": "^5.0.1",
|
|
23
|
+
"@react-native-masked-view/masked-view": "^0.3.2",
|
|
24
|
+
"@react-native-picker/picker": "^2.11.0",
|
|
25
|
+
"@react-navigation/bottom-tabs": "^7.2.0",
|
|
26
|
+
"@react-navigation/native": "^7.0.14",
|
|
27
|
+
"babel-plugin-module-resolver": "^5.0.2",
|
|
28
|
+
"babel-preset-expo": "^54.0.9",
|
|
29
|
+
"dayjs": "^1.11.19",
|
|
30
|
+
"expo": "^54.0.7",
|
|
31
|
+
"expo-auth-session": "^7.0.9",
|
|
32
|
+
"expo-av": "~16.0.6",
|
|
33
|
+
"expo-blur": "~15.0.6",
|
|
34
|
+
"expo-camera": "~17.0.10",
|
|
35
|
+
"expo-constants": "~18.0.8",
|
|
36
|
+
"expo-crypto": "^15.0.7",
|
|
37
|
+
"expo-font": "~14.0.7",
|
|
38
|
+
"expo-haptics": "~15.0.6",
|
|
39
|
+
"expo-image-picker": "~17.0.7",
|
|
40
|
+
"expo-linear-gradient": "~15.0.6",
|
|
41
|
+
"expo-linking": "~8.0.7",
|
|
42
|
+
"expo-location": "~19.0.7",
|
|
43
|
+
"expo-router": "~6.0.0",
|
|
44
|
+
"expo-splash-screen": "~31.0.8",
|
|
45
|
+
"expo-status-bar": "~3.0.7",
|
|
46
|
+
"expo-symbols": "~1.0.6",
|
|
47
|
+
"expo-system-ui": "~6.0.9",
|
|
48
|
+
"expo-web-browser": "~15.0.10",
|
|
49
|
+
"react": "19.1.0",
|
|
50
|
+
"react-dom": "19.1.0",
|
|
51
|
+
"react-native": "0.81.5",
|
|
52
|
+
"react-native-chart-kit": "^6.12.0",
|
|
53
|
+
"react-native-gesture-handler": "~2.28.0",
|
|
54
|
+
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
55
|
+
"react-native-modal-datetime-picker": "18.0.0",
|
|
56
|
+
"react-native-reanimated": "~4.1.0",
|
|
57
|
+
"react-native-safe-area-context": "~5.6.0",
|
|
58
|
+
"react-native-screens": "~4.16.0",
|
|
59
|
+
"react-native-svg": "15.15.0",
|
|
60
|
+
"react-native-toast-message": "^2.3.3",
|
|
61
|
+
"react-native-web": "^0.21.2",
|
|
62
|
+
"react-native-webview": "~13.15.0",
|
|
63
|
+
"react-native-worklets": "0.5.1",
|
|
64
|
+
"zod": "^4.2.1"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@babel/core": "^7.25.2",
|
|
68
|
+
"@eslint/js": "^9.27.0",
|
|
69
|
+
"@types/jest": "^29.5.12",
|
|
70
|
+
"@types/react": "~19.1.0",
|
|
71
|
+
"@types/react-test-renderer": "19.1.0",
|
|
72
|
+
"chalk": "^4.1.2",
|
|
73
|
+
"depcheck": "^1.4.7",
|
|
74
|
+
"esbuild": "0.27.2",
|
|
75
|
+
"eslint": "^9.39.2",
|
|
76
|
+
"eslint-formatter-compact": "^9.0.1",
|
|
77
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
78
|
+
"eslint-plugin-import": "^2.32.0",
|
|
79
|
+
"eslint-plugin-react": "^7.37.5",
|
|
80
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
81
|
+
"eslint-plugin-regexp": "^2.10.0",
|
|
82
|
+
"globals": "^16.1.0",
|
|
83
|
+
"jest": "^29.2.1",
|
|
84
|
+
"jest-expo": "~54.0.10",
|
|
85
|
+
"react-test-renderer": "19.1.0",
|
|
86
|
+
"tsx": "^4.21.0",
|
|
87
|
+
"typescript": "^5.8.3",
|
|
88
|
+
"typescript-eslint": "^8.32.1",
|
|
89
|
+
"connect": "^3.7.0",
|
|
90
|
+
"http-proxy-middleware": "^3.0.5"
|
|
91
|
+
}
|
|
92
|
+
}
|