Skip to content

Commit e57a072

Browse files
authored
Merge branch 'main' into patch-3
2 parents b544c9f + 7887d02 commit e57a072

File tree

415 files changed

+29951
-25343
lines changed

Some content is hidden

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

415 files changed

+29951
-25343
lines changed

β€Ž.eslintrc.js

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,40 @@ module.exports = {
33
browser: true,
44
commonjs: true,
55
es2020: true,
6-
node: true
6+
node: true,
77
},
88
parser: '@babel/eslint-parser',
9-
extends: [
10-
'eslint:recommended',
11-
'standard',
12-
'prettier'
13-
],
9+
extends: ['eslint:recommended', 'standard', 'prettier'],
1410
parserOptions: {
15-
ecmaVersion: 11
11+
ecmaVersion: 11,
12+
requireConfigFile: 'false',
13+
babelOptions: { configFile: './.babelrc' },
1614
},
1715
rules: {
18-
'import/no-extraneous-dependencies': ['error'],
16+
'import/no-extraneous-dependencies': ['error', { packageDir: '.' }],
1917
'node/global-require': ['error'],
20-
'import/no-dynamic-require': ['error']
18+
'import/no-dynamic-require': ['error'],
2119
},
2220
overrides: [
2321
{
24-
files: [
25-
'**/tests/**/*.js'
26-
],
22+
files: ['**/tests/**/*.js'],
2723
env: {
28-
jest: true
29-
}
24+
jest: true,
25+
},
3026
},
3127
{
32-
files: [
33-
'**/*.tsx', '**/*.ts'
34-
],
35-
plugins: [
36-
'@typescript-eslint',
37-
'jsx-a11y'
38-
],
28+
files: ['**/*.tsx', '**/*.ts'],
29+
plugins: ['@typescript-eslint', 'jsx-a11y'],
3930
extends: ['plugin:jsx-a11y/recommended'],
4031
parser: '@typescript-eslint/parser',
4132
rules: {
42-
'camelcase': 'off',
33+
camelcase: 'off',
4334
'no-unused-vars': 'off',
4435
'no-undef': 'off',
4536
'no-use-before-define': 'off',
4637
'@typescript-eslint/no-unused-vars': ['error'],
4738
'jsx-a11y/no-onchange': 'off',
48-
}
39+
},
4940
},
50-
]
41+
],
5142
}
Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
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

6-
async function run () {
6+
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-
11-
const deprecationIssues = await octokit.request(`GET /search/issues?q=${query}+label:"enterprise%20deprecation"`)
12-
const releaseIssues = await octokit.request(`GET /search/issues?q=${query}+label:"enterprise%20release"`)
10+
11+
const deprecationIssues = await octokit.request(
12+
`GET /search/issues?q=${query}+label:"enterprise%20deprecation"`
13+
)
14+
const releaseIssues = await octokit.request(
15+
`GET /search/issues?q=${query}+label:"enterprise%20release"`
16+
)
1317
const isDeprecationIssue = deprecationIssues.data.items.length === 0 ? 'false' : 'true'
1418
const isReleaseIssue = releaseIssues.data.items.length === 0 ? 'false' : 'true'
15-
core.setOutput('deprecationIssue', isDeprecationIssue)
16-
core.setOutput('releaseIssue', isReleaseIssue)
19+
setOutput('deprecationIssue', isDeprecationIssue)
20+
setOutput('releaseIssue', isReleaseIssue)
1721
return `Set outputs deprecationIssue: ${isDeprecationIssue}, releaseIssue: ${isReleaseIssue}`
1822
}
1923

20-
run()
21-
.then(
22-
(response) => { console.log(`Finished running: ${response}`) },
23-
(error) => {
24-
console.log(`#ERROR# ${error}`)
25-
process.exit(1)
26-
}
27-
)
24+
run().then(
25+
(response) => {
26+
console.log(`Finished running: ${response}`)
27+
},
28+
(error) => {
29+
console.log(`#ERROR# ${error}`)
30+
process.exit(1)
31+
}
32+
)
Lines changed: 50 additions & 38 deletions
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

@@ -19,45 +20,46 @@ const numberOfdaysBeforeDeprecationToOpenIssue = 15
1920
// number of days.
2021
//
2122
// When a milestone is within the specified number of days, a new issue is
22-
// created using the templates in
23-
// .github/actions-scripts/enterprise-server-issue-templates.
23+
// created using the templates in
24+
// .github/actions-scripts/enterprise-server-issue-templates.
2425
//
2526
// Release issues are then added to the docs content squad board for triage.
26-
// Deprecations issues are owned by docs engineering and are added to the
27+
// Deprecations issues are owned by docs engineering and are added to the
2728
// docs engineering squad board automatically when the engineering label is added.
2829
//
2930
// [end-readme]
3031

3132
run()
3233

33-
async function run () {
34-
35-
34+
async function run() {
3635
const milestone = process.argv[2]
3736
if (!acceptedMilestones.includes(milestone)) {
38-
console.log('Please specify either \'release\' or \'deprecation\'\n')
37+
console.log("Please specify either 'release' or 'deprecation'\n")
3938
console.log('Example: script/open-enterprise-issue.js release')
4039
process.exit(1)
4140
}
4241

4342
// Milestone-dependent values.
44-
const numberOfdaysBeforeMilestoneToOpenIssue = milestone === 'release'
45-
? numberOfdaysBeforeReleaseToOpenIssue
46-
: numberOfdaysBeforeDeprecationToOpenIssue
43+
const numberOfdaysBeforeMilestoneToOpenIssue =
44+
milestone === 'release'
45+
? numberOfdaysBeforeReleaseToOpenIssue
46+
: numberOfdaysBeforeDeprecationToOpenIssue
4747

48-
const versionNumber = milestone === 'release'
49-
? getNextVersionNumber()
50-
: oldestSupported
48+
const versionNumber = milestone === 'release' ? getNextVersionNumber() : oldestSupported
5149

5250
if (!versionNumber) {
53-
console.log(`Could not find the next version number after ${latest} in enterprise-dates.json. Try running script/udpate-enterprise-dates.js, then rerun this script.`)
51+
console.log(
52+
`Could not find the next version number after ${latest} in enterprise-dates.json. Try running script/udpate-enterprise-dates.js, then rerun this script.`
53+
)
5454
process.exit(0)
5555
}
5656

5757
const datesForVersion = enterpriseDates[versionNumber]
5858

5959
if (!datesForVersion) {
60-
console.log(`Could not find ${versionNumber} in enterprise-dates.json. Try running script/udpate-enterprise-dates.js, then rerun this script.`)
60+
console.log(
61+
`Could not find ${versionNumber} in enterprise-dates.json. Try running script/udpate-enterprise-dates.js, then rerun this script.`
62+
)
6163
process.exit(0)
6264
}
6365

@@ -66,11 +68,19 @@ async function run () {
6668

6769
// If the milestone is more than the specific days away, exit now.
6870
if (daysUntilMilestone > numberOfdaysBeforeMilestoneToOpenIssue) {
69-
console.log(`The ${versionNumber} ${milestone} is not until ${nextMilestoneDate}! An issue will be opened when it is ${numberOfdaysBeforeMilestoneToOpenIssue} days away.`)
71+
console.log(
72+
`The ${versionNumber} ${milestone} is not until ${nextMilestoneDate}! An issue will be opened when it is ${numberOfdaysBeforeMilestoneToOpenIssue} days away.`
73+
)
7074
process.exit(0)
7175
}
7276

73-
const milestoneSteps = fs.readFileSync(path.join(process.cwd(), `.github/actions-scripts/enterprise-server-issue-templates/${milestone}-issue.md`), 'utf8')
77+
const milestoneSteps = fs.readFileSync(
78+
path.join(
79+
process.cwd(),
80+
`.github/actions-scripts/enterprise-server-issue-templates/${milestone}-issue.md`
81+
),
82+
'utf8'
83+
)
7484
const issueLabels = [`enterprise ${milestone}`, `engineering`]
7585
const issueTitle = `[${nextMilestoneDate}] Enterprise Server ${versionNumber} ${milestone} (technical steps)`
7686

@@ -81,68 +91,70 @@ async function run () {
8191
const token = process.env.GITHUB_TOKEN
8292

8393
// Create the milestone issue
84-
const octokit = github.getOctokit(token)
94+
const octokit = getOctokit(token)
8595
try {
8696
issue = await octokit.request('POST /repos/{owner}/{repo}/issues', {
8797
owner: 'github',
8898
repo: 'docs-internal',
8999
title: issueTitle,
90100
body: issueBody,
91-
labels: issueLabels
101+
labels: issueLabels,
92102
})
93103
if (issue.status === 201) {
94104
// Write the values to disk for use in the workflow.
95-
console.log(`Issue #${issue.data.number} for the ${versionNumber} ${milestone} was opened: ${issue.data.html_url}`)
105+
console.log(
106+
`Issue #${issue.data.number} for the ${versionNumber} ${milestone} was opened: ${issue.data.html_url}`
107+
)
96108
}
97109
} catch (error) {
98110
console.error(`#ERROR# ${error}`)
99111
console.log(`πŸ›‘ There was an error creating the issue.`)
100112
process.exit(1)
101113
}
102114

103-
// Add the release issue to the 'Needs triage' column on the
115+
// Add the release issue to the 'Needs triage' column on the
104116
// docs content squad project board:
105117
// https://github.com/orgs/github/projects/1773#column-12198119
106118
// Deprecation issues are owned by docs engineering only and will
107119
// be triaged by adding the engineering label to the issue.
108120
if (milestone === 'release') {
109121
try {
110122
const addCard = await octokit.request('POST /projects/columns/{column_id}/cards', {
111-
column_id: 12198119,
123+
column_id: 12198119,
112124
content_id: issue.data.id,
113125
content_type: 'Issue',
114126
mediaType: {
115-
previews: [
116-
'inertia'
117-
]
118-
}
127+
previews: ['inertia'],
128+
},
119129
})
120130

121131
if (addCard.status === 201) {
122132
// Write the values to disk for use in the workflow.
123-
console.log(`The issue #${issue.data.number} was added to https://github.com/orgs/github/projects/1773#column-12198119.`)
124-
}
125-
} catch(error) {
133+
console.log(
134+
`The issue #${issue.data.number} was added to https://github.com/orgs/github/projects/1773#column-12198119.`
135+
)
136+
}
137+
} catch (error) {
126138
console.error(`#ERROR# ${error}`)
127139
console.log(`πŸ›‘ There was an error adding the issue to the project board.`)
128140
process.exit(1)
129141
}
130142
}
131143
}
132144

133-
function getNextVersionNumber () {
145+
function getNextVersionNumber() {
134146
const indexOfLatest = Object.keys(enterpriseDates).indexOf(latest)
135147
const indexOfNext = indexOfLatest + 1
136148
return Object.keys(enterpriseDates)[indexOfNext]
137149
}
138150

139-
function calculateDaysUntilMilestone (nextMilestoneDate) {
151+
function calculateDaysUntilMilestone(nextMilestoneDate) {
140152
const today = new Date().toISOString().slice(0, 10)
141153
const differenceInMilliseconds = getTime(nextMilestoneDate) - getTime(today)
142154
// Return the difference in days
143-
return Math.floor((differenceInMilliseconds) / (1000 * 60 * 60 * 24))
155+
return Math.floor(differenceInMilliseconds / (1000 * 60 * 60 * 24))
144156
}
145157

146-
function getTime (date) {
158+
function getTime(date) {
147159
return new Date(date).getTime()
148160
}

β€Ž.github/actions-scripts/enterprise-algolia-label.js

Lines changed: 7 additions & 6 deletions
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:
@@ -19,8 +20,8 @@ if (!(labelsArray && labelsArray.length)) {
1920

2021
// Find the relevant label
2122
const algoliaLabel = labelsArray
22-
.map(label => label.name)
23-
.find(label => label.startsWith(labelText))
23+
.map((label) => label.name)
24+
.find((label) => label.startsWith(labelText))
2425

2526
// Exit early if no relevant label is found
2627
if (!algoliaLabel) {
@@ -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

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,44 @@
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:
10-
* - Ensures the `info.version` property is a semantic version.
11-
* In development mode, the `info.version` property is a string
12-
* containing the `github/github` branch name.
13-
* - Ensures the decorated schema matches the dereferenced schema.
14-
* The workflow that calls this script runs `script/rest/update-files.js`
15-
* with the `--decorate-only` switch then checks to see if files changed.
16-
*
17-
*/
10+
* - Ensures the `info.version` property is a semantic version.
11+
* In development mode, the `info.version` property is a string
12+
* containing the `github/github` branch name.
13+
* - Ensures the decorated schema matches the dereferenced schema.
14+
* The workflow that calls this script runs `script/rest/update-files.js`
15+
* with the `--decorate-only` switch then checks to see if files changed.
16+
*
17+
*/
1818

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-
schemas.forEach(filename => {
23-
const schema = require(path.join(dereferencedDir, filename))
22+
23+
schemas.forEach((filename) => {
24+
const schema = JSON.parse(fs.readFileSync(path.join(dereferencedDir, filename)))
2425
if (!semver.valid(schema.info.version)) {
25-
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. πŸ›‘`)
26+
console.log(
27+
`🚧⚠️ Your branch contains a development mode OpenAPI schema: ${schema.info.version}. This check is a reminder to not 🚒 OpenAPI files in development mode. πŸ›‘`
28+
)
2629
process.exit(1)
2730
}
2831
})
2932

3033
// Check that the decorated schema matches the dereferenced schema
3134
const changedFiles = execSync('git diff --name-only HEAD').toString()
3235

33-
if(changedFiles !== '') {
36+
if (changedFiles !== '') {
3437
console.log(`These files were changed:\n${changedFiles}`)
35-
console.log(`🚧⚠️ Your decorated and dereferenced schema files don't match. Ensure you're using decorated and dereferenced schemas from the automatically created pull requests by the 'github-openapi-bot' user. For more information, see 'script/rest/README.md'. πŸ›‘`)
36-
process.exit(1)
38+
console.log(
39+
`🚧⚠️ Your decorated and dereferenced schema files don't match. Ensure you're using decorated and dereferenced schemas from the automatically created pull requests by the 'github-openapi-bot' user. For more information, see 'script/rest/README.md'. πŸ›‘`
40+
)
41+
process.exit(1)
3742
}
3843

3944
// All checks pass, ready to ship

0 commit comments

Comments
Β (0)