| 16 | console.log(`GitHub Repository: ${process.env.GITHUB_REPOSITORY || 'not set'}`) |
| 17 | |
| 18 | function updatePackageJson(filePath, packageName) { |
| 19 | try { |
| 20 | if (!fs.existsSync(filePath)) { |
| 21 | console.warn(`Package.json not found: ${filePath}`) |
| 22 | return |
| 23 | } |
| 24 | |
| 25 | const packageJson = JSON.parse(fs.readFileSync(filePath, 'utf8')) |
| 26 | packageJson.name = packageName |
| 27 | |
| 28 | // Update repository URL to match current GitHub repo for provenance validation |
| 29 | if (packageJson.repository && packageJson.repository.url) { |
| 30 | const githubRepo = process.env.GITHUB_REPOSITORY |
| 31 | if (githubRepo) { |
| 32 | packageJson.repository.url = `git+https://github.com/${githubRepo}.git` |
| 33 | console.log( |
| 34 | `📝 Updated repository URL to: ${packageJson.repository.url}` |
| 35 | ) |
| 36 | } else { |
| 37 | console.log( |
| 38 | `⚠️ GITHUB_REPOSITORY not found, keeping original repository URL: ${packageJson.repository.url}` |
| 39 | ) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | fs.writeFileSync(filePath, JSON.stringify(packageJson, null, 2) + '\n') |
| 44 | console.log(`✅ Updated ${filePath} with name: ${packageName}`) |
| 45 | } catch (error) { |
| 46 | console.error(`❌ Error updating ${filePath}:`, error.message) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | function updateBindingIndex(filePath, packageName) { |
| 51 | try { |