Files
Investidor-V2/tools/desk-activation-evidence.php
nala 1106509116
tests / ci (push) Canceled after 0s
vrsao 2
2026-10-08 14:02:01 +02:00

46 lines
2.5 KiB
PHP

<?php
use App\Services\VirtualDeskInstallation;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Support\Facades\DB;
require dirname(__DIR__).'/vendor/autoload.php';
$root = dirname(__DIR__);
$read = function (string $path): string {
$bytes = file_get_contents($path);
if (str_starts_with($bytes, "\xff\xfe")) {
return mb_convert_encoding(substr($bytes, 2), 'UTF-8', 'UTF-16LE');
}
return $bytes;
};
$tests = json_decode(trim($read($root.'/storage/app/private/investmoz-v2/second-phpunit.txt')), true, 512, JSON_THROW_ON_ERROR);
if (($tests['tool'] ?? null) !== 'phpunit' || ($tests['result'] ?? null) !== 'passed') {
throw new RuntimeException('Full QA success evidence required.');
}
foreach (['second-phpstan.txt' => '"errors":0', 'second-types.txt' => 'tsc --noEmit', 'second-build.txt' => 'built in', 'second-frontend.txt' => 'pass 151'] as $name => $needle) {
if (! str_contains($read($root.'/storage/app/private/investmoz-v2/'.$name), $needle)) {
throw new RuntimeException('Required QA evidence missing: '.$name);
}
}
$app = require $root.'/bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
$db = DB::connection();
$db->beginTransaction();
$db->statement('SET TRANSACTION READ ONLY');
$identity = $db->selectOne('select current_database() as database, inet_server_port() as port');
if ($identity->database !== 'investemoz' || (int) $identity->port !== 5432) {
throw new RuntimeException('Active read-only identity rejected.');
}
$installation = app(VirtualDeskInstallation::class);
$qa = ['passed' => true, 'verified_at' => gmdate('c'), 'code_hash' => $installation->fingerprint(),
'database' => 'investmoz_v2_20261008_test', 'port' => 55441, 'tests' => $tests,
'limitation' => 'Three real ClamD integration tests skipped because no local service is available. No real scan asserted.'];
file_put_contents(storage_path('app/private/virtual-desk/guidance-qa-evidence.json'), json_encode($qa, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));
$preview = $installation->preview();
$db->rollBack();
file_put_contents(storage_path('app/private/virtual-desk/activation-preview.json'), json_encode($preview, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));
echo json_encode(['target' => $preview['target'], 'pending' => $preview['pendingMigrations'], 'backup' => $preview['backupVerified'],
'qa' => $preview['qaVerified'], 'compatibility' => $preview['compatibilityVerified'], 'scanner' => $preview['scanner'],
'page' => '/management/balcao-install'], JSON_THROW_ON_ERROR);