#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")" # Existing Linux deployments can explicitly start the persistent-session units. if [ "${1:-}" = --services ]; then systemctl --user start vibemake-pcb2-session.service vibemake-pcb2-web.service exec systemctl --user --no-pager status vibemake-pcb2-session.service vibemake-pcb2-web.service fi # A configured runtime is optional; ordinary Node 20+ installations also work. if ! command -v node >/dev/null || [ "$(node -p 'Number(process.versions.node.split(".")[0])')" -lt 20 ]; then runtime="$HOME/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin" if [ -x "$runtime/node" ]; then export PATH="$runtime:$PATH"; else echo 'Please install Node.js 20+ (recommended 22 LTS) and npm first.'; exit 1; fi fi # Local configuration is read by Node's env parser, never evaluated as shell code. node_args=() if [ -f .env.local ]; then node_args=("--env-file=$PWD/.env.local") fi if ! command -v npm >/dev/null; then echo 'npm is required to bootstrap the pinned pnpm version.'; exit 1; fi if [ ! -d node_modules ]; then npm exec --yes --package=pnpm@10.33.0 -- pnpm install --frozen-lockfile; fi if [ ! -f designer/dist/index.html ] || [ ! -f designer/dist/pcb-service-config.json ] || [ "${REBUILD:-0}" = 1 ] || find designer/src ai common -type f -newer designer/dist/index.html -print -quit | grep -q .; then npm exec --yes --package=pnpm@10.33.0 -- pnpm -C designer build fi exec node "${node_args[@]}" scripts/serve.mjs