diff --git a/lib/Enterprise/RepositorySynchronizer.php b/lib/Enterprise/RepositorySynchronizer.php index b89ee60..a0b82d9 100644 --- a/lib/Enterprise/RepositorySynchronizer.php +++ b/lib/Enterprise/RepositorySynchronizer.php @@ -32,8 +32,6 @@ use RuntimeException; */ class RepositorySynchronizer { - /** @deprecated Sync definitions removed — Template repos are now canonical */ - private const SYNC_DEFINITION_DIR = 'definitions/sync'; /** Override file path — resolved at runtime via adapter's getMetadataDir(). */ private const SYNC_OVERRIDE_FILE_SUFFIX = 'override.tf'; private const STANDARDS_VERSION = '04.06.00'; @@ -234,10 +232,6 @@ class RepositorySynchronizer if ($prNumber) { $this->logger->logInfo("Successfully created PR #{$prNumber} for {$repo}"); - // Generate / update definitions/sync/{repo}.def.tf AFTER the sync so it - // reflects exactly what was pushed in this run. - $this->generateRepositoryDefinition($org, $repo, $platform, $repoInfo, $summary); - return (int) $prNumber; } @@ -265,136 +259,6 @@ class RepositorySynchronizer return null; } - /** - * Generate / update the repository tracking definition after a successful sync. - * - * Writes definitions/sync/{repo}.def.tf with: - * - the base platform definition as a foundation - * - a sync_record block recording what was actually pushed (files created/updated/skipped) - * - full timestamps and platform metadata - * - * @param string $org - * @param string $repo - * @param string $platform Detected platform slug (e.g. 'dolibarr') - * @param array $repoInfo Raw GitHub API repository object - * @param array $summary Sync result from createSyncPR: {copied[], skipped[], total} - * @return bool - */ - private function generateRepositoryDefinition( - string $org, - string $repo, - string $platform, - array $repoInfo, - array $summary - ): bool { - try { - $this->logger->logInfo("Writing sync tracking definition for {$org}/{$repo}"); - - $timestamp = date('c'); - $description = addslashes($repoInfo['description'] ?? ''); - $defaultBranch = $repoInfo['default_branch'] ?? 'main'; - - // Resolve repo root relative to this file's location - $repoRoot = dirname(dirname(__DIR__)); - $baseDefPath = "{$repoRoot}/definitions/default/{$platform}.tf"; - if (!file_exists($baseDefPath)) { - $baseDefPath = "{$repoRoot}/definitions/default/generic.tf"; - } - $baseDefinition = file_get_contents($baseDefPath) ?: ''; - - // Extract definition version from the source .tf metadata block - $definitionVersion = 'unknown'; - if (preg_match('/\bversion\s*=\s*"([^"]+)"/', $baseDefinition, $vm)) { - $definitionVersion = $vm[1]; - } - - // Cache the nullable sub-arrays once to avoid repeated null-coalescing - $copiedItems = $summary['copied'] ?? []; - $skippedItems = $summary['skipped'] ?? []; - $totalCount = (int) ($summary['total'] ?? 0); - - // Build the synced_files list - $syncedEntries = ''; - foreach ($copiedItems as $item) { - $action = addslashes($item['action'] ?? 'synced'); - $file = addslashes($item['file'] ?? ''); - $syncedEntries .= " { path = \"{$file}\" action = \"{$action}\" },\n"; - } - - $skippedEntries = ''; - foreach ($skippedItems as $item) { - $file = addslashes($item['file'] ?? ''); - $reason = addslashes($item['reason'] ?? ''); - $skippedEntries .= " { path = \"{$file}\" reason = \"{$reason}\" },\n"; - } - - $createdCount = count(array_filter($copiedItems, fn($i) => ($i['action'] ?? '') === 'created')); - $updatedCount = count(array_filter($copiedItems, fn($i) => ($i['action'] ?? '') === 'updated')); - $skippedCount = count($skippedItems); - - // Assemble the definition file using PHP 7.3+ flexible heredoc: - // the closing marker is indented, so PHP strips that many leading spaces automatically. - $definition = <<logger->logInfo("Wrote sync tracking definition: {$defFilePath}"); - $this->metrics->increment('definitions_generated'); - - return true; - } catch (Exception $e) { - $this->logger->logError("Failed to write tracking definition for {$repo}: " . $e->getMessage()); - return false; - } - } - /** * Detect platform from repository info */ @@ -515,7 +379,7 @@ HCL; } /** - * Create a PR with sync updates driven by the flat entry list from DefinitionParser. + * Create a PR with sync updates driven by the file entry list. * * @param string $org * @param string $repo diff --git a/validate/check_version_consistency.php b/validate/check_version_consistency.php index 5c05a55..95bfc7f 100755 --- a/validate/check_version_consistency.php +++ b/validate/check_version_consistency.php @@ -165,46 +165,8 @@ class CheckVersionConsistency extends CliFramework $this->progress($phpTotal, $phpTotal, '', true); // ── Check Terraform definition files ───────────────────────────────── - // Each .tf file has TWO version locations that must both match: - // - Block-comment header: * Version: XX.XX.XX - // - HCL metadata field: version = "XX.XX.XX" - $this->section('Checking Terraform definition files'); - - $defFiles = glob($path . '/definitions/default/*.tf') ?: []; - $defTotal = count($defFiles); - - foreach ($defFiles as $i => $file) { - $this->progress($i + 1, $defTotal, basename($file)); - $content = (string) file_get_contents($file); - $filePassed = true; - $rel = str_replace($path . '/', '', $file); - - // Block-comment header version - preg_match_all('/\*\s*Version:\s*(\d{2}\.\d{2}\.\d{2})/', $content, $headerMatches, PREG_OFFSET_CAPTURE); - foreach ($headerMatches[1] as $match) { - if ($match[0] !== $expected) { - $this->progress($i + 1, $defTotal, '', true); - $this->status(false, $rel, "header Version: found {$match[0]}, expected {$expected}"); - $issues[] = $rel; - $filePassed = false; - } - } - - // HCL metadata version field - preg_match_all('/^\s*version\s*=\s*"(\d{2}\.\d{2}\.\d{2})"/m', $content, $hclMatches, PREG_OFFSET_CAPTURE); - foreach ($hclMatches[1] as $match) { - if ($match[0] !== $expected) { - $this->progress($i + 1, $defTotal, '', true); - $this->status(false, $rel, "HCL version = found {$match[0]}, expected {$expected}"); - $issues[] = $rel; - $filePassed = false; - } - } - - if ($filePassed) { - $this->status(true, $rel); - } - } + // HCL definition files removed — Template repos are now canonical + // Skipping .tf version check $this->progress($defTotal, $defTotal, '', true); // ── Summary ───────────────────────────────────────────────────────────