* 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>
51 lines
1.9 KiB
JavaScript
Executable File
51 lines
1.9 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
import fs from 'fs'
|
|
import path from 'path'
|
|
import xRimraf from 'rimraf'
|
|
import allVersions from '../../lib/all-versions.js'
|
|
|
|
const rimraf = xRimraf.sync
|
|
|
|
const graphqlDataDir = path.join(process.cwd(), 'data/graphql')
|
|
const webhooksStaticDir = path.join(process.cwd(), 'lib/webhooks/static')
|
|
const graphqlStaticDir = path.join(process.cwd(), 'lib/graphql/static')
|
|
const restDecoratedDir = path.join(process.cwd(), 'lib/rest/static/decorated')
|
|
const restDereferencedDir = path.join(process.cwd(), 'lib/rest/static/dereferenced')
|
|
|
|
// [start-readme]
|
|
//
|
|
// This script removes the static GraphQL, REST, and webhook files for any deprecated GHES versions.
|
|
//
|
|
// [end-readme]
|
|
|
|
const supportedEnterpriseVersions = Object.values(allVersions).filter(v => v.plan === 'enterprise-server')
|
|
|
|
// webhooks and GraphQL
|
|
const supportedMiscVersions = supportedEnterpriseVersions.map(v => v.miscVersionName)
|
|
// The miscBaseName is the same for all GHES versions (currently `ghes-`), so we can just grab the first one
|
|
const miscBaseName = supportedEnterpriseVersions.map(v => v.miscBaseName)[0]
|
|
|
|
;[graphqlDataDir, graphqlStaticDir, webhooksStaticDir].forEach(dir => {
|
|
removeFiles(dir, miscBaseName, supportedMiscVersions)
|
|
})
|
|
|
|
// REST
|
|
const supportedOpenApiVersions = supportedEnterpriseVersions.map(v => v.openApiVersionName)
|
|
// The openApiBaseName is the same for all GHES versions (currently `ghes-`), so we can just grab the first one
|
|
const openApiBaseName = supportedEnterpriseVersions.map(v => v.openApiBaseName)[0]
|
|
|
|
;[restDecoratedDir, restDereferencedDir].forEach(dir => {
|
|
removeFiles(dir, openApiBaseName, supportedOpenApiVersions)
|
|
})
|
|
|
|
function removeFiles (dir, baseName, supportedVersions) {
|
|
fs.readdirSync(dir)
|
|
.filter(file => file.includes(baseName))
|
|
.filter(file => supportedVersions.every(version => !file.includes(version)))
|
|
.forEach(file => {
|
|
const fullPath = path.join(dir, file)
|
|
console.log(`removing ${fullPath}`)
|
|
rimraf(fullPath)
|
|
})
|
|
}
|