#!/usr/bin/env bash # Copyright IBM Corp. 2020, 2026 # SPDX-License-Identifier: BUSL-1.1 set -e if [ -z "$UI_CLONE_DIR" ]; then echo "Must set UI_CLONE_DIR"; exit 1 fi if [ -z "$UI_VERSION_FILE" ]; then echo "Must set UI_VERSION_FILE"; exit 1 fi UI_EDITION=$(make --no-print-directory edition) # Threshold ships a single (community) edition of the admin UI, built from the # CyberCoveLLC/threshold-ui fork of hashicorp/boundary-ui. UI_REPO=${UI_REPO:-https://repo.anhonesthost.net/CyberCoveLLC/threshold-ui.git} UI_CURRENT_COMMIT=$(head -n1 < "${UI_VERSION_FILE}" | cut -d' ' -f1) if [ -z "$UI_COMMITISH" ]; then echo "==> Building default UI version from $UI_VERSION_FILE: $UI_CURRENT_COMMIT" export UI_COMMITISH="$UI_CURRENT_COMMIT" else echo "==> Building custom UI version $UI_COMMITISH" fi; if ! which pnpm &> /dev/null; then echo "Pnpm must be installed to build ui assets from a git clone.\nPlease ensure Node v20+ and Pnpm v10+ are installed." exit 1 fi tempdir="$(dirname "${UI_CLONE_DIR}")" mkdir -p "${tempdir}" echo "*" > "${tempdir}/.gitignore" if ! [ -d "${UI_CLONE_DIR}/.git" ]; then # clear out dir, incase it was previously an artifact download rm -rf "${UI_CLONE_DIR}" git clone "${UI_REPO}" "${UI_CLONE_DIR}" fi pushd "${UI_CLONE_DIR}" git reset --hard git fetch origin "${UI_COMMITISH}" git checkout "${UI_COMMITISH}" git pull --ff-only origin "${UI_COMMITISH}" git reset --hard "${UI_COMMITISH}" pnpm install --frozen-lockfile --filter "admin..." EDITION=${UI_EDITION} pnpm build popd