ui.sh 1.1 KB
Newer Older
G
gaocongli 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/bin/bash
# Copyright 2020 Huawei Technologies Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

李鸿章 已提交
16 17 18
set -e

SCRIPT_BASEDIR=$(realpath "$(dirname "$0")")
G
gaocongli 已提交
19 20

build_ui() {
李鸿章 已提交
21
    cd "$(realpath "$SCRIPT_BASEDIR/../../mindinsight/ui")" || exit
G
gaocongli 已提交
22

李鸿章 已提交
23 24 25
    if ! command -v npm; then
        command npm
    fi
G
gaocongli 已提交
26

27
    rm -f package-lock.json
G
gaocongli 已提交
28 29
    rm -rf dist

李鸿章 已提交
30 31 32
    npm config set strict-ssl false
    npm config set unsafe-perm true
    npm config set user 0
G
gaocongli 已提交
33

李鸿章 已提交
34
    npm install --loglevel=error
李鸿章 已提交
35
    npm run build
G
gaocongli 已提交
36 37 38 39 40 41 42 43 44 45

    if [ ! -f "dist/index.html" ]; then
        echo "dist does not have file index.html, build failed"
        exit 1
    fi

    rm -rf node_modules
}

build_ui