Skip to content

Commit cd2a217

Browse files
committed
do not error if frontmatter includes next GHES release or hardcoded next
1 parent fb5dec6 commit cd2a217

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

lib/enterprise-server-releases.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ const versionSatisfiesRange = require('./version-satisfies-range')
44
// enterprise-releases/docs/supported-versions.md#release-lifecycle-dates
55
const dates = require('../lib/enterprise-dates.json')
66

7+
// Some frontmatter may contain the upcoming GHES release number
8+
const next = '3.1'
9+
710
const supported = [
811
'3.0',
912
'2.22',
@@ -57,6 +60,7 @@ const deprecatedReleasesWithNewFormat = deprecated.filter(version => versionSati
5760
const deprecatedReleasesOnDeveloperSite = deprecated.filter(version => versionSatisfiesRange(version, '<=2.16'))
5861

5962
module.exports = {
63+
next,
6064
supported,
6165
deprecated,
6266
legacyAssetVersions,

lib/get-applicable-versions.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const allVersions = require('./all-versions')
2+
const { next } = require('./enterprise-server-releases')
23
const versionSatisfiesRange = require('./version-satisfies-range')
34

45
// return an array of versions that an article's product versions encompasses
@@ -15,6 +16,8 @@ function getApplicableVersions (frontmatterVersions, filepath) {
1516
// get an array like: [ 'free-pro-team@latest', 'enterprise-server@2.21', 'enterprise-cloud@latest' ]
1617
const applicableVersions = []
1718

19+
let nextVersion = false
20+
1821
// where frontmatter is something like:
1922
// free-pro-team: '*'
2023
// enterprise-server: '>=2.19'
@@ -23,6 +26,15 @@ function getApplicableVersions (frontmatterVersions, filepath) {
2326
// ^ where each key corresponds to a plan
2427
Object.entries(frontmatterVersions)
2528
.forEach(([plan, planValue]) => {
29+
// Special handling for frontmatter that evalues to the next GHES release number or a hardcoded `next`:
30+
// we don't want to return it in the applicable versions array or it will become a permalink,
31+
// but we also don't want to throw an error if no other versions are found.
32+
if (planValue !== '*') {
33+
if (versionSatisfiesRange(next, planValue) || planValue === 'next') {
34+
nextVersion = true
35+
}
36+
}
37+
2638
// for each plan (e.g., enterprise-server), get matching versions from allVersions object
2739
const relevantVersions = Object.values(allVersions).filter(v => v.plan === plan)
2840

@@ -42,7 +54,7 @@ function getApplicableVersions (frontmatterVersions, filepath) {
4254
})
4355
})
4456

45-
if (!applicableVersions.length) {
57+
if (!applicableVersions.length && !nextVersion) {
4658
throw new Error(`No applicable versions found for ${filepath}. Please double-check the page's \`versions\` frontmatter.`)
4759
}
4860

0 commit comments

Comments
 (0)