true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Content-Type: application/json'], CURLOPT_POSTFIELDS => $flowJson, ]); $response = curl_exec($ch); $error = curl_error($ch); curl_close($ch); return $error ?: $response; } // Haal alle versie-bestanden op in een map function findVersionedJsonFilesInDir(string $dir): array { $matches = []; foreach (scandir($dir) as $file) { if (preg_match('/^version\d+_\d{12}\.json$/', $file)) { $matches[] = ['name' => $file]; } } usort($matches, fn($a,$b) => strcmp($a['name'],$b['name'])); return $matches; } // Vind het laatst gedeployde bestand function findLatestDeployFile(string $dir): ?string { $files = findVersionedJsonFilesInDir($dir); return !empty($files) ? end($files)['name'] : null; } // Haal versie uit een JSON-bestand function getVersionFromJson(string $filePath): int { if (!file_exists($filePath)) return 0; $json = json_decode(file_get_contents($filePath), true); return $json[0]['version'] ?? 0; } // Haal versie uit een template function getVersionFromTemplate(string $templatePath): int { if (!file_exists($templatePath)) return 0; preg_match('/"version"\s*:\s*(\d+)/', file_get_contents($templatePath), $m); return $m[1] ?? 0; } // Controleer of de template een hogere versie heeft dan de laatste deploy function checkNewTemplateVersionAlert(string $templatePath, string $deployDir): ?string { $templateVersion = getVersionFromTemplate($templatePath); $latestDeployFile = findLatestDeployFile($deployDir); $latestVersion = $latestDeployFile ? getVersionFromJson($deployDir.'/'.$latestDeployFile) : 0; if ($templateVersion > $latestVersion) { return "