25 lines
3.6 KiB
Python
25 lines
3.6 KiB
Python
from pathlib import Path
|
|
import json,shutil,subprocess
|
|
out=Path(__file__).parent.resolve();root=out.parents[1];private=Path('C:/Users/macbook/.config/investmoz/navegacao-consolidacao-QA-20261016');source=private/'source';compat=private/'compatibility-source';assert not compat.exists()
|
|
shutil.copytree(source,compat,ignore=shutil.ignore_patterns('vendor','node_modules','storage','.git','cache'))
|
|
for name in ['vendor','node_modules']:subprocess.run(['cmd.exe','/d','/c','mklink','/J',str(compat/name),str(root/name)],check=True,capture_output=True)
|
|
for d in ['bootstrap/cache','storage/app/private','storage/framework/cache/data','storage/framework/views','storage/framework/sessions','storage/logs']:(compat/d).mkdir(parents=True,exist_ok=True)
|
|
files=json.loads((out/'source-files.json').read_text('utf-8'))
|
|
keep=['app/Services/InvestorContext.php','app/Services/InvestorContextConsumers.php','app/Services/InvestorPath.php','app/Services/VirtualDesk.php','app/Http/Controllers/InvestorContextController.php','app/Http/Controllers/VirtualDeskController.php','app/Http/Controllers/LandAssistanceController.php','app/Http/Controllers/InvestmentSubmissionController.php','app/Http/Requests/StoreLandAssistanceCaseRequest.php','database/migrations/2026_10_16_150000_create_investor_navigation_preferences.php','resources/js/lib/investor-context.ts','resources/js/lib/investor-path.ts','resources/js/components/dossier-prefill.tsx','resources/js/components/simulation-form.tsx','resources/js/pages/desk/request.tsx','resources/js/pages/land-assistance/form.tsx','resources/js/pages/investment/submission.tsx','resources/js/pages/investor-path/show.tsx']
|
|
for f in files:
|
|
if f in keep:continue
|
|
target=(compat/f).resolve();assert target.is_relative_to(compat.resolve())
|
|
if(root/f).is_file():shutil.copy2(root/f,target)
|
|
else:target.unlink()
|
|
# Only read-only access to existing context survives; no editing or installation endpoints remain enabled.
|
|
f=compat/'routes/investor-path.php';s=f.read_text('utf-8');where=" Route::get('/', [Path::class, 'index']);";assert where in s;s=s.replace(where,where+"\n Route::get('/{id}/contexto',[\\App\\Http\\Controllers\\InvestorContextController::class,'show'])->whereUuid('id');",1);f.write_text(s,'utf-8');keep.append('routes/investor-path.php')
|
|
f=compat/'resources/js/pages/investor-path/show.tsx';s=f.read_text('utf-8')
|
|
# Remove only the new edit link; preserved context and stale financial/request markers remain visible.
|
|
import re
|
|
s,n=re.subn(r'\{path.canWrite && \(\s*<Link[^>]*href=\{`/investimentos/\$\{path.case.id\}/contexto/editar`\}[^>]*>\s*Comparar e alterar contexto\s*</Link>\s*\)\}', '<p>Alteração de contexto suspensa pela reversão compatível; referências e histórico preservados.</p>',s,count=1);assert n==1;f.write_text(s,'utf-8')
|
|
env=(compat/'.env').read_text('utf-8').replace('navigation_consolidation_20261016_test','navigation_consolidation_restore_20261016_test').replace('18536','18538');(compat/'.env').write_text(env,'utf-8')
|
|
boot=(out/'boot-restored-QA.php').read_text('utf-8').replace(source.as_posix(),compat.as_posix());(out/'boot-compatibility-QA.php').write_text(boot,'utf-8')
|
|
(compat/'artisan').write_text("#!/usr/bin/env php\n<?php\ndefine('LARAVEL_START',microtime(true));require '"+(out/'boot-compatibility-QA.php').as_posix()+"';exit($app->handleCommand(new Symfony\\Component\\Console\\Input\\ArgvInput));\n",'utf-8')
|
|
(out/'COMPATIBILITY-FILES.json').write_text(json.dumps({'retained_sources':sorted(keep),'schema_retained':True,'editing_disabled':True,'business_sources_restored_from_QA':False},indent=2)+'\n','utf-8')
|
|
print('Compatibility source prepared against restored QA only; previous navigation restored, context writes suspended')
|