зеркало из https://github.com/github/docs.git
adding mostly readfilesync of path updates to require
This commit is contained in:
Родитель
0762734b43
Коммит
8154d3b701
|
@ -6,7 +6,7 @@ const operations = {}
|
|||
fs.readdirSync(schemasPath)
|
||||
.forEach(filename => {
|
||||
const key = filename.replace('.json', '')
|
||||
const value = require(path.join(schemasPath, filename))
|
||||
const value = JSON.parse(fs.readFileSync(path.join(schemasPath, filename)))
|
||||
operations[key] = value
|
||||
})
|
||||
const allVersions = require('../all-versions')
|
||||
|
|
|
@ -19,7 +19,7 @@ versions.forEach(version => {
|
|||
// payload file: /path/to/check_run.completed.payload.json
|
||||
// payload path: check_run.completed
|
||||
const payloadPath = path.basename(payloadFile).replace('.payload.json', '')
|
||||
set(payloadsPerVersion, payloadPath, formatAsJsonCodeBlock(require(payloadFile)))
|
||||
set(payloadsPerVersion, payloadPath, formatAsJsonCodeBlock(JSON.parse(fs.readFileSync(payloadFile))))
|
||||
})
|
||||
|
||||
payloads[version] = payloadsPerVersion
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const previews = require('../../lib/graphql/static/previews')
|
||||
const upcomingChanges = require('../../lib/graphql/static/upcoming-changes')
|
||||
const changelog = require('../../lib/graphql/static/changelog')
|
||||
|
@ -23,7 +25,7 @@ module.exports = function graphqlContext (req, res, next) {
|
|||
const graphqlVersion = currentVersionObj.miscVersionName
|
||||
|
||||
req.context.graphql = {
|
||||
schemaForCurrentVersion: require(`../../lib/graphql/static/schema-${graphqlVersion}`),
|
||||
schemaForCurrentVersion: JSON.parse(fs.readFileSync(path.join(process.cwd(), '/lib/graphql/static/schema-' + graphqlVersion + '.json'))),
|
||||
previewsForCurrentVersion: previews[graphqlVersion],
|
||||
upcomingChangesForCurrentVersion: upcomingChanges[graphqlVersion],
|
||||
prerenderedObjectsForCurrentVersion: prerenderedObjects[graphqlVersion],
|
||||
|
|
|
@ -63,7 +63,7 @@ async function main () {
|
|||
fs.writeFileSync(newDereferencedFile, newDereferenceContent)
|
||||
console.log(`Created ${newDereferencedFile}.`)
|
||||
|
||||
const dereferencedSchema = require(path.join(process.cwd(), newDereferencedFile))
|
||||
const dereferencedSchema = JSON.parse(fs.readFileSync(path.join(process.cwd(), newDereferencedFile)))
|
||||
|
||||
// Store all operations in an array of operation objects
|
||||
const operations = await getOperations(dereferencedSchema)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const glob = require('glob')
|
||||
const program = require('commander')
|
||||
const getOperations = require('./utils/get-operations')
|
||||
|
@ -28,8 +29,8 @@ if (filesToCheck.length) {
|
|||
|
||||
async function check (files) {
|
||||
console.log('Verifying OpenAPI files are valid with decorator')
|
||||
|
||||
const documents = files.map(filename => [filename, require(filename)])
|
||||
// Check this one to make sure it's reading the right files
|
||||
const documents = files.map(filename => [filename, JSON.parse(fs.readFileSync(path.join(process.cwd(), filename)))])
|
||||
|
||||
for (const [filename, schema] of documents) {
|
||||
try {
|
||||
|
|
|
@ -75,7 +75,7 @@ async function getDereferencedFiles () {
|
|||
// name of the `github/github` checkout. A CI test
|
||||
// checks the version and fails if it's not a semantic version.
|
||||
schemas.forEach(filename => {
|
||||
const schema = require(path.join(dereferencedPath, filename))
|
||||
const schema = JSON.parse(fs.readFileSync(path.join(dereferencedPath, filename)))
|
||||
schema.info.version = `${githubBranch} !!DEVELOPMENT MODE - DO NOT MERGE!!`
|
||||
fs.writeFileSync(path.join(dereferencedPath, filename), JSON.stringify(schema, null, 2))
|
||||
})
|
||||
|
@ -85,7 +85,7 @@ async function decorate () {
|
|||
console.log('\n🎄 Decorating the OpenAPI schema files in lib/rest/static/dereferenced.\n')
|
||||
|
||||
const dereferencedSchemas = schemas.reduce((acc, filename) => {
|
||||
const schema = require(path.join(dereferencedPath, filename))
|
||||
const schema = JSON.parse(fs.readFileSync(path.join(dereferencedPath, filename)))
|
||||
const key = filename.replace('.deref.json', '')
|
||||
return { ...acc, [key]: schema }
|
||||
}, {})
|
||||
|
|
|
@ -6,6 +6,7 @@ const httpStatusCodes = require('http-status-code')
|
|||
const renderContent = require('../../../lib/render-content')
|
||||
const createCodeSamples = require('./create-code-samples')
|
||||
const Ajv = require('ajv')
|
||||
const operationSchema = require('./operation-schema')
|
||||
|
||||
// titles that can't be derived by sentence-casing the ID
|
||||
const categoryTitles = { scim: 'SCIM' }
|
||||
|
@ -40,7 +41,7 @@ module.exports = class Operation {
|
|||
}
|
||||
|
||||
get schema () {
|
||||
return require('./operation-schema')
|
||||
return operationSchema
|
||||
}
|
||||
|
||||
async process () {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const previewsJson = require('../../lib/graphql/static/previews')
|
||||
const upcomingChangesJson = require('../../lib/graphql/static/upcoming-changes')
|
||||
const prerenderedObjectsJson = require('../../lib/graphql/static/prerendered-objects')
|
||||
|
@ -20,7 +22,7 @@ describe('graphql json files', () => {
|
|||
|
||||
test('schemas object validation', () => {
|
||||
graphqlVersions.forEach(version => {
|
||||
const schemaJsonPerVersion = require(`../../lib/graphql/static/schema-${version}`)
|
||||
const schemaJsonPerVersion = JSON.parse(fs.readFileSync(path.join(process.cwd(), '/lib/graphql/static/schema-' + version + '.json')))
|
||||
// all graphql types are arrays except for queries
|
||||
graphqlTypes
|
||||
.filter(type => type !== 'queries')
|
||||
|
|
Загрузка…
Ссылка в новой задаче