@@ -5,14 +5,26 @@ use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
require dirname(__DIR__).'/vendor/autoload.php';
|
||||
if (! in_array('--read-only', $argv, true)) {
|
||||
$installed = in_array('--installed-read-only', $argv, true);
|
||||
if (! in_array('--read-only', $argv, true) && ! $installed) {
|
||||
throw new LogicException('READ_ONLY_ACTIVATION_PREFLIGHT_REQUIRED');
|
||||
}
|
||||
$root = dirname(__DIR__);
|
||||
$plan = json_decode(file_get_contents($root.'/docs/proofs/compras-standalone-pilot-activation-proposal.json'), true, 512, JSON_THROW_ON_ERROR);
|
||||
$sourcePath = 'C:/laragon/data/sgf-tempo/secrets/payables-demo-compras.json';
|
||||
$source = json_decode(file_get_contents($sourcePath), true, 32, JSON_THROW_ON_ERROR);
|
||||
if (! hash_equals($plan['active_settings_sha256'], hash_file('sha256', $sourcePath))
|
||||
$expectedSettings = $plan['active_settings_sha256'];
|
||||
$expectedManifest = $plan['frontend']['previous_manifest_sha256'];
|
||||
if ($installed) {
|
||||
$activation = json_decode(file_get_contents($root.'/docs/proofs/compras-standalone-pilot-activation.json'), true, 32, JSON_THROW_ON_ERROR);
|
||||
$previous = json_decode(file_get_contents($activation['backup_directory'].'/settings.before.private.json'), true, 32, JSON_THROW_ON_ERROR);
|
||||
if ($activation['state'] !== 'passed' || $source !== [...$previous, ...$plan['proposed_runtime_settings']]) {
|
||||
throw new LogicException('ACTIVATION_POSTCHECK_SETTINGS_DIFFER');
|
||||
}
|
||||
$expectedSettings = hash_file('sha256', $sourcePath);
|
||||
$expectedManifest = $plan['frontend']['manifest_sha256'];
|
||||
}
|
||||
if (! hash_equals($expectedSettings, hash_file('sha256', $sourcePath))
|
||||
|| $source['APP_ENV'] !== 'payable-testing' || $source['DB_HOST'] !== '127.0.0.1'
|
||||
|| realpath($source['HOST_ROOT']) !== realpath($root)
|
||||
|| ! preg_match('/^compras_receipts_test_([a-f0-9]{12})$/D', $source['DB_DATABASE'], $match)
|
||||
@@ -22,7 +34,7 @@ if (! hash_equals($plan['active_settings_sha256'], hash_file('sha256', $sourcePa
|
||||
}
|
||||
$assets = $root.'/'.$plan['frontend']['candidate_root'];
|
||||
if (! hash_equals($plan['frontend']['manifest_sha256'], hash_file('sha256', $assets.'/manifest.json'))
|
||||
|| ! hash_equals($plan['frontend']['previous_manifest_sha256'], hash_file('sha256', $root.'/public/build/manifest.json'))) {
|
||||
|| ! hash_equals($expectedManifest, hash_file('sha256', $root.'/public/build/manifest.json'))) {
|
||||
throw new LogicException('ACTIVATION_PREFLIGHT_MANIFEST_CHANGED');
|
||||
}
|
||||
foreach ($plan['frontend']['files'] as $file => $hash) {
|
||||
@@ -51,12 +63,13 @@ $runtime->assertLoadedPackages();
|
||||
if (! $runtime->enabled() || count(array_filter(StandaloneRuntime::FEATURES, fn ($name) => $runtime->requested($name))) !== 24) {
|
||||
throw new LogicException('ACTIVATION_PREFLIGHT_CAPABILITIES_INCOMPLETE');
|
||||
}
|
||||
if (! hash_equals($plan['active_settings_sha256'], hash_file('sha256', $sourcePath))) {
|
||||
if (! hash_equals($expectedSettings, hash_file('sha256', $sourcePath))) {
|
||||
throw new LogicException('ACTIVATION_PREFLIGHT_SETTINGS_CHANGED');
|
||||
}
|
||||
$result = ['date' => gmdate('c'), 'state' => 'passed', 'database_enforced_read_only' => true,
|
||||
'all_24_capabilities_start_with_pinned_installed_packages' => true, 'source_instance_preserved' => true,
|
||||
'frontend_assets_verified' => count($plan['frontend']['files']), 'active_settings_changed' => false,
|
||||
'assets_published' => false, 'new_grants_or_business_commands' => false];
|
||||
file_put_contents($root.'/docs/proofs/compras-standalone-pilot-activation-preflight.json', json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR).PHP_EOL);
|
||||
'mode' => $installed ? 'installed_configuration_read_only_postcheck' : 'prospective_read_only_preflight',
|
||||
'assets_published' => $installed, 'new_grants_or_business_commands' => false];
|
||||
file_put_contents($root.'/docs/proofs/'.($installed ? 'compras-standalone-pilot-activation-check.json' : 'compras-standalone-pilot-activation-preflight.json'), json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR).PHP_EOL);
|
||||
echo json_encode($result, JSON_THROW_ON_ERROR).PHP_EOL;
|
||||
|
||||
Reference in New Issue
Block a user