* Validates all change files in the repository * Exits with code 1 if any validation errors are found
()
| 22 | * Exits with code 1 if any validation errors are found |
| 23 | */ |
| 24 | function main() { |
| 25 | let hasErrors = false; |
| 26 | |
| 27 | // Validate all packages have changelogs |
| 28 | console.log("Validating package changelogs...\n"); |
| 29 | let missingChangelogPackageDirNames = getMissingChangelogPackageDirNames(); |
| 30 | |
| 31 | if (missingChangelogPackageDirNames.length > 0) { |
| 32 | hasErrors = true; |
| 33 | console.error(colorize("Missing changelogs", colors.red) + "\n"); |
| 34 | for (let packageDirName of missingChangelogPackageDirNames) { |
| 35 | console.error(`📦 ${packageDirName}: Missing CHANGELOG.md file`); |
| 36 | } |
| 37 | console.error(); |
| 38 | } |
| 39 | |
| 40 | // Validate change files |
| 41 | console.log("Validating change files...\n"); |
| 42 | let result = parseAllChangeFiles(); |
| 43 | |
| 44 | if (!result.valid) { |
| 45 | hasErrors = true; |
| 46 | console.error(colorize("Invalid change files", colors.red) + "\n"); |
| 47 | console.error(formatValidationErrors(result.errors)); |
| 48 | console.error(); |
| 49 | } else if (result.releases.length === 0) { |
| 50 | console.log(colorize("Nothing to release!", colors.lightGreen) + "\n"); |
| 51 | } else { |
| 52 | console.log( |
| 53 | colorize("All change files are valid!", colors.lightGreen) + "\n", |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | if (hasErrors) { |
| 58 | process.exit(1); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | main(); |
no test coverage detected