- BRIEF.md y CLAUDE.md como fuente de verdad y reglas del repositorio - Astro 7 estático con Tailwind 4; tokens en src/styles/tokens.css (claro/oscuro) - Fuentes propias en public/fonts (Fraunces, Instrument Sans, JetBrains Mono) - Layout Base con SEO y Open Graph; Header con menú accesible; Footer - Componentes Stat (cifra con método) y Video (fondo/captura/externo) - Colección cifras con esquema zod; esquemas de proyectos y equipo - Página de inicio; referencia/ con el borrador y los chats originales Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
38 lines
1.9 KiB
JavaScript
38 lines
1.9 KiB
JavaScript
// Capturas de pantalla y comprobación de scroll horizontal sobre dist/ (astro preview).
|
|
// Uso: node scripts/capturas.mjs <raíz> <carpeta-salida> "/,/proyectos"
|
|
import { chromium } from 'playwright';
|
|
import { spawn } from 'node:child_process';
|
|
import { setTimeout as sleep } from 'node:timers/promises';
|
|
import { mkdirSync } from 'node:fs';
|
|
|
|
const raiz = process.argv[2];
|
|
const salida = process.argv[3];
|
|
const rutas = (process.argv[4] || '/').split(',');
|
|
mkdirSync(salida, { recursive: true });
|
|
|
|
const srv = spawn('npx', ['astro', 'preview', '--port', '4321'], { cwd: raiz, stdio: 'ignore' });
|
|
await sleep(2500);
|
|
const browser = await chromium.launch();
|
|
try {
|
|
for (const ruta of rutas) {
|
|
for (const [ancho, alto] of [[320, 700], [360, 780], [768, 900], [1280, 900], [1920, 1000]]) {
|
|
for (const esquema of ['light', 'dark']) {
|
|
const ctx = await browser.newContext({ viewport: { width: ancho, height: alto }, colorScheme: esquema, deviceScaleFactor: 1 });
|
|
const page = await ctx.newPage();
|
|
const errores = [];
|
|
page.on('console', (m) => { if (m.type() === 'error') errores.push(m.text()); });
|
|
page.on('requestfailed', (r) => errores.push('request failed: ' + r.url()));
|
|
await page.goto('http://localhost:4321' + ruta, { waitUntil: 'networkidle' });
|
|
const sw = await page.evaluate(() => [document.documentElement.scrollWidth, document.documentElement.clientWidth]);
|
|
const nombre = ruta.replace(/\//g, '_').replace(/^_$/, 'inicio').replace(/^_/, '');
|
|
if ([360, 1280].includes(ancho)) await page.screenshot({ path: `${salida}/${nombre}-${ancho}-${esquema}.png`, fullPage: true });
|
|
console.log(`${ruta} ${ancho}px ${esquema}: scrollWidth=${sw[0]} clientWidth=${sw[1]} ${sw[0] > sw[1] ? 'SCROLL HORIZONTAL' : 'ok'} ${errores.length ? 'ERRORES: ' + errores.join(' | ') : ''}`);
|
|
await ctx.close();
|
|
}
|
|
}
|
|
}
|
|
} finally {
|
|
await browser.close();
|
|
srv.kill();
|
|
}
|