496a72e7d7
The flights-front deploy repo ships k8s manifests at deployment/k8s/, a sibling of Aeroflot.Flights.Front/. Previously the sync script only copied the app source, so any env change landed on the k8s side had to be hand-edited in the deploy repo and was never reflected back. - Bring deployment/k8s/flights-ui.yaml into this repo (with the new MAP_TILE_URL env pointing at flights.test.aeroflot.ru) so the cluster config lives next to the code that reads it. - sync-to-flights-front.sh resolves the deploy-repo root from the target path and mirrors this repo's deployment/ directory there, mkdir'ing and copying contents without wiping unrelated files. - Bump step numbering (1/6..6/6) and the summary now lists the synced deployment files in addition to the app files.
145 lines
5.5 KiB
Bash
Executable File
145 lines
5.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Sync the React app from this repo to the flights-front deployment repo.
|
|
#
|
|
# Usage:
|
|
# ./scripts/sync-to-flights-front.sh [target-dir]
|
|
#
|
|
# Default target: /Users/gnezim/_projects/tims/flights-front/Aeroflot.Flights.Front
|
|
#
|
|
# The deploy repo has the shape:
|
|
# flights-front/
|
|
# Aeroflot.Flights.Front/ ← app source (target of this sync)
|
|
# deployment/ ← k8s manifests, ci scripts, etc.
|
|
# Anything under this repo's top-level deployment/ is copied to the
|
|
# sibling deployment/ in the deploy repo so cluster config lives with
|
|
# the source that consumes its env vars.
|
|
|
|
SRC_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
TARGET_DIR="${1:-/Users/gnezim/_projects/tims/flights-front/Aeroflot.Flights.Front}"
|
|
DEPLOY_ROOT="$(cd "$TARGET_DIR/.." && pwd)"
|
|
|
|
if [ ! -d "$TARGET_DIR" ]; then
|
|
echo "Error: target directory does not exist: $TARGET_DIR"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Syncing: $SRC_DIR → $TARGET_DIR"
|
|
echo " $SRC_DIR/deployment → $DEPLOY_ROOT/deployment"
|
|
echo ""
|
|
|
|
# ── Step 1: Clean target (preserve node_modules, .git, .dockerignore) ────────
|
|
|
|
echo "1/6 Cleaning target directory..."
|
|
find "$TARGET_DIR" -mindepth 1 -maxdepth 1 \
|
|
! -name "node_modules" \
|
|
! -name ".dockerignore" \
|
|
-exec rm -rf {} +
|
|
|
|
# ── Step 2: Copy source files ────────────────────────────────────────────────
|
|
|
|
echo "2/6 Copying source files..."
|
|
|
|
# App source & config
|
|
cp -r "$SRC_DIR/src" "$TARGET_DIR/src"
|
|
cp -r "$SRC_DIR/tests" "$TARGET_DIR/tests"
|
|
cp -r "$SRC_DIR/scripts" "$TARGET_DIR/scripts"
|
|
# Modern.js publicDir — fonts, images, leaflet icons, favicons. Copied to
|
|
# dist/standalone/public/ at build time. Without these the app serves the
|
|
# SPA index for /assets/** and breaks @font-face, img references, tile icons.
|
|
cp -r "$SRC_DIR/config" "$TARGET_DIR/config"
|
|
cp "$SRC_DIR/package.json" "$TARGET_DIR/package.json"
|
|
cp "$SRC_DIR/pnpm-lock.yaml" "$TARGET_DIR/pnpm-lock.yaml"
|
|
cp "$SRC_DIR/tsconfig.json" "$TARGET_DIR/tsconfig.json"
|
|
cp "$SRC_DIR/modern.config.ts" "$TARGET_DIR/modern.config.ts"
|
|
cp "$SRC_DIR/module-federation.config.ts" "$TARGET_DIR/module-federation.config.ts"
|
|
cp "$SRC_DIR/vitest.config.ts" "$TARGET_DIR/vitest.config.ts"
|
|
cp "$SRC_DIR/playwright.config.ts" "$TARGET_DIR/playwright.config.ts"
|
|
cp "$SRC_DIR/eslint.config.js" "$TARGET_DIR/eslint.config.js"
|
|
cp "$SRC_DIR/Makefile" "$TARGET_DIR/Makefile"
|
|
cp "$SRC_DIR/CLAUDE.md" "$TARGET_DIR/CLAUDE.md"
|
|
cp "$SRC_DIR/AGENTS.md" "$TARGET_DIR/AGENTS.md"
|
|
|
|
# Dockerfile — use the SSR-specific one
|
|
cp "$SRC_DIR/Dockerfile.react" "$TARGET_DIR/Dockerfile"
|
|
|
|
# ── Step 3: Copy deployment configs to the sibling deployment/ dir ──────────
|
|
|
|
echo "3/6 Copying deployment configs..."
|
|
|
|
if [ -d "$SRC_DIR/deployment" ]; then
|
|
mkdir -p "$DEPLOY_ROOT/deployment"
|
|
# Mirror deployment/ without nuking unrelated files under the deploy
|
|
# repo's deployment dir — copy contents, don't wipe the target.
|
|
cp -R "$SRC_DIR/deployment/." "$DEPLOY_ROOT/deployment/"
|
|
echo " copied $(find "$SRC_DIR/deployment" -type f | wc -l | tr -d ' ') file(s) into $DEPLOY_ROOT/deployment"
|
|
else
|
|
echo " (no deployment/ dir in source repo — skipping)"
|
|
fi
|
|
|
|
# ── Step 4: Clean up artifacts that shouldn't be in the target ────────────────
|
|
|
|
echo "4/6 Cleaning up artifacts..."
|
|
|
|
# Remove debug screenshots
|
|
find "$TARGET_DIR" -maxdepth 1 -name "*.png" -delete 2>/dev/null || true
|
|
|
|
# Remove Angular-specific files that may have leaked
|
|
rm -rf "$TARGET_DIR/src/server/middleware/"*.test.ts 2>/dev/null || true
|
|
|
|
# Remove this sync script from the target (it's only needed in the source repo)
|
|
rm -f "$TARGET_DIR/scripts/sync-to-flights-front.sh" 2>/dev/null || true
|
|
|
|
# Remove dev-server proxy script (flights-front has its own deployment)
|
|
# Keep it — it's useful for local dev
|
|
|
|
# Remove Angular comparison scripts
|
|
rm -rf "$TARGET_DIR/scripts/phase-0" 2>/dev/null || true
|
|
rm -f "$TARGET_DIR/scripts/screenshot-diff.ts" 2>/dev/null || true
|
|
|
|
# Remove playwright-angular config if copied
|
|
rm -f "$TARGET_DIR/playwright-angular.config.ts" 2>/dev/null || true
|
|
|
|
# Remove test files that reference Angular
|
|
rm -rf "$TARGET_DIR/tests/e2e-angular" 2>/dev/null || true
|
|
rm -rf "$TARGET_DIR/tests/parity" 2>/dev/null || true
|
|
|
|
# ── Step 5: Ensure .dockerignore exists ──────────────────────────────────────
|
|
|
|
echo "5/6 Ensuring .dockerignore..."
|
|
|
|
if [ ! -f "$TARGET_DIR/.dockerignore" ]; then
|
|
cat > "$TARGET_DIR/.dockerignore" << 'DOCKERIGNORE'
|
|
node_modules
|
|
dist
|
|
coverage
|
|
test-results
|
|
playwright-report
|
|
.playwright-mcp
|
|
*.png
|
|
*.md
|
|
.git
|
|
.claude
|
|
.gstack
|
|
DOCKERIGNORE
|
|
fi
|
|
|
|
# ── Step 6: Summary ─────────────────────────────────────────────────────────
|
|
|
|
echo "6/6 Done!"
|
|
echo ""
|
|
echo "Synced app files:"
|
|
ls -1 "$TARGET_DIR" | grep -v node_modules
|
|
if [ -d "$DEPLOY_ROOT/deployment" ]; then
|
|
echo ""
|
|
echo "Synced deployment files:"
|
|
(cd "$DEPLOY_ROOT" && find deployment -type f | sort)
|
|
fi
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " cd $TARGET_DIR"
|
|
echo " pnpm install # if lock file changed"
|
|
echo " make check # typecheck + lint + test"
|
|
echo " cd $DEPLOY_ROOT && git diff # review changes"
|