Files
SGF/scripts/sgf-install-fiscal-rules.php
2026-11-11 09:00:17 +02:00

5 lines
2.4 KiB
PHP

<?php
$book='8085';require __DIR__.'/sgf-single-bootstrap.php';foreach([$run['root'].'/private/receipt-composition-b4093c6f6707/single-integration/20261110-190138-e1c57bb4/fiscal-rules-result.json',$run['root'].'/private/receipt-composition-b4093c6f6707/fiscal-rules-concurrency/result.json',$run['root'].'/private/receipt-composition-b4093c6f6707/single-integration/20261110-190357-58ef4f30/fiscal-rules-boundaries.json']as$file)if((json_decode(file_get_contents($file),true)['passed']??false)!==true)throw new LogicException('Require valid affected proofs');if(!is_file($s['root'].'/fiscal-rules-backup-pointer.json')||!$host->getSchemaBuilder()->hasTable('fr_events'))throw new LogicException('Require backup/approved setup');
$files=['app/Modules/Services/FiscalRuleExpression.php','app/Modules/Services/FiscalRules.php','app/Modules/Services/Http/FiscalRulesController.php','app/Shared/Context/ModuleNavigation.php','app/Modules/Identity/Services/IdentityWorkflow.php','routes/web.php','resources/data/fiscal-rule-qa.json','resources/views/fiscal/rules.blade.php','public/sgf-fiscal-rules.mjs'];foreach($files as$file)if(str_ends_with($file,'.php'))(new Symfony\Component\Process\Process([PHP_BINARY,'-l',$repo.'/'.$file]))->mustRun();$build=$run['root'].'/private/single-fiscal-rules-build-20261110';if(!is_file($build.'/manifest.json'))throw new LogicException('Private build required');
$hashes=[];$copy=function($src,$file)use($s,$work,&$hashes){$dest=$s['app'].'/'.$file;$backup=$work.'/before/'.$file;if(is_file($dest)){if(!is_dir(dirname($backup)))mkdir(dirname($backup),0700,true);copy($dest,$backup);}if(!is_dir(dirname($dest)))mkdir(dirname($dest),0700,true);copy($src,$dest);$hashes[$file]=hash_file('sha256',$dest);};foreach($files as$file)$copy($repo.'/'.$file,$file);$config=$work.'/fiscal_rules_qa.php';file_put_contents($config,"<?php\nreturn ".var_export(['enabled'=>true,'source_sha256'=>hash_file('sha256',$repo.'/resources/data/fiscal-rule-qa.json')],true).";\n");$copy($config,'config/fiscal_rules_qa.php');foreach(glob($build.'/assets/*')as$file)$copy($file,'public/build/assets/'.basename($file));$copy($build.'/manifest.json','public/build/manifest.json');file_put_contents($work.'/fiscal-rules-installation.json',json_encode(['passed'=>true,'hashes'=>$hashes,'cache_cleared'=>false,'new_demo'=>false,'native_writes'=>0],JSON_PRETTY_PRINT));echo json_encode(['passed'=>true,'proof'=>$work.'/fiscal-rules-installation.json']).PHP_EOL;