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>
This commit is contained in:
@@ -2,53 +2,115 @@ import fs from 'node:fs/promises';
|
||||
import crypto from 'node:crypto';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
let plan = JSON.parse(await fs.readFile('docs/proofs/compras-standalone-pilot-activation-proposal.json', 'utf8'));
|
||||
let plan = JSON.parse(
|
||||
await fs.readFile(
|
||||
'docs/proofs/compras-standalone-pilot-activation-proposal.json',
|
||||
'utf8',
|
||||
),
|
||||
);
|
||||
let interfaceDelta = false;
|
||||
try {
|
||||
const result = JSON.parse(await fs.readFile('docs/proofs/analytics-print-publication.json', 'utf8'));
|
||||
const bytes = await fs.readFile('docs/proofs/analytics-print-publication-proposal.json');
|
||||
const result = JSON.parse(
|
||||
await fs.readFile(
|
||||
'docs/proofs/analytics-print-publication.json',
|
||||
'utf8',
|
||||
),
|
||||
);
|
||||
const bytes = await fs.readFile(
|
||||
'docs/proofs/analytics-print-publication-proposal.json',
|
||||
);
|
||||
const proposal = JSON.parse(bytes);
|
||||
const approval = JSON.parse(await fs.readFile('docs/proofs/analytics-print-publication-authorization.json', 'utf8'));
|
||||
const approval = JSON.parse(
|
||||
await fs.readFile(
|
||||
'docs/proofs/analytics-print-publication-authorization.json',
|
||||
'utf8',
|
||||
),
|
||||
);
|
||||
assert.equal(result.pilot_state ?? result.state, 'passed');
|
||||
assert.equal(approval.state, 'approved');
|
||||
assert.equal(approval.proposal_sha256, crypto.createHash('sha256').update(bytes).digest('hex'));
|
||||
assert.equal(
|
||||
approval.proposal_sha256,
|
||||
crypto.createHash('sha256').update(bytes).digest('hex'),
|
||||
);
|
||||
assert.equal(result.manifest_sha256, proposal.manifest_sha256);
|
||||
assert.equal(proposal.previous_manifest_sha256, plan.frontend.manifest_sha256);
|
||||
assert.equal(
|
||||
proposal.previous_manifest_sha256,
|
||||
plan.frontend.manifest_sha256,
|
||||
);
|
||||
plan = { ...plan, frontend: proposal };
|
||||
interfaceDelta = true;
|
||||
} catch (error) {
|
||||
if (error.code !== 'ENOENT') throw error;
|
||||
}
|
||||
const activation = JSON.parse(await fs.readFile('docs/proofs/compras-standalone-pilot-activation.json', 'utf8'));
|
||||
const activation = JSON.parse(
|
||||
await fs.readFile(
|
||||
'docs/proofs/compras-standalone-pilot-activation.json',
|
||||
'utf8',
|
||||
),
|
||||
);
|
||||
assert.equal(activation.state, 'passed');
|
||||
assert.equal(plan.target, 'http://127.0.0.1:8005');
|
||||
let verified = 0;
|
||||
const queue = Object.entries(plan.frontend.files);
|
||||
await Promise.all(Array.from({ length: 3 }, async () => {
|
||||
for (;;) {
|
||||
const entry = queue.shift();
|
||||
if (!entry) return;
|
||||
const [file, hash] = entry;
|
||||
assert.ok(file.startsWith('assets/') && !file.includes('..'));
|
||||
const response = await fetch(`${plan.target}/build/${file}`, { signal: AbortSignal.timeout(10000) });
|
||||
assert.equal(response.status, 200, file);
|
||||
assert.equal(crypto.createHash('sha256').update(new Uint8Array(await response.arrayBuffer())).digest('hex'), hash, file);
|
||||
verified++;
|
||||
}
|
||||
}));
|
||||
const response = await fetch('https://compras.tempo.co.mz/dashboard', { signal: AbortSignal.timeout(15000) });
|
||||
await Promise.all(
|
||||
Array.from({ length: 3 }, async () => {
|
||||
for (;;) {
|
||||
const entry = queue.shift();
|
||||
if (!entry) return;
|
||||
const [file, hash] = entry;
|
||||
assert.ok(file.startsWith('assets/') && !file.includes('..'));
|
||||
const response = await fetch(`${plan.target}/build/${file}`, {
|
||||
signal: AbortSignal.timeout(10000),
|
||||
});
|
||||
assert.equal(response.status, 200, file);
|
||||
assert.equal(
|
||||
crypto
|
||||
.createHash('sha256')
|
||||
.update(new Uint8Array(await response.arrayBuffer()))
|
||||
.digest('hex'),
|
||||
hash,
|
||||
file,
|
||||
);
|
||||
verified++;
|
||||
}
|
||||
}),
|
||||
);
|
||||
const response = await fetch('https://compras.tempo.co.mz/dashboard', {
|
||||
signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
assert.equal(response.status, 200);
|
||||
const html = await response.text();
|
||||
const bootstrap = html.match(/<script data-page="app" type="application\/json">([\s\S]*?)<\/script>/);
|
||||
const bootstrap = html.match(
|
||||
/<script data-page="app" type="application\/json">([\s\S]*?)<\/script>/,
|
||||
);
|
||||
assert.ok(bootstrap, 'Expected public Inertia bootstrap');
|
||||
const page = JSON.parse(bootstrap[1]);
|
||||
assert.equal(page.props.auth.user, null);
|
||||
assert.deepEqual(page.props.commonFinanceNavigation, { payments: false, ledger: false, configuration: false });
|
||||
const manifest = JSON.parse(await fs.readFile('public/build/manifest.json', 'utf8'));
|
||||
assert.deepEqual(page.props.commonFinanceNavigation, {
|
||||
payments: false,
|
||||
ledger: false,
|
||||
configuration: false,
|
||||
});
|
||||
const manifest = JSON.parse(
|
||||
await fs.readFile('public/build/manifest.json', 'utf8'),
|
||||
);
|
||||
const publicCurrent = html.includes(manifest['resources/js/app.tsx'].file);
|
||||
const proof = { date: new Date().toISOString(), state: publicCurrent ? 'passed' : 'pilot_passed_public_installation_pending', pilot_asset_responses_and_hashes: verified,
|
||||
public_domain_html_delivers_new_entry: publicCurrent, public_anonymous_identity_preserved: true,
|
||||
private_finance_navigation_not_exposed_publicly: true, new_grants_or_business_operations: false };
|
||||
await fs.writeFile(interfaceDelta ? 'docs/proofs/analytics-print-publication-http.json' : 'docs/proofs/compras-standalone-published-assets.json', JSON.stringify(proof, null, 2) + '\n');
|
||||
const proof = {
|
||||
date: new Date().toISOString(),
|
||||
state: publicCurrent
|
||||
? 'passed'
|
||||
: 'pilot_passed_public_installation_pending',
|
||||
pilot_asset_responses_and_hashes: verified,
|
||||
public_domain_html_delivers_new_entry: publicCurrent,
|
||||
public_anonymous_identity_preserved: true,
|
||||
private_finance_navigation_not_exposed_publicly: true,
|
||||
new_grants_or_business_operations: false,
|
||||
};
|
||||
await fs.writeFile(
|
||||
interfaceDelta
|
||||
? 'docs/proofs/analytics-print-publication-http.json'
|
||||
: 'docs/proofs/compras-standalone-published-assets.json',
|
||||
JSON.stringify(proof, null, 2) + '\n',
|
||||
);
|
||||
console.log(JSON.stringify(proof));
|
||||
if (!publicCurrent) process.exitCode = 1;
|
||||
|
||||
Reference in New Issue
Block a user