Files
compras/scripts/compare-compras-installation.php
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

66 lines
3.3 KiB
PHP

<?php
use App\Services\StandaloneRuntime;
use App\Services\WorkContext;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Schema;
$root = dirname(__DIR__);
require $root.'/vendor/autoload.php';
if (($argv[1] ?? '') === '--local-read-only') {
$settings = json_decode(file_get_contents('C:/laragon/data/sgf-tempo/secrets/payables-demo-compras.json'), true, 32, JSON_THROW_ON_ERROR);
foreach ([...$settings, 'APP_CONFIG_CACHE' => $root.'/storage/framework/absent-comparison-config.php',
'PGOPTIONS' => '-c default_transaction_read_only=on', 'CACHE_STORE' => 'array', 'SESSION_DRIVER' => 'array'] as $key => $value) {
putenv($key.'='.$value);
$_ENV[$key] = $_SERVER[$key] = $value;
}
} elseif (($argv[1] ?? '') !== '--public-read-only') {
throw new LogicException('Explicit read-only comparison required');
}
$app = require $root.'/bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
DB::statement('SET default_transaction_read_only=on');
$runtime = app(StandaloneRuntime::class);
$runtime->configure(DB::connection());
$runtime->assertLoadedPackages();
$features = [];
foreach (StandaloneRuntime::FEATURES as $feature) {
$features[$feature] = $runtime->requested($feature);
}
$routes = [];
foreach (Route::getRoutes() as $route) {
if (str_starts_with($route->uri(), 'avaliar') || str_starts_with($route->uri(), '_')) {
continue;
}
$routes[$route->uri().' '.implode('|', $route->methods())] = $route->getActionName();
}
ksort($routes);
$components = [];
foreach (['standalone-runtime', 'inventory_conversion', 'order_cancellation'] as $key) {
$components[$key] = config($key.'.enabled');
}
$tenants = DB::table('tenants')->select('work_context_policy')->get()->map(fn ($row) => $row->work_context_policy === null ? null : json_decode($row->work_context_policy, true))->all();
$flags = [];
$collectFlags = function (array $values, string $prefix = '') use (&$collectFlags, &$flags): void {
foreach ($values as $key => $value) {
$path = $prefix.$key;
if (is_array($value)) {
$collectFlags($value, $path.'.');
} elseif (is_bool($value) && preg_match('/(?:enabled|synthetic_only|prepare_only|enforced)$/D', (string) $key)) {
$flags[$path] = $value;
}
}
};
$collectFlags(config()->all());
ksort($flags);
echo json_encode(['state' => 'passed', 'runtime_enabled' => $runtime->enabled(), 'features' => $features,
'deployment_flags' => $flags,
'history_schema' => ['pa_history_imports' => Schema::hasTable('pa_history_imports'), 'pa_imported_payments' => Schema::hasTable('pa_imported_payments')],
'pending_application_migrations' => array_values(array_diff(array_map(fn ($file) => basename($file, '.php'), glob($root.'/database/migrations/*.php')), DB::table('migrations')->pluck('migration')->all())),
'routes' => $routes, 'component_flags' => $components, 'company_context_policies' => $tenants,
'context_entitlements_configured' => count(config('work_context.entitlements', [])) > 0,
'operational_contexts' => array_combine(array_keys(WorkContext::OPTIONS), array_map(fn ($key) => WorkContext::operational($key), array_keys(WorkContext::OPTIONS))),
'business_data_changed' => false], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR).PHP_EOL;