Skip to content

Commit

Permalink
Pretty format (github#20352)
Browse files Browse the repository at this point in the history
* Update prettier flow to include JS

* Run prettier

* ...run prettier
  • Loading branch information
heiskr authored Jul 14, 2021
1 parent ae3db79 commit 8a56437
Show file tree
Hide file tree
Showing 333 changed files with 6,929 additions and 5,375 deletions.
35 changes: 12 additions & 23 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,40 @@ module.exports = {
browser: true,
commonjs: true,
es2020: true,
node: true
node: true,
},
parser: '@babel/eslint-parser',
extends: [
'eslint:recommended',
'standard',
'prettier'
],
extends: ['eslint:recommended', 'standard', 'prettier'],
parserOptions: {
ecmaVersion: 11,
requireConfigFile: 'false',
babelOptions: { configFile: './.babelrc' }
babelOptions: { configFile: './.babelrc' },
},
rules: {
'import/no-extraneous-dependencies': ['error', { packageDir: '.' }],
'node/global-require': ['error'],
'import/no-dynamic-require': ['error']
'import/no-dynamic-require': ['error'],
},
overrides: [
{
files: [
'**/tests/**/*.js'
],
files: ['**/tests/**/*.js'],
env: {
jest: true
}
jest: true,
},
},
{
files: [
'**/*.tsx', '**/*.ts'
],
plugins: [
'@typescript-eslint',
'jsx-a11y'
],
files: ['**/*.tsx', '**/*.ts'],
plugins: ['@typescript-eslint', 'jsx-a11y'],
extends: ['plugin:jsx-a11y/recommended'],
parser: '@typescript-eslint/parser',
rules: {
'camelcase': 'off',
camelcase: 'off',
'no-unused-vars': 'off',
'no-undef': 'off',
'no-use-before-define': 'off',
'@typescript-eslint/no-unused-vars': ['error'],
'jsx-a11y/no-onchange': 'off',
}
},
},
]
],
}
27 changes: 16 additions & 11 deletions .github/actions-scripts/check-for-enterprise-issues-by-label.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,30 @@
import { getOctokit } from '@actions/github'
import { setOutput } from '@actions/core'

async function run () {
async function run() {
const token = process.env.GITHUB_TOKEN
const octokit = getOctokit(token)
const query = encodeURIComponent('is:open repo:github/docs-internal is:issue')

const deprecationIssues = await octokit.request(`GET /search/issues?q=${query}+label:"enterprise%20deprecation"`)
const releaseIssues = await octokit.request(`GET /search/issues?q=${query}+label:"enterprise%20release"`)
const deprecationIssues = await octokit.request(
`GET /search/issues?q=${query}+label:"enterprise%20deprecation"`
)
const releaseIssues = await octokit.request(
`GET /search/issues?q=${query}+label:"enterprise%20release"`
)
const isDeprecationIssue = deprecationIssues.data.items.length === 0 ? 'false' : 'true'
const isReleaseIssue = releaseIssues.data.items.length === 0 ? 'false' : 'true'
setOutput('deprecationIssue', isDeprecationIssue)
setOutput('releaseIssue', isReleaseIssue)
return `Set outputs deprecationIssue: ${isDeprecationIssue}, releaseIssue: ${isReleaseIssue}`
}

run()
.then(
(response) => { console.log(`Finished running: ${response}`) },
(error) => {
console.log(`#ERROR# ${error}`)
process.exit(1)
}
)
run().then(
(response) => {
console.log(`Finished running: ${response}`)
},
(error) => {
console.log(`#ERROR# ${error}`)
process.exit(1)
}
)
74 changes: 43 additions & 31 deletions .github/actions-scripts/create-enterprise-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,46 @@ const numberOfdaysBeforeDeprecationToOpenIssue = 15
// number of days.
//
// When a milestone is within the specified number of days, a new issue is
// created using the templates in
// .github/actions-scripts/enterprise-server-issue-templates.
// created using the templates in
// .github/actions-scripts/enterprise-server-issue-templates.
//
// Release issues are then added to the docs content squad board for triage.
// Deprecations issues are owned by docs engineering and are added to the
// Deprecations issues are owned by docs engineering and are added to the
// docs engineering squad board automatically when the engineering label is added.
//
// [end-readme]

run()

async function run () {

async function run() {
const milestone = process.argv[2]
if (!acceptedMilestones.includes(milestone)) {
console.log('Please specify either \'release\' or \'deprecation\'\n')
console.log("Please specify either 'release' or 'deprecation'\n")
console.log('Example: script/open-enterprise-issue.js release')
process.exit(1)
}

// Milestone-dependent values.
const numberOfdaysBeforeMilestoneToOpenIssue = milestone === 'release'
? numberOfdaysBeforeReleaseToOpenIssue
: numberOfdaysBeforeDeprecationToOpenIssue
const numberOfdaysBeforeMilestoneToOpenIssue =
milestone === 'release'
? numberOfdaysBeforeReleaseToOpenIssue
: numberOfdaysBeforeDeprecationToOpenIssue

const versionNumber = milestone === 'release'
? getNextVersionNumber()
: oldestSupported
const versionNumber = milestone === 'release' ? getNextVersionNumber() : oldestSupported

if (!versionNumber) {
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.`)
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.`
)
process.exit(0)
}

const datesForVersion = enterpriseDates[versionNumber]

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

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

// If the milestone is more than the specific days away, exit now.
if (daysUntilMilestone > numberOfdaysBeforeMilestoneToOpenIssue) {
console.log(`The ${versionNumber} ${milestone} is not until ${nextMilestoneDate}! An issue will be opened when it is ${numberOfdaysBeforeMilestoneToOpenIssue} days away.`)
console.log(
`The ${versionNumber} ${milestone} is not until ${nextMilestoneDate}! An issue will be opened when it is ${numberOfdaysBeforeMilestoneToOpenIssue} days away.`
)
process.exit(0)
}

const milestoneSteps = fs.readFileSync(path.join(process.cwd(), `.github/actions-scripts/enterprise-server-issue-templates/${milestone}-issue.md`), 'utf8')
const milestoneSteps = fs.readFileSync(
path.join(
process.cwd(),
`.github/actions-scripts/enterprise-server-issue-templates/${milestone}-issue.md`
),
'utf8'
)
const issueLabels = [`enterprise ${milestone}`, `engineering`]
const issueTitle = `[${nextMilestoneDate}] Enterprise Server ${versionNumber} ${milestone} (technical steps)`

Expand All @@ -88,61 +98,63 @@ async function run () {
repo: 'docs-internal',
title: issueTitle,
body: issueBody,
labels: issueLabels
labels: issueLabels,
})
if (issue.status === 201) {
// Write the values to disk for use in the workflow.
console.log(`Issue #${issue.data.number} for the ${versionNumber} ${milestone} was opened: ${issue.data.html_url}`)
console.log(
`Issue #${issue.data.number} for the ${versionNumber} ${milestone} was opened: ${issue.data.html_url}`
)
}
} catch (error) {
console.error(`#ERROR# ${error}`)
console.log(`🛑 There was an error creating the issue.`)
process.exit(1)
}

// Add the release issue to the 'Needs triage' column on the
// Add the release issue to the 'Needs triage' column on the
// docs content squad project board:
// https://github.com/orgs/github/projects/1773#column-12198119
// Deprecation issues are owned by docs engineering only and will
// be triaged by adding the engineering label to the issue.
if (milestone === 'release') {
try {
const addCard = await octokit.request('POST /projects/columns/{column_id}/cards', {
column_id: 12198119,
column_id: 12198119,
content_id: issue.data.id,
content_type: 'Issue',
mediaType: {
previews: [
'inertia'
]
}
previews: ['inertia'],
},
})

if (addCard.status === 201) {
// Write the values to disk for use in the workflow.
console.log(`The issue #${issue.data.number} was added to https://github.com/orgs/github/projects/1773#column-12198119.`)
}
} catch(error) {
console.log(
`The issue #${issue.data.number} was added to https://github.com/orgs/github/projects/1773#column-12198119.`
)
}
} catch (error) {
console.error(`#ERROR# ${error}`)
console.log(`🛑 There was an error adding the issue to the project board.`)
process.exit(1)
}
}
}

function getNextVersionNumber () {
function getNextVersionNumber() {
const indexOfLatest = Object.keys(enterpriseDates).indexOf(latest)
const indexOfNext = indexOfLatest + 1
return Object.keys(enterpriseDates)[indexOfNext]
}

function calculateDaysUntilMilestone (nextMilestoneDate) {
function calculateDaysUntilMilestone(nextMilestoneDate) {
const today = new Date().toISOString().slice(0, 10)
const differenceInMilliseconds = getTime(nextMilestoneDate) - getTime(today)
// Return the difference in days
return Math.floor((differenceInMilliseconds) / (1000 * 60 * 60 * 24))
return Math.floor(differenceInMilliseconds / (1000 * 60 * 60 * 24))
}

function getTime (date) {
function getTime(date) {
return new Date(date).getTime()
}
4 changes: 2 additions & 2 deletions .github/actions-scripts/enterprise-algolia-label.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ if (!(labelsArray && labelsArray.length)) {

// Find the relevant label
const algoliaLabel = labelsArray
.map(label => label.name)
.find(label => label.startsWith(labelText))
.map((label) => label.name)
.find((label) => label.startsWith(labelText))

// Exit early if no relevant label is found
if (!algoliaLabel) {
Expand Down
30 changes: 17 additions & 13 deletions .github/actions-scripts/openapi-schema-branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,38 @@ import semver from 'semver'

/*
* This script performs two checks to prevent shipping development mode OpenAPI schemas:
* - Ensures the `info.version` property is a semantic version.
* In development mode, the `info.version` property is a string
* containing the `github/github` branch name.
* - Ensures the decorated schema matches the dereferenced schema.
* The workflow that calls this script runs `script/rest/update-files.js`
* with the `--decorate-only` switch then checks to see if files changed.
*
*/
* - Ensures the `info.version` property is a semantic version.
* In development mode, the `info.version` property is a string
* containing the `github/github` branch name.
* - Ensures the decorated schema matches the dereferenced schema.
* The workflow that calls this script runs `script/rest/update-files.js`
* with the `--decorate-only` switch then checks to see if files changed.
*
*/

// Check that the `info.version` property is a semantic version
const dereferencedDir = path.join(process.cwd(), 'lib/rest/static/dereferenced')
const schemas = fs.readdirSync(dereferencedDir)

schemas.forEach(filename => {
schemas.forEach((filename) => {
const schema = JSON.parse(fs.readFileSync(path.join(dereferencedDir, filename)))
if (!semver.valid(schema.info.version)) {
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. 🛑`)
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. 🛑`
)
process.exit(1)
}
})

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

if(changedFiles !== '') {
if (changedFiles !== '') {
console.log(`These files were changed:\n${changedFiles}`)
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'. 🛑`)
process.exit(1)
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'. 🛑`
)
process.exit(1)
}

// All checks pass, ready to ship
Expand Down
64 changes: 32 additions & 32 deletions .github/allowed-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@
// can be added it this list.

export default [
"actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f", // v2.3.4
"actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d", // v4.0.2
"actions/labeler@5f867a63be70efff62b767459b009290364495eb", // v2.2.0
"actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f", // v2.2.0
"actions/setup-python@dc73133d4da04e56a135ae2246682783cc7c7cb6", // v2.2.2
"actions/stale@9d6f46564a515a9ea11e7762ab3957ee58ca50da", // v3.0.16
"alex-page/github-project-automation-plus@fdb7991b72040d611e1123d2b75ff10eda9372c9",
"andymckay/labeler@22d5392de2b725cea4b284df5824125054049d84",
"crowdin/github-action@fd9429dd63d6c0f8a8cb4b93ad8076990bd6e688",
"crykn/copy_folder_to_another_repo_action@0282e8b9fef06de92ddcae9fe6cb44df6226646c",
"cschleiden/actions-linter@0ff16d6ac5103cca6c92e6cbc922b646baaea5be",
"dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911",
"docker://chinthakagodawita/autoupdate-action:v1",
"dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58",
"github/codeql-action/analyze@v1",
"github/codeql-action/init@v1",
"juliangruber/approve-pull-request-action@c530832d4d346c597332e20e03605aa94fa150a8",
"juliangruber/find-pull-request-action@db875662766249c049b2dcd85293892d61cb0b51", // v1.5.0
"juliangruber/read-file-action@e0a316da496006ffd19142f0fd594a1783f3b512",
"lee-dohm/close-matching-issues@22002609b2555fe18f52b8e2e7c07cbf5529e8a8",
"lee-dohm/no-response@9bb0a4b5e6a45046f00353d5de7d90fb8bd773bb",
"pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07", // v0.12.0
"peter-evans/create-issue-from-file@b4f9ee0a9d4abbfc6986601d9b1a4f8f8e74c77e",
"peter-evans/create-or-update-comment@5221bf4aa615e5c6e95bb142f9673a9c791be2cd",
"peter-evans/create-pull-request@8c603dbb04b917a9fc2dd991dc54fef54b640b43",
"rachmari/actions-add-new-issue-to-column@1a459ef92308ba7c9c9dc2fcdd72f232495574a9",
"rachmari/labeler@832d42ec5523f3c6d46e8168de71cd54363e3e2e",
"repo-sync/github-sync@3832fe8e2be32372e1b3970bbae8e7079edeec88",
"repo-sync/pull-request@33777245b1aace1a58c87a29c90321aa7a74bd7d",
"someimportantcompany/github-actions-slack-message@0b470c14b39da4260ed9e3f9a4f1298a74ccdefd",
"tjenkinson/gh-action-auto-merge-dependency-updates@4d7756c04d9d999c5968697a621b81c47f533d61",
"EndBug/add-and-commit@b3c7c1e078a023d75fb0bd326e02962575ce0519"
'actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f', // v2.3.4
'actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d', // v4.0.2
'actions/labeler@5f867a63be70efff62b767459b009290364495eb', // v2.2.0
'actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f', // v2.2.0
'actions/setup-python@dc73133d4da04e56a135ae2246682783cc7c7cb6', // v2.2.2
'actions/stale@9d6f46564a515a9ea11e7762ab3957ee58ca50da', // v3.0.16
'alex-page/github-project-automation-plus@fdb7991b72040d611e1123d2b75ff10eda9372c9',
'andymckay/labeler@22d5392de2b725cea4b284df5824125054049d84',
'crowdin/github-action@fd9429dd63d6c0f8a8cb4b93ad8076990bd6e688',
'crykn/copy_folder_to_another_repo_action@0282e8b9fef06de92ddcae9fe6cb44df6226646c',
'cschleiden/actions-linter@0ff16d6ac5103cca6c92e6cbc922b646baaea5be',
'dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911',
'docker://chinthakagodawita/autoupdate-action:v1',
'dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58',
'github/codeql-action/analyze@v1',
'github/codeql-action/init@v1',
'juliangruber/approve-pull-request-action@c530832d4d346c597332e20e03605aa94fa150a8',
'juliangruber/find-pull-request-action@db875662766249c049b2dcd85293892d61cb0b51', // v1.5.0
'juliangruber/read-file-action@e0a316da496006ffd19142f0fd594a1783f3b512',
'lee-dohm/close-matching-issues@22002609b2555fe18f52b8e2e7c07cbf5529e8a8',
'lee-dohm/no-response@9bb0a4b5e6a45046f00353d5de7d90fb8bd773bb',
'pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07', // v0.12.0
'peter-evans/create-issue-from-file@b4f9ee0a9d4abbfc6986601d9b1a4f8f8e74c77e',
'peter-evans/create-or-update-comment@5221bf4aa615e5c6e95bb142f9673a9c791be2cd',
'peter-evans/create-pull-request@8c603dbb04b917a9fc2dd991dc54fef54b640b43',
'rachmari/actions-add-new-issue-to-column@1a459ef92308ba7c9c9dc2fcdd72f232495574a9',
'rachmari/labeler@832d42ec5523f3c6d46e8168de71cd54363e3e2e',
'repo-sync/github-sync@3832fe8e2be32372e1b3970bbae8e7079edeec88',
'repo-sync/pull-request@33777245b1aace1a58c87a29c90321aa7a74bd7d',
'someimportantcompany/github-actions-slack-message@0b470c14b39da4260ed9e3f9a4f1298a74ccdefd',
'tjenkinson/gh-action-auto-merge-dependency-updates@4d7756c04d9d999c5968697a621b81c47f533d61',
'EndBug/add-and-commit@b3c7c1e078a023d75fb0bd326e02962575ce0519',
]
Loading

0 comments on commit 8a56437

Please sign in to comment.