1
0
mirror of synced 2025-12-23 21:07:12 -05:00
This commit is contained in:
Octomerger Bot
2021-03-05 04:52:15 +10:00
committed by GitHub
parent 136a6bd1a3
commit cedfe4dd59
15 changed files with 226 additions and 16 deletions

View File

@@ -2,10 +2,10 @@ name: Browser Tests
on: on:
workflow_dispatch: workflow_dispatch:
push: # push:
branches: # branches:
- main # - main
pull_request: # pull_request:
jobs: jobs:
see_if_should_skip: see_if_should_skip:

View File

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

View File

@@ -45,7 +45,7 @@ You can search for the following information across all repositories you can acc
- [Discussions](/github/searching-for-information-on-github/searching-discussions){% endif %} - [Discussions](/github/searching-for-information-on-github/searching-discussions){% endif %}
- [Code](/articles/searching-code) - [Code](/articles/searching-code)
- [Commits](/articles/searching-commits) - [Commits](/articles/searching-commits)
- [Users](/articles/searching-users){% if currentVersion == "free-pro-team@latest" or currentVersion == "github-ae@latest" or currentVersion ver_gt "enterprise-server@2.1" %} - [Users](/articles/searching-users){% if currentVersion == "free-pro-team@latest" or currentVersion == "github-ae@latest" or currentVersion ver_gt "enterprise-server@2.21" %}
- [Packages](/github/searching-for-information-on-github/searching-for-packages){% endif %} - [Packages](/github/searching-for-information-on-github/searching-for-packages){% endif %}
- [Wikis](/articles/searching-wikis) - [Wikis](/articles/searching-wikis)

View File

@@ -35,8 +35,9 @@ The repository owner has full control of the repository. In addition to the acti
| Delete the repository | "[Deleting a repository](/github/administering-a-repository/deleting-a-repository)" | | Delete the repository | "[Deleting a repository](/github/administering-a-repository/deleting-a-repository)" |
| Manage the repository's topics | "[Classifying your repository with topics](/github/administering-a-repository/classifying-your-repository-with-topics)" |{% if currentVersion == "free-pro-team@latest" %} | Manage the repository's topics | "[Classifying your repository with topics](/github/administering-a-repository/classifying-your-repository-with-topics)" |{% if currentVersion == "free-pro-team@latest" %}
| Manage security and analysis settings for the repository | "[Managing security and analysis settings for your repository](/github/administering-a-repository/managing-security-and-analysis-settings-for-your-repository)" |{% endif %}{% if currentVersion == "free-pro-team@latest" %} | Manage security and analysis settings for the repository | "[Managing security and analysis settings for your repository](/github/administering-a-repository/managing-security-and-analysis-settings-for-your-repository)" |{% endif %}{% if currentVersion == "free-pro-team@latest" %}
| Enable the dependency graph for a private repository | "[Exploring the dependencies of a repository](/github/visualizing-repository-data-with-graphs/exploring-the-dependencies-of-a-repository#enabling-and-disabling-the-dependency-graph-for-a-private-repository)" |{% endif %} | Enable the dependency graph for a private repository | "[Exploring the dependencies of a repository](/github/visualizing-repository-data-with-graphs/exploring-the-dependencies-of-a-repository#enabling-and-disabling-the-dependency-graph-for-a-private-repository)" |{% endif %}{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@3.0" %}
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@3.0" %}| Delete and restore packages | "[Deleting and restoring a package](/packages/learn-github-packages/deleting-and-restoring-a-package)" |{% elsif currentVersion ver_lt "enterprise-server@3.1" or currentVersion == "github-ae@latest" %}| Delete packages | "[Deleting packages](/packages/learn-github-packages/deleting-a-package)" |{% endif %} | Delete and restore packages | "[Deleting and restoring a package](/packages/learn-github-packages/deleting-and-restoring-a-package)" |{% endif %}{% if currentVersion == "enterprise-server@2.22" or currentVersion == "enterprise-server@3.0" or currentVersion == "github-ae@latest" %}
| Delete packages | "[Deleting packages](/packages/learn-github-packages/deleting-a-package)" |{% endif %}
| Customize the repository's social media preview | "[Customizing your repository's social media preview](/github/administering-a-repository/customizing-your-repositorys-social-media-preview)" | | Customize the repository's social media preview | "[Customizing your repository's social media preview](/github/administering-a-repository/customizing-your-repositorys-social-media-preview)" |
| Create a template from the repository | "[Creating a template repository](/github/creating-cloning-and-archiving-repositories/creating-a-template-repository)" |{% if currentVersion == "free-pro-team@latest" or enterpriseServerVersions contains currentVersion %} | Create a template from the repository | "[Creating a template repository](/github/creating-cloning-and-archiving-repositories/creating-a-template-repository)" |{% if currentVersion == "free-pro-team@latest" or enterpriseServerVersions contains currentVersion %}
| Receive {% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.21" %}{% data variables.product.prodname_dependabot_alerts %}{% else %}security alerts{% endif %} for vulnerable dependencies | "[About alerts for vulnerable dependencies](/github/managing-security-vulnerabilities/about-alerts-for-vulnerable-dependencies)" |{% endif %}{% if currentVersion == "free-pro-team@latest" %} | Receive {% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.21" %}{% data variables.product.prodname_dependabot_alerts %}{% else %}security alerts{% endif %} for vulnerable dependencies | "[About alerts for vulnerable dependencies](/github/managing-security-vulnerabilities/about-alerts-for-vulnerable-dependencies)" |{% endif %}{% if currentVersion == "free-pro-team@latest" %}

View File

@@ -1,2 +1,2 @@
1. In the left sidebar, click **OAuth Apps**. 1. In the left sidebar, click **OAuth Apps**.
![OAuth Apps section](/assets/images/settings/developer-settings-oauth-apps.png) ![OAuth Apps section](/assets/images/help/settings/developer-settings-oauth-apps.png)

View File

@@ -66,6 +66,10 @@ module.exports = async function renderContent (
.trim() .trim()
} }
if (options.cheerioObject) {
return cheerio.load(html, { xmlMode: true })
}
if (options.encodeEntities) html = entities.encode(html) if (options.encodeEntities) html = entities.encode(html)
return html.trim() return html.trim()

View File

@@ -139709,7 +139709,7 @@
"name", "name",
"head_sha" "head_sha"
], ],
"anyOf": [ "oneOf": [
{ {
"properties": { "properties": {
"status": { "status": {
@@ -139719,6 +139719,7 @@
} }
}, },
"required": [ "required": [
"status",
"conclusion" "conclusion"
], ],
"additionalProperties": true "additionalProperties": true

View File

@@ -79203,7 +79203,7 @@
"name", "name",
"head_sha" "head_sha"
], ],
"anyOf": [ "oneOf": [
{ {
"properties": { "properties": {
"status": { "status": {
@@ -79213,6 +79213,7 @@
} }
}, },
"required": [ "required": [
"status",
"conclusion" "conclusion"
], ],
"additionalProperties": true "additionalProperties": true

View File

@@ -82135,7 +82135,7 @@
"name", "name",
"head_sha" "head_sha"
], ],
"anyOf": [ "oneOf": [
{ {
"properties": { "properties": {
"status": { "status": {
@@ -82145,6 +82145,7 @@
} }
}, },
"required": [ "required": [
"status",
"conclusion" "conclusion"
], ],
"additionalProperties": true "additionalProperties": true

View File

@@ -84244,7 +84244,7 @@
"name", "name",
"head_sha" "head_sha"
], ],
"anyOf": [ "oneOf": [
{ {
"properties": { "properties": {
"status": { "status": {
@@ -84254,6 +84254,7 @@
} }
}, },
"required": [ "required": [
"status",
"conclusion" "conclusion"
], ],
"additionalProperties": true "additionalProperties": true

View File

@@ -95077,7 +95077,7 @@
"name", "name",
"head_sha" "head_sha"
], ],
"anyOf": [ "oneOf": [
{ {
"properties": { "properties": {
"status": { "status": {
@@ -95087,6 +95087,7 @@
} }
}, },
"required": [ "required": [
"status",
"conclusion" "conclusion"
], ],
"additionalProperties": true "additionalProperties": true

View File

@@ -121969,7 +121969,7 @@
"name", "name",
"head_sha" "head_sha"
], ],
"anyOf": [ "oneOf": [
{ {
"properties": { "properties": {
"status": { "status": {
@@ -121979,6 +121979,7 @@
} }
}, },
"required": [ "required": [
"status",
"conclusion" "conclusion"
], ],
"additionalProperties": true "additionalProperties": true

View File

@@ -127095,7 +127095,7 @@
"name", "name",
"head_sha" "head_sha"
], ],
"anyOf": [ "oneOf": [
{ {
"properties": { "properties": {
"status": { "status": {
@@ -127105,6 +127105,7 @@
} }
}, },
"required": [ "required": [
"status",
"conclusion" "conclusion"
], ],
"additionalProperties": true "additionalProperties": true

View File

@@ -109550,7 +109550,7 @@
"name", "name",
"head_sha" "head_sha"
], ],
"anyOf": [ "oneOf": [
{ {
"properties": { "properties": {
"status": { "status": {
@@ -109560,6 +109560,7 @@
} }
}, },
"required": [ "required": [
"status",
"conclusion" "conclusion"
], ],
"additionalProperties": true "additionalProperties": true

197
script/update-internal-links.js Executable file
View File

@@ -0,0 +1,197 @@
#!/usr/bin/env node
const fs = require('fs')
const walk = require('walk-sync')
const path = require('path')
const astFromMarkdown = require('mdast-util-from-markdown')
const visit = require('unist-util-visit')
const { loadPages, loadPageMap } = require('../lib/pages')
const loadSiteData = require('../lib/site-data')
const loadRedirects = require('../lib/redirects/precompile')
const { getPathWithoutLanguage, getPathWithoutVersion } = require('../lib/path-utils')
const allVersions = Object.keys(require('../lib/all-versions'))
const frontmatter = require('../lib/read-frontmatter')
const renderContent = require('../lib/render-content')
const patterns = require('../lib/patterns')
const walkFiles = (pathToWalk) => {
return walk(path.posix.join(__dirname, '..', pathToWalk), { includeBasePath: true, directories: false })
.filter(file => file.endsWith('.md') && !file.endsWith('README.md'))
.filter(file => !file.includes('/early-access/')) // ignore EA for now
}
const allFiles = walkFiles('content').concat(walkFiles('data'))
// The script will throw an error if it finds any markup not represented here.
// Hacky but it captures the current rare edge cases.
const linkInlineMarkup = {
emphasis: '*',
strong: '**'
}
const currentVersionWithSpacesRegex = /\/enterprise\/{{ currentVersion }}/g
const currentVersionWithoutSpaces = '/enterprise/{{currentVersion}}'
// [start-readme]
//
// Run this script to find internal links in all content and data Markdown files, check if either the title or link
// (or both) are outdated, and automatically update them if so.
//
// Exceptions:
// * Links with fragments (e.g., [Bar](/foo#bar)) will get their root links updated if necessary, but the fragment
// and title will be unchanged (e.g., [Bar](/noo#bar)).
// * Links with hardcoded versions (e.g., [Foo](/enterprise-server/baz)) will get their root links updated if
// necessary, but the hardcoded versions will be preserved (e.g., [Foo](/enterprise-server/qux)).
// * Links with Liquid in the titles will have their root links updated if necessary, but the titles will be preserved.
//
// [end-readme]
main()
async function main () {
console.log('Working...')
const pageList = await loadPages()
const pageMap = await loadPageMap(pageList)
const redirects = await loadRedirects(pageList)
const site = await loadSiteData()
const context = {
pages: pageMap,
redirects,
site: site.en.site,
currentLanguage: 'en'
}
for (const file of allFiles) {
const { data, content } = frontmatter(fs.readFileSync(file, 'utf8'))
let newContent = content
// Do a blanket find-replace for /enterprise/{{ currentVersion }}/ to /enterprise/{{currentVersion}}/
// so that the AST parser recognizes the link as a link node. The spaces prevent it from doing so.
newContent = newContent.replace(currentVersionWithSpacesRegex, currentVersionWithoutSpaces)
const ast = astFromMarkdown(newContent)
// We can't do async functions within visit, so gather the nodes upfront
const nodesPerFile = []
visit(ast, node => {
if (node.type !== 'link') return
if (!node.url.startsWith('/')) return
if (node.url.startsWith('/assets')) return
if (node.url.startsWith('/public')) return
if (node.url.includes('/11.10.340/')) return
if (node.url.includes('/2.1/')) return
if (node.url === '/') return
nodesPerFile.push(node)
})
// For every Markdown link...
for (const node of nodesPerFile) {
const oldLink = node.url
// Find and preserve any inline markup in link titles, like [*Foo*](/foo)
let inlineMarkup = ''
if (node.children[0].children) {
inlineMarkup = linkInlineMarkup[node.children[0].type]
if (!inlineMarkup) {
console.error(`Cannot find an inline markup entry for ${node.children[0].type}!`)
process.exit(1)
}
}
const oldTitle = node.children[0].value || node.children[0].children[0].value
const oldMarkdownLink = `[${inlineMarkup}${oldTitle}${inlineMarkup}](${oldLink})`
// As a blanket rule, only update titles in links that begin with quotes. (Many links
// have punctuation before the closing quotes, so we'll only check for opening quotes.)
// Update: "[Foo](/foo)
// Do not update: [Bar](/bar)
const hasQuotesAroundLink = newContent.includes(`"${oldMarkdownLink}`)
let foundPage, fragmentMatch, versionMatch
// Run through all supported versions...
for (const version of allVersions) {
context.currentVersion = version
// Render the link for each version using the renderContent pipeline, which includes the rewrite-local-links plugin.
const $ = await renderContent(oldMarkdownLink, context, { cheerioObject: true })
let linkToCheck = $('a').attr('href')
// We need to preserve fragments and hardcoded versions if any are found.
fragmentMatch = oldLink.match(/(#.*$)/)
versionMatch = oldLink.match(/(enterprise-server(?:@.[^/]*?)?)\//)
// Remove the fragment for now.
linkToCheck = linkToCheck
.replace(/#.*$/, '')
.replace(patterns.trailingSlash, '$1')
// Try to find the rendered link in the set of pages!
foundPage = findPage(linkToCheck, pageMap, redirects)
// Once a page is found for a particular version, exit immediately; we don't need to check the other versions
// because all we care about is the page title and path.
if (foundPage) {
break
}
}
if (!foundPage) {
console.error(`Can't find link in pageMap! ${oldLink} in ${file.replace(process.cwd(), '')}`)
process.exit(1)
}
// If the original link includes a fragment OR the original title includes Liquid, do not change;
// otherwise, use the found page title. (We don't want to update the title if a fragment is found because
// the title likely points to the fragment section header, not the page title.)
const newTitle = fragmentMatch || oldTitle.includes('{%') || !hasQuotesAroundLink ? oldTitle : foundPage.title
// If the original link includes a fragment, append it to the found page path.
// Also remove the language code because Markdown links don't include language codes.
let newLink = getPathWithoutLanguage(fragmentMatch ? foundPage.path + fragmentMatch[1] : foundPage.path)
// If the original link includes a hardcoded version, preserve it; otherwise, remove versioning
// because Markdown links don't include versioning.
newLink = versionMatch ? `/${versionMatch[1]}${getPathWithoutVersion(newLink)}` : getPathWithoutVersion(newLink)
let newMarkdownLink = `[${inlineMarkup}${newTitle}${inlineMarkup}](${newLink})`
// Handle a few misplaced quotation marks.
if (oldMarkdownLink.includes('["')) {
newMarkdownLink = `"${newMarkdownLink}`
}
// Stream the results to console as we find them.
if (oldMarkdownLink !== newMarkdownLink) {
console.log('old link', oldMarkdownLink)
console.log('new link', newMarkdownLink)
console.log('-------')
}
newContent = newContent.replace(oldMarkdownLink, newMarkdownLink)
}
fs.writeFileSync(file, frontmatter.stringify(newContent, data, { lineWidth: 10000 }))
}
console.log('Done!')
}
function findPage (tryPath, pageMap, redirects) {
if (pageMap[tryPath]) {
return {
title: pageMap[tryPath].title,
path: tryPath
}
}
if (pageMap[redirects[tryPath]]) {
return {
title: pageMap[redirects[tryPath]].title,
path: redirects[tryPath]
}
}
}