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

36 lines
2.6 KiB
Python

from pathlib import Path
import re,json
ROOT=Path(__file__).resolve().parent.parent
PRIVATE=ROOT/'storage/app/private/investmoz-v2/portal-audit'
plan=json.loads((PRIVATE/'country-c110-source-latest.json').read_text())
SOURCE=Path(plan['source']);OUT=Path(plan['output'])
entries=['resources/js/pages/investment/profile.tsx','resources/js/pages/investment/submission.tsx','resources/js/pages/management/opportunity-install.tsx']
def graph(base):
seen=set();queue=[base/p for p in entries]
while queue:
p=queue.pop()
if p in seen or not p.is_file():continue
seen.add(p)
for spec in re.findall(r'(?:from\s*|import\s*\()\s*[\'\"]([^\'\"]+)[\'\"]',p.read_text(encoding='utf-8')):
q=base/'resources/js'/spec[2:] if spec.startswith('@/') else p.parent/spec if spec.startswith('.') else None
if q is None:continue
for candidate in [q,q.with_suffix('.tsx'),q.with_suffix('.ts'),q/'index.tsx',q/'index.ts']:
if candidate.is_file():queue.append(candidate.resolve());break
calls=[]
for p in sorted(seen):
for i,line in enumerate(p.read_text(encoding='utf-8').splitlines(),1):
if re.search(r'(?:crypto|globalThis\.crypto)\.randomUUID\(',line):calls.append({'file':p.relative_to(base).as_posix(),'line':i})
return {'dependency_files':len(seen),'calls':calls}
before=graph(ROOT);after=graph(SOURCE)
assert len(before['calls'])==1 and after['calls']==[]
excluded=[]
for p in (ROOT/'resources/js').rglob('*'):
if p.suffix not in ['.ts','.tsx']:continue
for i,line in enumerate(p.read_text(encoding='utf-8').splitlines(),1):
if re.search(r'(?:crypto|globalThis\.crypto)\.randomUUID\(',line) and p.relative_to(ROOT).as_posix() not in {x['file'] for x in before['calls']}:
excluded.append({'file':p.relative_to(ROOT).as_posix(),'line':i,'scope':'Outside COUNTRY02 mounted consumers; unchanged, no activation or acceptance implied'})
result={'entries':entries,'before':before,'after':after,'shared_installer_consumers':['/management/opportunity-management-install','/management/opportunity-resources-install','/management/opportunity-resources-install/organization-country'],'other_occurrences':excluded,'excluded_occurrences':len(excluded),'live_sources_modified':False,'no_Math_random_or_timestamp_key':True}
(OUT/'inventario-uuid.json').write_text(json.dumps(result,indent=2),encoding='utf-8')
print(json.dumps({'dependency_files':after['dependency_files'],'package_calls_before':len(before['calls']),'package_calls_after':len(after['calls']),'outside_occurrences':len(excluded)}))