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:
2026-11-30 23:01:42 +02:00
co-authored by Claude Opus 5.5
parent 9f719695e3
commit ec934455e7
148 changed files with 9455 additions and 2413 deletions
+65 -19
View File
@@ -6,45 +6,91 @@ import crypto from 'node:crypto';
import { spawnSync } from 'node:child_process';
const workspace = 'C:/laragon/www/compras';
if (path.resolve(process.cwd()) !== path.resolve(workspace)) throw Error('Compras workspace required');
if (path.resolve(process.cwd()) !== path.resolve(workspace))
throw Error('Compras workspace required');
const canonical = 'C:/laragon/www/sgf-tempo/packages';
const hash = bytes => crypto.createHash('sha256').update(bytes).digest('hex');
const hash = (bytes) => crypto.createHash('sha256').update(bytes).digest('hex');
const sources = ['finance-bundle/Bundle.php'];
for (const name of ['payables', 'general-ledger']) {
for (const file of ['bootstrap.php', 'README.md']) {
if (fs.existsSync(path.join(canonical, name, file))) sources.push(`${name}/${file}`);
if (fs.existsSync(path.join(canonical, name, file)))
sources.push(`${name}/${file}`);
}
for (const dir of ['src', 'ui']) {
for (const file of fs.readdirSync(path.join(canonical, name, dir)).sort()) {
if (!/^[A-Za-z0-9_-]+\.php$/.test(file)) throw Error('Unexpected runtime source');
for (const file of fs
.readdirSync(path.join(canonical, name, dir))
.sort()) {
if (!/^[A-Za-z0-9_-]+\.php$/.test(file))
throw Error('Unexpected runtime source');
sources.push(`${name}/${dir}/${file}`);
}
}
}
const content = sources.map(source => {
const actual = path.join(canonical, source);
if (!fs.lstatSync(actual).isFile() || fs.lstatSync(actual).isSymbolicLink()) throw Error('Regular runtime files required');
return { file: source === 'finance-bundle/Bundle.php' ? 'Bundle.php' : source, bytes: fs.readFileSync(actual) };
}).sort((a, b) => a.file.localeCompare(b.file));
const content = sources
.map((source) => {
const actual = path.join(canonical, source);
if (
!fs.lstatSync(actual).isFile() ||
fs.lstatSync(actual).isSymbolicLink()
)
throw Error('Regular runtime files required');
return {
file:
source === 'finance-bundle/Bundle.php' ? 'Bundle.php' : source,
bytes: fs.readFileSync(actual),
};
})
.sort((a, b) => a.file.localeCompare(b.file));
const files = content.map(({ file, bytes }) => ({ file, sha256: hash(bytes) }));
const manifest = JSON.stringify({ contract: 'COMMON-FINANCE-BUNDLE-v1', synthetic_only: true, files }, null, 2) + '\n';
const manifest =
JSON.stringify(
{ contract: 'COMMON-FINANCE-BUNDLE-v1', synthetic_only: true, files },
null,
2,
) + '\n';
const pin = hash(manifest);
const root = path.join(workspace, 'storage/framework/testing', `requisition-ledger-runtime-qa-${pin.slice(0, 16)}`);
const root = path.join(
workspace,
'storage/framework/testing',
`requisition-ledger-runtime-qa-${pin.slice(0, 16)}`,
);
if (!fs.existsSync(root)) {
fs.mkdirSync(root);
for (const { file, bytes } of content) {
fs.mkdirSync(path.dirname(path.join(root, file)), { recursive: true });
fs.writeFileSync(path.join(root, file), bytes, { flag: 'wx' });
}
fs.writeFileSync(path.join(root, 'manifest.json'), manifest, { flag: 'wx' });
fs.writeFileSync(path.join(root, 'manifest.json'), manifest, {
flag: 'wx',
});
}
if (hash(fs.readFileSync(path.join(root, 'manifest.json'))) !== pin) throw Error('Existing artefact differs; never overwrite');
if (hash(fs.readFileSync(path.join(root, 'manifest.json'))) !== pin)
throw Error('Existing artefact differs; never overwrite');
// The caller fixes this manifest and loader hash before loading any executable.
for (const { file, sha256 } of files) {
const target = path.join(root, file);
if (!fs.lstatSync(target).isFile() || fs.lstatSync(target).isSymbolicLink() || hash(fs.readFileSync(target)) !== sha256) throw Error('Artefact byte mismatch');
if (
!fs.lstatSync(target).isFile() ||
fs.lstatSync(target).isSymbolicLink() ||
hash(fs.readFileSync(target)) !== sha256
)
throw Error('Artefact byte mismatch');
}
const code = 'require $argv[1]."/Bundle.php"; echo json_encode(Tempo\\Finance\\Composition\\Bundle::verify($argv[1],$argv[2]),JSON_THROW_ON_ERROR);';
const checked = spawnSync('php', ['-r', code, root, pin], { windowsHide: true, encoding: 'utf8' });
if (checked.status !== 0) throw Error('Existing common bundle verifier refused the private artefact');
console.log(JSON.stringify({ root, manifest_sha256: pin, files: files.length, verified: true, synthetic_only: true, installed_or_activated: false }));
const code =
'require $argv[1]."/Bundle.php"; echo json_encode(Tempo\\Finance\\Composition\\Bundle::verify($argv[1],$argv[2]),JSON_THROW_ON_ERROR);';
const checked = spawnSync('php', ['-r', code, root, pin], {
windowsHide: true,
encoding: 'utf8',
});
if (checked.status !== 0)
throw Error('Existing common bundle verifier refused the private artefact');
console.log(
JSON.stringify({
root,
manifest_sha256: pin,
files: files.length,
verified: true,
synthetic_only: true,
installed_or_activated: false,
}),
);