@@ -36,16 +36,25 @@ The day after a GHES version's [deprecation date](https://github.com/github/docs
|
||||
In your `docs-internal` checkout:
|
||||
- [ ] Create a new branch: `git checkout -b deprecate-<version>`.
|
||||
- [ ] Edit `lib/enterprise-server-releases.js` by moving the number to be deprecated into the `deprecated` array.
|
||||
- [ ] Run `script/enterprise-server-deprecations/remove-static-files.js` and commit results.
|
||||
- [ ] Run `script/enterprise-server-deprecations/remove-redirects.js` and commit results.
|
||||
- [ ] Open a new PR. Make sure to check the following:
|
||||
- [ ] Tests are passing.
|
||||
- [ ] The deprecated version renders on staging as expected.
|
||||
- [ ] The new oldest supported version renders on staging as expected. Also check the banner text.
|
||||
- [ ] Remove the outdated Liquid markup and frontmatter. It's recommended to create a topic branch off of your `deprecate-<version>` branch to isolate the changes for review.
|
||||
- [ ] In your `docs-internal` checkout, from your `deprecate-<version>` branch: `git checkout -b remove-<version>-markup`
|
||||
- [ ] The deprecated version renders on staging as expected. You should be able to navigate to docs.github.com/enterprise/<DEPRECATED VERSION> to access the docs. You should also be able to navigate to a page that is available in the deprecated version and change the version in the URL to the deprecated version, to test redirects.
|
||||
- [ ] The new oldest supported version renders on staging as expected. You should see a banner on the top of every page for the oldest supported version that notes when the version will be deprecated.
|
||||
|
||||
## Step 5: Remove static files for the version
|
||||
|
||||
- [ ] In your `docs-internal` checkout, from your `remove-<version>-static-files` branch: `git checkout -b remove-<version>-static-files`
|
||||
- [ ] Run `script/enterprise-server-deprecations/remove-static-files.js` and commit results.
|
||||
- [ ] Run `script/enterprise-server-deprecations/remove-redirects.js` and commit results.
|
||||
- [ ] Open a new PR.
|
||||
- [ ] Get a review from docs-engineering and merge. This step can be merged independently from step 6. The purpose of splitting up steps 5 and 6 is to focus the review on specific files.
|
||||
|
||||
## Step 6: Remove the liquid conditionals and content for the version
|
||||
|
||||
- [ ] In your `docs-internal` checkout, from your `remove-<version>-markup` branch: `git checkout -b remove-<version>-markup`
|
||||
- [ ] Remove the outdated Liquid markup and frontmatter.
|
||||
- [ ] Run the script: `script/enterprise-server-deprecations/remove-version-markup.js --release <number>`.
|
||||
- [ ] Spot check a few changes. Content, frontmatter, and data files should all have been updated.
|
||||
- [ ] Open a PR with the results. The diff may be large and complex, so make sure to get a review from `@github/docs-content`.
|
||||
- [ ] Debug any test failures or unexpected results.
|
||||
- [ ] When the PR is approved, merge it in to complete the deprecation.
|
||||
- [ ] When the PR is approved, merge it in to complete the deprecation. This can be merged independently from step 5.
|
||||
|
||||
@@ -65,7 +65,7 @@ class RewriteAssetPathsPlugin {
|
||||
// https://githubdocs.azureedge.net/github-images/enterprise/2.17/assets/images/foo/bar.png
|
||||
if (resource.isHtml()) {
|
||||
newBody = text.replace(
|
||||
/(?<attribute>src|href)="(?:\.\.\/)*(?<basepath>_next\/static|javascripts|stylesheets|assets\/fonts|assets\/images|node_modules)/g,
|
||||
/(?<attribute>src|href)="(?:\.\.\/|\/)*(?<basepath>_next\/static|javascripts|stylesheets|assets\/fonts|assets\/images|node_modules)/g,
|
||||
(match, attribute, basepath) => {
|
||||
let replaced = path.join('/enterprise', this.version, basepath)
|
||||
if (basepath === 'assets/images') {
|
||||
|
||||
@@ -16,6 +16,7 @@ const webhooksStaticDir = path.join(process.cwd(), 'lib/webhooks/static')
|
||||
const graphqlStaticDir = path.join(process.cwd(), 'lib/graphql/static')
|
||||
const restDecoratedDir = path.join(process.cwd(), 'lib/rest/static/decorated')
|
||||
const restDereferencedDir = path.join(process.cwd(), 'lib/rest/static/dereferenced')
|
||||
const lunrIndexDir = path.join(process.cwd(), 'lib/search/indexes')
|
||||
|
||||
const supportedEnterpriseVersions = Object.values(allVersions).filter(
|
||||
(v) => v.plan === 'enterprise-server'
|
||||
@@ -39,6 +40,13 @@ const openApiBaseName = supportedEnterpriseVersions.map((v) => v.openApiBaseName
|
||||
removeFiles(dir, openApiBaseName, supportedOpenApiVersions)
|
||||
})
|
||||
|
||||
// Lunr
|
||||
const lunrBaseName = 'github-docs-'
|
||||
const supportedLunrVersions = Object.values(allVersions).map((v) =>
|
||||
v.miscVersionName.replace('ghes-', '')
|
||||
)
|
||||
removeFiles(lunrIndexDir, lunrBaseName, supportedLunrVersions)
|
||||
|
||||
function removeFiles(dir, baseName, supportedVersions) {
|
||||
fs.readdirSync(dir)
|
||||
.filter((file) => file.includes(baseName))
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { getLiquidConditionalsWithContent } from './get-liquid-conditionals.js'
|
||||
import getVersionBlocks from './get-version-blocks.js'
|
||||
import { allVersions } from '../../lib/all-versions.js'
|
||||
import { Tokenizer } from 'liquidjs'
|
||||
const supportedShortVersions = Object.values(allVersions).map((v) => v.shortName)
|
||||
const updateRangeKeepGhes = 'updateRangeKeepGhes'
|
||||
const updateRangeRemoveGhes = 'updateRangeRemoveGhes'
|
||||
const removeRangeAndContent = 'removeRangeAndContent'
|
||||
|
||||
const tokenize = (str) => {
|
||||
const tokenizer = new Tokenizer(str)
|
||||
return tokenizer.readTopLevelTokens()
|
||||
}
|
||||
// This module is used by script/enterprise-server-deprecations/remove-version-markup.js to remove
|
||||
// and update Liquid conditionals when a GHES release is being deprecated. It is also used by
|
||||
// tests/content/remove-liquid-statements.js.
|
||||
@@ -187,9 +191,25 @@ export default function removeLiquidStatements(content, release, nextOldestRelea
|
||||
|
||||
// If the block has an else, remove the else, its content, and the endif.
|
||||
if (versionBlock.hasElse) {
|
||||
const replaceRegex = /{%-? else -?%}[\S\s]+?{%-? endif -?%}\n?/
|
||||
|
||||
versionBlock.newContent = versionBlock.newContent.replace(replaceRegex, '')
|
||||
let elseStartIndex
|
||||
let ifCondFlag = false
|
||||
// tokenize the content including the nested conditionals to find
|
||||
// the unmatched else tag. Remove content from the start of the
|
||||
// else tag to the end of the content. The tokens return have different
|
||||
// `kind`s and can be liquid tags, HTML, and a variety of things.
|
||||
// A value of 4 is a liquid tag. See https://liquidjs.com/api/enums/parser_token_kind_.tokenkind.html.
|
||||
tokenize(versionBlock.newContent)
|
||||
.filter((elem) => elem.kind === 4)
|
||||
.forEach((tag) => {
|
||||
if (tag.name === 'ifversion' || tag.name === 'if') {
|
||||
ifCondFlag = true
|
||||
} else if (tag.name === 'endif' && ifCondFlag === true) {
|
||||
ifCondFlag = false
|
||||
} else if (tag.name === 'else' && ifCondFlag === false) {
|
||||
elseStartIndex = tag.begin
|
||||
}
|
||||
})
|
||||
versionBlock.newContent = versionBlock.newContent.slice(0, elseStartIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user