Overhaul script handling. Closes #125.

This commit is contained in:
Jack Kingsman
2026-03-30 15:40:13 -07:00
parent 60f3fa8e36
commit 3f6efaae1d
19 changed files with 184 additions and 67 deletions
+5 -5
View File
@@ -2,10 +2,10 @@
set -euo pipefail
# Collect third-party license texts into LICENSES.md
# Usage: scripts/collect_licenses.sh [output-path]
# Usage: scripts/build/collect_licenses.sh [output-path]
# output-path defaults to LICENSES.md at the repo root
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
OUT="${1:-$REPO_ROOT/LICENSES.md}"
FRONTEND_LICENSE_IMAGE="${FRONTEND_LICENSE_IMAGE:-node:20-slim}"
FRONTEND_LICENSE_NPM="${FRONTEND_LICENSE_NPM:-10.9.5}"
@@ -59,7 +59,7 @@ for d in data:
# ── Frontend (npm) ───────────────────────────────────────────────────
frontend_licenses_local() {
cd "$REPO_ROOT/frontend"
node "$REPO_ROOT/scripts/print_frontend_licenses.cjs"
node "$REPO_ROOT/scripts/build/print_frontend_licenses.cjs"
}
frontend_licenses_docker() {
@@ -73,7 +73,7 @@ frontend_licenses_docker() {
cd frontend
npm i -g npm@$FRONTEND_LICENSE_NPM >/dev/null
npm ci --ignore-scripts >/dev/null
node /src/scripts/print_frontend_licenses.cjs
node /src/scripts/build/print_frontend_licenses.cjs
"
}
@@ -85,7 +85,7 @@ frontend_licenses() {
{
echo "# Third-Party Licenses"
echo
echo "Auto-generated by \`scripts/collect_licenses.sh\` — do not edit by hand."
echo "Auto-generated by \`scripts/build/collect_licenses.sh\` — do not edit by hand."
echo
echo "## Backend (Python) Dependencies"
echo
+14 -14
View File
@@ -7,8 +7,8 @@ GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
cd "$SCRIPT_DIR"
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
cd "$REPO_ROOT"
RELEASE_WORK_DIR=""
RELEASE_BUNDLE_DIR_NAME="Remote-Terminal-for-MeshCore"
@@ -17,14 +17,14 @@ DOCKER_IMAGE="jkingsman/remoteterm-meshcore"
DOCKER_PLATFORMS="linux/amd64,linux/arm64"
cleanup_release_build_artifacts() {
if [ -d "$SCRIPT_DIR/frontend/prebuilt" ]; then
rm -rf "$SCRIPT_DIR/frontend/prebuilt"
if [ -d "$REPO_ROOT/frontend/prebuilt" ]; then
rm -rf "$REPO_ROOT/frontend/prebuilt"
fi
if [ -n "$RELEASE_WORK_DIR" ] && [ -d "$RELEASE_WORK_DIR" ]; then
rm -rf "$RELEASE_WORK_DIR"
fi
if [ -n "$RELEASE_ASSET" ] && [ -f "$SCRIPT_DIR/$RELEASE_ASSET" ]; then
rm -f "$SCRIPT_DIR/$RELEASE_ASSET"
if [ -n "$RELEASE_ASSET" ] && [ -f "$REPO_ROOT/$RELEASE_ASSET" ]; then
rm -f "$REPO_ROOT/$RELEASE_ASSET"
fi
}
@@ -78,7 +78,7 @@ echo
# Run frontend linting and formatting check
echo -e "${YELLOW}Running frontend lint (ESLint)...${NC}"
cd "$SCRIPT_DIR/frontend"
cd "$REPO_ROOT/frontend"
npm run lint
echo -e "${GREEN}Frontend lint passed!${NC}"
echo
@@ -97,11 +97,11 @@ echo
echo -e "${YELLOW}Building frontend...${NC}"
npm run build
echo -e "${GREEN}Frontend build complete!${NC}"
cd "$SCRIPT_DIR"
cd "$REPO_ROOT"
echo
echo -e "${YELLOW}Regenerating LICENSES.md...${NC}"
bash scripts/collect_licenses.sh LICENSES.md
bash scripts/build/collect_licenses.sh LICENSES.md
echo -e "${GREEN}LICENSES.md updated!${NC}"
echo
@@ -202,16 +202,16 @@ FULL_GIT_HASH=$(git rev-parse HEAD)
RELEASE_ASSET="remoteterm-prebuilt-frontend-v${VERSION}-${GIT_HASH}.zip"
echo -e "${YELLOW}Building packaged frontend artifact...${NC}"
cd "$SCRIPT_DIR/frontend"
cd "$REPO_ROOT/frontend"
npm run packaged-build
cd "$SCRIPT_DIR"
cd "$REPO_ROOT"
RELEASE_WORK_DIR=$(mktemp -d)
RELEASE_BUNDLE_DIR="$RELEASE_WORK_DIR/$RELEASE_BUNDLE_DIR_NAME"
mkdir -p "$RELEASE_BUNDLE_DIR"
git archive "$FULL_GIT_HASH" | tar -x -C "$RELEASE_BUNDLE_DIR"
mkdir -p "$RELEASE_BUNDLE_DIR/frontend"
cp -R "$SCRIPT_DIR/frontend/prebuilt" "$RELEASE_BUNDLE_DIR/frontend/prebuilt"
cp -R "$REPO_ROOT/frontend/prebuilt" "$RELEASE_BUNDLE_DIR/frontend/prebuilt"
cat > "$RELEASE_BUNDLE_DIR/build_info.json" <<EOF
{
"version": "$VERSION",
@@ -219,10 +219,10 @@ cat > "$RELEASE_BUNDLE_DIR/build_info.json" <<EOF
"build_source": "prebuilt-release"
}
EOF
rm -f "$SCRIPT_DIR/$RELEASE_ASSET"
rm -f "$REPO_ROOT/$RELEASE_ASSET"
(
cd "$RELEASE_WORK_DIR"
zip -qr "$SCRIPT_DIR/$RELEASE_ASSET" "$(basename "$RELEASE_BUNDLE_DIR")"
zip -qr "$REPO_ROOT/$RELEASE_ASSET" "$(basename "$RELEASE_BUNDLE_DIR")"
)
echo -e "${GREEN}Packaged release artifact created: $RELEASE_ASSET${NC}"
echo
+6 -6
View File
@@ -14,7 +14,7 @@ YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
echo -e "${YELLOW}=== RemoteTerm Quality Checks ===${NC}"
echo
@@ -24,13 +24,13 @@ echo
echo -e "${YELLOW}=== Phase 1: Lint & Format ===${NC}"
echo -e "${BLUE}[backend lint]${NC} Running ruff check + format..."
cd "$SCRIPT_DIR"
cd "$REPO_ROOT"
uv run ruff check app/ tests/ --fix
uv run ruff format app/ tests/
echo -e "${GREEN}[backend lint]${NC} Passed!"
echo -e "${BLUE}[frontend lint]${NC} Running eslint + prettier..."
cd "$SCRIPT_DIR/frontend"
cd "$REPO_ROOT/frontend"
npm run lint:fix
npm run format
echo -e "${GREEN}[frontend lint]${NC} Passed!"
@@ -43,17 +43,17 @@ echo
echo -e "${YELLOW}=== Phase 2: Typecheck, Tests & Build ===${NC}"
echo -e "${BLUE}[pyright]${NC} Running type check..."
cd "$SCRIPT_DIR"
cd "$REPO_ROOT"
uv run pyright app/
echo -e "${GREEN}[pyright]${NC} Passed!"
echo -e "${BLUE}[pytest]${NC} Running backend tests..."
cd "$SCRIPT_DIR"
cd "$REPO_ROOT"
PYTHONPATH=. uv run pytest tests/ -v
echo -e "${GREEN}[pytest]${NC} Passed!"
echo -e "${BLUE}[frontend]${NC} Running tests + build..."
cd "$SCRIPT_DIR/frontend"
cd "$REPO_ROOT/frontend"
npm run test:run
npm run build
echo -e "${GREEN}[frontend]${NC} Passed!"
+3 -3
View File
@@ -7,7 +7,7 @@ YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
NODE_VERSIONS=("20" "22" "24")
# Use explicit npm patch versions so resolver regressions are caught.
@@ -27,7 +27,7 @@ run_combo() {
local image="node:${node_version}-slim"
docker run --rm \
-v "$SCRIPT_DIR:/src:ro" \
-v "$REPO_ROOT:/src:ro" \
-w /tmp \
"$image" \
bash -lc "
@@ -79,7 +79,7 @@ cleanup() {
trap cleanup EXIT
echo -e "${YELLOW}=== Frontend Docker CI Matrix ===${NC}"
echo -e "${BLUE}Repo:${NC} $SCRIPT_DIR"
echo -e "${BLUE}Repo:${NC} $REPO_ROOT"
echo
for case_spec in "${TEST_CASES[@]}"; do
+2 -2
View File
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
echo "Starting E2E tests..."
cd "$SCRIPT_DIR/tests/e2e"
cd "$REPO_ROOT/tests/e2e"
npx playwright test "$@"
+4 -4
View File
@@ -6,23 +6,23 @@ GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
echo -e "${YELLOW}=== Extended Quality Checks ===${NC}"
echo
echo -e "${BLUE}[all_quality]${NC} Running full lint, typecheck, unit tests, and the standard frontend build..."
"$SCRIPT_DIR/scripts/all_quality.sh"
"$REPO_ROOT/scripts/quality/all_quality.sh"
echo -e "${GREEN}[all_quality]${NC} Passed!"
echo
echo -e "${BLUE}[e2e]${NC} Running end-to-end tests..."
"$SCRIPT_DIR/scripts/e2e.sh" "$@"
"$REPO_ROOT/scripts/quality/e2e.sh" "$@"
echo -e "${GREEN}[e2e]${NC} Passed!"
echo
echo -e "${BLUE}[docker_ci]${NC} Running Docker frontend install/build matrix..."
"$SCRIPT_DIR/scripts/docker_ci.sh"
"$REPO_ROOT/scripts/quality/docker_ci.sh"
echo -e "${GREEN}[docker_ci]${NC} Passed!"
echo
+2 -1
View File
@@ -21,7 +21,8 @@ API_URL = f"https://api.github.com/repos/{REPO}/releases/latest"
PREBUILT_PREFIX = "Remote-Terminal-for-MeshCore/frontend/prebuilt/"
SCRIPT_DIR = Path(__file__).resolve().parent
PREBUILT_DIR = SCRIPT_DIR.parent / "frontend" / "prebuilt"
REPO_ROOT = SCRIPT_DIR.parent.parent
PREBUILT_DIR = REPO_ROOT / "frontend" / "prebuilt"
def fetch_json(url: str) -> dict:
+4 -4
View File
@@ -7,7 +7,7 @@
# gymnastics.
#
# Run from anywhere inside the repo:
# bash scripts/install_service.sh
# bash scripts/setup/install_service.sh
set -e
@@ -19,7 +19,7 @@ BOLD='\033[1m'
NC='\033[0m'
SERVICE_NAME="remoteterm"
REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
REPO_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
CURRENT_USER="$(id -un)"
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
FRONTEND_MODE="build"
@@ -252,7 +252,7 @@ if [ "$FRONTEND_MODE" = "build" ]; then
)
else
echo -e "${YELLOW}Fetching prebuilt frontend...${NC}"
python3 "$REPO_DIR/scripts/fetch_prebuilt_frontend.py"
python3 "$REPO_DIR/scripts/setup/fetch_prebuilt_frontend.py"
fi
echo
@@ -402,7 +402,7 @@ echo -e " cd frontend && npm install && npm run build && cd .."
echo -e " sudo systemctl restart ${SERVICE_NAME}"
echo
echo -e "${YELLOW}Refresh prebuilt frontend only (skips local build):${NC}"
echo -e " python3 ${REPO_DIR}/scripts/fetch_prebuilt_frontend.py"
echo -e " python3 ${REPO_DIR}/scripts/setup/fetch_prebuilt_frontend.py"
echo -e " sudo systemctl restart ${SERVICE_NAME}"
echo
echo -e "${YELLOW}View live logs (useful for troubleshooting):${NC}"