Skip to content
This repository was archived by the owner on Dec 30, 2022. It is now read-only.

Commit 3227e70

Browse files
authored
Merge branch 'main' into repo-sync
2 parents 71ca3d9 + 42e785b commit 3227e70

File tree

351 files changed

+6472
-8225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

351 files changed

+6472
-8225
lines changed

.eslintrc.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ module.exports = {
1212
'prettier'
1313
],
1414
parserOptions: {
15-
ecmaVersion: 11
15+
ecmaVersion: 11,
16+
requireConfigFile: 'false',
17+
babelOptions: { configFile: './.babelrc' }
1618
},
1719
rules: {
18-
'import/no-extraneous-dependencies': ['error'],
20+
'import/no-extraneous-dependencies': ['error', { packageDir: '.' }],
1921
'node/global-require': ['error'],
2022
'import/no-dynamic-require': ['error']
2123
},

.github/actions-scripts/check-for-enterprise-issues-by-label.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#!/usr/bin/env node
22

3-
const github = require('@actions/github')
4-
const core = require('@actions/core')
3+
import { getOctokit } from '@actions/github'
4+
import { setOutput } from '@actions/core'
55

66
async function run () {
77
const token = process.env.GITHUB_TOKEN
8-
const octokit = github.getOctokit(token)
8+
const octokit = getOctokit(token)
99
const query = encodeURIComponent('is:open repo:github/docs-internal is:issue')
10-
10+
1111
const deprecationIssues = await octokit.request(`GET /search/issues?q=${query}+label:"enterprise%20deprecation"`)
1212
const releaseIssues = await octokit.request(`GET /search/issues?q=${query}+label:"enterprise%20release"`)
1313
const isDeprecationIssue = deprecationIssues.data.items.length === 0 ? 'false' : 'true'
1414
const isReleaseIssue = releaseIssues.data.items.length === 0 ? 'false' : 'true'
15-
core.setOutput('deprecationIssue', isDeprecationIssue)
16-
core.setOutput('releaseIssue', isReleaseIssue)
15+
setOutput('deprecationIssue', isDeprecationIssue)
16+
setOutput('releaseIssue', isReleaseIssue)
1717
return `Set outputs deprecationIssue: ${isDeprecationIssue}, releaseIssue: ${isReleaseIssue}`
1818
}
1919

.github/actions-scripts/create-enterprise-issue.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env node
22

3-
const fs = require('fs')
4-
const path = require('path')
5-
const github = require('@actions/github')
6-
const enterpriseDates = require('../../lib/enterprise-dates')
7-
const { latest, oldestSupported } = require('../../lib/enterprise-server-releases')
3+
import fs from 'fs'
4+
import path from 'path'
5+
import { getOctokit } from '@actions/github'
6+
import enterpriseDates from '../../lib/enterprise-dates.js'
7+
import { latest, oldestSupported } from '../../lib/enterprise-server-releases.js'
8+
89
const acceptedMilestones = ['release', 'deprecation']
910
const teamsToCC = '/cc @github/docs-content @github/docs-engineering'
1011

@@ -31,7 +32,6 @@ const numberOfdaysBeforeDeprecationToOpenIssue = 15
3132
run()
3233

3334
async function run () {
34-
3535

3636
const milestone = process.argv[2]
3737
if (!acceptedMilestones.includes(milestone)) {
@@ -81,7 +81,7 @@ async function run () {
8181
const token = process.env.GITHUB_TOKEN
8282

8383
// Create the milestone issue
84-
const octokit = github.getOctokit(token)
84+
const octokit = getOctokit(token)
8585
try {
8686
issue = await octokit.request('POST /repos/{owner}/{repo}/issues', {
8787
owner: 'github',

.github/actions-scripts/enterprise-algolia-label.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env node
22

3-
const fs = require('fs')
4-
const core = require('@actions/core')
3+
import fs from 'fs'
4+
import { setOutput } from '@actions/core'
5+
56
const eventPayload = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8'))
67

78
// This workflow-run script does the following:
@@ -32,5 +33,5 @@ if (!algoliaLabel) {
3233
const versionToSync = algoliaLabel.split(labelText)[1]
3334

3435
// Store the version so we can access it later in the workflow
35-
core.setOutput('versionToSync', versionToSync)
36-
process.exit(0)
36+
setOutput('versionToSync', versionToSync)
37+
process.exit(0)

.github/actions-scripts/openapi-schema-branch.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env node
22

3-
const fs = require('fs')
4-
const path = require('path')
5-
const { execSync } = require('child_process')
6-
const semver = require('semver')
3+
import fs from 'fs'
4+
import path from 'path'
5+
import { execSync } from 'child_process'
6+
import semver from 'semver'
77

88
/*
99
* This script performs two checks to prevent shipping development mode OpenAPI schemas:
@@ -19,8 +19,9 @@ const semver = require('semver')
1919
// Check that the `info.version` property is a semantic version
2020
const dereferencedDir = path.join(process.cwd(), 'lib/rest/static/dereferenced')
2121
const schemas = fs.readdirSync(dereferencedDir)
22+
2223
schemas.forEach(filename => {
23-
const schema = require(path.join(dereferencedDir, filename))
24+
const schema = JSON.parse(fs.readFileSync(path.join(dereferencedDir, filename)))
2425
if (!semver.valid(schema.info.version)) {
2526
console.log(`🚧⚠️ Your branch contains a development mode OpenAPI schema: ${schema.info.version}. This check is a reminder to not 🚢 OpenAPI files in development mode. 🛑`)
2627
process.exit(1)

.github/allowed-actions.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CI will fail and the action will need to be audited by the docs engineering team before it
44
// can be added it this list.
55

6-
module.exports = [
6+
export default [
77
"actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f", // v2.3.4
88
"actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d", // v4.0.2
99
"actions/labeler@5f867a63be70efff62b767459b009290364495eb", // v2.2.0
@@ -17,6 +17,7 @@ module.exports = [
1717
"cschleiden/actions-linter@0ff16d6ac5103cca6c92e6cbc922b646baaea5be",
1818
"dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911",
1919
"docker://chinthakagodawita/autoupdate-action:v1",
20+
"dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58",
2021
"github/codeql-action/analyze@v1",
2122
"github/codeql-action/init@v1",
2223
"juliangruber/approve-pull-request-action@c530832d4d346c597332e20e03605aa94fa150a8",
@@ -34,6 +35,5 @@ module.exports = [
3435
"repo-sync/pull-request@33777245b1aace1a58c87a29c90321aa7a74bd7d",
3536
"someimportantcompany/github-actions-slack-message@0b470c14b39da4260ed9e3f9a4f1298a74ccdefd",
3637
"tjenkinson/gh-action-auto-merge-dependency-updates@4d7756c04d9d999c5968697a621b81c47f533d61",
37-
"EndBug/add-and-commit@b3c7c1e078a023d75fb0bd326e02962575ce0519",
38-
"dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58",
39-
];
38+
"EndBug/add-and-commit@b3c7c1e078a023d75fb0bd326e02962575ce0519"
39+
]

.github/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"type":"module"}

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ jobs:
5959
- name: Run tests
6060
run: npx jest tests/${{ matrix.test-group }}/
6161
env:
62-
NODE_OPTIONS: '--max_old_space_size=8192'
62+
NODE_OPTIONS: '--max_old_space_size=8192 --experimental-vm-modules'

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ COPY --chown=node:node layouts ./layouts
9393
COPY --chown=node:node lib ./lib
9494
COPY --chown=node:node middleware ./middleware
9595
COPY --chown=node:node translations ./translations
96-
COPY --chown=node:node server.js ./server.js
96+
COPY --chown=node:node server.mjs ./server.mjs
9797
COPY --chown=node:node package*.json ./
9898
COPY --chown=node:node feature-flags.json ./
9999

100100
EXPOSE 80
101101
EXPOSE 443
102102
EXPOSE 4000
103-
CMD ["node", "server.js"]
103+
CMD ["node", "server.mjs"]

Procfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
web: NODE_ENV=production node server.js
1+
web: NODE_ENV=production node server.mjs
22

33
release: NODE_ENV=production script/release-heroku

data/allowed-topics.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// content model, add the entry to this list, and ensure you loop in the
1111
// content and/or content strategy team for review.
1212

13-
module.exports = [
13+
export default [
1414
'2FA',
1515
'Access management',
1616
'Accounts',

data/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"type":"module"}

lib/all-products.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const fs = require('fs')
2-
const path = require('path')
3-
const frontmatter = require('./read-frontmatter')
4-
const getApplicableVersions = require('./get-applicable-versions')
5-
const removeFPTFromPath = require('./remove-fpt-from-path')
1+
import fs from 'fs'
2+
import path from 'path'
3+
import frontmatter from './read-frontmatter.js'
4+
import getApplicableVersions from './get-applicable-versions.js'
5+
import removeFPTFromPath from './remove-fpt-from-path.js'
66

77
// Both internal and external products are specified in content/index.md
88
const homepage = path.posix.join(process.cwd(), 'content/index.md')
99
const { data } = frontmatter(fs.readFileSync(homepage, 'utf8'))
10-
const productIds = data.children
10+
export const productIds = data.children
1111
const externalProducts = data.externalProducts
1212

1313
const internalProducts = {}
@@ -37,9 +37,9 @@ productIds.forEach(productId => {
3737
internalProducts[productId].versions = applicableVersions
3838
})
3939

40-
const productMap = Object.assign({}, internalProducts, externalProducts)
40+
export const productMap = Object.assign({}, internalProducts, externalProducts)
4141

42-
module.exports = {
42+
export default {
4343
productIds,
4444
productMap
4545
}

lib/all-versions.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const enterpriseServerReleases = require('./enterprise-server-releases')
1+
import enterpriseServerReleases from './enterprise-server-releases.js'
22

33
// version = "plan"@"release"
44
// example: [email protected]
@@ -60,4 +60,4 @@ plans.forEach(planObj => {
6060
})
6161
})
6262

63-
module.exports = allVersions
63+
export default allVersions

lib/app.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const express = require('express')
2-
const middleware = require('../middleware')
1+
import express from 'express'
2+
import middleware from '../middleware/index.js'
33

44
function createApp () {
55
const app = express()
66
middleware(app)
77
return app
88
}
99

10-
module.exports = createApp
10+
export default createApp

lib/built-asset-urls.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const fs = require('fs')
2-
const path = require('path')
3-
const crypto = require('crypto')
1+
import fs from 'fs'
2+
import path from 'path'
3+
import crypto from 'crypto'
44

55
// Get an MD4 Digest Hex content hash, loosely based on Webpack `[contenthash]`
66
function getContentHash (absFilePath) {
@@ -15,7 +15,7 @@ function getUrl (relFilePath) {
1515
return `/${relFilePath}?hash=${getContentHash(absFilePath)}`
1616
}
1717

18-
module.exports = {
18+
export default {
1919
main: {
2020
js: getUrl('dist/index.js'),
2121
css: getUrl('dist/index.css')

lib/changelog.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const Parser = require('rss-parser')
1+
import Parser from 'rss-parser'
22

3-
async function getRssFeed (url) {
3+
export async function getRssFeed (url) {
44
const parser = new Parser({ timeout: 5000 })
55
const feedUrl = `${url}/feed`
66
let feed
@@ -15,7 +15,7 @@ async function getRssFeed (url) {
1515
return feed
1616
}
1717

18-
async function getChangelogItems (prefix, feed) {
18+
export async function getChangelogItems (prefix, feed) {
1919
if (!feed || !feed.items) {
2020
console.log(feed)
2121
console.error('feed is not valid or has no items')
@@ -39,4 +39,4 @@ async function getChangelogItems (prefix, feed) {
3939
return changelog
4040
}
4141

42-
module.exports = { getRssFeed, getChangelogItems }
42+
export default { getRssFeed, getChangelogItems }

lib/check-if-next-version-only.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const { next, latest } = require('./enterprise-server-releases')
2-
const versionSatisfiesRange = require('./version-satisfies-range')
1+
import { next, latest } from './enterprise-server-releases.js'
2+
import versionSatisfiesRange from './version-satisfies-range.js'
33

44
// Special handling for frontmatter that evalues to the next GHES release number or a hardcoded `next`:
55
// we don't want to return it as an applicable version or it will become a permalink,
66
// but we also don't want to throw an error if no other versions are found.
7-
module.exports = function checkIfNextVersionOnly (value) {
7+
export default function checkIfNextVersionOnly (value) {
88
if (value === '*') return false
99

1010
const ghesNextVersionOnly = versionSatisfiesRange(next, value) && !versionSatisfiesRange(latest, value)

lib/check-node-version.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
const semver = require('semver')
2-
const { engines } = require('../package.json')
1+
import semver from 'semver'
2+
import fs from 'fs'
3+
import path from 'path'
4+
5+
const packageFile = JSON.parse(fs.readFileSync(path.join(process.cwd(), './package.json')))
6+
const { engines } = packageFile
37

48
/* istanbul ignore next */
59
if (!semver.satisfies(process.version, engines.node)) {

lib/cookie-settings.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
httpOnly: true, // can't access these cookies through browser JavaScript
33
secure: !['test', 'development'].includes(process.env.NODE_ENV),
44
// requires https protocol

lib/create-tree.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
const fs = require('fs').promises
2-
const path = require('path')
3-
const Page = require('./page')
4-
5-
module.exports = async function createTree (originalPath, langObj) {
1+
import { fileURLToPath } from 'url'
2+
import path from 'path'
3+
import xFs from 'fs'
4+
import Page from './page.js'
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
6+
const fs = xFs.promises
7+
8+
export default async function createTree (originalPath, langObj) {
69
// This basePath definition is needed both here and in lib/page-data.js because this
710
// function runs recursively, and the value for originalPath changes on recursive runs.
811
const basePath = path.posix.join(__dirname, '..', langObj.dir, 'content')

lib/data-directory.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
const assert = require('assert')
2-
const fs = require('fs')
3-
const path = require('path')
4-
const walk = require('walk-sync')
5-
const yaml = require('js-yaml')
6-
const { isRegExp, set } = require('lodash')
7-
const filenameToKey = require('./filename-to-key')
1+
import assert from 'assert'
2+
import fs from 'fs'
3+
import path from 'path'
4+
import walk from 'walk-sync'
5+
import yaml from 'js-yaml'
6+
import { isRegExp, set } from 'lodash-es'
7+
import filenameToKey from './filename-to-key.js'
88

9-
module.exports = function dataDirectory (dir, opts = {}) {
9+
export default function dataDirectory (dir, opts = {}) {
1010
const defaultOpts = {
1111
preprocess: (content) => { return content },
1212
ignorePatterns: [/README\.md$/i],

lib/encode-bracketed-parentheses.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// prevent `[foo] (bar)` strings with a space between from being interpreted as markdown links
22
// by encoding the space character
33

4-
module.exports = function encodeBracketedParentheses (input) {
4+
export default function encodeBracketedParentheses (input) {
55
return input.replace(/] \(/g, '] (')
66
}

0 commit comments

Comments
 (0)