Update Enterprise Liquid deprecation handling to use new versions (#15818)

* update Liquid deprecation fixtures to use new versions

* update module that removes deprecated GHES frontmatter for new versions

* update module that removes deprecated GHES conditionals for new versions

* update script to use new versions and also remove internal-developer checkout option

* update deprecated Liquid tests to use new versions

* remove unnecessary leading slash in getEnterpriseServerNumber pattern

* include a step that runs script/remove-unused-assets.js

* Update script/remove-deprecated-enterprise-version-markup.js

Co-authored-by: Jason Etcovitch <jasonetco@github.com>

* require script instead of execSync

Co-authored-by: Jason Etcovitch <jasonetco@github.com>
This commit is contained in:
Sarah Schneider 2020-09-30 19:29:08 -04:00 коммит произвёл GitHub
Родитель 81a1e59865
Коммит 0b1c7ad466
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
14 изменённых файлов: 211 добавлений и 201 удалений

Просмотреть файл

@ -38,5 +38,5 @@ module.exports = {
// new versioning format patterns
adminProduct: /\/admin(\/|$|\?|#)/,
enterpriseServer: /\/enterprise-server@/,
getEnterpriseServerNumber: /\/enterprise-server@(\d+\.\d+)/
getEnterpriseServerNumber: /enterprise-server@(\d+\.\d+)/
}

Просмотреть файл

@ -1,25 +1,22 @@
module.exports = function removeDeprecatedFrontmatter (data, devCheckout, versionToDeprecate, nextOldestVersion) {
// there are currently different frontmatter conventions for developer docs vs. help docs
if (devCheckout) {
// skip files with no exclude_version frontmatter
if (!data.exclude_version) return data
const { getEnterpriseServerNumber } = require('./patterns')
// remove frontmatter like exclude_version: - "2.13"
if (data.exclude_version.includes(`${versionToDeprecate}`)) {
data.exclude_version = data.exclude_version.filter(version => !version.match(versionToDeprecate))
module.exports = function removeDeprecatedFrontmatter (file, frontmatterVersions, versionToDeprecate, nextOldestVersion) {
// skip files with no versions or Enterprise Server versions frontmatter
if (!frontmatterVersions) return
if (!frontmatterVersions['enterprise-server']) return
if (!data.exclude_version.length) delete data.exclude_version
}
} else {
// skip files with no versions or Enterprise versions frontmatter
if (!data.versions) return data
if (!data.versions.enterprise) return data
const enterpriseRange = frontmatterVersions['enterprise-server']
// change frontmatter like enterprise: '>=2.13' to enterprise: '*'
if (data.versions.enterprise === `>=${versionToDeprecate}` || data.versions.enterprise === `>=${nextOldestVersion}`) {
data.versions.enterprise = '*'
}
// skip files with versions frontmatter that applies to all enterprise-server releases
if (enterpriseRange === '*') return
// get the release numbers alone
const releaseToDeprecate = versionToDeprecate.match(getEnterpriseServerNumber)[1]
const nextOldestRelease = nextOldestVersion.match(getEnterpriseServerNumber)[1]
// if the release to deprecate is 2.13, and the FM is either '>=2.13' or '>=2.14',
// we can safely change the FM to enterprise-server: '*'
if (enterpriseRange === `>=${releaseToDeprecate}` || enterpriseRange === `>=${nextOldestRelease}`) {
frontmatterVersions['enterprise-server'] = '*'
}
return data
}

Просмотреть файл

@ -25,11 +25,11 @@ module.exports = function removeLiquidStatements (content, versionToDeprecate, n
// see tests/fixtures/remove-liquid-statements for examples
const regexes = {
// remove liquid only
greaterThanVersionToDeprecate: new RegExp(startTag.source + ` if ?(?: page.version == ('|")'?dotcom'?('|") ?or)? page.version ver_gte? ('|")${versionToDeprecate}('|") ` + endTag.source, 'gm'),
andGreaterThanVersionToDeprecate1: new RegExp('(' + startTag.source + ` if .*?) and page.version ver_gte? (?:'|")${versionToDeprecate}(?:'|")( ` + endTag.source + ')', 'gm'),
andGreaterThanVersionToDeprecate2: new RegExp('(' + startTag.source + ` if )page.version ver_gte? (?:'|")${versionToDeprecate}(?:'|") and (.*? ` + endTag.source + ')', 'gm'),
notEqualsVersionToDeprecate: new RegExp('(' + startTag.source + ` if)(?:( page.version .*?) or)? page.version != (?:'|")${versionToDeprecate}(?:'|")( ` + endTag.source + ')', 'gm'),
andNotEqualsVersionToDeprecate: new RegExp('(' + startTag.source + ` if .*?) and page.version != (?:'|")${versionToDeprecate}(?:'|")( ` + endTag.source + ')', 'gm'),
greaterThanVersionToDeprecate: new RegExp(startTag.source + ` if ?(?: currentVersion == ('|")'?free-pro-team@latest'?('|") ?or)? currentVersion ver_gt ('|")${versionToDeprecate}('|") ` + endTag.source, 'gm'),
andGreaterThanVersionToDeprecate1: new RegExp('(' + startTag.source + ` if .*?) and currentVersion ver_gt (?:'|")${versionToDeprecate}(?:'|")( ` + endTag.source + ')', 'gm'),
andGreaterThanVersionToDeprecate2: new RegExp('(' + startTag.source + ` if )currentVersion ver_gt (?:'|")${versionToDeprecate}(?:'|") and (.*? ` + endTag.source + ')', 'gm'),
notEqualsVersionToDeprecate: new RegExp('(' + startTag.source + ` if)(?:( currentVersion .*?) or)? currentVersion != (?:'|")${versionToDeprecate}(?:'|")( ` + endTag.source + ')', 'gm'),
andNotEqualsVersionToDeprecate: new RegExp('(' + startTag.source + ` if .*?) and currentVersion != (?:'|")${versionToDeprecate}(?:'|")( ` + endTag.source + ')', 'gm'),
// remove liquid and content
lessThanNextOldestVersion: new RegExp(startTag.source + ` if .*?ver_lt ('|")${nextOldestVersion}('|") ?` + endTag.source, 'm'),
equalsVersionToDeprecate: new RegExp(startTag.source + ` if .*?== ('|")${versionToDeprecate}('|") ?` + endTag.source, 'm')

Просмотреть файл

@ -4,83 +4,92 @@ const fs = require('fs')
const path = require('path')
const walk = require('walk-sync')
const matter = require('gray-matter')
const readlineSync = require('readline-sync')
const program = require('commander')
const { indexOf, nth } = require('lodash')
const removeLiquidStatements = require('../lib/remove-liquid-statements')
const removeDeprecatedFrontmatter = require('../lib/remove-deprecated-frontmatter')
const versionToDeprecate = require('../lib/enterprise-server-releases').deprecated[0]
const nextOldestVersion = require('../lib/enterprise-server-releases').oldestSupported
const devCheckout = process.argv[2]
const prompt = `This script will run in the current checkout of help.github.com.
Is that what you want? Press Y to continue, or enter any other key to cancel: `
const enterpriseServerReleases = require('../lib/enterprise-server-releases')
const contentPath = path.join(__dirname, '../content')
const dataPath = path.join(__dirname, '../data')
const removeUnusedAssetsScript = 'script/remove-unused-assets'
const elseifRegex = /{-?% elsif/
// [start-readme]
//
// Run this script after an Enterprise deprecation to remove Liquid statements and frontmatter that contain the deprecated Enterprise version.
// See the Enterprise deprecation issue template for instructions.
//
// You can run this script on either the help docs or the developer docs. To run it on the help docs, enter:
//
// `script/remove-deprecated-enterprise-version-markup.js`
//
// To run it on the developer docs, provide a path to your developer docs checkout as an argument. You can use a tilde to represent your home directory. For example:
//
// `script/remove-deprecated-enterprise-version-markup.js ~/Desktop/internal-developer.github.com/`
//
// [end-readme]
let contentDir = path.join(__dirname, '../content')
let dataDir = path.join(__dirname, '../data')
program
.description('Remove Liquid conditionals and update versions frontmatter for a given Enterprise Server release.')
.option('-r, --release <NUMBER>', 'Enterprise Server release number. Example: 2.19')
.parse(process.argv)
const elseifRegex = /{-?% elsif/
// determine whether to run the script on help docs or developer docs
if (devCheckout) {
try {
process.chdir(devCheckout)
console.log('OK, the script will run in ' + devCheckout)
contentDir = path.join(devCheckout, 'content')
dataDir = path.join(devCheckout, 'data')
} catch (err) {
console.log('No such directory! ' + devCheckout)
}
} else {
const answer = readlineSync.question(prompt)
if (!answer.match(/^Y$/mi)) {
console.log('Exiting!')
process.exit()
}
// verify CLI options
if (!program.release) {
console.log(program.description() + '\n')
program.options.forEach(opt => {
console.log(opt.flags)
console.log(opt.description + '\n')
})
process.exit(1)
}
if (!enterpriseServerReleases.all.includes(program.release)) {
console.log(`You specified ${program.release}! Please specify a supported or deprecated release number from lib/enterprise-server-releases.js`)
process.exit(1)
}
const versionToDeprecate = `enterprise-server@${program.release}`
const currentIndex = indexOf(enterpriseServerReleases.all, program.release)
const nextOldestRelease = nth(enterpriseServerReleases.all, currentIndex - 1)
const nextOldestVersion = `enterprise-server@${nextOldestRelease}`
console.log(`Deprecating ${versionToDeprecate}!\n`)
console.log(`Next oldest version: ${nextOldestVersion}\n`)
// gather content and data files
const contentFiles = walk(contentDir, { includeBasePath: true })
.filter(relativePath => relativePath.endsWith('.md') && !relativePath.match(/README/i))
const contentFiles = walk(contentPath, { includeBasePath: true, directories: false })
.filter(file => file.endsWith('.md'))
.filter(file => !(file.endsWith('README.md') || file === 'LICENSE'))
const dataFiles = walk(dataDir, { includeBasePath: true })
.filter(relativePath => relativePath.endsWith('.yml') || relativePath.endsWith('.md'))
.filter(relativePath => !relativePath.includes('/graphql/'))
const dataFiles = walk(dataPath, { includeBasePath: true, directories: false })
.filter(file => file.includes('data/reusables') || file.includes('data/variables'))
.filter(file => !file.endsWith('README.md'))
const files = contentFiles.concat(dataFiles)
const allFiles = contentFiles.concat(dataFiles)
main()
console.log(`Removed ${versionToDeprecate} markup from content and data files! Review and run script/test.`)
console.log(`\nRunning ${removeUnusedAssetsScript}...`)
require(`../${removeUnusedAssetsScript}`)
function printElseIfFoundWarning (location) {
console.log(`${location} has an 'elsif' condition! Resolve all elsifs by hand, then rerun the script.`)
}
function main () {
files.forEach(file => {
allFiles.forEach(file => {
const oldContents = fs.readFileSync(file, 'utf8')
const { content, data } = matter(oldContents)
// can't safely handle elseifs programmatically, too many possible outcomes
// (only intro and title frontmatter are likely to contain elseif tags)
if (content.match(elseifRegex) || (data.intro && data.intro.match(elseifRegex)) || (data.title && data.title.match(elseifRegex))) {
console.log(`${file} has an 'elsif' condition! Resolve all elsifs by hand, then rerun the script.`)
// we can't safely handle elseifs programmatically, too many possible outcomes
if (elseifRegex.test(content)) {
printElseIfFoundWarning(`content in ${file}`)
process.exit()
}
// update frontmatter data (i.e., productVersions field)
const newData = removeDeprecatedFrontmatter(data, devCheckout, versionToDeprecate, nextOldestVersion)
Object.keys(data).forEach(key => {
if (elseifRegex.test(data[key])) {
printElseIfFoundWarning(`frontmatter '${key}' in ${file}`)
process.exit()
}
})
// update liquid statements in body content
// update frontmatter versions prop
removeDeprecatedFrontmatter(file, data.versions, versionToDeprecate, nextOldestVersion)
// update liquid statements in content and data
const newContent = removeLiquidStatements(content, versionToDeprecate, nextOldestVersion)
// make sure any intro fields that exist and are empty return an empty string, not null
@ -89,8 +98,10 @@ function main () {
}
// put it all back together
const newContents = matter.stringify(newContent, newData, { lineWidth: 10000 })
const newContents = matter.stringify(newContent, data, { lineWidth: 10000 })
fs.writeFileSync(file, newContents)
})
console.log(`Removed ${versionToDeprecate} markup from content and data files! Review and run script/test.`)
}

Просмотреть файл

@ -7,8 +7,8 @@ const removeDeprecatedFrontmatter = require('../../lib/remove-deprecated-frontma
const removeLiquidStatementsFixtures = path.join(__dirname, '../fixtures/remove-liquid-statements')
// Hardcode values so tests don't go out of date
const versionToDeprecate = '2.13'
const nextOldestVersion = '2.14'
const versionToDeprecate = 'enterprise-server@2.13'
const nextOldestVersion = 'enterprise-server@2.14'
// Remove liquid only
const greaterThan = path.join(removeLiquidStatementsFixtures, 'greater-than.md')
@ -28,10 +28,10 @@ const frontmatter1 = path.join(removeLiquidStatementsFixtures, 'frontmatter1.md'
const frontmatter2 = path.join(removeLiquidStatementsFixtures, 'frontmatter2.md')
// process frontmatter
function processFrontmatter (contents) {
function processFrontmatter (contents, file) {
const { content, data } = matter(contents)
const newData = removeDeprecatedFrontmatter(data, false, versionToDeprecate, nextOldestVersion)
return matter.stringify(content, newData, { lineWidth: 10000 })
removeDeprecatedFrontmatter(file, data.versions, versionToDeprecate, nextOldestVersion)
return matter.stringify(content, data, { lineWidth: 10000 })
}
describe('removing liquid statements only', () => {
@ -42,17 +42,17 @@ describe('removing liquid statements only', () => {
expect($('.example1').text().trim()).toBe('Alpha')
expect($('.example2').text().trim()).toBe('Alpha')
expect($('.example3').text().trim()).toBe('Alpha')
expect($('.example4').text().trim()).toBe(`{% if page.version ver_gt "2.16" %}\n
expect($('.example4').text().trim()).toBe(`{% if currentVersion ver_gt "enterprise-server@2.16" %}\n
Alpha\n\n{% else %}\n\nBravo\n\nCharlie\n\n{% endif %}`)
expect($('.example5').text().trim()).toBe(`{% if page.version ver_lt "2.16" %}\n
expect($('.example5').text().trim()).toBe(`{% if currentVersion ver_lt "enterprise-server@2.16" %}\n
Alpha\n\nBravo\n\n{% else %}\n\nCharlie\n\n{% endif %}`)
expect($('.example6').text().trim()).toBe(`Alpha\n\n{% if page.version ver_lt "2.16" %}\n
expect($('.example6').text().trim()).toBe(`Alpha\n\n{% if currentVersion ver_lt "enterprise-server@2.16" %}\n
Bravo\n\n{% endif %}`)
expect($('.example7').text().trim()).toBe(`Alpha\n\n{% if page.version ver_gt "2.16" %}\n
expect($('.example7').text().trim()).toBe(`Alpha\n\n{% if currentVersion ver_gt "enterprise-server@2.16" %}\n
Bravo\n\n{% else %}\n\nCharlie\n\n{% endif %}`)
expect($('.example8').text().trim()).toBe('Alpha')
expect($('.example9').text().trim()).toBe(`{% if page.version == 'dotcom' %}\n
Alpha\n\n{% else %}\n\nBravo\n\n{% if page.version ver_gt "2.16" %}\n\nCharlie\n
expect($('.example9').text().trim()).toBe(`{% if currentVersion == "free-pro-team@latest" %}\n
Alpha\n\n{% else %}\n\nBravo\n\n{% if currentVersion ver_gt "enterprise-server@2.16" %}\n\nCharlie\n
{% endif %}\n\nDelta\n\n{% endif %}`)
expect($('.example10').text().trim()).toBe('Alpha')
})
@ -61,28 +61,28 @@ Alpha\n\n{% else %}\n\nBravo\n\n{% if page.version ver_gt "2.16" %}\n\nCharlie\n
let contents = fs.readFileSync(andGreaterThan1, 'utf8')
contents = removeLiquidStatements(contents, versionToDeprecate, nextOldestVersion)
const $ = cheerio.load(contents)
expect($('.example1').text().trim()).toBe('{% if page.version != \'dotcom\' %}\n\nAlpha\n\n{% endif %}')
expect($('.example2').text().trim()).toBe('{% if page.version != \'dotcom\' %}\n\nAlpha\n\n{% endif %}')
expect($('.example3').text().trim()).toBe(`{% if page.version ver_gt "2.16" %}\n
Alpha\n\n{% else %}\n\nBravo\n\n{% if page.version != 'dotcom' %}\n\nCharlie\n\n{% endif %}\n{% endif %}`)
expect($('.example4').text().trim()).toBe(`{% if page.version ver_lt "2.16" %}\n
Alpha\n\n{% if page.version != 'dotcom' %}\n\nBravo\n\n{% endif %}\n\n{% else %}\n\nCharlie\n\n{% endif %}`)
expect($('.example5').text().trim()).toBe(`{% if page.version != 'dotcom' %}\n
Alpha\n\n{% if page.version ver_gt "2.16" %}\n\nBravo\n\n{% endif %}\n\n{% endif %}`)
expect($('.example1').text().trim()).toBe('{% if currentVersion != "free-pro-team@latest" %}\n\nAlpha\n\n{% endif %}')
expect($('.example2').text().trim()).toBe('{% if currentVersion != "free-pro-team@latest" %}\n\nAlpha\n\n{% endif %}')
expect($('.example3').text().trim()).toBe(`{% if currentVersion ver_gt "enterprise-server@2.16" %}\n
Alpha\n\n{% else %}\n\nBravo\n\n{% if currentVersion != "free-pro-team@latest" %}\n\nCharlie\n\n{% endif %}\n{% endif %}`)
expect($('.example4').text().trim()).toBe(`{% if currentVersion ver_lt "enterprise-server@2.16" %}\n
Alpha\n\n{% if currentVersion != "free-pro-team@latest" %}\n\nBravo\n\n{% endif %}\n\n{% else %}\n\nCharlie\n\n{% endif %}`)
expect($('.example5').text().trim()).toBe(`{% if currentVersion != "free-pro-team@latest" %}\n
Alpha\n\n{% if currentVersion ver_gt "enterprise-server@2.16" %}\n\nBravo\n\n{% endif %}\n\n{% endif %}`)
})
test('removes liquid statements that specify "and greater than version to deprecate" (alternate format)', () => {
let contents = fs.readFileSync(andGreaterThan2, 'utf8')
contents = removeLiquidStatements(contents, versionToDeprecate, nextOldestVersion)
const $ = cheerio.load(contents)
expect($('.example1').text().trim()).toBe('{% if page.version ver_lt "2.16" %}\n\nAlpha\n\n{% endif %}')
expect($('.example2').text().trim()).toBe('{% if page.version ver_lt "2.16" %}\n\nAlpha\n\n{% endif %}')
expect($('.example3').text().trim()).toBe(`{% if page.version == "dotcom" %}\n
Alpha\n\n{% else %}\n\nBravo\n\n{% if page.version ver_lt "2.16" %}\n\nCharlie\n\n{% endif %}\n{% endif %}`)
expect($('.example4').text().trim()).toBe(`{% if page.version != "dotcom" %}\n
Alpha\n\n{% if page.version ver_lt "2.16" %}\n\nBravo\n\n{% endif %}\n\n{% else %}\n\nCharlie\n\n{% endif %}`)
expect($('.example5').text().trim()).toBe(`{% if page.version ver_lt "2.16" %}\n
Alpha\n\n{% if page.version != "dotcom" %}\n\nBravo\n\n{% endif %}\n\n{% endif %}`)
expect($('.example1').text().trim()).toBe('{% if currentVersion ver_lt "enterprise-server@2.16" %}\n\nAlpha\n\n{% endif %}')
expect($('.example2').text().trim()).toBe('{% if currentVersion ver_lt "enterprise-server@2.16" %}\n\nAlpha\n\n{% endif %}')
expect($('.example3').text().trim()).toBe(`{% if currentVersion == "free-pro-team@latest" %}\n
Alpha\n\n{% else %}\n\nBravo\n\n{% if currentVersion ver_lt "enterprise-server@2.16" %}\n\nCharlie\n\n{% endif %}\n{% endif %}`)
expect($('.example4').text().trim()).toBe(`{% if currentVersion != "free-pro-team@latest" %}\n
Alpha\n\n{% if currentVersion ver_lt "enterprise-server@2.16" %}\n\nBravo\n\n{% endif %}\n\n{% else %}\n\nCharlie\n\n{% endif %}`)
expect($('.example5').text().trim()).toBe(`{% if currentVersion ver_lt "enterprise-server@2.16" %}\n
Alpha\n\n{% if currentVersion != "free-pro-team@latest" %}\n\nBravo\n\n{% endif %}\n\n{% endif %}`)
})
test('removes liquid statements that specify "not equals version to deprecate"', () => {
@ -90,14 +90,14 @@ Alpha\n\n{% if page.version != "dotcom" %}\n\nBravo\n\n{% endif %}\n\n{% endif %
contents = removeLiquidStatements(contents, versionToDeprecate, nextOldestVersion)
const $ = cheerio.load(contents)
expect($('.example1').text().trim()).toBe('Alpha')
expect($('.example2').text().trim()).toBe('{% if page.version == \'dotcom\' %}\n\nAlpha\n\n{% endif %}')
expect($('.example3').text().trim()).toBe(`{% if page.version == "dotcom" %}\n
expect($('.example2').text().trim()).toBe('{% if currentVersion == "free-pro-team@latest" %}\n\nAlpha\n\n{% endif %}')
expect($('.example3').text().trim()).toBe(`{% if currentVersion == "free-pro-team@latest" %}\n
Alpha\n\n{% else %}\n\nBravo\n\nCharlie\n\n{% endif %}`)
expect($('.example4').text().trim()).toBe(`{% if page.version == "dotcom" %}\n
expect($('.example4').text().trim()).toBe(`{% if currentVersion == "free-pro-team@latest" %}\n
Alpha\n\nBravo\n\n{% else %}\n\nCharlie\n\n{% endif %}`)
expect($('.example5').text().trim()).toBe(`Alpha\n\n{% if page.version == "dotcom" %}\n
expect($('.example5').text().trim()).toBe(`Alpha\n\n{% if currentVersion == "free-pro-team@latest" %}\n
Bravo\n\n{% endif %}`)
expect($('.example6').text().trim()).toBe(`{% if page.version != 'dotcom' %}\n
expect($('.example6').text().trim()).toBe(`{% if currentVersion != "free-pro-team@latest" %}\n
Alpha\n\n{% endif %}`)
})
})
@ -109,9 +109,9 @@ describe('removing liquid statements and content', () => {
const $ = cheerio.load(contents)
expect($('.example1').text().trim()).toBe('')
expect($('.example2').text().trim()).toBe('')
expect($('.example3').text().trim()).toBe(`{% if page.version == "dotcom" %}\n
expect($('.example3').text().trim()).toBe(`{% if currentVersion == "free-pro-team@latest" %}\n
Alpha\n\n{% else %}\n\nBravo\n\n{% endif %}`)
expect($('.example4').text().trim()).toBe(`{% if page.version == "dotcom" %}\n
expect($('.example4').text().trim()).toBe(`{% if currentVersion == "free-pro-team@latest" %}\n
Alpha\n\n{% else %}\n\nCharlie\n\n{% endif %}`)
expect($('.example5').text().trim()).toBe('Charlie')
expect($('.example6').text().trim()).toBe('Charlie\n\nBravo')
@ -123,34 +123,36 @@ Alpha\n\n{% else %}\n\nCharlie\n\n{% endif %}`)
const $ = cheerio.load(contents)
expect($('.example1').text().trim()).toBe('Alpha')
expect($('.example2').text().trim()).toBe('Alpha')
expect($('.example3').text().trim()).toBe(`{% if page.version == "dotcom" %}\n
expect($('.example3').text().trim()).toBe(`{% if currentVersion == "free-pro-team@latest" %}\n
Alpha\n\n{% else %}\n\nBravo\n\n{% endif %}`)
expect($('.example4').text().trim()).toBe(`{% if page.version == "dotcom" %}\n
expect($('.example4').text().trim()).toBe(`{% if currentVersion == "free-pro-team@latest" %}\n
Alpha\n\n{% else %}\n\nCharlie\n\n{% endif %}`)
expect($('.example5').text().trim()).toBe('Charlie')
expect($('.example6').text().trim()).toBe(`{% if page.version ver_lt "2.16" %}\n
expect($('.example6').text().trim()).toBe(`{% if currentVersion ver_lt "enterprise-server@2.16" %}\n
Alpha\n\n{% else %}\n\nCharlie\n\n{% endif %}`)
expect($('.example7').text().trim()).toBe('')
expect($('.example8').text().trim()).toBe(`Bravo\n\n{% if page.version ver_gt "2.16" %}\n
expect($('.example8').text().trim()).toBe(`Bravo\n\n{% if currentVersion ver_gt "enterprise-server@2.16" %}\n
Charlie\n\n{% else %}\n\nDelta\n\n{% endif %}\n\nEcho`)
})
})
describe('updating frontmatter', () => {
test('updates productVersions Enterprise if set to greater-than-or-equal-to version to deprecate', () => {
test('updates frontmatter versions Enterprise if set to greater-than-or-equal-to version to deprecate', () => {
let contents = fs.readFileSync(frontmatter1, 'utf8')
contents = processFrontmatter(contents)
contents = processFrontmatter(contents, frontmatter1)
const $ = cheerio.load(contents)
expect($.text().includes('enterprise: \'*\'')).toBe(true)
expect($.text().includes('enterprise: \'>=2.13\'')).toBe(false)
// console.log('foo')
// console.log($.text())
expect($.text().includes('enterprise-server: \'*\'')).toBe(true)
expect($.text().includes('enterprise-server: \'>=2.13\'')).toBe(false)
})
test('updates productVersions Enterprise if set to greater-than-or-equal-to next oldest version', () => {
test('updates frontmatter versions Enterprise if set to greater-than-or-equal-to next oldest version', () => {
let contents = fs.readFileSync(frontmatter2, 'utf8')
contents = processFrontmatter(contents)
contents = processFrontmatter(contents, frontmatter2)
const $ = cheerio.load(contents)
expect($.text().includes('enterprise: \'*\'')).toBe(true)
expect($.text().includes('enterprise: \'>=2.14\'')).toBe(false)
expect($.text().includes('enterprise-server: \'*\'')).toBe(true)
expect($.text().includes('enterprise-server: \'>=2.14\'')).toBe(false)
})
})

Просмотреть файл

@ -6,7 +6,7 @@ intro: Remove liquid only
## 1
<div class="example1">
{% if page.version != 'dotcom' and page.version ver_gt "2.13" %}
{% if currentVersion != "free-pro-team@latest" and currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
@ -17,7 +17,7 @@ Alpha
## 2
<div class="example2">
{% if page.version != 'dotcom' and page.version ver_gt "2.13" %}
{% if currentVersion != "free-pro-team@latest" and currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
@ -32,7 +32,7 @@ Bravo
## 3
<div class="example3">
{% if page.version ver_gt "2.16" %}
{% if currentVersion ver_gt "enterprise-server@2.16" %}
Alpha
@ -40,7 +40,7 @@ Alpha
Bravo
{% if page.version != 'dotcom' and page.version ver_gt "2.13" %}
{% if currentVersion != "free-pro-team@latest" and currentVersion ver_gt "enterprise-server@2.13" %}
Charlie
@ -52,11 +52,11 @@ Charlie
## 4
<div class="example4">
{% if page.version ver_lt "2.16" %}
{% if currentVersion ver_lt "enterprise-server@2.16" %}
Alpha
{% if page.version != 'dotcom' and page.version ver_gt "2.13" %}
{% if currentVersion != "free-pro-team@latest" and currentVersion ver_gt "enterprise-server@2.13" %}
Bravo
@ -73,11 +73,11 @@ Charlie
## 5
<div class="example5">
{% if page.version != 'dotcom' and page.version ver_gt "2.13" %}
{% if currentVersion != "free-pro-team@latest" and currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
{% if page.version ver_gt "2.16" %}
{% if currentVersion ver_gt "enterprise-server@2.16" %}
Bravo

Просмотреть файл

@ -6,7 +6,7 @@ intro: Remove liquid only
## 1
<div class="example1">
{% if page.version ver_gt "2.13" and page.version ver_lt "2.16" %}
{% if currentVersion ver_gt "enterprise-server@2.13" and currentVersion ver_lt "enterprise-server@2.16" %}
Alpha
@ -17,7 +17,7 @@ Alpha
## 2
<div class="example2">
{% if page.version ver_gt "2.13" and page.version ver_lt "2.16" %}
{% if currentVersion ver_gt "enterprise-server@2.13" and currentVersion ver_lt "enterprise-server@2.16" %}
Alpha
@ -32,7 +32,7 @@ Bravo
## 3
<div class="example3">
{% if page.version == "dotcom" %}
{% if currentVersion == "free-pro-team@latest" %}
Alpha
@ -40,7 +40,7 @@ Alpha
Bravo
{% if page.version ver_gt "2.13" and page.version ver_lt "2.16" %}
{% if currentVersion ver_gt "enterprise-server@2.13" and currentVersion ver_lt "enterprise-server@2.16" %}
Charlie
@ -52,11 +52,11 @@ Charlie
## 4
<div class="example4">
{% if page.version != "dotcom" %}
{% if currentVersion != "free-pro-team@latest" %}
Alpha
{% if page.version ver_gt "2.13" and page.version ver_lt "2.16" %}
{% if currentVersion ver_gt "enterprise-server@2.13" and currentVersion ver_lt "enterprise-server@2.16" %}
Bravo
@ -73,11 +73,11 @@ Charlie
## 5
<div class="example5">
{% if page.version ver_gt "2.13" and page.version ver_lt "2.16" %}
{% if currentVersion ver_gt "enterprise-server@2.13" and currentVersion ver_lt "enterprise-server@2.16" %}
Alpha
{% if page.version != "dotcom" %}
{% if currentVersion != "free-pro-team@latest" %}
Bravo

Просмотреть файл

@ -6,7 +6,7 @@ intro: Remove liquid and content
## 1
<div class="example1">
{% if page.version == "2.13" %}
{% if currentVersion == "enterprise-server@2.13" %}
Alpha
@ -17,7 +17,7 @@ Alpha
## 2
<div class="example2">
{% if page.version != 'dotcom' and page.version == "2.13" %}
{% if currentVersion != "free-pro-team@latest" and currentVersion == "enterprise-server@2.13" %}
Alpha
@ -28,7 +28,7 @@ Alpha
## 3
<div class="example3">
{% if page.version == "dotcom" %}
{% if currentVersion == "free-pro-team@latest" %}
Alpha
@ -36,7 +36,7 @@ Alpha
Bravo
{% if page.version == "2.13" %}
{% if currentVersion == "enterprise-server@2.13" %}
Charlie
@ -48,11 +48,11 @@ Charlie
## 4
<div class="example4">
{% if page.version == "dotcom" %}
{% if currentVersion == "free-pro-team@latest" %}
Alpha
{% if page.version == "2.13" %}
{% if currentVersion == "enterprise-server@2.13" %}
Bravo
@ -69,11 +69,11 @@ Charlie
## 5
<div class="example5">
{% if page.version == "2.13" %}
{% if currentVersion == "enterprise-server@2.13" %}
Alpha
{% if page.version == "dotcom" %}
{% if currentVersion == "free-pro-team@latest" %}
Bravo
@ -90,7 +90,7 @@ Charlie
## 6
<div class="example6">
{% if page.version == "2.13" %}
{% if currentVersion == "enterprise-server@2.13" %}
Alpha
@ -98,7 +98,7 @@ Alpha
Charlie
{% if page.version == "dotcom" or page.version ver_gt "2.13" %}
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.13" %}
Bravo

Просмотреть файл

@ -1,6 +1,6 @@
---
title: Frontmatter
versions:
dotcom: '*'
enterprise: '>=2.13'
free-pro-team: '*'
enterprise-server: '>=2.13'
---

Просмотреть файл

@ -1,6 +1,6 @@
---
title: Frontmatter
versions:
dotcom: '*'
enterprise: '>=2.14'
free-pro-team: '*'
enterprise-server: '>=2.14'
---

Просмотреть файл

@ -6,7 +6,7 @@ intro: Remove liquid only
## 1
<div class="example1">
{% if page.version ver_gt "2.13" %}
{% if currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
@ -17,7 +17,7 @@ Alpha
## 2
<div class="example2">
{% if page.version == 'dotcom' or page.version ver_gt "2.13" %}
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
@ -28,7 +28,7 @@ Alpha
## 3
<div class="example3">
{% if page.version ver_gt "2.13" %}
{% if currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
@ -43,7 +43,7 @@ Bravo
## 4
<div class="example4">
{% if page.version ver_gt "2.16" %}
{% if currentVersion ver_gt "enterprise-server@2.16" %}
Alpha
@ -51,7 +51,7 @@ Alpha
Bravo
{% if page.version ver_gt "2.13" %}
{% if currentVersion ver_gt "enterprise-server@2.13" %}
Charlie
@ -63,11 +63,11 @@ Charlie
## 5
<div class="example5">
{% if page.version ver_lt "2.16" %}
{% if currentVersion ver_lt "enterprise-server@2.16" %}
Alpha
{% if page.version ver_gt "2.13" %}
{% if currentVersion ver_gt "enterprise-server@2.13" %}
Bravo
@ -84,11 +84,11 @@ Charlie
## 6
<div class="example6">
{% if page.version ver_gt "2.13" %}
{% if currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
{% if page.version ver_lt "2.16" %}
{% if currentVersion ver_lt "enterprise-server@2.16" %}
Bravo
@ -105,11 +105,11 @@ Charlie
## 7
<div class="example7">
{% if page.version ver_gt "2.13" %}
{% if currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
{% if page.version ver_gt "2.16" %}
{% if currentVersion ver_gt "enterprise-server@2.16" %}
Bravo
@ -125,7 +125,7 @@ Charlie
## 8
<div class="example8">
{% if page.version ver_gt "2.13" %}
{% if currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
@ -133,7 +133,7 @@ Alpha
Bravo
{% if page.version != "dotcom" %}
{% if currentVersion != "free-pro-team@latest" %}
Charlie
@ -148,7 +148,7 @@ Delta
## 9
<div class="example9">
{% if page.version == 'dotcom' %}
{% if currentVersion == "free-pro-team@latest" %}
Alpha
@ -156,13 +156,13 @@ Alpha
Bravo
{% if page.version ver_gt "2.16" %}
{% if currentVersion ver_gt "enterprise-server@2.16" %}
Charlie
{% endif %}
{% if page.version ver_gt "2.13" %}
{% if currentVersion ver_gt "enterprise-server@2.13" %}
Delta
@ -175,13 +175,13 @@ Delta
## 10
<div class="example10">
{% if page.version ver_gt "2.13" %}
{% if currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
{% else %}
Security alerts for vulnerable dependencies are available in {% data variables.product.prodname_ghe_server %} 2.17+. For more information, see "[Enabling security alerts for vulnerable dependencies on {% data variables.product.prodname_ghe_server %}](/enterprise/admin/installation/enabling-security-alerts-for-vulnerable-dependencies-on-github-enterprise-server)."
Security alerts for vulnerable dependencies are available in {{ site.data.variables.product.prodname_ghe_server }} 2.17+. For more information, see "[Enabling security alerts for vulnerable dependencies on {{ site.data.variables.product.prodname_ghe_server }}](/enterprise/admin/installation/enabling-security-alerts-for-vulnerable-dependencies-on-github-enterprise-server)."
{% endif %}

Просмотреть файл

@ -8,7 +8,7 @@ intro: Remove liquid and content
Alpha
{% if page.version ver_lt "2.14" %}
{% if currentVersion ver_lt "enterprise-server@2.14" %}
Bravo
@ -21,7 +21,7 @@ Bravo
Alpha
{% if page.version == 'dotcom' or page.version ver_lt "2.14" %}
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_lt "enterprise-server@2.14" %}
Bravo
@ -32,7 +32,7 @@ Bravo
## 3
<div class="example3">
{% if page.version == "dotcom" %}
{% if currentVersion == "free-pro-team@latest" %}
Alpha
@ -40,7 +40,7 @@ Alpha
Bravo
{% if page.version ver_lt "2.14" %}
{% if currentVersion ver_lt "enterprise-server@2.14" %}
Charlie
@ -53,11 +53,11 @@ Charlie
<div class="example4">
{% if page.version == "dotcom" %}
{% if currentVersion == "free-pro-team@latest" %}
Alpha
{% if page.version ver_lt "2.14" %}
{% if currentVersion ver_lt "enterprise-server@2.14" %}
Bravo
@ -74,11 +74,11 @@ Charlie
## 5
<div class="example5">
{% if page.version ver_lt "2.14" %}
{% if currentVersion ver_lt "enterprise-server@2.14" %}
Alpha
{% if page.version == "dotcom" %}
{% if currentVersion == "free-pro-team@latest" %}
Bravo
@ -95,7 +95,7 @@ Charlie
## 6
<div class="example6">
{% if page.version ver_lt "2.16" %}
{% if currentVersion ver_lt "enterprise-server@2.16" %}
Alpha
@ -103,7 +103,7 @@ Alpha
Charlie
{% if page.version != "dotcom" and page.version ver_lt "2.14" %}
{% if currentVersion != "free-pro-team@latest" and currentVersion ver_lt "enterprise-server@2.14" %}
Bravo
@ -116,11 +116,11 @@ Bravo
## 7
<div class="example7">
{% if page.version != "dotcom" and page.version ver_lt "2.14" %}
{% if currentVersion != "free-pro-team@latest" and currentVersion ver_lt "enterprise-server@2.14" %}
Alpha
{% if page.version ver_lt "2.14" %}
{% if currentVersion ver_lt "enterprise-server@2.14" %}
Bravo
@ -137,7 +137,7 @@ Charlie
## 8
<div class="example8">
{% if page.version ver_lt "2.14" %}
{% if currentVersion ver_lt "enterprise-server@2.14" %}
Alpha
@ -145,7 +145,7 @@ Alpha
Bravo
{% if page.version ver_gt "2.16" %}
{% if currentVersion ver_gt "enterprise-server@2.16" %}
Charlie

Просмотреть файл

@ -6,7 +6,7 @@ intro: Remove liquid only
## 1
<div class="example1">
{% if page.version != "2.13" %}
{% if currentVersion != "enterprise-server@2.13" %}
Alpha
@ -17,7 +17,7 @@ Alpha
## 2
<div class="example2">
{% if page.version == 'dotcom' or page.version != "2.13" %}
{% if currentVersion == "free-pro-team@latest" or currentVersion != "enterprise-server@2.13" %}
Alpha
@ -28,7 +28,7 @@ Alpha
## 3
<div class="example3">
{% if page.version == "dotcom" %}
{% if currentVersion == "free-pro-team@latest" %}
Alpha
@ -36,7 +36,7 @@ Alpha
Bravo
{% if page.version != "2.13" %}
{% if currentVersion != "enterprise-server@2.13" %}
Charlie
@ -48,11 +48,11 @@ Charlie
## 4
<div class="example4">
{% if page.version == "dotcom" %}
{% if currentVersion == "free-pro-team@latest" %}
Alpha
{% if page.version != "2.13" %}
{% if currentVersion != "enterprise-server@2.13" %}
Bravo
@ -69,11 +69,11 @@ Charlie
## 5
<div class="example5">
{% if page.version != "2.13" %}
{% if currentVersion != "enterprise-server@2.13" %}
Alpha
{% if page.version == "dotcom" %}
{% if currentVersion == "free-pro-team@latest" %}
Bravo
@ -90,7 +90,7 @@ Charlie
## 6
<div class="example6">
{% if page.version != 'dotcom' and page.version != "2.13" %}
{% if currentVersion != "free-pro-team@latest" and currentVersion != "enterprise-server@2.13" %}
Alpha

Просмотреть файл

@ -4,35 +4,35 @@ title: Whitespace tests
## 1
<div class="example1">
{% if page.version ver_gt "2.13" %}
{% if currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
{% endif %}
</div>
## 2
<div class="example2">
{%- if page.version ver_gt "2.13" %}
{%- if currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
{% endif %}
</div>
## 3
<div class="example3">
{% if page.version == 'dotcom' or page.version ver_gt "2.13" %}
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
{%- endif %}
</div>
## 4
<div class="example4">
{%- if page.version == 'dotcom' or page.version ver_gt "2.13" %}
{%- if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
{%- endif %}
</div>
## 5
<div class="example5">
{% if page.version ver_gt "2.13" %}
{% if currentVersion ver_gt "enterprise-server@2.13" %}
Alpha
{% endif %}
</div>
@ -40,7 +40,7 @@ title: Whitespace tests
## 6
<div class="example6">
Alpha
{% if page.version == 'dotcom' or page.version ver_gt "2.13" %}
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.13" %}
Bravo
{% endif %}
Charlie
@ -48,6 +48,6 @@ title: Whitespace tests
## 7
<div class="example7">
Alpha{% if page.version == 'dotcom' or page.version ver_gt "2.13" %}
Alpha{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.13" %}
Bravo{% endif %}
</div>