Some checks failed
Tests / Backend - Tests skipped: 8, passed: 74
Backend Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 78.38% (551/703)
* Lines of Code: 703
#### Quality Gates Summary
No active quality gates.
Tests / Frontend - Lint, Tests et Build passed: 72
Frontend Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 84.87% (505/595)
* Lines of Code: 595
#### Quality Gates Summary
No active quality gates.
THE-TIP-TOP-MULTIBRANCH/pipeline/head There was a failure building this commit
58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
import { mkdirSync, writeFileSync } from 'node:fs'
|
|
import { dirname, join } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { preview } from 'vite'
|
|
import { chromium } from 'playwright'
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
const root = join(__dirname, '..')
|
|
const distDir = join(root, 'dist')
|
|
|
|
// Pages publiques, indexables (voir public/robots.txt) : ce sont les seules
|
|
// qui ont besoin d'un HTML pré-rendu pour le SEO et les aperçus sociaux. Les
|
|
// pages privées (profil, mes gains, admin...) restent en rendu 100% client,
|
|
// servies par le index.html générique via le fallback SPA de nginx.
|
|
const ROUTES = [
|
|
'/accueil',
|
|
'/notre-concept',
|
|
'/regles-jeu',
|
|
'/contact',
|
|
'/mentions-legales',
|
|
'/confidentialite',
|
|
'/accessibilite',
|
|
'/cgu',
|
|
'/sitemap',
|
|
'/inscription',
|
|
'/connexion',
|
|
]
|
|
|
|
async function main() {
|
|
const server = await preview({ root, preview: { port: 4173, strictPort: false } })
|
|
const base = server.resolvedUrls.local[0].replace(/\/$/, '')
|
|
|
|
const browser = await chromium.launch({
|
|
executablePath: process.env.CHROMIUM_PATH || '/usr/bin/chromium-browser',
|
|
headless: true,
|
|
})
|
|
const page = await browser.newPage()
|
|
|
|
for (const route of ROUTES) {
|
|
await page.goto(`${base}${route}`, { waitUntil: 'networkidle' })
|
|
await page.waitForSelector('h1')
|
|
|
|
const html = await page.content()
|
|
const outDir = join(distDir, route.replace(/^\//, ''))
|
|
mkdirSync(outDir, { recursive: true })
|
|
writeFileSync(join(outDir, 'index.html'), `<!doctype html>\n${html}`)
|
|
console.log(`✓ pré-rendu ${route} -> dist${route}/index.html`)
|
|
}
|
|
|
|
await browser.close()
|
|
await server.close()
|
|
}
|
|
|
|
main().catch((error) => {
|
|
console.error('Erreur de pré-rendu :', error)
|
|
process.exit(1)
|
|
})
|