Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : KA Maps Engine8# File : sdk/web/scripts/test-vite.sh9# Module : sdk10# Repository : https://git.spboucher.ai/ka-maps-engine11# Created : 2026-12-0112# Last Modified : 2026-12-0113#14# Author : Simon-Pierre Boucher15# Position : Professor of Finance16# Institution : Université du Québec en Outaouais (UQO)17# Organization : SP Boucher18# Website : https://spboucher.ai19# Git : https://git.spboucher.ai20#21# Preferred Contact: support@spboucher.ai22# Technical Contact: dev@spboucher.ai23# Security/Admin : admin@spboucher.ai24#25# Copyright (c) 202626# Simon-Pierre Boucher27# All rights reserved where applicable. This file is governed by the28# applicable project license, copyright notices and relevant law.29# Existing third-party rights and notices remain unaffected.30#31# License : None specified (no license file in this repository)32#33# Do not embed credentials, private keys, access tokens,34# certificates or confidential personal information.35#36# =============================================================================37# END OF SP BOUCHER SOURCE HEADER38# =============================================================================3940# Essai d'intégration réel dans un site Vite + React : installe l'archive ka-maps-<version>.tgz dans41# tests/vite-app, vérifie les types (tsc), construit (vite build), sert le résultat sur le port 533042# (CSP stricte par balise <meta>) et vérifie sans fenêtre, dans trois navigateurs, que la carte se charge.43#44# scripts/build.sh --pack && scripts/test-vite.sh45set -euo pipefail46HERE="$(cd "$(dirname "$0")/.." && pwd)"47cd "$HERE"48VERSION="$(node -p "require('./package.json').version")"49TGZ="$HERE/ka-maps-$VERSION.tgz"50[ -f "$TGZ" ] || { echo "archive absente : lancer scripts/build.sh --pack" >&2; exit 1; }5152cd tests/vite-app53rm -rf node_modules/@ka dist54npm install --no-audit --no-fund --no-package-lock "$TGZ" >/dev/null55npm install --no-audit --no-fund --no-package-lock >/dev/null56echo "== tsc + vite build ($(node -p "require('vite/package.json').version"))"57npx tsc -p tsconfig.json58npx vite build --logLevel warn59ls -la "dist/ka-maps/$VERSION/"6061npx vite preview --host 127.0.0.1 --port 5330 --strictPort > /tmp/ka-maps-vite-fixture.log 2>&1 &62PID=$!63# Arrêt par PID (jamais par nom) : le lanceur npx et le serveur qui écoute sur le port.64stop() { kill $PID 2>/dev/null || true; for p in $(lsof -nP -tiTCP:5330 -sTCP:LISTEN 2>/dev/null); do kill "$p" 2>/dev/null || true; done; }65trap stop EXIT66for i in $(seq 1 60); do67 curl -sf -o /dev/null http://127.0.0.1:5330/ && break68 sleep 0.569done70cd "$HERE"71KA_FIXTURE_URL=http://127.0.0.1:5330/ KA_FIXTURE_GLOBAL=__kaVite KA_FIXTURE_BRAND=immoka node scripts/check-fixture.mjs72