-
-
Notifications
You must be signed in to change notification settings - Fork 395
/
build-output.sh
executable file
·82 lines (71 loc) · 1.91 KB
/
build-output.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#! /bin/bash
# 该脚本只保留生产环境运行所需文件到统一目录
if [ ! -f './config/prod.yaml' ]; then
echo "缺少 config/prod.yaml 文件,可参考 docker-prod-sample.yaml 进行配置"
exit 1
fi
# 构建
pnpm fetch --prod
pnpm install
pnpm run build
outputDir="output"
# 新建输出目录
if [ -d ${outputDir} ]; then
rm -rfv ${outputDir}
fi
mkdir -p ${outputDir}
cd ${outputDir}
mkdir -p packages
mkdir -p packages/config
mkdir -p packages/constants
mkdir -p packages/domains
mkdir -p packages/client
mkdir -p packages/server
cd ../
# 复制文件
cp -v -L -r config ${outputDir}
cd ${outputDir}/config
rm -f dev.yaml
cd ../../
cp -v -L package.json ${outputDir}
cp -v -L pnpm-lock.yaml ${outputDir}
cp -v -L pnpm-workspace.yaml ${outputDir}
# packages/config
cd packages/config
configOutput="../../${outputDir}/packages/config"
cp -v -L package.json ${configOutput}
cp -v -L -r lib ${configOutput}
cd ../../
# packages/constants
cd packages/constants
constantsOutput="../../${outputDir}/packages/constants"
cp -v -L package.json ${constantsOutput}
cp -v -L -r lib ${constantsOutput}
cd ../../
# packages/domains
cd packages/domains
domainsOutput="../../${outputDir}/packages/domains"
cp -v -L package.json ${domainsOutput}
cp -v -L -r lib ${domainsOutput}
cd ../../
# packages/client
cd packages/client
clientOutput="../../${outputDir}/packages/client"
cp -v -L package.json ${clientOutput}
cp -v -L prod-server.js ${clientOutput}
cp -v -L -r public ${clientOutput}
cp -v -L -r .next ${clientOutput}
cd ../../
# packages/server
cd packages/server
serverOutput="../../${outputDir}/packages/server"
cp -v -L package.json ${serverOutput}
cp -v -L nest-cli.json ${serverOutput}
cp -v -L -r dist ${serverOutput}
cd ../../
# @see https://github.com/typicode/husky/issues/914#issuecomment-826768549
cd ${outputDir}
npm set-script prepare ""
pnpm install -r --offline --prod
cd ../
echo "${outputDir} 打包完成"