39 lines
3.3 KiB
Python
39 lines
3.3 KiB
Python
from pathlib import Path
|
|
import json, shutil
|
|
|
|
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'])
|
|
backup = (ROOT / 'tools/portal-country-candidate-backup.php').read_text(encoding='utf-8')
|
|
backup = backup.replace('$root = dirname(__DIR__);', "$candidateRoot = dirname(__DIR__);\n$root = 'C:/laragon/www/portal-investidor';")
|
|
backup = backup.replace("require $root.'/vendor/autoload.php';", "require $candidateRoot.'/qa-autoload.php';\nDotenv\\Dotenv::createImmutable($root)->safeLoad();")
|
|
backup = backup.replace("$app = require $root.'/bootstrap/app.php';", "$app = require $candidateRoot.'/bootstrap/app.php';")
|
|
backup = backup.replace('country-production-stage-latest.json','country-c110-production-stage-latest.json')
|
|
backup = backup.replace('country-candidate-backup-latest.json','country-c110-backup-latest.json')
|
|
backup = backup.replace("$proof = ['verified_at'", "$proof = ['source_code_hash' => '36f7722ce5a51abc6a246116afcab22ebc8167fa3d06e493920ad18c7afbfca8', 'candidate_source' => $candidateRoot, 'verified_at'")
|
|
(source / 'tools/portal-country-c110-backup.php').write_text(backup,encoding='utf-8')
|
|
router = (ROOT / 'tools/portal-country-production-qa.php').read_text(encoding='utf-8')
|
|
router = router.replace('country-production-stage-latest.json','country-production-stage-latest.json')
|
|
router = router.replace('http://127.0.0.1:18101','http://country02-qa.test:18103')
|
|
router = router.replace('country_candidate_18101_qa','country_c110_18103_qa')
|
|
router = router.replace("require $root.'/vendor/autoload.php';", "require $root.'/qa-autoload.php';")
|
|
router = router.replace("'portal.legacy_content_qa_enabled' => false, 'portal.organization_country_enabled' => true", "'portal.legacy_content_qa_enabled' => false, 'portal.organization_country_enabled' => is_file($runtime.'/country-enabled-qa')")
|
|
router = router.replace("$relativeBuild = str_replace('\\\\', '/', substr($stage['build_directory'], strlen($root) + 1));\nVite::useManifestFilename('../../'.$relativeBuild.'/manifest.json');", "Vite::useManifestFilename('manifest.json');")
|
|
anchor = "if (PHP_SAPI === 'cli' && ($argv[1] ?? '') === 'seed') {"
|
|
flag = """if (PHP_SAPI === 'cli' && ($argv[1] ?? '') === 'enable-country') {
|
|
file_put_contents($runtime.'/country-enabled-qa', 'QA only');
|
|
echo json_encode(['result' => 'country_enabled_in_isolated_QA', 'active_writes' => 0]).PHP_EOL;
|
|
exit;
|
|
}
|
|
"""
|
|
assert anchor in router
|
|
router = router.replace(anchor,flag+anchor)
|
|
# Original proof is before QA fixtures; readiness must be bound to the prepared C110 fingerprint.
|
|
router = router.replace("'compatibility_verified' => true, 'reversal_verified' => true, 'scope'", "'compatibility_verified' => true, 'reversal_verified' => true, 'scope'")
|
|
(source / 'tools/portal-country-c110-qa.php').write_text(router,encoding='utf-8')
|
|
compat = (ROOT / 'tools/portal-country-candidate-compatibility-qa.php').read_text(encoding='utf-8')
|
|
compat = compat.replace("require $root.'/vendor/autoload.php';", "require $root.'/qa-autoload.php';")
|
|
(source / 'tools/portal-country-c110-compatibility-qa.php').write_text(compat,encoding='utf-8')
|
|
print(json.dumps({'source':str(source),'backup_inspection':'active READ ONLY, restore55441 *_test; no live providers', 'qa_origin':'http://country02-qa.test:18103'}))
|