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

set -e

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

13 14 15 16
if [ -f "$HOME/.cargo/env" ]; then
    source "$HOME/.cargo/env"
fi

P
Peter Pan 已提交
17
# clean
P
Peter Pan 已提交
18
yarn clean
P
Peter Pan 已提交
19

20
# build
P
Peter Pan 已提交
21
if [ "$SCOPE" = "serverless" ]; then
22
    npx lerna run --scope "@visualdl/core" --include-dependencies build
P
Peter Pan 已提交
23 24 25 26 27 28 29
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
30

31
# generate output
P
Peter Pan 已提交
32 33
rm -rf "$OUTPUT_PATH"
mkdir -p "$OUTPUT_PATH"
34 35

# package server files
P
Peter Pan 已提交
36
if [ -d "$SERVER_DIR_PATH" ]; then
37
    tar zcf "${OUTPUT_PATH}/server.tar.gz" --exclude="node_modules" --exclude=".gitignore" --exclude=".DS_Store" --dereference -C "$SERVER_DIR_PATH" .
P
Peter Pan 已提交
38
fi
39 40

# package serverless files
P
Peter Pan 已提交
41
if [ -d "$SERVERLESS_DIR_PATH" ]; then
42
    tar zcf "${OUTPUT_PATH}/serverless.tar.gz" -C "$SERVERLESS_DIR_PATH" .
P
Peter Pan 已提交
43
fi