40 lines
2.9 KiB
Python
40 lines
2.9 KiB
Python
from pathlib import Path
|
|
import hashlib, json, shutil, subprocess
|
|
|
|
ROOT=Path('C:/laragon/www/portal-investidor')
|
|
OUT=ROOT/'outputs/investmoz-classificacao-multidimensional-QA-20261015'
|
|
BASE=Path('C:/Users/macbook/.config/investmoz/fintech-QA-20261015/source')
|
|
HOME=Path('C:/Users/macbook/.config/investmoz/classificacao-QA-20261015')
|
|
QA=HOME/'source'
|
|
PG=Path('C:/Program Files/PostgreSQL/17/bin')
|
|
DB='classification_20261015_test'
|
|
def digest(p): return hashlib.sha256(p.read_bytes()).hexdigest()
|
|
OUT.mkdir(parents=True,exist_ok=True)
|
|
baseline={str(p.relative_to(ROOT)).replace('\\','/'):digest(p) for folder in ['app','config','routes','database','resources','public/build'] for p in (ROOT/folder).rglob('*') if p.is_file()}
|
|
(OUT/'ATIVO-FICHEIROS-ANTES.json').write_text(json.dumps(baseline,indent=2),encoding='utf8')
|
|
if QA.exists(): raise RuntimeError('QA already exists; inspect before continuing')
|
|
HOME.mkdir(parents=True,exist_ok=True)
|
|
QA.mkdir()
|
|
for name in ['app','config','routes','database','resources','bootstrap']:
|
|
shutil.copytree(ROOT/name,QA/name)
|
|
# Runtime files remain private; no junction to active storage/public/bootstrap cache.
|
|
shutil.copytree(BASE/'storage',QA/'storage')
|
|
shutil.copytree(BASE/'public',QA/'public')
|
|
for n in ['artisan','composer.json','composer.lock','package.json','package-lock.json','tsconfig.json','vite.config.ts','components.json']:
|
|
shutil.copy2(ROOT/n,QA/n)
|
|
shutil.copy2(BASE/'vite.delivery.config.ts',QA/'vite.delivery.config.ts')
|
|
for n in ['vendor','node_modules']:
|
|
subprocess.run(['powershell','-NoProfile','-Command',f"New-Item -ItemType Junction -Path '{QA/n}' -Target '{ROOT/n}' | Out-Null"],check=True)
|
|
# Snapshot ONLY the isolated QA database, with explicit loopback/port/database guards.
|
|
assert DB.endswith('_test') and DB!='investemoz'
|
|
dump=HOME/'qa-before.dump'
|
|
common=['-h','127.0.0.1','-p','55441','-U','postgres']
|
|
subprocess.run([str(PG/'pg_dump.exe'),*common,'-d','legacy_trio_20261015_test','-Fc','-f',str(dump)],check=True)
|
|
subprocess.run([str(PG/'createdb.exe'),*common,DB],check=True)
|
|
subprocess.run([str(PG/'pg_restore.exe'),*common,'-d',DB,'--exit-on-error','--no-owner','--no-privileges',str(dump)],check=True)
|
|
boot=(ROOT/'outputs/investmoz-fintech-investimento-QA-20261015/boot-QA.php').read_text(encoding='utf8').replace(str(BASE).replace('\\','/'),str(QA).replace('\\','/')).replace('legacy_trio_20261015_test',DB).replace('18518','18519').replace('fintech_delta_qa','classification_delta_qa')
|
|
(OUT/'boot-QA.php').write_text(boot,encoding='utf8')
|
|
shutil.copy2(ROOT/'outputs/investmoz-fintech-investimento-QA-20261015/router-QA.php',OUT/'router-QA.php')
|
|
(OUT/'QA-ISOLAMENTO.json').write_text(json.dumps({'database':DB,'host':'127.0.0.1','port':55441,'source':str(QA),'url':'http://127.0.0.1:18519','dump_sha256':digest(dump),'active_source_count':len(baseline),'active_changed':False},indent=2),encoding='utf8')
|
|
print(json.dumps({'ok':True,'database':DB,'protected_files':len(baseline)}))
|