Migrate CommonJS to ESM (#20301)
* First run of script * Get the app running --- ish * Get NextJS working * Remove `node:` * Get more tests passing in unit directory * Update FailBot test to use nock * Update test.yml * Update Dockerfile * tests/content fixes * Update page.js * Update build-changelog.js * updating tests/routing * Update orphan-tests.js * updating tests/rendering * Update .eslintrc.js * Update .eslintrc.js * Install jest/globals * "linting" tests * staging update to server.mjs * Change '.github/allowed-actions.js' to a ESM export * Lint * Fixes for the main package.json * Move Jest to be last in the npm test command so we can pass args * Just use 'npm run lint' in the npm test command * update algolia label script * update openapi script * update require on openapi * Update enterprise-algolia-label.js * forgot JSON.parse * Update lunr-search-index.js * Always explicitly include process.cwd() for JSON file reads pathed from project root * update graphql/update-files.js script * Update other npm scripts using jest to pass ESM NODE_OPTIONS * Update check-for-enterprise-issues-by-label.js for ESM * Update create-enterprise-issue.js for ESM * Import jest global for browser tests * Convert 'script/deploy' to ESM Co-authored-by: Grace Park <gracepark@github.com> Co-authored-by: James M. Greene <jamesmgreene@github.com>
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const github = require('@actions/github')
|
||||
const core = require('@actions/core')
|
||||
import { getOctokit } from '@actions/github'
|
||||
import { setOutput } from '@actions/core'
|
||||
|
||||
async function run () {
|
||||
const token = process.env.GITHUB_TOKEN
|
||||
const octokit = github.getOctokit(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 isDeprecationIssue = deprecationIssues.data.items.length === 0 ? 'false' : 'true'
|
||||
const isReleaseIssue = releaseIssues.data.items.length === 0 ? 'false' : 'true'
|
||||
core.setOutput('deprecationIssue', isDeprecationIssue)
|
||||
core.setOutput('releaseIssue', isReleaseIssue)
|
||||
setOutput('deprecationIssue', isDeprecationIssue)
|
||||
setOutput('releaseIssue', isReleaseIssue)
|
||||
return `Set outputs deprecationIssue: ${isDeprecationIssue}, releaseIssue: ${isReleaseIssue}`
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const github = require('@actions/github')
|
||||
const enterpriseDates = require('../../lib/enterprise-dates')
|
||||
const { latest, oldestSupported } = require('../../lib/enterprise-server-releases')
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { getOctokit } from '@actions/github'
|
||||
import enterpriseDates from '../../lib/enterprise-dates.js'
|
||||
import { latest, oldestSupported } from '../../lib/enterprise-server-releases.js'
|
||||
|
||||
const acceptedMilestones = ['release', 'deprecation']
|
||||
const teamsToCC = '/cc @github/docs-content @github/docs-engineering'
|
||||
|
||||
@@ -31,7 +32,6 @@ const numberOfdaysBeforeDeprecationToOpenIssue = 15
|
||||
run()
|
||||
|
||||
async function run () {
|
||||
|
||||
|
||||
const milestone = process.argv[2]
|
||||
if (!acceptedMilestones.includes(milestone)) {
|
||||
@@ -81,7 +81,7 @@ async function run () {
|
||||
const token = process.env.GITHUB_TOKEN
|
||||
|
||||
// Create the milestone issue
|
||||
const octokit = github.getOctokit(token)
|
||||
const octokit = getOctokit(token)
|
||||
try {
|
||||
issue = await octokit.request('POST /repos/{owner}/{repo}/issues', {
|
||||
owner: 'github',
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs')
|
||||
const core = require('@actions/core')
|
||||
import fs from 'fs'
|
||||
import { setOutput } from '@actions/core'
|
||||
|
||||
const eventPayload = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8'))
|
||||
|
||||
// This workflow-run script does the following:
|
||||
@@ -32,5 +33,5 @@ if (!algoliaLabel) {
|
||||
const versionToSync = algoliaLabel.split(labelText)[1]
|
||||
|
||||
// Store the version so we can access it later in the workflow
|
||||
core.setOutput('versionToSync', versionToSync)
|
||||
process.exit(0)
|
||||
setOutput('versionToSync', versionToSync)
|
||||
process.exit(0)
|
||||
|
||||
11
.github/actions-scripts/openapi-schema-branch.js
vendored
11
.github/actions-scripts/openapi-schema-branch.js
vendored
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { execSync } = require('child_process')
|
||||
const semver = require('semver')
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { execSync } from 'child_process'
|
||||
import semver from 'semver'
|
||||
|
||||
/*
|
||||
* This script performs two checks to prevent shipping development mode OpenAPI schemas:
|
||||
@@ -19,8 +19,9 @@ const semver = require('semver')
|
||||
// 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 => {
|
||||
const schema = require(path.join(dereferencedDir, 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. 🛑`)
|
||||
process.exit(1)
|
||||
|
||||
8
.github/allowed-actions.js
vendored
8
.github/allowed-actions.js
vendored
@@ -3,7 +3,7 @@
|
||||
// CI will fail and the action will need to be audited by the docs engineering team before it
|
||||
// can be added it this list.
|
||||
|
||||
module.exports = [
|
||||
export default [
|
||||
"actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f", // v2.3.4
|
||||
"actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d", // v4.0.2
|
||||
"actions/labeler@5f867a63be70efff62b767459b009290364495eb", // v2.2.0
|
||||
@@ -17,6 +17,7 @@ module.exports = [
|
||||
"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",
|
||||
@@ -34,6 +35,5 @@ module.exports = [
|
||||
"repo-sync/pull-request@33777245b1aace1a58c87a29c90321aa7a74bd7d",
|
||||
"someimportantcompany/github-actions-slack-message@0b470c14b39da4260ed9e3f9a4f1298a74ccdefd",
|
||||
"tjenkinson/gh-action-auto-merge-dependency-updates@4d7756c04d9d999c5968697a621b81c47f533d61",
|
||||
"EndBug/add-and-commit@b3c7c1e078a023d75fb0bd326e02962575ce0519",
|
||||
"dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58",
|
||||
];
|
||||
"EndBug/add-and-commit@b3c7c1e078a023d75fb0bd326e02962575ce0519"
|
||||
]
|
||||
|
||||
1
.github/package.json
vendored
Normal file
1
.github/package.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"type":"module"}
|
||||
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -59,4 +59,4 @@ jobs:
|
||||
- name: Run tests
|
||||
run: npx jest tests/${{ matrix.test-group }}/
|
||||
env:
|
||||
NODE_OPTIONS: '--max_old_space_size=8192'
|
||||
NODE_OPTIONS: '--max_old_space_size=8192 --experimental-vm-modules'
|
||||
|
||||
Reference in New Issue
Block a user