Spec v1.2, Logosmental-based design direction and tokens, pnpm monorepo (apps/demo, packages/data|features|i18n|db/seed), student + admin screens in 4 locales, simulated ArifPay checkout on the real order state machine, artifact inline/check tools, domain rule checks and UI audit fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
2.1 KiB
JavaScript
34 lines
2.1 KiB
JavaScript
// CI check: loads the inlined demo in jsdom with ALL network blocked and fails if the page
|
|
// tries to fetch or load any script (e.g. a lazy chunk or an RSC .txt payload), or throws.
|
|
// Usage: node tools/artifact-check.mjs dist/demo.html
|
|
import { JSDOM, VirtualConsole } from 'jsdom'; import fs from 'fs';
|
|
const file = process.argv[2] || 'dist/demo.html';
|
|
const errors = [], network = [];
|
|
const vc = new VirtualConsole();
|
|
vc.on('jsdomError', (e) => errors.push(String(e.message)));
|
|
const dom = new JSDOM(fs.readFileSync(file, 'utf8'), {
|
|
runScripts: 'dangerously', url: 'https://artifact.local/', virtualConsole: vc, pretendToBeVisual: true,
|
|
beforeParse(w) {
|
|
Object.assign(w, { TextEncoder, TextDecoder, MessageChannel, ReadableStream, structuredClone });
|
|
w.fetch = (u) => { network.push(`fetch ${u}`); return Promise.reject(new Error('blocked')); };
|
|
const create = w.document.createElement.bind(w.document);
|
|
w.document.createElement = (tag, ...rest) => {
|
|
const el = create(tag, ...rest);
|
|
if (tag === 'script') {
|
|
const d = Object.getOwnPropertyDescriptor(w.HTMLScriptElement.prototype, 'src');
|
|
Object.defineProperty(el, 'src', { set(v) { network.push(`script ${v}`); d.set.call(el, v); }, get() { return d.get.call(el); } });
|
|
}
|
|
return el;
|
|
};
|
|
},
|
|
});
|
|
const w = dom.window;
|
|
await new Promise((r) => setTimeout(r, 2000));
|
|
for (const route of ['#/am', '#/am/courses', '#/admin']) { w.location.hash = route; await new Promise((r) => setTimeout(r, 300)); }
|
|
// React can re-insert hoisted <link>/<script> tags at hydration; jsdom doesn't fetch them, so scan the DOM too.
|
|
for (const el of w.document.querySelectorAll('link[href],script[src]')) network.push(`${el.tagName.toLowerCase()} ${el.getAttribute('href') ?? el.getAttribute('src')}`);
|
|
const allowed = (u) => /^link https:\/\/fonts\.(googleapis|gstatic)\.com/.test(u) || /cdnjs\.cloudflare\.com|cdn\.jsdelivr\.net\/npm|fonts\.googleapis\.com|fonts\.gstatic\.com/.test(u);
|
|
const bad = network.filter((n) => !allowed(n));
|
|
console.log({ networkAttempts: bad, errors });
|
|
process.exit(bad.length || errors.length ? 1 : 0);
|