Repository Public
1#!/usr/bin/env bash2# Author: Simon-Pierre Boucher — contact@spboucher.ai3# File: Scripts/dev-session.sh4# Description: Opens an SSH tunnel to the DEVELOPMENT backend (never production) and mints a session for its scratch database, for Debug runs and tests.5#6# Usage: eval "$(Scripts/dev-session.sh)" → exports SPNOTES_SERVER and SPNOTES_SESSION_TOKEN7# Debug builds only honour these variables, and only for a loopback server.8set -euo pipefail9# 2.0: the integration build of « SP Note Next » (branch next-int, scratch database note_next_int_dev) — never production10NODE="${DEV_NODE:-M4M64c}"; DIR="${DEV_DIR:-dev/note-next-int}"; PORT="${DEV_PORT:-8486}"11curl -fsS -m 3 "http://localhost:$PORT/api/health" >/dev/null 2>&1 || ssh -f -N -o ExitOnForwardFailure=yes -L "$PORT:127.0.0.1:$PORT" "$NODE"12TOKEN="$(ssh "$NODE" "export PATH=/opt/homebrew/bin:\$PATH; cd $DIR && set -a && . ./.env && set +a && node node_modules/tsx/dist/cli.mjs scripts/dev-session.ts 'SPNotes/2.0.0 (Macintosh; macOS dev) native' 2>/dev/null | tail -1")"13[[ ${#TOKEN} -eq 43 ]] || { echo "echo 'ERROR: could not mint a development session' >&2; false"; exit 1; }14echo "export SPNOTES_SERVER=http://localhost:$PORT SPNOTES_SESSION_TOKEN=$TOKEN"15