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>
39 lines
1.8 KiB
PHP
39 lines
1.8 KiB
PHP
<?php
|
|
|
|
use Illuminate\Contracts\Console\Kernel;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
$host = getenv('SOURCING_CLONE');
|
|
$work = getenv('SOURCING_WORK');
|
|
require $host.'/vendor/autoload.php';
|
|
$app = require $host.'/bootstrap/app.php';
|
|
$app->make(Kernel::class)->bootstrap();
|
|
try {
|
|
$db = DB::connection();
|
|
if (! preg_match('/^sgf_sourcing_test_[a-f0-9]{12}$/D', $db->getDatabaseName())) {
|
|
throw new RuntimeException('Copy only');
|
|
}
|
|
$fixture = json_decode(file_get_contents($work.'/fixture.json'), true);
|
|
$command = $argv[1];
|
|
if (in_array($command, ['revoke-evaluate', 'restore-evaluate', 'revoke-propose', 'restore-propose', 'revoke-view', 'restore-view'])) {
|
|
$right = str_contains($command, 'evaluate') ? 'purchasing_sourcing.evaluate' : (str_contains($command, 'propose') ? 'purchasing_sourcing.propose' : 'purchasing_requisitions.view');
|
|
$id = str_contains($command, 'evaluate') ? $fixture['user_id'] : (str_contains($command, 'propose') ? 2 : 3);
|
|
$scope = ['user_id' => $id, 'tenant_id' => 1, 'company_id' => 1, 'unit_id' => 1, 'permission' => $right];
|
|
if (str_starts_with($command, 'revoke')) {
|
|
$db->table('permission_grants')->where($scope)->delete();
|
|
} else {
|
|
$db->table('permission_grants')->insertOrIgnore($scope + ['created_at' => now(), 'updated_at' => now()]);
|
|
}
|
|
} elseif ($command === 'fail-on') {
|
|
file_put_contents($host.'/storage/framework/sourcing-failure.fixture', 'isolated failure injection');
|
|
} elseif ($command === 'fail-off') {
|
|
unlink($host.'/storage/framework/sourcing-failure.fixture');
|
|
} else {
|
|
throw new RuntimeException('Unsupported fixture control');
|
|
}
|
|
echo json_encode(['ok' => true]);
|
|
} catch (Throwable $e) {
|
|
fwrite(STDERR, $e->getMessage());
|
|
exit(1);
|
|
}
|