( file, frontmatterVersions, releaseToDeprecate, nextOldestRelease )
| 1 | export default function removeDeprecatedFrontmatter( |
| 2 | file, |
| 3 | frontmatterVersions, |
| 4 | releaseToDeprecate, |
| 5 | nextOldestRelease |
| 6 | ) { |
| 7 | // skip files with no Enterprise Server versions frontmatter |
| 8 | if (!frontmatterVersions) return |
| 9 | if (!frontmatterVersions.ghes) return |
| 10 | |
| 11 | const ghesRange = frontmatterVersions.ghes |
| 12 | |
| 13 | // skip files with versions frontmatter that already applies to all enterprise-server releases |
| 14 | if (ghesRange === '*') return |
| 15 | |
| 16 | // if the release to deprecate is 2.13, and the FM is either '>=2.13', '>2.13', or '>=2.14', |
| 17 | // we can safely change the FM to ghes: '*' |
| 18 | const appliesToAllSupportedGhesReleases = |
| 19 | ghesRange === `>=${releaseToDeprecate}` || |
| 20 | ghesRange === `>${releaseToDeprecate}` || |
| 21 | ghesRange === `>=${nextOldestRelease}` |
| 22 | |
| 23 | if (appliesToAllSupportedGhesReleases) { |
| 24 | frontmatterVersions.ghes = '*' |
| 25 | return |
| 26 | } |
| 27 | |
| 28 | // if the release to deprecate is 2.13, and the FM is either '=2.13', '<2.13', '<=2.13', or '<2.14', |
| 29 | // delete (aka deprecate) the ghes frontmatter property. |
| 30 | const appliesToNoSupportedGhesReleases = |
| 31 | ghesRange === `=${releaseToDeprecate}` || |
| 32 | ghesRange === `<${releaseToDeprecate}` || |
| 33 | ghesRange === `<=${releaseToDeprecate}` || |
| 34 | ghesRange === `<${nextOldestRelease}` |
| 35 | |
| 36 | if (appliesToNoSupportedGhesReleases) { |
| 37 | // Throw a warning if there are no other frontmatter versions specified. |
| 38 | if (Object.keys(frontmatterVersions).length === 1) { |
| 39 | console.log( |
| 40 | `Warning! ${file} has frontmatter versioning that will make it never appear when ${releaseToDeprecate} is deprecated. The article should probably be removed.` |
| 41 | ) |
| 42 | return |
| 43 | } |
| 44 | |
| 45 | delete frontmatterVersions.ghes |
| 46 | } |
| 47 | } |
no outgoing calls
no test coverage detected