feat: template frontend diverge - #17
Conversation
| for (const rel of missingFiles) { | ||
| console.error(` - ${rel} (missing in sgs_frontend/)`); | ||
| } | ||
| if (drifted.length || missingFiles.length) { | ||
| console.error('❌ Shared frontend core has drifted from template_frontend/:'); | ||
| for (const rel of drifted) { | ||
| console.error(` - ${rel}`); | ||
| } | ||
| console.error(' Run "bun run sync:core" to copy template_frontend/ into sgs_frontend/.'); | ||
| process.exit(1); | ||
| } |
There was a problem hiding this comment.
💡 Quality: check:core prints missing-file lines before the error header
In the check() function the loop printing - <file> (missing in sgs_frontend/) runs before the ❌ Shared frontend core has drifted... header and the drifted-file loop. When files are missing, CI output shows the indented bullet lines first with no preceding context, then the header, producing confusing/out-of-order diagnostics. Move the missing-file loop inside the if (drifted.length || missingFiles.length) block after the header (and after the drifted loop) so all details print under the header.
Print all drift/missing details under the error header in a consistent order.:
if (drifted.length || missingFiles.length) {
console.error('❌ Shared frontend core has drifted from template_frontend/:');
for (const rel of drifted) {
console.error(` - ${rel}`);
}
for (const rel of missingFiles) {
console.error(` - ${rel} (missing in sgs_frontend/)`);
}
console.error(' Run "bun run sync:core" to copy template_frontend/ into sgs_frontend/.');
process.exit(1);
}
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsEstablishes clear ownership of 💡 Quality: check:core prints missing-file lines before the error header📄 scripts/frontend-core.ts:96-106 In the Print all drift/missing details under the error header in a consistent order.🤖 Prompt for agentsOptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Important Your trial ends in 3 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more. Was this helpful? React with 👍 / 👎 | Gitar |
|




Resumen
template_frontendysgs_frontendcompartían 31 archivos idénticos byte por byte que debían mantenerse en dos lugares diferentes, sin ningún mecanismo para detectar divergencias entre ellos. Este cambio define claramente el propósito de cada frontend, asigna nombres de paquete distintos, establece el template como única fuente del código compartido y añade CI para detectar futuras divergencias.Rol de cada frontend
template_frontend/es el template. Es la única fuente mantenida manualmente del núcleo compartido del frontend del juego (componentes de layout/wallet, hooks, servicios, store, utils, configuración y archivos de build), además del ejemplo de number-guess.bun run create <game>lo copia para generar un nuevo<game>-frontend.sgs_frontend/es el catálogo y sitio de documentación de Studio (se genera endocs/para GitHub Pages). Añade código exclusivo de Studio (biblioteca de juegos, recursos, páginas y assets) sobre el núcleo compartido, que ahora copia desde el template en lugar de mantenerlo manualmente.Cambios
Arquitectura documentada en
README.mdmediante una nueva sección Frontends, incluyendo la lista de archivos que intencionalmente son específicos de cada frontend (index.html,package.json,src/App.tsx,src/index.css,src/components/Layout.*,src/games/number-guess/NumberGuessGame.tsx). El mapa del repositorio también se replicó enAGENTS.md/CLAUDE.md, los cuales deben mantenerse idénticos.Nombres de paquete diferenciados:
sgs_frontend/package.jsonahora utiliza el nombresgs-studio-frontend(el template ya utilizabasgs-template-frontend), por lo que ambos paquetes ya no comparten la misma identidadsgs-frontend.Una única fuente para el código compartido: se añadió
scripts/frontend-core.ts, que define el manifiesto canónico de archivos compartidos:bun run sync:corecopia los archivos desdetemplate_frontend/haciasgs_frontend/.bun run check:corefalla si las dos copias presentan divergencias e indica cómo solucionarlas.Protección mediante CI: se añadió
.github/workflows/frontends.yml, que se ejecuta en cada push/PR y:check:corepara detectar divergencias,sgs_frontend(build:docs) ytemplate_frontend(build).Verificación
bun run check:corepasa correctamente y no existen divergencias actualmente.Se verificó la detección de divergencias: una modificación simulada en un archivo compartido hace que
check:corefalle con código de salida 1 y muestre la sugerencia de ejecutarbun run sync:core; al revertir el cambio, la comprobación vuelve a pasar.Ambos frontends se construyen correctamente:
bun --cwd=sgs_frontend run build:docsbun --cwd=template_frontend run buildNotas
bun.locky los artefactossgs_frontend/dist-node/template_frontend/dist-nodeno forman parte intencionalmente del manifiesto del núcleo compartido, ya que corresponden a dependencias/lockfile y salidas de build generadas, no a código fuente mantenido manualmente.docs/,*.tsbuildinfo) no han sido modificados por este PR.Closes #4