Files
SGF/scripts/sgf-install-workshop-stock.php
T
2026-11-11 09:00:17 +02:00

11 lines
2.4 KiB
PHP

<?php
use Symfony\Component\Process\Process;
$book='8085';require __DIR__.'/sgf-single-bootstrap.php';$pins=json_decode(file_get_contents($s['root'].'/single-binding-pins.json'),true);$build=$run['root'].'/private/single-stock-ui-build-20261110';
$files=['app/Modules/Workshop/WorkshopStock.php','app/Modules/Workshop/ComposedWorkshopStockBook.php','app/Modules/Workshop/Http/WorkshopStockController.php','packages/general-ledger/src/StockValuation.php','packages/inventory-issue/bootstrap.php','packages/inventory-issue/src/IssueMovementWriter.php','packages/inventory-return/bootstrap.php','packages/inventory-return/src/DeliveryReturnWriter.php'];$before=[];$hashes=[];
$copy=function($source,$relative)use($s,$work,&$before,&$hashes){$target=$s['app'].'/'.$relative;$backup=$work.'/before/'.$relative;if(is_file($target)){if(!is_dir(dirname($backup)))mkdir(dirname($backup),0700,true);$before[$relative]=hash_file('sha256',$target);copy($target,$backup);}else $before[$relative]=null;if(!is_dir(dirname($target)))mkdir(dirname($target),0700,true);copy($source,$target);$hashes[$relative]=hash_file('sha256',$target);};
foreach($files as $file)(new Process([PHP_BINARY,'-l',$repo.'/'.$file]))->mustRun();foreach($files as $file)$copy($repo.'/'.$file,$file);
foreach(glob($build.'/assets/*') as $file)$copy($file,'public/build/assets/'.basename($file));$copy($build.'/manifest.json','public/build/manifest.json');
$configuration=require $s['app'].'/config/sgf_single_installation.php';$configuration['bindings_sha256']=$pins['single-bindings.json'];
foreach(['sgf_single_installation'=>$configuration,'stock_operations'=>['enabled'=>true,'profile_sha256'=>$pins['stock-operations-binding.json']],'workshop_stock'=>['synthetic_sources'=>[],'composed_enabled'=>true,'composed_sha256'=>$pins['workshop-stock-binding.json']]] as $name=>$data){$source=$work.'/'.$name.'.php';file_put_contents($source,"<?php\nreturn ".var_export($data,true).";\n");$copy($source,'config/'.$name.'.php');}
file_put_contents($work.'/workshop-stock-installation.json',json_encode(['passed'=>true,'installation'=>$tag,'source_hashes'=>$hashes,'before'=>$before,'native_bundle_changed'=>false,'host_balance_created'=>false,'cache_cleared'=>false,'new_demo'=>false,'browser_visual_review'=>false],JSON_PRETTY_PRINT));echo json_encode(['passed'=>true,'files'=>count($hashes),'proof'=>$work.'/workshop-stock-installation.json']).PHP_EOL;