Files
vibemake-pcb-studio/build.sh
T

30 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build an independently deployable /pcb/ archive without the main site or CAD.
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
cd "$ROOT_DIR"
for tool in node npm zip unzip; do
if ! command -v "$tool" >/dev/null 2>&1; then
printf 'Error: required build tool is missing: %s\n' "$tool" >&2
exit 1
fi
done
if [ "$(node -p 'Number(process.versions.node.split(".")[0])')" -lt 20 ]; then
printf 'Error: Node.js 20 or newer is required.\n' >&2
exit 1
fi
if [ "${VITE_BASE:-/pcb/}" != '/pcb/' ]; then
printf 'Error: this package is deployed at /pcb/ and requires VITE_BASE=/pcb/.\n' >&2
exit 1
fi
PACKAGE_MANAGER="$(node -p 'require("./package.json").packageManager')"
if [ ! -d node_modules ] || [ ! -d designer/node_modules ]; then
npm exec --yes --package="$PACKAGE_MANAGER" -- pnpm install --frozen-lockfile
fi
printf 'Building the PCB application for /pcb/...\n'
VITE_BASE=/pcb/ npm exec --yes --package="$PACKAGE_MANAGER" -- pnpm -C designer build
node scripts/package-pcb.mjs