Files
compras/scripts/check-public-demo-assets.mjs
T
nalaandClaude Opus 5.5 ec934455e7 Aplicar Pint e formatação de frontend; delimitar o âmbito do lint
Só formatação automática (pint, vp check --fix), sem alterar comportamento.
Excluídos da formatação os registos e artefactos com bytes fixos: docs/,
integrations/, storage/, tmp/, output/, resources/data/, tests/Fixtures/,
compras-release.json e AGENTS*.md. Scripts operacionais, integrations e
auxiliares de teste ficam fora do lint (usam new Function; limpeza na fase 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 23:01:42 +02:00

64 lines
2.0 KiB
JavaScript

import fs from 'node:fs/promises';
import crypto from 'node:crypto';
import assert from 'node:assert/strict';
const file = 'docs/proofs/public-demonstration-frontend.json';
const proof = JSON.parse(await fs.readFile(file, 'utf8'));
const queue = Object.entries(proof.files);
let checked = 0;
await Promise.all(
Array.from({ length: 4 }, async () => {
for (;;) {
const entry = queue.shift();
if (!entry) return;
const [name, hash] = entry;
const response = await fetch(
'https://compras.tempo.co.mz/build/' + name,
{ signal: AbortSignal.timeout(20000) },
);
assert.equal(response.status, 200, name);
assert.equal(
crypto
.createHash('sha256')
.update(new Uint8Array(await response.arrayBuffer()))
.digest('hex'),
hash,
name,
);
checked++;
}
}),
);
Object.assign(proof, {
state: 'assets_passed_banner_pending',
public_assets_responses_and_hashes: checked,
});
await fs.writeFile(file, JSON.stringify(proof, null, 2) + '\n');
const response = await fetch('https://compras.tempo.co.mz/login', {
signal: AbortSignal.timeout(15000),
});
assert.equal(response.status, 200);
const html = await response.text();
const manifest = JSON.parse(
await fs.readFile(
'storage/framework/testing/compras-presentation-final-ui-20261129/manifest.json',
'utf8',
),
);
assert.ok(html.includes(manifest['resources/js/app.tsx'].file));
assert.ok(html.includes('Empresa e dados fictícios'));
Object.assign(proof, {
state: 'passed',
date: new Date().toISOString(),
public_entry_current: true,
demonstration_banner_present: true,
});
await fs.writeFile(file, JSON.stringify(proof, null, 2) + '\n');
console.log(
JSON.stringify({
state: proof.state,
public_assets_responses_and_hashes: checked,
public_entry_current: true,
}),
);