Skip to content

Commit eaadfa5

Browse files
authored
Merge pull request #9140 from github/repo-sync
repo sync
2 parents d09de3c + 3b002ae commit eaadfa5

File tree

4 files changed

+49
-12
lines changed

4 files changed

+49
-12
lines changed

.github/actions-scripts/enterprise-server-issue-templates/deprecation-issue.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,25 @@ The day after a GHES version's [deprecation date](https://github.com/github/docs
3636
In your `docs-internal` checkout:
3737
- [ ] Create a new branch: `git checkout -b deprecate-<version>`.
3838
- [ ] Edit `lib/enterprise-server-releases.js` by moving the number to be deprecated into the `deprecated` array.
39-
- [ ] Run `script/enterprise-server-deprecations/remove-static-files.js` and commit results.
40-
- [ ] Run `script/enterprise-server-deprecations/remove-redirects.js` and commit results.
4139
- [ ] Open a new PR. Make sure to check the following:
4240
- [ ] Tests are passing.
43-
- [ ] The deprecated version renders on staging as expected.
44-
- [ ] The new oldest supported version renders on staging as expected. Also check the banner text.
45-
- [ ] 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.
46-
- [ ] In your `docs-internal` checkout, from your `deprecate-<version>` branch: `git checkout -b remove-<version>-markup`
41+
- [ ] 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.
42+
- [ ] 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.
43+
44+
## Step 5: Remove static files for the version
45+
46+
- [ ] In your `docs-internal` checkout, from your `remove-<version>-static-files` branch: `git checkout -b remove-<version>-static-files`
47+
- [ ] Run `script/enterprise-server-deprecations/remove-static-files.js` and commit results.
48+
- [ ] Run `script/enterprise-server-deprecations/remove-redirects.js` and commit results.
49+
- [ ] Open a new PR.
50+
- [ ] 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.
51+
52+
## Step 6: Remove the liquid conditionals and content for the version
53+
54+
- [ ] In your `docs-internal` checkout, from your `remove-<version>-markup` branch: `git checkout -b remove-<version>-markup`
55+
- [ ] Remove the outdated Liquid markup and frontmatter.
4756
- [ ] Run the script: `script/enterprise-server-deprecations/remove-version-markup.js --release <number>`.
4857
- [ ] Spot check a few changes. Content, frontmatter, and data files should all have been updated.
4958
- [ ] Open a PR with the results. The diff may be large and complex, so make sure to get a review from `@github/docs-content`.
5059
- [ ] Debug any test failures or unexpected results.
51-
- [ ] When the PR is approved, merge it in to complete the deprecation.
60+
- [ ] When the PR is approved, merge it in to complete the deprecation. This can be merged independently from step 5.

script/enterprise-server-deprecations/archive-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class RewriteAssetPathsPlugin {
6565
// https://githubdocs.azureedge.net/github-images/enterprise/2.17/assets/images/foo/bar.png
6666
if (resource.isHtml()) {
6767
newBody = text.replace(
68-
/(?<attribute>src|href)="(?:\.\.\/)*(?<basepath>_next\/static|javascripts|stylesheets|assets\/fonts|assets\/images|node_modules)/g,
68+
/(?<attribute>src|href)="(?:\.\.\/|\/)*(?<basepath>_next\/static|javascripts|stylesheets|assets\/fonts|assets\/images|node_modules)/g,
6969
(match, attribute, basepath) => {
7070
let replaced = path.join('/enterprise', this.version, basepath)
7171
if (basepath === 'assets/images') {

script/enterprise-server-deprecations/remove-static-files.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const webhooksStaticDir = path.join(process.cwd(), 'lib/webhooks/static')
1616
const graphqlStaticDir = path.join(process.cwd(), 'lib/graphql/static')
1717
const restDecoratedDir = path.join(process.cwd(), 'lib/rest/static/decorated')
1818
const restDereferencedDir = path.join(process.cwd(), 'lib/rest/static/dereferenced')
19+
const lunrIndexDir = path.join(process.cwd(), 'lib/search/indexes')
1920

2021
const supportedEnterpriseVersions = Object.values(allVersions).filter(
2122
(v) => v.plan === 'enterprise-server'
@@ -39,6 +40,13 @@ const openApiBaseName = supportedEnterpriseVersions.map((v) => v.openApiBaseName
3940
removeFiles(dir, openApiBaseName, supportedOpenApiVersions)
4041
})
4142

43+
// Lunr
44+
const lunrBaseName = 'github-docs-'
45+
const supportedLunrVersions = Object.values(allVersions).map((v) =>
46+
v.miscVersionName.replace('ghes-', '')
47+
)
48+
removeFiles(lunrIndexDir, lunrBaseName, supportedLunrVersions)
49+
4250
function removeFiles(dir, baseName, supportedVersions) {
4351
fs.readdirSync(dir)
4452
.filter((file) => file.includes(baseName))

script/helpers/remove-liquid-statements.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { getLiquidConditionalsWithContent } from './get-liquid-conditionals.js'
22
import getVersionBlocks from './get-version-blocks.js'
33
import { allVersions } from '../../lib/all-versions.js'
4+
import { Tokenizer } from 'liquidjs'
45
const supportedShortVersions = Object.values(allVersions).map((v) => v.shortName)
56
const updateRangeKeepGhes = 'updateRangeKeepGhes'
67
const updateRangeRemoveGhes = 'updateRangeRemoveGhes'
78
const removeRangeAndContent = 'removeRangeAndContent'
8-
9+
const tokenize = (str) => {
10+
const tokenizer = new Tokenizer(str)
11+
return tokenizer.readTopLevelTokens()
12+
}
913
// This module is used by script/enterprise-server-deprecations/remove-version-markup.js to remove
1014
// and update Liquid conditionals when a GHES release is being deprecated. It is also used by
1115
// tests/content/remove-liquid-statements.js.
@@ -187,9 +191,25 @@ export default function removeLiquidStatements(content, release, nextOldestRelea
187191

188192
// If the block has an else, remove the else, its content, and the endif.
189193
if (versionBlock.hasElse) {
190-
const replaceRegex = /{%-? else -?%}[\S\s]+?{%-? endif -?%}\n?/
191-
192-
versionBlock.newContent = versionBlock.newContent.replace(replaceRegex, '')
194+
let elseStartIndex
195+
let ifCondFlag = false
196+
// tokenize the content including the nested conditionals to find
197+
// the unmatched else tag. Remove content from the start of the
198+
// else tag to the end of the content. The tokens return have different
199+
// `kind`s and can be liquid tags, HTML, and a variety of things.
200+
// A value of 4 is a liquid tag. See https://liquidjs.com/api/enums/parser_token_kind_.tokenkind.html.
201+
tokenize(versionBlock.newContent)
202+
.filter((elem) => elem.kind === 4)
203+
.forEach((tag) => {
204+
if (tag.name === 'ifversion' || tag.name === 'if') {
205+
ifCondFlag = true
206+
} else if (tag.name === 'endif' && ifCondFlag === true) {
207+
ifCondFlag = false
208+
} else if (tag.name === 'else' && ifCondFlag === false) {
209+
elseStartIndex = tag.begin
210+
}
211+
})
212+
versionBlock.newContent = versionBlock.newContent.slice(0, elseStartIndex)
193213
}
194214
}
195215
}

0 commit comments

Comments
 (0)