Merge branch 'main' of github.com:github/docs-internal into yank-outdated-redirect-code
This commit is contained in:
68
lib/data-directory.js
Normal file
68
lib/data-directory.js
Normal file
@@ -0,0 +1,68 @@
|
||||
const assert = require('assert')
|
||||
const fs = require('fs').promises
|
||||
const path = require('path')
|
||||
const walk = require('walk-sync')
|
||||
const yaml = require('js-yaml')
|
||||
const { isRegExp, set } = require('lodash')
|
||||
const filenameToKey = require('./filename-to-key')
|
||||
|
||||
module.exports = async function dataDirectory (dir, opts = {}) {
|
||||
const defaultOpts = {
|
||||
preprocess: (content) => { return content },
|
||||
ignorePatterns: [/README\.md$/i],
|
||||
extensions: [
|
||||
'.json',
|
||||
'.md',
|
||||
'.markdown',
|
||||
'.yaml',
|
||||
'.yml'
|
||||
]
|
||||
}
|
||||
|
||||
opts = Object.assign({}, defaultOpts, opts)
|
||||
|
||||
// validate input
|
||||
assert(Array.isArray(opts.ignorePatterns))
|
||||
assert(opts.ignorePatterns.every(isRegExp))
|
||||
assert(Array.isArray(opts.extensions))
|
||||
assert(opts.extensions.length)
|
||||
|
||||
// start with an empty data object
|
||||
const data = {}
|
||||
|
||||
// find YAML and Markdown files in the given directory, recursively
|
||||
await Promise.all(walk(dir, { includeBasePath: true })
|
||||
.filter(filename => {
|
||||
// ignore files that match any of ignorePatterns regexes
|
||||
if (opts.ignorePatterns.some(pattern => pattern.test(filename))) return false
|
||||
|
||||
// ignore files that don't have a whitelisted file extension
|
||||
return opts.extensions.includes(path.extname(filename).toLowerCase())
|
||||
})
|
||||
.map(async filename => {
|
||||
// derive `foo.bar.baz` object key from `foo/bar/baz.yml` filename
|
||||
const key = filenameToKey(path.relative(dir, filename))
|
||||
const extension = path.extname(filename).toLowerCase()
|
||||
|
||||
let fileContent = await fs.readFile(filename, 'utf8')
|
||||
|
||||
if (opts.preprocess) fileContent = opts.preprocess(fileContent)
|
||||
|
||||
// add this file's data to the global data object
|
||||
switch (extension) {
|
||||
case '.json':
|
||||
set(data, key, JSON.parse(fileContent))
|
||||
break
|
||||
case '.yaml':
|
||||
case '.yml':
|
||||
set(data, key, yaml.safeLoad(fileContent, { filename }))
|
||||
break
|
||||
case '.md':
|
||||
case '.markdown':
|
||||
set(data, key, fileContent)
|
||||
break
|
||||
}
|
||||
}))
|
||||
|
||||
return data
|
||||
}
|
||||
28
lib/filename-to-key.js
Normal file
28
lib/filename-to-key.js
Normal file
@@ -0,0 +1,28 @@
|
||||
/* eslint-disable prefer-regex-literals */
|
||||
const path = require('path')
|
||||
const { escapeRegExp } = require('lodash')
|
||||
|
||||
// slash at the beginning of a filename
|
||||
const leadingPathSeparator = new RegExp(`^${escapeRegExp(path.sep)}`)
|
||||
const windowsLeadingPathSeparator = new RegExp('^/')
|
||||
|
||||
// all slashes in the filename. path.sep is OS agnostic (windows, mac, etc)
|
||||
const pathSeparator = new RegExp(escapeRegExp(path.sep), 'g')
|
||||
const windowsPathSeparator = new RegExp('/', 'g')
|
||||
|
||||
// handle MS Windows style double-backslashed filenames
|
||||
const windowsDoubleSlashSeparator = new RegExp('\\\\', 'g')
|
||||
|
||||
// derive `foo.bar.baz` object key from `foo/bar/baz.yml` filename
|
||||
module.exports = function filenameToKey (filename) {
|
||||
const extension = new RegExp(`${path.extname(filename)}$`)
|
||||
const key = filename
|
||||
.replace(extension, '')
|
||||
.replace(leadingPathSeparator, '')
|
||||
.replace(windowsLeadingPathSeparator, '')
|
||||
.replace(pathSeparator, '.')
|
||||
.replace(windowsPathSeparator, '.')
|
||||
.replace(windowsDoubleSlashSeparator, '.')
|
||||
|
||||
return key
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
const Liquid = require('liquid')
|
||||
|
||||
const Syntax = /([a-z0-9/\\_.-]+)/i
|
||||
const Syntax = /([a-z0-9/\\_.\-[\]]+)/i
|
||||
const SyntaxHelp = "Syntax Error in 'data' - Valid syntax: data [path]"
|
||||
|
||||
module.exports = class Data extends Liquid.Tag {
|
||||
|
||||
25
lib/page.js
25
lib/page.js
@@ -1,5 +1,5 @@
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const fs = require('fs').promises
|
||||
const path = require('path')
|
||||
const cheerio = require('cheerio')
|
||||
const patterns = require('./patterns')
|
||||
@@ -23,15 +23,30 @@ const slash = require('slash')
|
||||
const statsd = require('./statsd')
|
||||
|
||||
class Page {
|
||||
constructor (opts) {
|
||||
static async init (opts) {
|
||||
assert(opts.relativePath, 'relativePath is required')
|
||||
assert(opts.basePath, 'basePath is required')
|
||||
|
||||
const relativePath = slash(opts.relativePath)
|
||||
const fullPath = slash(path.join(opts.basePath, relativePath))
|
||||
const raw = await fs.readFile(fullPath, 'utf8')
|
||||
|
||||
return new Page({ ...opts, relativePath, fullPath, raw })
|
||||
}
|
||||
|
||||
static async exists (path) {
|
||||
try {
|
||||
return await fs.stat(path)
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') return false
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
|
||||
constructor (opts) {
|
||||
assert(opts.languageCode, 'languageCode is required')
|
||||
|
||||
Object.assign(this, { ...opts })
|
||||
this.relativePath = slash(this.relativePath)
|
||||
this.fullPath = slash(path.join(this.basePath, this.relativePath))
|
||||
this.raw = fs.readFileSync(this.fullPath, 'utf8')
|
||||
|
||||
// TODO remove this when crowdin-support issue 66 has been resolved
|
||||
if (this.languageCode !== 'en' && this.raw.includes(': verdadero')) {
|
||||
|
||||
54
lib/pages.js
54
lib/pages.js
@@ -2,42 +2,50 @@ const path = require('path')
|
||||
const walk = require('walk-sync').entries
|
||||
const Page = require('./page')
|
||||
const languages = require('./languages')
|
||||
const fs = require('fs')
|
||||
const { mapLimit, filterLimit } = require('async')
|
||||
const FILE_READ_LIMIT = 500
|
||||
|
||||
async function loadPageList () {
|
||||
const pageList = []
|
||||
|
||||
// load english pages
|
||||
const englishPath = path.join(__dirname, '..', languages.en.dir, 'content')
|
||||
const englishPages = walk(englishPath)
|
||||
.filter(({ relativePath }) => {
|
||||
return relativePath.endsWith('.md') &&
|
||||
!relativePath.includes('README')
|
||||
})
|
||||
.map(fileData => new Page({ ...fileData, languageCode: languages.en.code }))
|
||||
|
||||
const englishPaths = walk(englishPath)
|
||||
.filter(({ relativePath }) =>
|
||||
relativePath.endsWith('.md') && !relativePath.includes('README')
|
||||
)
|
||||
const englishPages = await mapLimit(
|
||||
englishPaths,
|
||||
FILE_READ_LIMIT,
|
||||
async fileData => await Page.init({ ...fileData, languageCode: languages.en.code })
|
||||
)
|
||||
pageList.push(...englishPages)
|
||||
|
||||
// load matching pages in other languages
|
||||
for (const page of englishPages) {
|
||||
for (const language of Object.values(languages)) {
|
||||
if (language.code === 'en') continue
|
||||
|
||||
let localizedPaths = Object.values(languages)
|
||||
.filter(({ code }) => code !== 'en')
|
||||
.map(language => {
|
||||
const basePath = path.join(__dirname, '..', language.dir, 'content')
|
||||
const localizedPath = path.join(basePath, page.relativePath)
|
||||
try {
|
||||
fs.statSync(localizedPath)
|
||||
} catch (_) {
|
||||
continue
|
||||
}
|
||||
|
||||
pageList.push(new Page({
|
||||
relativePath: page.relativePath,
|
||||
return englishPages.map(page => ({
|
||||
basePath,
|
||||
relativePath: page.relativePath,
|
||||
localizedPath: path.join(basePath, page.relativePath),
|
||||
languageCode: language.code
|
||||
}))
|
||||
}
|
||||
}
|
||||
})
|
||||
.flat()
|
||||
localizedPaths = await filterLimit(
|
||||
localizedPaths,
|
||||
FILE_READ_LIMIT,
|
||||
async ({ localizedPath }) => Page.exists(localizedPath)
|
||||
)
|
||||
const localizedPages = await mapLimit(
|
||||
localizedPaths,
|
||||
FILE_READ_LIMIT,
|
||||
async ({ basePath, relativePath, languageCode }) =>
|
||||
await Page.init({ basePath, relativePath, languageCode })
|
||||
)
|
||||
pageList.push(...localizedPages)
|
||||
|
||||
return pageList
|
||||
}
|
||||
|
||||
@@ -15,7 +15,25 @@ module.exports = function getDocsPathFromDeveloperPath (oldDeveloperPath, allRed
|
||||
// oneoff redirect
|
||||
const v3OrgPreReceiveHooks = '/v3/orgs/pre_receive_hooks'
|
||||
if (newPath.endsWith(v3OrgPreReceiveHooks)) {
|
||||
newPath = newPath.replace(v3OrgPreReceiveHooks, '/v3/enterprise-admin/org_pre_receive_hooks')
|
||||
newPath = newPath.replace(v3OrgPreReceiveHooks, '/v3/enterprise-admin/organization_pre_receive_hooks')
|
||||
}
|
||||
|
||||
// oneoff redirect
|
||||
const v3RepoPreReceiveHooks = '/v3/repos/pre_receive_hooks'
|
||||
if (newPath.endsWith(v3RepoPreReceiveHooks)) {
|
||||
newPath = newPath.replace(v3RepoPreReceiveHooks, '/v3/enterprise-admin/repository_pre_receive_hooks')
|
||||
}
|
||||
|
||||
// oneoff redirect
|
||||
const v3OrgHooks = '/v3/orgs/hooks'
|
||||
if (newPath.endsWith(v3OrgHooks)) {
|
||||
newPath = newPath.replace(v3OrgHooks, '/v3/orgs/webhooks')
|
||||
}
|
||||
|
||||
// oneoff redirect
|
||||
const v3RepoHooks = '/v3/repos/hooks'
|
||||
if (newPath.endsWith(v3RepoHooks)) {
|
||||
newPath = newPath.replace(v3RepoHooks, '/v3/repos/webhooks')
|
||||
}
|
||||
|
||||
// oneoff redirect for a dotcom developer path to Enterprise-only path on docs.github.com
|
||||
@@ -46,6 +64,7 @@ module.exports = function getDocsPathFromDeveloperPath (oldDeveloperPath, allRed
|
||||
.replace(/_/g, '-')
|
||||
// this is a special oneoff replacement
|
||||
.replace('org-pre-receive-hooks', 'organization-pre-receive-hooks')
|
||||
.replace('repo-pre-receive-hooks', 'repository-pre-receive-hooks')
|
||||
: lastSegment
|
||||
}
|
||||
|
||||
|
||||
@@ -5975,6 +5975,123 @@
|
||||
"bodyParameters": [],
|
||||
"descriptionHTML": "<p>Forces the removal of a self-hosted runner from an enterprise. You can use this endpoint to completely remove the runner when the machine you were using no longer exists.</p>\n<p>You must authenticate using an access token with the <code>admin:enterprise</code> scope to use this endpoint.</p>"
|
||||
},
|
||||
{
|
||||
"verb": "get",
|
||||
"requestPath": "/enterprises/{enterprise}/audit-log",
|
||||
"serverUrl": "https://api.github.com",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "enterprise",
|
||||
"description": "The slug version of the enterprise name. You can also substitute this value with the enterprise id.",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"descriptionHTML": "<p>The slug version of the enterprise name. You can also substitute this value with the enterprise id.</p>"
|
||||
},
|
||||
{
|
||||
"name": "phrase",
|
||||
"description": "A search phrase. For more information, see [Searching the audit log](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/reviewing-the-audit-log-for-your-organization#searching-the-audit-log).",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"descriptionHTML": "<p>A search phrase. For more information, see <a href=\"https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/reviewing-the-audit-log-for-your-organization#searching-the-audit-log\">Searching the audit log</a>.</p>"
|
||||
},
|
||||
{
|
||||
"name": "include",
|
||||
"description": "The event types to include:\n\n- `web` - returns web (non-Git) events\n- `git` - returns Git events\n- `all` - returns both web and Git events\n\nThe default is `web`.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"web",
|
||||
"git",
|
||||
"all"
|
||||
]
|
||||
},
|
||||
"descriptionHTML": "<p>The event types to include:</p>\n<ul>\n<li><code>web</code> - returns web (non-Git) events</li>\n<li><code>git</code> - returns Git events</li>\n<li><code>all</code> - returns both web and Git events</li>\n</ul>\n<p>The default is <code>web</code>.</p>"
|
||||
},
|
||||
{
|
||||
"name": "after",
|
||||
"description": "A cursor, as given in the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header). If specified, the query only searches for events after this cursor.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"descriptionHTML": "<p>A cursor, as given in the <a href=\"https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header\">Link header</a>. If specified, the query only searches for events after this cursor.</p>"
|
||||
},
|
||||
{
|
||||
"name": "before",
|
||||
"description": "A cursor, as given in the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header). If specified, the query only searches for events before this cursor.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"descriptionHTML": "<p>A cursor, as given in the <a href=\"https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header\">Link header</a>. If specified, the query only searches for events before this cursor.</p>"
|
||||
},
|
||||
{
|
||||
"name": "per_page",
|
||||
"description": "Results per page (max 100)",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"default": 30
|
||||
},
|
||||
"descriptionHTML": "<p>Results per page (max 100)</p>"
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "Shell",
|
||||
"source": "curl \\\n -H \"Accept: application/vnd.github.v3+json\" \\\n https://api.github.com/enterprises/ENTERPRISE/audit-log",
|
||||
"html": "<pre><code class=\"hljs language-shell\">curl \\\n -H \"Accept: application/vnd.github.v3+json\" \\\n https://api.github.com/enterprises/ENTERPRISE/audit-log</code></pre>"
|
||||
},
|
||||
{
|
||||
"lang": "JavaScript",
|
||||
"source": "await octokit.request('GET /enterprises/{enterprise}/audit-log', {\n enterprise: 'enterprise'\n})",
|
||||
"html": "<pre><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">await</span> octokit.request(<span class=\"hljs-string\">'GET /enterprises/{enterprise}/audit-log'</span>, {\n <span class=\"hljs-attr\">enterprise</span>: <span class=\"hljs-string\">'enterprise'</span>\n})\n</code></pre>"
|
||||
}
|
||||
],
|
||||
"summary": "Get the audit log for an enterprise",
|
||||
"description": "**Note:** The audit log REST API is currently in beta and is subject to change. To join the beta, talk to your services or sales contact at GitHub.\n\nGets the audit log for an enterprise. To use this endpoint, you must be an enterprise admin, and you must use an access token with the `admin:enterprise` scope.",
|
||||
"operationId": "audit-log/get-audit-log",
|
||||
"tags": [
|
||||
"audit-log"
|
||||
],
|
||||
"externalDocs": {
|
||||
"description": "API method documentation",
|
||||
"url": "https://docs.github.com/rest/reference/enterprise-admin#get-the-audit-log-for-an-enterprise"
|
||||
},
|
||||
"x-github": {
|
||||
"githubCloudOnly": true,
|
||||
"enabledForGitHubApps": false,
|
||||
"previews": [],
|
||||
"category": "enterprise-admin",
|
||||
"subcategory": "audit-log"
|
||||
},
|
||||
"slug": "get-the-audit-log-for-an-enterprise",
|
||||
"category": "enterprise-admin",
|
||||
"categoryLabel": "Enterprise admin",
|
||||
"subcategory": "audit-log",
|
||||
"subcategoryLabel": "Audit log",
|
||||
"notes": [],
|
||||
"bodyParameters": [],
|
||||
"descriptionHTML": "<p><strong>Note:</strong> The audit log REST API is currently in beta and is subject to change. To join the beta, talk to your services or sales contact at GitHub.</p>\n<p>Gets the audit log for an enterprise. To use this endpoint, you must be an enterprise admin, and you must use an access token with the <code>admin:enterprise</code> scope.</p>",
|
||||
"responses": [
|
||||
{
|
||||
"httpStatusCode": "200",
|
||||
"httpStatusMessage": "OK",
|
||||
"description": "Default response",
|
||||
"payload": "<pre><code class=\"hljs language-json\">[\n {\n <span class=\"hljs-attr\">\"@timestamp\"</span>: <span class=\"hljs-number\">1606929874512</span>,\n <span class=\"hljs-attr\">\"action\"</span>: <span class=\"hljs-string\">\"team.add_member\"</span>,\n <span class=\"hljs-attr\">\"actor\"</span>: <span class=\"hljs-string\">\"octocat\"</span>,\n <span class=\"hljs-attr\">\"created_at\"</span>: <span class=\"hljs-number\">1606929874512</span>,\n <span class=\"hljs-attr\">\"org\"</span>: <span class=\"hljs-string\">\"octo-corp\"</span>,\n <span class=\"hljs-attr\">\"team\"</span>: <span class=\"hljs-string\">\"octo-corp/example-team\"</span>,\n <span class=\"hljs-attr\">\"user\"</span>: <span class=\"hljs-string\">\"monalisa\"</span>\n },\n {\n <span class=\"hljs-attr\">\"@timestamp\"</span>: <span class=\"hljs-number\">1606507117008</span>,\n <span class=\"hljs-attr\">\"action\"</span>: <span class=\"hljs-string\">\"org.create\"</span>,\n <span class=\"hljs-attr\">\"actor\"</span>: <span class=\"hljs-string\">\"octocat\"</span>,\n <span class=\"hljs-attr\">\"created_at\"</span>: <span class=\"hljs-number\">1606507117008</span>,\n <span class=\"hljs-attr\">\"org\"</span>: <span class=\"hljs-string\">\"octocat-test-org\"</span>\n },\n {\n <span class=\"hljs-attr\">\"@timestamp\"</span>: <span class=\"hljs-number\">1605719148837</span>,\n <span class=\"hljs-attr\">\"action\"</span>: <span class=\"hljs-string\">\"repo.destroy\"</span>,\n <span class=\"hljs-attr\">\"actor\"</span>: <span class=\"hljs-string\">\"monalisa\"</span>,\n <span class=\"hljs-attr\">\"created_at\"</span>: <span class=\"hljs-number\">1605719148837</span>,\n <span class=\"hljs-attr\">\"org\"</span>: <span class=\"hljs-string\">\"mona-org\"</span>,\n <span class=\"hljs-attr\">\"repo\"</span>: <span class=\"hljs-string\">\"mona-org/mona-test-repo\"</span>,\n <span class=\"hljs-attr\">\"visibility\"</span>: <span class=\"hljs-string\">\"private\"</span>\n }\n]\n</code></pre>"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"verb": "get",
|
||||
"requestPath": "/enterprises/{enterprise}/settings/billing/actions",
|
||||
@@ -14225,6 +14342,120 @@
|
||||
"bodyParameters": [],
|
||||
"descriptionHTML": "<p>Removes a repository from an organization secret when the <code>visibility</code> for repository access is set to <code>selected</code>. The visibility is set when you <a href=\"https://docs.github.com/rest/reference/actions#create-or-update-an-organization-secret\">Create or update an organization secret</a>. You must authenticate using an access token with the <code>admin:org</code> scope to use this endpoint. GitHub Apps must have the <code>secrets</code> organization permission to use this endpoint.</p>"
|
||||
},
|
||||
{
|
||||
"verb": "get",
|
||||
"requestPath": "/orgs/{org}/audit-log",
|
||||
"serverUrl": "https://api.github.com",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "org",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"descriptionHTML": ""
|
||||
},
|
||||
{
|
||||
"name": "phrase",
|
||||
"description": "A search phrase. For more information, see [Searching the audit log](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/reviewing-the-audit-log-for-your-organization#searching-the-audit-log).",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"descriptionHTML": "<p>A search phrase. For more information, see <a href=\"https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/reviewing-the-audit-log-for-your-organization#searching-the-audit-log\">Searching the audit log</a>.</p>"
|
||||
},
|
||||
{
|
||||
"name": "include",
|
||||
"description": "The event types to include:\n\n- `web` - returns web (non-Git) events\n- `git` - returns Git events\n- `all` - returns both web and Git events\n\nThe default is `web`.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"web",
|
||||
"git",
|
||||
"all"
|
||||
]
|
||||
},
|
||||
"descriptionHTML": "<p>The event types to include:</p>\n<ul>\n<li><code>web</code> - returns web (non-Git) events</li>\n<li><code>git</code> - returns Git events</li>\n<li><code>all</code> - returns both web and Git events</li>\n</ul>\n<p>The default is <code>web</code>.</p>"
|
||||
},
|
||||
{
|
||||
"name": "after",
|
||||
"description": "A cursor, as given in the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header). If specified, the query only searches for events after this cursor.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"descriptionHTML": "<p>A cursor, as given in the <a href=\"https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header\">Link header</a>. If specified, the query only searches for events after this cursor.</p>"
|
||||
},
|
||||
{
|
||||
"name": "before",
|
||||
"description": "A cursor, as given in the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header). If specified, the query only searches for events before this cursor.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"descriptionHTML": "<p>A cursor, as given in the <a href=\"https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header\">Link header</a>. If specified, the query only searches for events before this cursor.</p>"
|
||||
},
|
||||
{
|
||||
"name": "per_page",
|
||||
"description": "Results per page (max 100)",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"default": 30
|
||||
},
|
||||
"descriptionHTML": "<p>Results per page (max 100)</p>"
|
||||
}
|
||||
],
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "Shell",
|
||||
"source": "curl \\\n -H \"Accept: application/vnd.github.v3+json\" \\\n https://api.github.com/orgs/ORG/audit-log",
|
||||
"html": "<pre><code class=\"hljs language-shell\">curl \\\n -H \"Accept: application/vnd.github.v3+json\" \\\n https://api.github.com/orgs/ORG/audit-log</code></pre>"
|
||||
},
|
||||
{
|
||||
"lang": "JavaScript",
|
||||
"source": "await octokit.request('GET /orgs/{org}/audit-log', {\n org: 'org'\n})",
|
||||
"html": "<pre><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">await</span> octokit.request(<span class=\"hljs-string\">'GET /orgs/{org}/audit-log'</span>, {\n <span class=\"hljs-attr\">org</span>: <span class=\"hljs-string\">'org'</span>\n})\n</code></pre>"
|
||||
}
|
||||
],
|
||||
"summary": "Get the audit log for an organization",
|
||||
"description": "**Note:** The audit log REST API is currently in beta and is subject to change. To join the beta, talk to your services or sales contact at GitHub.\n\nGets the audit log for an organization. For more information, see \"[Reviewing the audit log for your organization](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/reviewing-the-audit-log-for-your-organization).\"\n\nTo use this endpoint, you must be an organization owner, and you must use an access token with the `admin:org` scope. GitHub Apps must have the `organization_administration` read permission to use this endpoint.",
|
||||
"operationId": "orgs/get-audit-log",
|
||||
"tags": [
|
||||
"orgs"
|
||||
],
|
||||
"externalDocs": {
|
||||
"description": "API method documentation",
|
||||
"url": "https://docs.github.com/rest/reference/orgs#get-the-audit-log-for-an-organization"
|
||||
},
|
||||
"x-github": {
|
||||
"githubCloudOnly": true,
|
||||
"enabledForGitHubApps": true,
|
||||
"previews": [],
|
||||
"category": "orgs",
|
||||
"subcategory": null
|
||||
},
|
||||
"slug": "get-the-audit-log-for-an-organization",
|
||||
"category": "orgs",
|
||||
"categoryLabel": "Orgs",
|
||||
"notes": [],
|
||||
"bodyParameters": [],
|
||||
"descriptionHTML": "<p><strong>Note:</strong> The audit log REST API is currently in beta and is subject to change. To join the beta, talk to your services or sales contact at GitHub.</p>\n<p>Gets the audit log for an organization. For more information, see \"<a href=\"https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/reviewing-the-audit-log-for-your-organization\">Reviewing the audit log for your organization</a>.\"</p>\n<p>To use this endpoint, you must be an organization owner, and you must use an access token with the <code>admin:org</code> scope. GitHub Apps must have the <code>organization_administration</code> read permission to use this endpoint.</p>",
|
||||
"responses": [
|
||||
{
|
||||
"httpStatusCode": "200",
|
||||
"httpStatusMessage": "OK",
|
||||
"description": "Default response",
|
||||
"payload": "<pre><code class=\"hljs language-json\">[\n {\n <span class=\"hljs-attr\">\"@timestamp\"</span>: <span class=\"hljs-number\">1606929874512</span>,\n <span class=\"hljs-attr\">\"action\"</span>: <span class=\"hljs-string\">\"team.add_member\"</span>,\n <span class=\"hljs-attr\">\"actor\"</span>: <span class=\"hljs-string\">\"octocat\"</span>,\n <span class=\"hljs-attr\">\"created_at\"</span>: <span class=\"hljs-number\">1606929874512</span>,\n <span class=\"hljs-attr\">\"org\"</span>: <span class=\"hljs-string\">\"octo-corp\"</span>,\n <span class=\"hljs-attr\">\"team\"</span>: <span class=\"hljs-string\">\"octo-corp/example-team\"</span>,\n <span class=\"hljs-attr\">\"user\"</span>: <span class=\"hljs-string\">\"monalisa\"</span>\n },\n {\n <span class=\"hljs-attr\">\"@timestamp\"</span>: <span class=\"hljs-number\">1606507117008</span>,\n <span class=\"hljs-attr\">\"action\"</span>: <span class=\"hljs-string\">\"org.create\"</span>,\n <span class=\"hljs-attr\">\"actor\"</span>: <span class=\"hljs-string\">\"octocat\"</span>,\n <span class=\"hljs-attr\">\"created_at\"</span>: <span class=\"hljs-number\">1606507117008</span>,\n <span class=\"hljs-attr\">\"org\"</span>: <span class=\"hljs-string\">\"octocat-test-org\"</span>\n },\n {\n <span class=\"hljs-attr\">\"@timestamp\"</span>: <span class=\"hljs-number\">1605719148837</span>,\n <span class=\"hljs-attr\">\"action\"</span>: <span class=\"hljs-string\">\"repo.destroy\"</span>,\n <span class=\"hljs-attr\">\"actor\"</span>: <span class=\"hljs-string\">\"monalisa\"</span>,\n <span class=\"hljs-attr\">\"created_at\"</span>: <span class=\"hljs-number\">1605719148837</span>,\n <span class=\"hljs-attr\">\"org\"</span>: <span class=\"hljs-string\">\"mona-org\"</span>,\n <span class=\"hljs-attr\">\"repo\"</span>: <span class=\"hljs-string\">\"mona-org/mona-test-repo\"</span>,\n <span class=\"hljs-attr\">\"visibility\"</span>: <span class=\"hljs-string\">\"private\"</span>\n }\n]\n</code></pre>"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"verb": "get",
|
||||
"requestPath": "/orgs/{org}/blocks",
|
||||
|
||||
@@ -17051,6 +17051,254 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/enterprises/{enterprise}/audit-log": {
|
||||
"get": {
|
||||
"summary": "Get the audit log for an enterprise",
|
||||
"description": "**Note:** The audit log REST API is currently in beta and is subject to change. To join the beta, talk to your services or sales contact at GitHub.\n\nGets the audit log for an enterprise. To use this endpoint, you must be an enterprise admin, and you must use an access token with the `admin:enterprise` scope.",
|
||||
"operationId": "audit-log/get-audit-log",
|
||||
"tags": [
|
||||
"audit-log"
|
||||
],
|
||||
"externalDocs": {
|
||||
"description": "API method documentation",
|
||||
"url": "https://docs.github.com/rest/reference/enterprise-admin#get-the-audit-log-for-an-enterprise"
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "enterprise",
|
||||
"description": "The slug version of the enterprise name. You can also substitute this value with the enterprise id.",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "phrase",
|
||||
"description": "A search phrase. For more information, see [Searching the audit log](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/reviewing-the-audit-log-for-your-organization#searching-the-audit-log).",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "include",
|
||||
"description": "The event types to include:\n\n- `web` - returns web (non-Git) events\n- `git` - returns Git events\n- `all` - returns both web and Git events\n\nThe default is `web`.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"web",
|
||||
"git",
|
||||
"all"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "after",
|
||||
"description": "A cursor, as given in the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header). If specified, the query only searches for events after this cursor.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "before",
|
||||
"description": "A cursor, as given in the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header). If specified, the query only searches for events before this cursor.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "per_page",
|
||||
"description": "Results per page (max 100)",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"default": 30
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@timestamp": {
|
||||
"type": "integer",
|
||||
"description": "The time the audit log event occurred, given as a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time)."
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"description": "The name of the action that was performed, for example `user.login` or `repo.create`."
|
||||
},
|
||||
"active": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"active_was": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"actor": {
|
||||
"type": "string",
|
||||
"description": "The actor who performed the action."
|
||||
},
|
||||
"blocked_user": {
|
||||
"type": "string",
|
||||
"description": "The username of the account being blocked."
|
||||
},
|
||||
"business": {
|
||||
"type": "string"
|
||||
},
|
||||
"config": {
|
||||
"type": "array"
|
||||
},
|
||||
"config_was": {
|
||||
"type": "array"
|
||||
},
|
||||
"content_type": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "integer",
|
||||
"description": "The time the audit log event was recorded, given as a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time)."
|
||||
},
|
||||
"deploy_key_fingerprint": {
|
||||
"type": "string"
|
||||
},
|
||||
"emoji": {
|
||||
"type": "string"
|
||||
},
|
||||
"events": {
|
||||
"type": "array"
|
||||
},
|
||||
"events_were": {
|
||||
"type": "array"
|
||||
},
|
||||
"explanation": {
|
||||
"type": "string"
|
||||
},
|
||||
"fingerprint": {
|
||||
"type": "string"
|
||||
},
|
||||
"hook_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"limited_availability": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"old_user": {
|
||||
"type": "string"
|
||||
},
|
||||
"openssh_public_key": {
|
||||
"type": "string"
|
||||
},
|
||||
"org": {
|
||||
"type": "string"
|
||||
},
|
||||
"previous_visibility": {
|
||||
"type": "string"
|
||||
},
|
||||
"read_only": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"repo": {
|
||||
"type": "string",
|
||||
"description": "The name of the repository."
|
||||
},
|
||||
"repository": {
|
||||
"type": "string",
|
||||
"description": "The name of the repository."
|
||||
},
|
||||
"repository_public": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"target_login": {
|
||||
"type": "string"
|
||||
},
|
||||
"team": {
|
||||
"type": "string"
|
||||
},
|
||||
"transport_protocol": {
|
||||
"type": "integer",
|
||||
"description": "The type of protocol (for example, HTTP or SSH) used to transfer Git data."
|
||||
},
|
||||
"transport_protocol_name": {
|
||||
"type": "string",
|
||||
"description": "A human readable name for the protocol (for example, HTTP or SSH) used to transfer Git data."
|
||||
},
|
||||
"user": {
|
||||
"type": "string",
|
||||
"description": "The user that was affected by the action performed (if available)."
|
||||
},
|
||||
"visibility": {
|
||||
"type": "string",
|
||||
"description": "The repository visibility, for example `public` or `private`."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"examples": {
|
||||
"default": {
|
||||
"value": [
|
||||
{
|
||||
"@timestamp": 1606929874512,
|
||||
"action": "team.add_member",
|
||||
"actor": "octocat",
|
||||
"created_at": 1606929874512,
|
||||
"org": "octo-corp",
|
||||
"team": "octo-corp/example-team",
|
||||
"user": "monalisa"
|
||||
},
|
||||
{
|
||||
"@timestamp": 1606507117008,
|
||||
"action": "org.create",
|
||||
"actor": "octocat",
|
||||
"created_at": 1606507117008,
|
||||
"org": "octocat-test-org"
|
||||
},
|
||||
{
|
||||
"@timestamp": 1605719148837,
|
||||
"action": "repo.destroy",
|
||||
"actor": "monalisa",
|
||||
"created_at": 1605719148837,
|
||||
"org": "mona-org",
|
||||
"repo": "mona-org/mona-test-repo",
|
||||
"visibility": "private"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-github": {
|
||||
"githubCloudOnly": true,
|
||||
"enabledForGitHubApps": false,
|
||||
"previews": [
|
||||
|
||||
],
|
||||
"category": "enterprise-admin",
|
||||
"subcategory": "audit-log"
|
||||
}
|
||||
}
|
||||
},
|
||||
"/enterprises/{enterprise}/settings/billing/actions": {
|
||||
"get": {
|
||||
"summary": "Get GitHub Actions billing for an enterprise",
|
||||
@@ -49105,6 +49353,253 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/orgs/{org}/audit-log": {
|
||||
"get": {
|
||||
"summary": "Get the audit log for an organization",
|
||||
"description": "**Note:** The audit log REST API is currently in beta and is subject to change. To join the beta, talk to your services or sales contact at GitHub.\n\nGets the audit log for an organization. For more information, see \"[Reviewing the audit log for your organization](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/reviewing-the-audit-log-for-your-organization).\"\n\nTo use this endpoint, you must be an organization owner, and you must use an access token with the `admin:org` scope. GitHub Apps must have the `organization_administration` read permission to use this endpoint.",
|
||||
"operationId": "orgs/get-audit-log",
|
||||
"tags": [
|
||||
"orgs"
|
||||
],
|
||||
"externalDocs": {
|
||||
"description": "API method documentation",
|
||||
"url": "https://docs.github.com/rest/reference/orgs#get-the-audit-log-for-an-organization"
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "org",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "phrase",
|
||||
"description": "A search phrase. For more information, see [Searching the audit log](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/reviewing-the-audit-log-for-your-organization#searching-the-audit-log).",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "include",
|
||||
"description": "The event types to include:\n\n- `web` - returns web (non-Git) events\n- `git` - returns Git events\n- `all` - returns both web and Git events\n\nThe default is `web`.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"web",
|
||||
"git",
|
||||
"all"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "after",
|
||||
"description": "A cursor, as given in the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header). If specified, the query only searches for events after this cursor.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "before",
|
||||
"description": "A cursor, as given in the [Link header](https://docs.github.com/rest/overview/resources-in-the-rest-api#link-header). If specified, the query only searches for events before this cursor.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "per_page",
|
||||
"description": "Results per page (max 100)",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"default": 30
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@timestamp": {
|
||||
"type": "integer",
|
||||
"description": "The time the audit log event occurred, given as a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time)."
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"description": "The name of the action that was performed, for example `user.login` or `repo.create`."
|
||||
},
|
||||
"active": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"active_was": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"actor": {
|
||||
"type": "string",
|
||||
"description": "The actor who performed the action."
|
||||
},
|
||||
"blocked_user": {
|
||||
"type": "string",
|
||||
"description": "The username of the account being blocked."
|
||||
},
|
||||
"business": {
|
||||
"type": "string"
|
||||
},
|
||||
"config": {
|
||||
"type": "array"
|
||||
},
|
||||
"config_was": {
|
||||
"type": "array"
|
||||
},
|
||||
"content_type": {
|
||||
"type": "string"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "integer",
|
||||
"description": "The time the audit log event was recorded, given as a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time)."
|
||||
},
|
||||
"deploy_key_fingerprint": {
|
||||
"type": "string"
|
||||
},
|
||||
"emoji": {
|
||||
"type": "string"
|
||||
},
|
||||
"events": {
|
||||
"type": "array"
|
||||
},
|
||||
"events_were": {
|
||||
"type": "array"
|
||||
},
|
||||
"explanation": {
|
||||
"type": "string"
|
||||
},
|
||||
"fingerprint": {
|
||||
"type": "string"
|
||||
},
|
||||
"hook_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"limited_availability": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"old_user": {
|
||||
"type": "string"
|
||||
},
|
||||
"openssh_public_key": {
|
||||
"type": "string"
|
||||
},
|
||||
"org": {
|
||||
"type": "string"
|
||||
},
|
||||
"previous_visibility": {
|
||||
"type": "string"
|
||||
},
|
||||
"read_only": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"repo": {
|
||||
"type": "string",
|
||||
"description": "The name of the repository."
|
||||
},
|
||||
"repository": {
|
||||
"type": "string",
|
||||
"description": "The name of the repository."
|
||||
},
|
||||
"repository_public": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"target_login": {
|
||||
"type": "string"
|
||||
},
|
||||
"team": {
|
||||
"type": "string"
|
||||
},
|
||||
"transport_protocol": {
|
||||
"type": "integer",
|
||||
"description": "The type of protocol (for example, HTTP or SSH) used to transfer Git data."
|
||||
},
|
||||
"transport_protocol_name": {
|
||||
"type": "string",
|
||||
"description": "A human readable name for the protocol (for example, HTTP or SSH) used to transfer Git data."
|
||||
},
|
||||
"user": {
|
||||
"type": "string",
|
||||
"description": "The user that was affected by the action performed (if available)."
|
||||
},
|
||||
"visibility": {
|
||||
"type": "string",
|
||||
"description": "The repository visibility, for example `public` or `private`."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"examples": {
|
||||
"default": {
|
||||
"value": [
|
||||
{
|
||||
"@timestamp": 1606929874512,
|
||||
"action": "team.add_member",
|
||||
"actor": "octocat",
|
||||
"created_at": 1606929874512,
|
||||
"org": "octo-corp",
|
||||
"team": "octo-corp/example-team",
|
||||
"user": "monalisa"
|
||||
},
|
||||
{
|
||||
"@timestamp": 1606507117008,
|
||||
"action": "org.create",
|
||||
"actor": "octocat",
|
||||
"created_at": 1606507117008,
|
||||
"org": "octocat-test-org"
|
||||
},
|
||||
{
|
||||
"@timestamp": 1605719148837,
|
||||
"action": "repo.destroy",
|
||||
"actor": "monalisa",
|
||||
"created_at": 1605719148837,
|
||||
"org": "mona-org",
|
||||
"repo": "mona-org/mona-test-repo",
|
||||
"visibility": "private"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-github": {
|
||||
"githubCloudOnly": true,
|
||||
"enabledForGitHubApps": true,
|
||||
"previews": [
|
||||
|
||||
],
|
||||
"category": "orgs",
|
||||
"subcategory": null
|
||||
}
|
||||
}
|
||||
},
|
||||
"/orgs/{org}/blocks": {
|
||||
"get": {
|
||||
"summary": "List users blocked by an organization",
|
||||
|
||||
@@ -2,6 +2,7 @@ const externalRedirects = Object.keys(require('./redirects/external-sites'))
|
||||
const pathUtils = require('./path-utils')
|
||||
const assert = require('assert')
|
||||
const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version')
|
||||
const supportedPlans = Object.values(require('./all-versions')).map(v => v.plan)
|
||||
|
||||
// Content authors write links like `/some/article/path`, but they need to be
|
||||
// rewritten on the fly to match the current language and page version
|
||||
@@ -24,11 +25,21 @@ function getNewHref (link, languageCode, version) {
|
||||
// e.g. `/contact` should not be replaced with `/en/contact`
|
||||
if (externalRedirects.includes(href)) return
|
||||
|
||||
let newHref
|
||||
|
||||
// If the link has a hardcoded plan name in it (e.g., /enterprise-server/rest/reference/oauth-authorizations),
|
||||
// only rewrite it with a language code
|
||||
if (supportedPlans.includes(href.split('/')[1])) {
|
||||
newHref = pathUtils.getPathWithLanguage(href, languageCode)
|
||||
}
|
||||
|
||||
// If link is dotcom-only, just get the language code
|
||||
// Otherwise, get the versioned path with language code
|
||||
const newHref = link.hasClass('dotcom-only')
|
||||
? pathUtils.getVersionedPathWithLanguage(href, nonEnterpriseDefaultVersion, languageCode)
|
||||
: pathUtils.getVersionedPathWithLanguage(href, version, languageCode)
|
||||
if (!newHref) {
|
||||
newHref = link.hasClass('dotcom-only')
|
||||
? pathUtils.getVersionedPathWithLanguage(href, nonEnterpriseDefaultVersion, languageCode)
|
||||
: pathUtils.getVersionedPathWithLanguage(href, version, languageCode)
|
||||
}
|
||||
|
||||
if (href !== newHref) link.attr('href', newHref)
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ const path = require('path')
|
||||
const flat = require('flat')
|
||||
const { get, set } = require('lodash')
|
||||
const languages = require('./languages')
|
||||
const dataDirectory = require('@github-docs/data-directory')
|
||||
const dataDirectory = require('./data-directory')
|
||||
const encodeBracketedParentheticals = require('./encode-bracketed-parentheticals')
|
||||
|
||||
const loadSiteDataFromDir = dir => ({
|
||||
const loadSiteDataFromDir = async dir => ({
|
||||
site: {
|
||||
data: dataDirectory(path.join(dir, 'data'), {
|
||||
data: await dataDirectory(path.join(dir, 'data'), {
|
||||
preprocess: dataString =>
|
||||
encodeBracketedParentheticals(dataString.trimEnd()),
|
||||
ignorePatterns: [/README\.md$/]
|
||||
@@ -18,7 +18,7 @@ const loadSiteDataFromDir = dir => ({
|
||||
module.exports = async function loadSiteData () {
|
||||
// load english site data
|
||||
const siteData = {
|
||||
en: loadSiteDataFromDir(languages.en.dir)
|
||||
en: await loadSiteDataFromDir(languages.en.dir)
|
||||
}
|
||||
|
||||
// load and add other language data to siteData where keys match english keys,
|
||||
@@ -26,7 +26,7 @@ module.exports = async function loadSiteData () {
|
||||
const englishKeys = Object.keys(flat(siteData.en))
|
||||
for (const language of Object.values(languages)) {
|
||||
if (language.code === 'en') continue
|
||||
const data = loadSiteDataFromDir(language.dir)
|
||||
const data = await loadSiteDataFromDir(language.dir)
|
||||
for (const key of englishKeys) {
|
||||
set(
|
||||
siteData,
|
||||
|
||||
@@ -4,6 +4,16 @@ const loadRedirects = require('./redirects/precompile')
|
||||
const loadSiteData = require('./site-data')
|
||||
const loadSiteTree = require('./site-tree')
|
||||
|
||||
// Instrument these functions so that
|
||||
// it's wrapped in a timer that reports to Datadog
|
||||
const dog = {
|
||||
loadPages: statsd.asyncTimer(loadPages, 'load_pages'),
|
||||
loadPageMap: statsd.asyncTimer(loadPageMap, 'load_page_map'),
|
||||
loadRedirects: statsd.asyncTimer(loadRedirects, 'load_redirects'),
|
||||
loadSiteData: statsd.asyncTimer(loadSiteData, 'load_site_data'),
|
||||
loadSiteTree: statsd.asyncTimer(loadSiteTree, 'load_site_tree')
|
||||
}
|
||||
|
||||
// For local caching
|
||||
let pageList, pageMap, site, redirects, siteTree
|
||||
|
||||
@@ -32,21 +42,21 @@ async function warmServer () {
|
||||
if (!pageList || !site) {
|
||||
// Promise.all is used to load multiple things in parallel
|
||||
[pageList, site] = await Promise.all([
|
||||
pageList || loadPages(),
|
||||
site || loadSiteData()
|
||||
pageList || dog.loadPages(),
|
||||
site || dog.loadSiteData()
|
||||
])
|
||||
}
|
||||
|
||||
if (!pageMap) {
|
||||
pageMap = await loadPageMap(pageList)
|
||||
pageMap = await dog.loadPageMap(pageList)
|
||||
}
|
||||
|
||||
if (!redirects) {
|
||||
redirects = await loadRedirects(pageList, pageMap)
|
||||
redirects = await dog.loadRedirects(pageList, pageMap)
|
||||
}
|
||||
|
||||
if (!siteTree) {
|
||||
siteTree = await loadSiteTree(pageMap, site, redirects)
|
||||
siteTree = await dog.loadSiteTree(pageMap, site, redirects)
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
@@ -58,7 +68,7 @@ async function warmServer () {
|
||||
|
||||
// Instrument the `warmServer` function so that
|
||||
// it's wrapped in a timer that reports to Datadog
|
||||
const instrumentedWarmServer = statsd.asyncTimer(warmServer, 'warm_server')
|
||||
dog.warmServer = statsd.asyncTimer(warmServer, 'warm_server')
|
||||
|
||||
// We only want statistics if the priming needs to occur, so let's wrap the
|
||||
// real method and return early [without statistics] whenever possible
|
||||
@@ -68,5 +78,5 @@ module.exports = async function warmServerWrapper () {
|
||||
return getWarmedCache()
|
||||
}
|
||||
|
||||
return instrumentedWarmServer()
|
||||
return dog.warmServer()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user