зеркало из https://github.com/github/docs.git
do not error if frontmatter includes next GHES release or hardcoded next
This commit is contained in:
Родитель
fb5dec6479
Коммит
cd2a217a77
|
@ -4,6 +4,9 @@ const versionSatisfiesRange = require('./version-satisfies-range')
|
|||
// enterprise-releases/docs/supported-versions.md#release-lifecycle-dates
|
||||
const dates = require('../lib/enterprise-dates.json')
|
||||
|
||||
// Some frontmatter may contain the upcoming GHES release number
|
||||
const next = '3.1'
|
||||
|
||||
const supported = [
|
||||
'3.0',
|
||||
'2.22',
|
||||
|
@ -57,6 +60,7 @@ const deprecatedReleasesWithNewFormat = deprecated.filter(version => versionSati
|
|||
const deprecatedReleasesOnDeveloperSite = deprecated.filter(version => versionSatisfiesRange(version, '<=2.16'))
|
||||
|
||||
module.exports = {
|
||||
next,
|
||||
supported,
|
||||
deprecated,
|
||||
legacyAssetVersions,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const allVersions = require('./all-versions')
|
||||
const { next } = require('./enterprise-server-releases')
|
||||
const versionSatisfiesRange = require('./version-satisfies-range')
|
||||
|
||||
// return an array of versions that an article's product versions encompasses
|
||||
|
@ -15,6 +16,8 @@ function getApplicableVersions (frontmatterVersions, filepath) {
|
|||
// get an array like: [ 'free-pro-team@latest', 'enterprise-server@2.21', 'enterprise-cloud@latest' ]
|
||||
const applicableVersions = []
|
||||
|
||||
let nextVersion = false
|
||||
|
||||
// where frontmatter is something like:
|
||||
// free-pro-team: '*'
|
||||
// enterprise-server: '>=2.19'
|
||||
|
@ -23,6 +26,15 @@ function getApplicableVersions (frontmatterVersions, filepath) {
|
|||
// ^ where each key corresponds to a plan
|
||||
Object.entries(frontmatterVersions)
|
||||
.forEach(([plan, planValue]) => {
|
||||
// Special handling for frontmatter that evalues to the next GHES release number or a hardcoded `next`:
|
||||
// we don't want to return it in the applicable versions array or it will become a permalink,
|
||||
// but we also don't want to throw an error if no other versions are found.
|
||||
if (planValue !== '*') {
|
||||
if (versionSatisfiesRange(next, planValue) || planValue === 'next') {
|
||||
nextVersion = true
|
||||
}
|
||||
}
|
||||
|
||||
// for each plan (e.g., enterprise-server), get matching versions from allVersions object
|
||||
const relevantVersions = Object.values(allVersions).filter(v => v.plan === plan)
|
||||
|
||||
|
@ -42,7 +54,7 @@ function getApplicableVersions (frontmatterVersions, filepath) {
|
|||
})
|
||||
})
|
||||
|
||||
if (!applicableVersions.length) {
|
||||
if (!applicableVersions.length && !nextVersion) {
|
||||
throw new Error(`No applicable versions found for ${filepath}. Please double-check the page's \`versions\` frontmatter.`)
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче