| 1 | #!/usr/bin/env node |
| 2 | import { resolve, dirname } from "node:path"; |
| 3 | import { fileURLToPath } from "node:url"; |
| 4 | import { readDocTopics } from "./docs-sources-lib.mjs"; |
| 5 | import { checkReleaseDocs, currentRelease, deriveReleaseDocs, readCommittedReleaseDocs, readCommittedReleaseDocsIndex, tagResolves } from "./release-docs-lib.mjs"; |
| 6 | |
| 7 | const webDir = resolve(dirname(fileURLToPath(import.meta.url)), ".."); |
| 8 | const allowShallow = process.argv.includes("--allow-shallow") || process.env.CODEWHALE_ALLOW_SHALLOW_CHECKOUT === "1"; |
| 9 | const release = currentRelease(); |
| 10 | const snapshot = readCommittedReleaseDocs(); |
| 11 | const tagAvailable = Boolean(release && tagResolves(release.tag)); |
| 12 | const derived = tagAvailable ? deriveReleaseDocs(webDir, release) : null; |
| 13 | if (release && !tagAvailable && allowShallow) { |
| 14 | console.warn(`[check-release-docs] warning: tag ${release.tag} is not in this checkout, so the snapshot was not recomputed (--allow-shallow)`); |
| 15 | } |
| 16 | const problems = checkReleaseDocs( |
| 17 | snapshot, |
| 18 | release, |
| 19 | readDocTopics(webDir), |
| 20 | derived, |
| 21 | readCommittedReleaseDocsIndex(), |
| 22 | { allowShallow: allowShallow && !tagAvailable }, |
| 23 | ); |
| 24 | if (problems.length > 0) { |
| 25 | for (const problem of problems) console.error(`[check-release-docs] FAIL — ${problem}`); |
| 26 | process.exit(1); |
| 27 | } |
| 28 | console.log(`[check-release-docs] OK — snapshot is for ${snapshot.tag}, the published release`); |
| 29 |