build.sh 1.0 KB
Newer Older
1 2 3 4
#!/bin/bash

set -e

P
Peter Pan 已提交
5
WORKING_PATH=$(pwd)
6
SERVER_DIR="packages/server/dist"
7
SERVER_DIR_PATH="$WORKING_PATH/$SERVER_DIR"
8
SERVERLESS_DIR="packages/serverless/dist"
9
SERVERLESS_DIR_PATH="$WORKING_PATH/$SERVERLESS_DIR"
10 11
OUTPUT="output"
OUTPUT_PATH="$WORKING_PATH/$OUTPUT"
12

P
Peter Pan 已提交
13 14 15 16
# clean
rm -rf "$SERVER_DIR_PATH"
rm -rf "$SERVERLESS_DIR_PATH"

17
# build
P
Peter Pan 已提交
18 19 20 21 22 23 24 25 26
if [ "$SCOPE" = "serverless" ]; then
    npx lerna run --scope "@visualdl/serverless" --include-dependencies build
elif [ "$SCOPE" = "server" ]; then
    npx lerna run --scope "@visualdl/server" --include-dependencies build
elif [ "$SCOPE" = "cli" ]; then
    npx lerna run --scope "@visualdl/cli" --include-dependencies build
else
    npx lerna run build
fi
27

28
# generate output
P
Peter Pan 已提交
29 30
rm -rf "$OUTPUT_PATH"
mkdir -p "$OUTPUT_PATH"
31 32

# package server files
P
Peter Pan 已提交
33 34 35
if [ -d "$SERVER_DIR_PATH" ]; then
    (cd "$SERVER_DIR_PATH" && tar zcf "${OUTPUT_PATH}/server.tar.gz" .)
fi
36 37

# package serverless files
P
Peter Pan 已提交
38 39 40
if [ -d "$SERVERLESS_DIR_PATH" ]; then
    (cd "$SERVERLESS_DIR_PATH" && tar zcf "${OUTPUT_PATH}/serverless.tar.gz" .)
fi