* Update dependencies 2

* Lint fixes

* Update graphql packages

* Update changelog-entry.json

* Update @octokit/rest

* Update commander with help from @rachmari

@rachmari

* Upgrade helmet

* Upgrade js-yaml

* Update server.js

* Update cheerio

* Revert "Update cheerio"

This reverts commit 8aa17c39fbf564ee554037d89e7a473027d16984.
This commit is contained in:
Kevin Heis 2021-05-19 10:32:47 -07:00 коммит произвёл GitHub
Родитель dcd72d15f0
Коммит f6acb1f08a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
29 изменённых файлов: 3447 добавлений и 4275 удалений

Просмотреть файл

@ -57,7 +57,7 @@ module.exports = function dataDirectory (dir, opts = {}) {
break
case '.yaml':
case '.yml':
set(data, key, yaml.safeLoad(fileContent, { filename }))
set(data, key, yaml.load(fileContent, { filename }))
break
case '.md':
case '.markdown':

Просмотреть файл

@ -17,10 +17,10 @@ class RedisAccessor {
} = {}) {
const redisClient = useRealRedis
? createRedisClient({
url: REDIS_URL,
db: databaseNumber,
name: name || 'redis-accessor'
})
url: REDIS_URL,
db: databaseNumber,
name: name || 'redis-accessor'
})
: InMemoryRedis.createClient()
this._client = redisClient

Просмотреть файл

@ -36,8 +36,8 @@ module.exports = function (app) {
// *** Security ***
app.use(require('./cors'))
app.use(require('./csp')) // Must come before helmet
app.use(require('helmet')())
app.use(require('./csp')) // Must come after helmet
app.use(require('./cookie-parser')) // Must come before csrf
app.use(express.json()) // Must come before csrf
app.use(require('./csrf'))

7406
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -9,80 +9,80 @@
},
"license": "(MIT AND CC-BY-4.0)",
"dependencies": {
"@babel/core": "^7.12.9",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/core": "^7.14.3",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-syntax-class-properties": "^7.12.1",
"@babel/plugin-transform-modules-amd": "^7.12.1",
"@babel/plugin-transform-modules-commonjs": "^7.12.1",
"@babel/plugin-transform-react-jsx": "^7.12.7",
"@babel/plugin-transform-runtime": "^7.11.0",
"@babel/preset-env": "^7.12.7",
"@babel/preset-react": "^7.12.7",
"@babel/runtime": "^7.11.2",
"@graphql-inspector/core": "^2.3.0",
"@graphql-tools/load": "^6.2.5",
"@primer/components": "^28.0.1",
"@babel/plugin-transform-modules-amd": "^7.14.2",
"@babel/plugin-transform-modules-commonjs": "^7.14.0",
"@babel/plugin-transform-react-jsx": "^7.14.3",
"@babel/plugin-transform-runtime": "^7.14.3",
"@babel/preset-env": "^7.14.2",
"@babel/preset-react": "^7.13.13",
"@babel/runtime": "^7.14.0",
"@graphql-inspector/core": "^2.5.0",
"@graphql-tools/load": "^6.2.8",
"@primer/components": "^28.0.4",
"@primer/css": "^16.2.0",
"@primer/octicons": "^13.0.0",
"@primer/octicons-react": "^13.0.0",
"@primer/octicons": "^14.1.0",
"@primer/octicons-react": "^14.1.0",
"ajv": "^6.11.0",
"algoliasearch": "^3.35.1",
"algoliasearch": "^4.9.1",
"assert": "^2.0.0",
"babel-loader": "^8.1.0",
"babel-loader": "^8.2.2",
"babel-preset-env": "^1.7.0",
"browser-date-formatter": "^3.0.3",
"change-case": "^3.1.0",
"change-case": "^4.1.2",
"cheerio": "^1.0.0-rc.3",
"classnames": "^2.3.1",
"compression": "^1.7.4",
"connect-datadog": "0.0.9",
"connect-slashes": "^1.4.0",
"cookie-parser": "^1.4.5",
"copy-webpack-plugin": "^6.0.3",
"copy-webpack-plugin": "^8.1.1",
"cors": "^2.8.5",
"cross-env": "^7.0.2",
"css-loader": "^4.3.0",
"cross-env": "^7.0.3",
"css-loader": "^5.2.4",
"csurf": "^1.11.0",
"date-fns": "^2.21.3",
"directory-tree": "^2.2.5",
"dotenv": "^8.2.0",
"directory-tree": "^2.2.9",
"dotenv": "^9.0.2",
"express": "^4.17.1",
"express-rate-limit": "^5.1.3",
"express-rate-limit": "^5.2.6",
"express-timeout-handler": "^2.2.0",
"flat": "^5.0.0",
"github-slugger": "^1.2.1",
"got": "^9.6.0",
"gray-matter": "^4.0.2",
"flat": "^5.0.2",
"github-slugger": "^1.3.0",
"got": "^11.8.2",
"gray-matter": "^4.0.3",
"hast-util-from-parse5": "^6.0.1",
"hast-util-parse-selector": "^2.2.5",
"hast-util-select": "^4.0.2",
"hast-util-to-string": "^1.0.4",
"hastscript": "^6.0.0",
"helmet": "^3.21.2",
"helmet": "^4.6.0",
"highlightjs-graphql": "^1.0.2",
"hot-shots": "^8.2.0",
"hot-shots": "^8.3.1",
"html-entities": "^1.2.1",
"imurmurhash": "^0.1.4",
"is-url": "^1.2.4",
"js-cookie": "^2.2.1",
"js-yaml": "^3.14.0",
"js-yaml": "^4.1.0",
"linkinator": "^2.13.6",
"liquidjs": "^9.22.1",
"lodash": "^4.17.21",
"lunr": "^2.3.9",
"lunr-languages": "^1.4.0",
"mdast-util-from-markdown": "^0.8.4",
"mini-css-extract-plugin": "^1.4.1",
"mkdirp": "^1.0.3",
"morgan": "^1.9.1",
"mini-css-extract-plugin": "^1.6.0",
"mkdirp": "^1.0.4",
"morgan": "^1.10.0",
"next": "^10.2.0",
"node-fetch": "^2.6.1",
"parse5": "^6.0.1",
"port-used": "^2.0.8",
"rate-limit-redis": "^2.1.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"redis": "^3.1.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"redis": "^3.1.2",
"redis-mock": "^0.56.3",
"rehype-autolink-headings": "^2.0.5",
"rehype-highlight": "^4.1.0",
@ -93,89 +93,89 @@
"remark-gemoji-to-emoji": "^1.1.0",
"remark-parse": "^7.0.2",
"remark-rehype": "^5.0.0",
"resolve-url-loader": "^3.1.2",
"resolve-url-loader": "^4.0.0",
"revalidator": "^0.3.1",
"rimraf": "^3.0.0",
"rimraf": "^3.0.2",
"rss-parser": "^3.12.0",
"sass": "^1.26.3",
"sass-loader": "^9.0.2",
"sass": "^1.32.13",
"sass-loader": "^11.1.1",
"search-with-your-keyboard": "1.1.0",
"semver": "^5.7.1",
"semver": "^7.3.5",
"slash": "^3.0.0",
"strip-html-comments": "^1.0.0",
"style-loader": "^1.2.1",
"style-loader": "^2.0.0",
"styled-components": "^5.3.0",
"throng": "^5.0.0",
"unified": "^8.4.2",
"unist-util-visit": "^2.0.3",
"uuid": "^8.3.0",
"walk-sync": "^1.1.4",
"webpack": "^5.30.0",
"webpack-cli": "^4.6.0"
"uuid": "^8.3.2",
"walk-sync": "^2.2.0",
"webpack": "^5.37.0",
"webpack-cli": "^4.7.0"
},
"devDependencies": {
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0",
"@octokit/rest": "^16.43.2",
"@types/lodash": "^4.14.168",
"@types/react": "^17.0.4",
"@types/react-dom": "^17.0.3",
"@actions/core": "^1.2.7",
"@actions/github": "^5.0.0",
"@octokit/rest": "^18.5.3",
"@types/lodash": "^4.14.169",
"@types/react": "^17.0.6",
"@types/react-dom": "^17.0.5",
"async": "^3.2.0",
"await-sleep": "0.0.1",
"aws-sdk": "^2.610.0",
"aws-sdk": "^2.909.0",
"babel-eslint": "^10.1.0",
"babel-plugin-styled-components": "^1.12.0",
"chalk": "^4.0.0",
"commander": "^6.2.0",
"chalk": "^4.1.1",
"commander": "^7.2.0",
"count-array-values": "^1.2.1",
"csp-parse": "0.0.2",
"csv-parse": "^4.8.8",
"csv-parser": "^2.3.3",
"csv-parse": "^4.15.4",
"csv-parser": "^3.0.0",
"dedent": "^0.7.0",
"del": "^4.1.1",
"domwaiter": "^1.1.0",
"eslint": "^7.13.0",
"eslint-config-standard": "^16.0.1",
"eslint-plugin-import": "^2.22.1",
"del": "^6.0.0",
"domwaiter": "^1.3.0",
"eslint": "^7.26.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.23.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-promise": "^5.1.0",
"event-to-promise": "^0.8.0",
"glob": "^7.1.6",
"graphql": "^14.5.8",
"glob": "^7.1.7",
"graphql": "^15.5.0",
"heroku-client": "^3.1.0",
"http-status-code": "^2.1.0",
"husky": "^4.2.1",
"image-size": "^0.7.4",
"husky": "^6.0.0",
"image-size": "^1.0.0",
"japanese-characters": "^1.1.0",
"javascript-stringify": "^2.0.1",
"javascript-stringify": "^2.1.0",
"jest": "^26.6.3",
"jest-expect-message": "^1.0.2",
"jest-github-actions-reporter": "^1.0.2",
"jest-puppeteer": "^4.4.0",
"jest-silent-reporter": "^0.2.1",
"jest-github-actions-reporter": "^1.0.3",
"jest-puppeteer": "^5.0.3",
"jest-silent-reporter": "^0.5.0",
"jest-slow-test-reporter": "^1.0.0",
"jimp": "^0.16.1",
"make-promises-safe": "^5.1.0",
"mime": "^2.4.4",
"mock-express-response": "^0.2.2",
"mockdate": "^3.0.2",
"nock": "^13.0.4",
"nodemon": "^2.0.4",
"npm-merge-driver-install": "^2.0.0",
"object-hash": "^2.0.1",
"pa11y-ci": "^2.4.0",
"prettier": "^2.1.2",
"mock-express-response": "^0.3.0",
"mockdate": "^3.0.5",
"nock": "^13.0.11",
"nodemon": "^2.0.7",
"npm-merge-driver-install": "^2.0.1",
"object-hash": "^2.1.1",
"pa11y-ci": "^2.4.1",
"prettier": "^2.3.0",
"process": "^0.11.10",
"puppeteer": "^5.5.0",
"replace": "^1.2.0",
"robots-parser": "^2.1.1",
"start-server-and-test": "^1.12.0",
"strip-ansi": "^6.0.0",
"supertest": "^4.0.2",
"puppeteer": "^9.1.1",
"replace": "^1.2.1",
"robots-parser": "^2.3.0",
"start-server-and-test": "^1.12.2",
"strip-ansi": "^7.0.0",
"supertest": "^6.1.3",
"typescript": "^4.2.4",
"url-template": "^2.0.8",
"webpack-dev-middleware": "^4.1.0",
"website-scraper": "^4.2.0",
"webpack-dev-middleware": "^4.2.0",
"website-scraper": "^4.2.3",
"xlsx-populate": "^1.21.0"
},
"scripts": {

Просмотреть файл

@ -47,10 +47,10 @@ const languagesToSkip = Object.keys(require('../lib/languages'))
const enterpriseReleasesToSkip = new RegExp(`${root}.+?[/@](${deprecated.join('|')})(/|$)`)
const config = {
path: program.path || englishRoot,
path: program.opts().path || englishRoot,
concurrency: 300,
// If this is a dry run, turn off recursion.
recurse: !program.dryRun,
recurse: !program.opts().dryRun,
silent: true,
// The values in this array are treated as regexes.
linksToSkip: [
@ -86,7 +86,7 @@ async function main () {
// Without this, undefined codes get JSON.stringified as `0`, which is not useful output.
.map(link => { link.status = link.status || 'Invalid'; return link })
if (!program.doNotRetry) {
if (!program.opts().doNotRetry) {
// Links to retry individually.
const linksToRetry = brokenLinks
.filter(link => retryStatusCodes.includes(link.status))

Просмотреть файл

@ -11,7 +11,7 @@ const path = require('path')
const yaml = require('js-yaml')
const inputFile = path.join(__dirname, '../data/glossary.yml')
const glossary = yaml.safeLoad(fs.readFileSync(inputFile, 'utf8'))
const glossary = yaml.load(fs.readFileSync(inputFile, 'utf8'))
console.log(glossary)
const external = []

Просмотреть файл

@ -24,7 +24,7 @@ program
.option('-u, --unlink', 'remove the symlinks')
.parse(process.argv)
const { pathToEarlyAccessRepo, unlink } = program
const { pathToEarlyAccessRepo, unlink } = program.opts()
if (!pathToEarlyAccessRepo && !unlink) {
throw new Error('Must provide either `--path-to-early-access-repo <PATH>` or `--unlink`')

Просмотреть файл

@ -25,17 +25,19 @@ program
.option('-r, --remove', 'Remove "early-access" from data and image paths.')
.parse(process.argv)
if (!(program.add || program.remove)) {
const { add, remove, pathToEarlyAccessContentFile } = program.opts()
if (!(add || remove)) {
console.error('Error! Must specify either `--add` or `--remove`.')
process.exit(1)
}
let earlyAccessContentAndDataFiles
if (program.pathToEarlyAccessContentFile) {
earlyAccessContentAndDataFiles = path.posix.join(process.cwd(), program.pathToEarlyAccessContentFile)
if (pathToEarlyAccessContentFile) {
earlyAccessContentAndDataFiles = path.posix.join(process.cwd(), pathToEarlyAccessContentFile)
if (!fs.existsSync(earlyAccessContentAndDataFiles)) {
console.error(`Error! ${program.pathToEarlyAccessContentFile} can't be found. Make sure the path starts with 'content/early-access'.`)
console.error(`Error! ${pathToEarlyAccessContentFile} can't be found. Make sure the path starts with 'content/early-access'.`)
process.exit(1)
}
earlyAccessContentAndDataFiles = [earlyAccessContentAndDataFiles]
@ -60,7 +62,7 @@ earlyAccessContentAndDataFiles
const replacements = {}
if (program.add) {
if (add) {
dataRefs
// Since we're adding early-access to the path, filter for those that do not already include it
.filter(dataRef => !dataRef.includes('data early-access.'))
@ -78,7 +80,7 @@ earlyAccessContentAndDataFiles
})
}
if (program.remove) {
if (remove) {
dataRefs
// Since we're removing early-access from the path, filter for those that include it
.filter(dataRef => dataRef.includes('{% data early-access.'))
@ -131,7 +133,7 @@ function checkVariable (dataRef) {
if (!fs.existsSync(variablePath)) return false
// If the variable file exists but doesn't have the referenced key, exclude it
const variableFileContent = yaml.safeLoad(fs.readFileSync(variablePath, 'utf8'))
const variableFileContent = yaml.load(fs.readFileSync(variablePath, 'utf8'))
return variableFileContent[variableKey]
}

Просмотреть файл

@ -30,8 +30,8 @@ program
.option('-d, --dry-run', 'only scrape the first 10 pages for testing purposes')
.parse(process.argv)
const pathToArchivalRepo = program.pathToArchivalRepo
const dryRun = program.dryRun
const pathToArchivalRepo = program.opts().pathToArchivalRepo
const dryRun = program.opts().dryRun
main()

Просмотреть файл

@ -26,8 +26,10 @@ program
.option('-r, --release <NUMBER>', 'Enterprise Server release number. Example: 2.19')
.parse(process.argv)
const release = program.opts().release
// verify CLI options
if (!program.release) {
if (!release) {
console.log(program.description() + '\n')
program.options.forEach(opt => {
console.log(opt.flags)
@ -36,13 +38,13 @@ if (!program.release) {
process.exit(1)
}
if (!enterpriseServerReleases.all.includes(program.release)) {
console.log(`You specified ${program.release}! Please specify a supported or deprecated release number from lib/enterprise-server-releases.js`)
if (!enterpriseServerReleases.all.includes(release)) {
console.log(`You specified ${release}! Please specify a supported or deprecated release number from lib/enterprise-server-releases.js`)
process.exit(1)
}
const versionToDeprecate = `enterprise-server@${program.release}`
const currentIndex = indexOf(enterpriseServerReleases.all, program.release)
const versionToDeprecate = `enterprise-server@${release}`
const currentIndex = indexOf(enterpriseServerReleases.all, release)
const nextOldestRelease = nth(enterpriseServerReleases.all, currentIndex - 1)
const nextOldestVersion = `enterprise-server@${nextOldestRelease}`

Просмотреть файл

@ -20,8 +20,8 @@ program
.option('-o, --oldVersion <version>', 'The version to copy the files from. Must be in <plan@release> format.')
.parse(process.argv)
const newVersion = program.newVersion
const oldVersion = program.oldVersion
const newVersion = program.opts().newVersion
const oldVersion = program.opts().oldVersion
if (!(newVersion && oldVersion)) {
console.log('Error! You must provide --newVersion and --oldVersion.')

Просмотреть файл

@ -22,8 +22,8 @@ program
.option('-o, --oldVersion <version>', 'The existing version to copy the REST files from. Must be in <plan@release> format.')
.parse(process.argv)
const newVersion = program.newVersion
const oldVersion = program.oldVersion
const newVersion = program.opts().newVersion
const oldVersion = program.opts().oldVersion
if (!(newVersion && oldVersion)) {
console.log('Error! You must provide --newVersion and --oldVersion.')

Просмотреть файл

@ -19,8 +19,8 @@ program
.option('-o, --oldVersion <version>', 'The version to copy the payloads from. Must be in <plan@release> format.')
.parse(process.argv)
const newVersion = program.newVersion
const oldVersion = program.oldVersion
const newVersion = program.opts().newVersion
const oldVersion = program.opts().oldVersion
if (!(newVersion && oldVersion)) {
console.log('Error! You must provide --newVersion and --oldVersion.')

Просмотреть файл

@ -27,20 +27,22 @@ program
.option('-t, --translations', 'Run the script on content and data in translations too.')
.parse(process.argv)
if (!program.ghesRelease) {
const { ghesRelease, products, translations } = program.opts()
if (!ghesRelease) {
console.error('Must provide an Enterprise Server release number!')
process.exit(1)
}
console.log(`✅ Adding AE versioning based on GHES ${program.ghesRelease} versioning`)
console.log(`✅ Adding AE versioning based on GHES ${ghesRelease} versioning`)
if (program.products) {
console.log(`✅ Running on the following products: ${program.products}`)
if (products) {
console.log(`✅ Running on the following products: ${products}`)
} else {
console.log('✅ Running on all products')
}
if (program.translations) {
if (translations) {
console.log('✅ Running on both English and translated content and data\n')
} else {
console.log('✅ Running on English content and data\n')
@ -59,8 +61,8 @@ const englishContentFiles = walkContent(contentPath)
const englishDataFiles = walkData(dataPath)
function walkContent (dirPath) {
const products = program.products || ['']
return products.map(product => {
const productArray = products || ['']
return productArray.map(product => {
dirPath = path.join(contentPath, product)
return walk(dirPath, { includeBasePath: true, directories: false })
.filter(file => file.includes('/content/'))
@ -76,7 +78,7 @@ function walkData (dirPath) {
}
let allContentFiles, allDataFiles
if (program.translations) {
if (translations) {
const translatedContentFiles = walkContent(translationsPath)
const translatedDataFiles = walkData(translationsPath)
allContentFiles = englishContentFiles.concat(translatedContentFiles)
@ -113,7 +115,7 @@ allContentFiles
const { data, content } = frontmatter(fs.readFileSync(file, 'utf8'))
// Return early if the current page frontmatter does not apply to either GHAE or the given GHES release
if (!(data.versions['github-ae'] || versionSatisfiesRange(program.ghesRelease, data.versions['enterprise-server']))) return
if (!(data.versions['github-ae'] || versionSatisfiesRange(ghesRelease, data.versions['enterprise-server']))) return
const conditionalsToUpdate = getConditionalsToUpdate(content)
if (!conditionalsToUpdate.length) return
@ -181,5 +183,5 @@ function doesReleaseSatisfyConditional (enterpriseServerMatch) {
// Example range: >2.21
const range = `${semverOperator}${number}`
return versionSatisfiesRange(program.ghesRelease, range)
return versionSatisfiesRange(ghesRelease, range)
}

Просмотреть файл

@ -38,7 +38,7 @@ if (!(Object.keys(allVersions).includes(options.version))) {
}
// Load the release candidate variable
const releaseCandidateData = yaml.safeLoad(fs.readFileSync(releaseCandidateYaml, 'utf8'))
const releaseCandidateData = yaml.load(fs.readFileSync(releaseCandidateYaml, 'utf8'))
// Create or remove the variable
if (options.action === 'create') {

Просмотреть файл

@ -40,7 +40,7 @@ async function main () {
if (path.endsWith('yml')) {
let data; let errors = []
try {
data = yaml.safeLoad(fileContents)
data = yaml.load(fileContents)
} catch {}
if (data && schema) {
({ errors } = revalidator.validate(data, schema))

Просмотреть файл

@ -65,13 +65,13 @@ async function main () {
// 1. UPDATE PREVIEWS
const previewsPath = getDataFilepath('previews', graphqlVersion)
const safeForPublicPreviews = yaml.safeLoad(await getRemoteRawContent(previewsPath, graphqlVersion))
const safeForPublicPreviews = yaml.load(await getRemoteRawContent(previewsPath, graphqlVersion))
updateFile(previewsPath, yaml.safeDump(safeForPublicPreviews))
previewsJson[graphqlVersion] = processPreviews(safeForPublicPreviews)
// 2. UPDATE UPCOMING CHANGES
const upcomingChangesPath = getDataFilepath('upcomingChanges', graphqlVersion)
const previousUpcomingChanges = yaml.safeLoad(fs.readFileSync(upcomingChangesPath, 'utf8'))
const previousUpcomingChanges = yaml.load(fs.readFileSync(upcomingChangesPath, 'utf8'))
const safeForPublicChanges = await getRemoteRawContent(upcomingChangesPath, graphqlVersion)
updateFile(upcomingChangesPath, safeForPublicChanges)
upcomingChangesJson[graphqlVersion] = await processUpcomingChanges(safeForPublicChanges)
@ -106,7 +106,7 @@ async function main () {
safeForPublicSchema,
safeForPublicPreviews,
previousUpcomingChanges.upcoming_changes,
yaml.safeLoad(safeForPublicChanges).upcoming_changes
yaml.load(safeForPublicChanges).upcoming_changes
)
if (changelogEntry) {
prependDatedEntry(changelogEntry, path.join(process.cwd(), 'lib/graphql/static/changelog.json'))

Просмотреть файл

@ -3,7 +3,7 @@ const { groupBy } = require('lodash')
const renderContent = require('../../../lib/render-content')
module.exports = async function processUpcomingChanges (upcomingChangesYml) {
const upcomingChanges = yaml.safeLoad(upcomingChangesYml).upcoming_changes
const upcomingChanges = yaml.load(upcomingChangesYml).upcoming_changes
for (const change of upcomingChanges) {
change.date = change.date.slice(0, 10)

Просмотреть файл

@ -26,7 +26,7 @@ function move (dir) {
.forEach(file => {
const fullPath = path.join(file.basePath, file.relativePath)
const fileContent = fs.readFileSync(fullPath, 'utf8')
const data = flat(yaml.safeLoad(fileContent))
const data = flat(yaml.load(fileContent))
Object.keys(data).forEach(key => {
const value = get(data, key)

Просмотреть файл

@ -25,9 +25,9 @@ program
.option('-d, --dry-run', 'print URLs to be purged without actually purging')
.parse(process.argv)
const singleUrl = program.single
const batchFile = program.batch
const dryRun = program.dryRun
const singleUrl = program.opts().single
const batchFile = program.opts().batch
const dryRun = program.opts().dryRun
// verify CLI options
if (!singleUrl && !batchFile) {

Просмотреть файл

@ -51,7 +51,7 @@ const relativePath = fs.existsSync(pathArg)
? path.relative(process.cwd(), pathArg)
: pathArg
if (program.preferMain) {
if (program.opts().preferMain) {
try {
execSync(`git checkout main -- ${relativePath}`, { stdio: 'pipe' })
console.log('-> reverted to file from main branch: %s', relativePath)

Просмотреть файл

@ -15,7 +15,7 @@ program
.requiredOption('-f, --files [files...]', 'A list of OpenAPI description files to check. Can parse literal glob patterns.')
.parse(process.argv)
const filenames = program.files
const filenames = program.opts().files
const filesToCheck = filenames.flatMap(filename => glob.sync(filename))

Просмотреть файл

@ -23,7 +23,7 @@ program
.option('--decorate-only', '⚠️ Only used by a 🤖 to generate decorated schema files from existing dereferenced schema files.')
.parse(process.argv)
const decorateOnly = program.decorateOnly
const decorateOnly = program.opts().decorateOnly
main()

Просмотреть файл

@ -76,7 +76,7 @@ describe('Liquid references', () => {
'in "%s"',
async (yamlRelPath, yamlAbsPath) => {
const fileContents = await readFileAsync(yamlAbsPath, 'utf8')
const dictionary = yaml.safeLoad(fileContents, { filename: yamlRelPath })
const dictionary = yaml.load(fileContents, { filename: yamlRelPath })
const matches = []

10
tests/fixtures/changelog-entry.json поставляемый
Просмотреть файл

@ -2,8 +2,8 @@
"previewChanges": [
{
"changes": [
"Field `Query.previewField` changed type from `PreviewType` to `PreviewType!`",
"Type for argument `changeTypeArgument` on field 'PreviewType.field1` changed from `Int` to `Float'"
"Type for argument `changeTypeArgument` on field 'PreviewType.field1` changed from `Int` to `Float'",
"Field `Query.previewField` changed type from `PreviewType` to `PreviewType!`"
],
"title": "The [Test preview](/graphql/overview/schema-previews#test-preview) includes these changes:"
}
@ -12,10 +12,10 @@
{
"changes": [
"Field `removedField` was removed from object type `Query`",
"Type for argument `argumentMadeRequired` on field `Query.argumentsField` changed from `Int` to `Int!`",
"Type for argument `argumentMadeOptional` on field `Query.argumentsField` changed from `Int!` to `Int`",
"Argument `removedRequiredArgument: Int!` was removed from field `Query.argumentsField`",
"Argument `removedOptionalArgument: Int!` was removed from field `Query.argumentsField`"
"Argument `removedOptionalArgument: Int!` was removed from field `Query.argumentsField`",
"Type for argument `argumentMadeRequired` on field `Query.argumentsField` changed from `Int` to `Int!`",
"Type for argument `argumentMadeOptional` on field `Query.argumentsField` changed from `Int!` to `Int`"
],
"title": "The GraphQL schema includes these changes:"
}

Просмотреть файл

@ -45,7 +45,7 @@ describe('creating a changelog from old schema and new schema', () => {
}
`
const previews = yaml.safeLoad(`
const previews = yaml.load(`
- title: Test preview
description: This preview is just for test
toggled_by: ':test_preview'
@ -58,14 +58,14 @@ describe('creating a changelog from old schema and new schema', () => {
- '@github/engineering'
`)
const oldUpcomingChanges = yaml.safeLoad(`
const oldUpcomingChanges = yaml.load(`
upcoming_changes:
- location: EnterprisePendingCollaboratorEdge.isUnlicensed
description: '\`isUnlicensed\` will be removed.'
date: '2021-01-01T00:00:00+00:00'
`).upcoming_changes
const newUpcomingChanges = yaml.safeLoad(`
const newUpcomingChanges = yaml.load(`
upcoming_changes:
- location: Query.stableField
description: '\`stableField\` will be removed.'

Просмотреть файл

@ -292,7 +292,7 @@ describe('lint markdown content', () => {
yamlScheduledWorkflows = (await Promise.all(yamlScheduledWorkflows.map(async (snippet) => {
// If we don't parse the Liquid first, yaml loading chokes on {% raw %} tags
const rendered = await renderContent.liquid.parseAndRender(snippet)
const parsed = yaml.safeLoad(rendered)
const parsed = yaml.load(rendered)
return parsed.on.schedule
})))
.flat()
@ -479,7 +479,7 @@ describe('lint yaml content', () => {
beforeAll(async () => {
const fileContents = await readFileAsync(yamlAbsPath, 'utf8')
dictionary = yaml.safeLoad(fileContents, { filename: yamlRelPath })
dictionary = yaml.load(fileContents, { filename: yamlRelPath })
isEarlyAccess = yamlRelPath.split('/').includes('early-access')
})
@ -670,7 +670,7 @@ describe('lint release notes', () => {
beforeAll(async () => {
const fileContents = await readFileAsync(yamlAbsPath, 'utf8')
dictionary = yaml.safeLoad(fileContents, { filename: yamlRelPath })
dictionary = yaml.load(fileContents, { filename: yamlRelPath })
})
it('matches the schema', () => {
@ -716,7 +716,7 @@ describe('lint learning tracks', () => {
beforeAll(async () => {
const fileContents = await readFileAsync(yamlAbsPath, 'utf8')
dictionary = yaml.safeLoad(fileContents, { filename: yamlRelPath })
dictionary = yaml.load(fileContents, { filename: yamlRelPath })
})
it('matches the schema', () => {

Просмотреть файл

@ -42,8 +42,6 @@ describe('server', () => {
test('sets Content Security Policy (CSP) headers', async () => {
const res = await get('/en')
expect('content-security-policy' in res.headers).toBe(true)
expect('x-content-security-policy' in res.headers).toBe(true)
expect('x-webkit-csp' in res.headers).toBe(true)
const csp = new (require('csp-parse'))(res.headers['content-security-policy'])
expect(csp.get('default-src')).toBe("'none'")