mirror of
https://github.com/jlengrand/sample-node-api.git
synced 2026-03-10 08:41:23 +00:00
81 lines
2.8 KiB
Bash
Executable File
81 lines
2.8 KiB
Bash
Executable File
#!/bin/bash -e
|
|
|
|
################################################################################
|
|
# This program and the accompanying materials are made available under the terms of the
|
|
# Eclipse Public License v2.0 which accompanies this distribution, and is available at
|
|
# https://www.eclipse.org/legal/epl-v20.html
|
|
#
|
|
# SPDX-License-Identifier: EPL-2.0
|
|
#
|
|
# Copyright IBM Corporation 2018, 2020
|
|
################################################################################
|
|
|
|
################################################################################
|
|
# Build script
|
|
#
|
|
# - build client
|
|
#################################################################################
|
|
|
|
# contants
|
|
SCRIPT_NAME=$(basename "$0")
|
|
BASEDIR=$(dirname "$0")
|
|
PAX_WORKSPACE_DIR=.pax
|
|
PACKAGE_NAME=$(node -e "console.log(require('./package.json').name)")
|
|
PACKAGE_VERSION=$(node -e "console.log(require('./package.json').version)")
|
|
PACKAGE_DESC=$(node -e "console.log(require('./package.json').description)")
|
|
ZOWE_PLUGIN_ID="com.ibm.${PACKAGE_NAME}"
|
|
|
|
cd $BASEDIR
|
|
cd ..
|
|
ROOT_DIR=$(pwd)
|
|
|
|
# prepare pax workspace
|
|
echo "[${SCRIPT_NAME}] cleaning PAX workspace ..."
|
|
rm -fr "${PAX_WORKSPACE_DIR}/content"
|
|
mkdir -p "${PAX_WORKSPACE_DIR}/content"
|
|
|
|
cp manifest.yaml "${PAX_WORKSPACE_DIR}/content"
|
|
cp README.md "${PAX_WORKSPACE_DIR}/content"
|
|
cp LICENSE "${PAX_WORKSPACE_DIR}/content"
|
|
|
|
# build client
|
|
echo "[${SCRIPT_NAME}] building client ..."
|
|
cd "dist"
|
|
npm install --only=prod
|
|
|
|
cd "${ROOT_DIR}"
|
|
|
|
# copy sample-node-api to target folder
|
|
# copy start script to target folder - included in dist
|
|
echo "[${SCRIPT_NAME}] copying sample node api backend ..."
|
|
mkdir -p "${PAX_WORKSPACE_DIR}/content"
|
|
cp -r dist/. "${PAX_WORKSPACE_DIR}/content"
|
|
|
|
# move content to another folder
|
|
rm -fr "${PAX_WORKSPACE_DIR}/ascii"
|
|
mkdir -p "${PAX_WORKSPACE_DIR}/ascii"
|
|
|
|
# update build information
|
|
# BRANCH_NAME and BUILD_NUMBER is Jenkins environment variable
|
|
commit_hash=$(git rev-parse --verify HEAD)
|
|
current_timestamp=$(date +%s%3N)
|
|
sed -e "s|{{build\.branch}}|${BRANCH_NAME}|g" \
|
|
-e "s|{{build\.number}}|${BUILD_NUMBER}|g" \
|
|
-e "s|{{build\.commitHash}}|${commit_hash}|g" \
|
|
-e "s|{{build\.timestamp}}|${current_timestamp}|g" \
|
|
"${PAX_WORKSPACE_DIR}/content/manifest.yaml" > "${PAX_WORKSPACE_DIR}/content/manifest.yaml.tmp"
|
|
mv "${PAX_WORKSPACE_DIR}/content/manifest.yaml.tmp" "${PAX_WORKSPACE_DIR}/content/manifest.yaml"
|
|
echo "[${SCRIPT_NAME}] manifest:"
|
|
cat "${PAX_WORKSPACE_DIR}/content/manifest.yaml"
|
|
echo
|
|
|
|
rsync -rv \
|
|
--include '*.json' --include '*.html' --include '*.jcl' --include '*.template' \
|
|
--exclude '*.zip' --exclude '*.png' --exclude '*.tgz' --exclude '*.tar.gz' --exclude '*.pax' \
|
|
--prune-empty-dirs --remove-source-files \
|
|
"${PAX_WORKSPACE_DIR}/content/" \
|
|
"${PAX_WORKSPACE_DIR}/ascii"
|
|
|
|
echo "[${SCRIPT_NAME}] ${PAX_WORKSPACE_DIR} folder is prepared."
|
|
exit 0
|