#!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd -- "$SCRIPT_DIR/.." && pwd)" TOOL_DIR="$SCRIPT_DIR/sdlc-delivery" SOURCE_DIR="$ROOT_DIR/sdlc" DELIVERY_ROOT="$ROOT_DIR/sdlc-delivery" STAGING_DIR="$ROOT_DIR/.sdlc-delivery.staging" if [[ ! -d "$TOOL_DIR/node_modules/playwright" ]]; then echo "Installing the local PDF renderer..." npm install --prefix "$TOOL_DIR" npx --prefix "$TOOL_DIR" playwright install chromium fi # The Software Design figures are drawn in scripts/sdlc-seed/figures.mjs and # rasterised with the document font before the seed copies them into sdlc/. echo "Rendering Software Design figures..." node "$TOOL_DIR/render-figures.mjs" # sdlc/ is generated output: the seed rebuilds every work product from the # controlled project data in scripts/sdlc-seed/ before anything is rendered. echo "Seeding work products from project data..." node "$SCRIPT_DIR/sdlc-seed/build.mjs" rm -rf "$STAGING_DIR" mkdir -p "$STAGING_DIR" while IFS= read -r -d '' source; do relative="${source#"$ROOT_DIR/sdlc/"}" destination="$STAGING_DIR/${relative%.md}.pdf" echo "Rendering ${relative%.md}.pdf" node "$TOOL_DIR/render-sdlc.mjs" "$source" "$destination" done < <(find "$SOURCE_DIR" -type f -name '*.md' -print0 | sort -z) echo "Verifying staged delivery package..." "$SCRIPT_DIR/verify-sdlc-delivery.sh" "$STAGING_DIR" rm -rf "$DELIVERY_ROOT" mv "$STAGING_DIR" "$DELIVERY_ROOT" echo "Delivery and verification passed: $DELIVERY_ROOT"