-
Notifications
You must be signed in to change notification settings - Fork 24
/
pack-web-zip.sh
executable file
·64 lines (52 loc) · 1.34 KB
/
pack-web-zip.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# 添加参数处理
BEDROCK_ENDPOINT=""
# 解析命令行参数
while [[ $# -gt 0 ]]; do
case $1 in
--endpoint)
BEDROCK_ENDPOINT="$2"
shift 2
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
# 如果没有通过参数指定 endpoint,尝试从 .env.local 读取
if [ -z "$BEDROCK_ENDPOINT" ] && [ -f ".env.local" ]; then
# 从 .env.local 文件中读取 NEXT_PUBLIC_BEDROCK_ENDPOINT
BEDROCK_ENDPOINT=$(grep NEXT_PUBLIC_BEDROCK_ENDPOINT .env.local | cut -d '=' -f2)
fi
# 如果仍然没有 endpoint,使用默认值
if [ -z "$BEDROCK_ENDPOINT" ]; then
BEDROCK_ENDPOINT=""
fi
# 设置环境变量
export NEXT_PUBLIC_BEDROCK_ENDPOINT="$BEDROCK_ENDPOINT"
echo "Using Bedrock endpoint: $NEXT_PUBLIC_BEDROCK_ENDPOINT"
# 执行构建命令
echo "Running yarn build..."
yarn build
echo "Running yarn export..."
yarn export
# 检查 yarn export 是否成功
if [ $? -eq 0 ]; then
echo "yarn export completed successfully."
# 创建 zip 文件
echo "Creating zip file..."
cd out
zip -r ../brclient-web.zip *
cd ..
if [ $? -eq 0 ]; then
echo "Zip file created successfully: brclient-web.zip"
else
echo "Error: Failed to create zip file."
exit 1
fi
else
echo "Error: yarn export failed."
exit 1
fi
echo "Script completed."