Files
Investidor-V2/tools/portal-internal-designation-build.py
T
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

27 lines
2.7 KiB
Python

from pathlib import Path
import json, hashlib, subprocess, os, sys
R=Path(__file__).resolve().parent.parent; P=R/'storage/app/private/investmoz-v2/portal-audit'
plan=json.loads((P/'internal-designation-plan.json').read_text()); old=json.loads((P/'onboarding-governance-plan.json').read_text()); S=Path(plan['source'])
assert S.parent==P and S.name.startswith('onboarding-qa-internal-') and plan['target']['port']==55441
files=sorted(set(row['path'] for row in old['files'])|{'app/Services/PortalInternalDesignation.php','app/Services/OpportunityManagement.php','app/Services/OpportunityProfileWorkflow.php','app/Http/Controllers/PortalProfileController.php','app/Services/OpportunityCanonicalContract.php','resources/js/pages/management/opportunity-draft.tsx','resources/js/types/profile-access.ts'})
previous=plan.get('files',[])
plan['files']=[{'path':f,'before_sha256':hashlib.sha256((R/f).read_bytes()).hexdigest() if (R/f).exists() else None,'after_sha256':hashlib.sha256((S/f).read_bytes()).hexdigest()} for f in files]
plan['delta_sha256']=hashlib.sha256(json.dumps(plan['files'],sort_keys=True).encode()).hexdigest()
env=dict(os.environ); env['PATH']='C:/laragon/bin/php/php-8.5.11-Win32-vs17-x64;C:/Users/macbook/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin;'+env.get('PATH','')
if '--backend-only' in sys.argv:
assert plan['production_build_passed'] and plan['production_manifest_sha256']==hashlib.sha256((S/'public/build/manifest.json').read_bytes()).hexdigest()
for row in previous:
if row['path'].startswith(('resources/','routes/')):assert row['after_sha256']==hashlib.sha256((S/row['path']).read_bytes()).hexdigest()
result_code=0
else:
with (P/'internal-designation-build.log').open('w',encoding='utf-8') as log:
result=subprocess.run(['C:/Users/macbook/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin/node.exe',str(R/'node_modules/vite-plus/bin/vp'),'build'],cwd=S,env=env,stdout=log,stderr=subprocess.STDOUT,timeout=300)
result_code=result.returncode
plan['production_build_passed']=result_code==0
if result_code==0:
plan['production_manifest_sha256']=hashlib.sha256((S/'public/build/manifest.json').read_bytes()).hexdigest()
plan['assets']=[{'path':str(f.relative_to(S)).replace('\\','/'),'sha256':hashlib.sha256(f.read_bytes()).hexdigest()} for f in sorted((S/'public/build').rglob('*')) if f.is_file()]
(P/'internal-designation-plan.json').write_text(json.dumps(plan,indent=2),encoding='utf-8')
print(json.dumps({'result':'passed' if result_code==0 else 'stopped','revision':plan['delta_sha256'][:12],'source_files':len(files),'active_application_changes':0,'active_database_writes':0}))
raise SystemExit(result_code)