from pathlib import Path import hashlib,json,subprocess,time R=Path('C:/laragon/www/portal-investidor');O=Path(__file__).parent;Q=Path('C:/Users/macbook/.config/investmoz/classificacao-QA-20261015/source') def sha(p):return hashlib.sha256(p.read_bytes()).hexdigest() changes=[] for folder in ['app','config','routes','database','resources']: for p in (Q/folder).rglob('*'): if p.is_file(): rel=p.relative_to(Q);a=R/rel if not a.exists() or a.read_bytes()!=p.read_bytes():changes.append(rel.as_posix()) proof={'commands':[],'active_changed':[],'source_count':len(changes)} php='C:/laragon/bin/php/php-8.5.11-Win32-vs17-x64/php.exe' for file in changes: if file.endswith('.php'): c=[php,'-l',str(Q/file)];p=subprocess.run(c,capture_output=True,text=True,encoding='utf8');proof['commands'].append({'command':['php','-l',file],'exit_code':p.returncode});assert p.returncode==0,p.stdout files=[f for f in changes if f.endswith('.tsx')] for name,args in [('lint',['exec','--','vp','lint',*files]),('typescript',['exec','tsc','--','noEmit'])]: if name=='typescript':args=['exec','tsc','--','--noEmit','--pretty','false'] p=subprocess.run(['cmd','/c','npm.cmd',*args],cwd=Q,capture_output=True,text=True,encoding='utf8');(O/(name+'.log')).write_text(p.stdout+p.stderr,encoding='utf8');proof['commands'].append({'command':['npm.cmd',*args],'exit_code':p.returncode,'log':name+'.log'});assert p.returncode==0,p.stdout+p.stderr manifest=json.loads((Q/'public/build/manifest.json').read_text(encoding='utf8')) referenced=set() for v in manifest.values(): referenced.add(v['file']);referenced.update(v.get('css',[]));referenced.update(v.get('assets',[])) for f in referenced:assert (Q/'public/build'/f).is_file(),f proof['build']={'manifest_sha256':sha(Q/'public/build/manifest.json'),'referenced_files':len(referenced),'all_present':True,'build_command':'npm.cmd exec vite build -- --config vite.delivery.config.ts','last_observed_exit_code':0,'harness_config_excluded_from_delivery':True} baseline=json.loads((O/'ATIVO-FICHEIROS-ANTES.json').read_text(encoding='utf8')) for file,expected in baseline.items(): if not (R/file).is_file() or sha(R/file)!=expected:proof['active_changed'].append(file) assert not proof['active_changed'],proof['active_changed'] proof['protected_active_files_unchanged']=len(baseline) proof['proof_files']={f:sha(O/f) for f in ['HTTP-DELTA-QA.json','SERVICOS-DELTA-QA.json','REVERSAO-COMPAT-QA.json']} proof['result']='passed' (O/'VERIFICACAO-LOCAL.json').write_text(json.dumps(proof,ensure_ascii=False,indent=2),encoding='utf8') print(json.dumps({'result':'passed','syntax_files':sum(f.endswith('.php')for f in changes),'sources':len(changes),'protected_active_files':len(baseline),'build_files_verified':len(referenced)}))