Repository Public License
1#!/bin/sh2# ORIX Navigator — regenerates the Lunar Glass reference material.3#4# scripts/render-design-reference.sh gallery + reference mockups + tokens.json5# scripts/render-design-reference.sh --tokens tokens.json only6# scripts/render-design-reference.sh --icon app icon only (scripts/make-icon.swift)7# scripts/render-design-reference.sh --all everything above8# add --isolated to build LunarDesign alone (useful while another module of the package does not compile)9#10# Output: DesignSystem/reference/*.png, DesignSystem/tokens.json, DesignSystem/AppIcon/.11# The renders come from the LunarReferenceRender test suite (Tests/LunarDesignTests), which draws the real12# components offscreen with ImageRenderer. Nothing is brought on screen. One build at a time: do not run this while13# another swift build of the same scratch path is in progress.14set -eu1516ROOT=$(cd "$(dirname "$0")/.." && pwd)17PACKAGE="$ROOT/Packages/NavigatorKit"18MODE=render19ISOLATED=020for arg in "$@"; do21 case "$arg" in22 --tokens) MODE=tokens ;;23 --icon) MODE=icon ;;24 --all) MODE=all ;;25 --isolated) ISOLATED=1 ;;26 -h|--help) sed -n '2,13p' "$0"; exit 0 ;;27 *) echo "unknown option: $arg" >&2; exit 2 ;;28 esac29done3031if [ "$MODE" = icon ] || [ "$MODE" = all ]; then32 swift "$ROOT/scripts/make-icon.swift" "$ROOT/DesignSystem/AppIcon"33 [ "$MODE" = icon ] && exit 034fi3536export LUNAR_REPO_ROOT="$ROOT"37if [ "$MODE" = tokens ]; then38 export LUNAR_EXPORT_TOKENS=139 FILTER=LunarReferenceRender/exportTokens40else41 export LUNAR_RENDER_REFERENCE=142 FILTER=LunarReferenceRender43 mkdir -p "$ROOT/DesignSystem/reference"44fi4546if [ "$ISOLATED" = 1 ]; then47 # A throwaway package (under the git-ignored build/ directory) that contains only LunarDesign and its tests.48 HARNESS="$PACKAGE/build/design-harness"49 mkdir -p "$HARNESS/Sources" "$HARNESS/Tests"50 ln -sfn "$PACKAGE/Sources/LunarDesign" "$HARNESS/Sources/LunarDesign"51 ln -sfn "$PACKAGE/Tests/LunarDesignTests" "$HARNESS/Tests/LunarDesignTests"52 cat > "$HARNESS/Package.swift" <<'PKG'53// swift-tools-version: 6.054// Generated by scripts/render-design-reference.sh --isolated. Builds LunarDesign and its tests alone.55import PackageDescription56let package = Package(57 name: "LunarDesignHarness", defaultLocalization: "en", platforms: [.macOS(.v15), .iOS(.v18)],58 products: [.library(name: "LunarDesign", targets: ["LunarDesign"])],59 targets: [60 .target(name: "LunarDesign", path: "Sources/LunarDesign", resources: [.process("Resources")],61 swiftSettings: [.swiftLanguageMode(.v6)]),62 .testTarget(name: "LunarDesignTests", dependencies: ["LunarDesign"], path: "Tests/LunarDesignTests",63 swiftSettings: [.swiftLanguageMode(.v6)]),64 ])65PKG66 cd "$HARNESS"67 swift test --disable-keychain --scratch-path .build --filter "$FILTER"68else69 cd "$PACKAGE"70 swift test --disable-keychain --scratch-path build/spm-design --filter "$FILTER"71fi7273echo "Reference material written under $ROOT/DesignSystem"74