SPB Git

Repository Public MIT

sync-studio-resources.sh 2.7 KB 68 lines shellscript

1#!/usr/bin/env bash2# =============================================================================3#                  SP BOUCHER | SOFTWARE & RESEARCH4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : SP GlassKit8# File             : Scripts/sync-studio-resources.sh9# Module           : Scripts10# Repository       : https://git.spboucher.ai/sp-glasskit11# Project Website  : https://glass.spboucher.ai12# Created          : 2026-12-0213# Last Modified    : 2026-12-0214#15# Author           : Simon-Pierre Boucher16# Position         : Professor of Finance17# Institution      : Université du Québec en Outaouais (UQO)18# Organization     : SP Boucher19# Website          : https://spboucher.ai20# Git              : https://git.spboucher.ai21#22# Preferred Contact: contact@spboucher.ai23# Development      : dev@spboucher.ai24# Support          : support@spboucher.ai25# Security/Admin   : admin@spboucher.ai26#27# Copyright (c) 202628# Simon-Pierre Boucher29# All rights reserved where applicable. This file is governed by the30# applicable project license, copyright notices and relevant law.31# Existing third-party rights and notices remain unaffected.32#33# License          : MIT34#35# Do not embed credentials, private keys, access tokens,36# certificates or confidential personal information.37#38# =============================================================================39# END OF SP BOUCHER SOURCE HEADER40# =============================================================================4142# Copies the component documentation pages and example sources into the Studio's resources, so that the43# Studio shows them offline. Usage: Scripts/sync-studio-resources.sh [--check]44set -euo pipefail45ROOT="$(cd "$(dirname "$0")/.." && pwd)"46DEST="$ROOT/Apps/GlassStudio/Kit/Resources"47TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT48for page in "$ROOT"/docs/components/*.md; do49  cp "$page" "$TMP/doc-$(basename "$page")"50done51for example in "$ROOT"/Examples/Gallery/*/*Example.swift; do52  id="$(sed -n 's/.*static let componentID = "\(.*\)".*/\1/p' "$example" | head -1)"53  [ -n "$id" ] || { echo "no componentID in $example" >&2; exit 1; }54  # Drop the file header: keep from the first import onwards.55  awk 'found || /^import /{found=1; print}' "$example" > "$TMP/example-$id.txt"56done57if [ "${1:-}" = "--check" ]; then58  status=059  for file in "$TMP"/*; do60    cmp -s "$file" "$DEST/$(basename "$file")" || { echo "stale: $(basename "$file")"; status=1; }61  done62  [ "$status" = 0 ] && echo "Studio resources up to date ($(ls "$TMP" | wc -l | tr -d ' ') files)"63  exit "$status"64fi65rm -f "$DEST"/doc-*.md "$DEST"/example-*.txt66cp "$TMP"/* "$DEST"/67echo "synced $(ls "$TMP" | wc -l | tr -d ' ') files"68
Files main
Menu

Theme