1
0
mirror of synced 2025-12-19 18:10:59 -05:00

Pipelines webhook data dir (#34775)

This commit is contained in:
Rachael Sewell
2023-02-15 10:43:55 -08:00
committed by GitHub
parent f95d515829
commit 8babc127b2
11 changed files with 9 additions and 11456 deletions

View File

@@ -6,11 +6,10 @@ import { slug } from 'github-slugger'
import { allVersions } from '../../../../lib/all-versions.js' import { allVersions } from '../../../../lib/all-versions.js'
import { categoriesWithoutSubcategories } from '../../lib/index.js' import { categoriesWithoutSubcategories } from '../../lib/index.js'
import getOperations, { getWebhooks } from './get-operations.js' import getOperations, { getWebhooks } from './get-operations.js'
import { WEBHOOK_DATA_DIR, WEBHOOK_SCHEMA_FILENAME } from '../../../webhooks/lib/index.js'
const ENABLED_APPS = 'src/github-apps/data/enabled-for-apps.json' const ENABLED_APPS = 'src/github-apps/data/enabled-for-apps.json'
const STATIC_REDIRECTS = 'lib/redirects/static/client-side-rest-api-redirects.json' const STATIC_REDIRECTS = 'lib/redirects/static/client-side-rest-api-redirects.json'
const REST_DECORATED_DIR = 'src/rest/data' const REST_DECORATED_DIR = 'src/rest/data'
const WEBHOOK_DECORATED_DIR = 'src/webhooks/data'
const REST_DEREFERENCED_DIR = 'src/rest/data/dereferenced' const REST_DEREFERENCED_DIR = 'src/rest/data/dereferenced'
export async function decorate(schemas) { export async function decorate(schemas) {
@@ -216,11 +215,11 @@ async function createStaticWebhookFiles(webhookSchemas) {
} }
}) })
const webhooksFilename = path const webhooksFilename = path
.join(WEBHOOK_DECORATED_DIR, `${schemaName}.json`) .join(WEBHOOK_DATA_DIR, schemaName, WEBHOOK_SCHEMA_FILENAME)
.replace('.deref', '') .replace('.deref', '')
if (Object.keys(categorizedWebhooks).length > 0) { if (Object.keys(categorizedWebhooks).length > 0) {
if (!existsSync(WEBHOOK_DECORATED_DIR)) { if (!existsSync(`${WEBHOOK_DATA_DIR}/${schemaName}`)) {
mkdirSync(WEBHOOK_DECORATED_DIR) mkdirSync(`${WEBHOOK_DATA_DIR}/${schemaName}`)
} }
await writeFile(webhooksFilename, JSON.stringify(categorizedWebhooks, null, 2)) await writeFile(webhooksFilename, JSON.stringify(categorizedWebhooks, null, 2))
console.log('Wrote', path.relative(process.cwd(), webhooksFilename)) console.log('Wrote', path.relative(process.cwd(), webhooksFilename))

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,8 @@ import path from 'path'
import { allVersions } from '../../../lib/all-versions.js' import { allVersions } from '../../../lib/all-versions.js'
import { readCompressedJsonFileFallback } from '../../../lib/read-json-file.js' import { readCompressedJsonFileFallback } from '../../../lib/read-json-file.js'
const schemasPath = 'src/webhooks/data' export const WEBHOOK_DATA_DIR = 'src/webhooks/data'
export const WEBHOOK_SCHEMA_FILENAME = 'schema.json'
// cache for webhook data per version // cache for webhook data per version
const webhooksCache = new Map() const webhooksCache = new Map()
@@ -62,13 +63,13 @@ export async function getWebhook(version, webhookCategory) {
export async function getWebhooks(version) { export async function getWebhooks(version) {
const openApiVersion = getOpenApiVersion(version) const openApiVersion = getOpenApiVersion(version)
if (!webhooksCache.has(openApiVersion)) { if (!webhooksCache.has(openApiVersion)) {
const filename = `${openApiVersion}.json`
// The `readCompressedJsonFileFallback()` function // The `readCompressedJsonFileFallback()` function
// will check for both a .br and .json extension. // will check for both a .br and .json extension.
webhooksCache.set( webhooksCache.set(
openApiVersion, openApiVersion,
readCompressedJsonFileFallback(path.join(schemasPath, filename)) readCompressedJsonFileFallback(
path.join(WEBHOOK_DATA_DIR, openApiVersion, WEBHOOK_SCHEMA_FILENAME)
)
) )
} }