25 lines
1.9 KiB
Python
25 lines
1.9 KiB
Python
from pathlib import Path
|
|
from datetime import datetime,timezone
|
|
import hashlib,json,re
|
|
ROOT=Path(__file__).resolve().parents[2];PRIVATE=ROOT/'storage/app/private/investmoz-v2/portal-audit';OUT=Path(__file__).resolve().parent
|
|
plans={'qa18118':json.loads((PRIVATE/'internal-designation-plan.json').read_text()),'qa18445':json.loads((PRIVATE/'portal-stability-latest.json').read_text())}
|
|
records={}
|
|
def sha(p):return hashlib.sha256(p.read_bytes()).hexdigest()
|
|
for label,plan in plans.items():
|
|
qa=Path(plan['source']);assert qa.resolve().is_relative_to(PRIVATE.resolve())
|
|
env=qa/('.env.stability-consumers' if label=='qa18445' else '.env')
|
|
variables={}
|
|
for line in env.read_text().splitlines():
|
|
m=re.match(r'^([A-Z_]+)=(.*)$',line)
|
|
if m and (m[1] in ['APP_ENV','APP_URL','DB_DATABASE','DB_PORT','SESSION_COOKIE','SESSION_SECURE_COOKIE','QUEUE_CONNECTION','CACHE_STORE','SESSION_DRIVER'] or m[1].startswith('PORTAL_') and m[1].endswith('_ENABLED')):variables[m[1]]=m[2].strip('"\'')
|
|
differences=[]
|
|
for folder in ['app','config','routes','resources']:
|
|
for p in (ROOT/folder).rglob('*'):
|
|
if not p.is_file() or any(part in ['actions','wayfinder'] for part in p.relative_to(ROOT).parts) or '/resources/js/routes/' in p.as_posix():continue
|
|
rel=p.relative_to(ROOT).as_posix();other=qa/rel
|
|
if not other.is_file() or sha(p)!=sha(other):differences.append(rel)
|
|
records[label]={'source':str(qa),'configuration':variables,'source_differences_from_active':differences,'same_production_manifest':sha(ROOT/'public/build/manifest.json')==sha(qa/'public/build/manifest.json') if (qa/'public/build/manifest.json').exists() else False}
|
|
proof={'at':datetime.now(timezone.utc).isoformat(),'read_only':True,'environments':records}
|
|
(OUT/'environment-differences.json').write_text(json.dumps(proof,ensure_ascii=False,indent=2),encoding='utf-8')
|
|
print(json.dumps(proof))
|