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

update script that creates ghes release stubs for graphql (#31329)

This commit is contained in:
Rachael Sewell
2022-09-30 11:58:57 -07:00
committed by GitHub
parent 4c0489e18e
commit 57d7b216ce

View File

@@ -63,26 +63,12 @@ try {
// the other files are objects with versions as keys, so we need to require them
const previewsFile = path.join(graphqlStaticDir, 'previews.json')
const changesFile = path.join(graphqlStaticDir, 'upcoming-changes.json')
const objectsFile = path.join(graphqlStaticDir, 'prerendered-objects.json')
const inputObjectsFile = path.join(graphqlStaticDir, 'prerendered-input-objects.json')
const previews = JSON.parse(await fs.readFile(previewsFile))
const changes = JSON.parse(await fs.readFile(changesFile))
const objects = JSON.parse(await fs.readFile(objectsFile))
const inputObjects = JSON.parse(await fs.readFile(inputObjectsFile))
// The prerendered objects file for the "old version" contains hardcoded links with the old version number.
// We need to update those links to include the new version to prevent a test from failing.
const regexOldVersion = new RegExp(oldVersion, 'gi')
const stringifiedObject = JSON.stringify(objects[oldVersionId]).replace(regexOldVersion, newVersion)
const stringifiedInputObject = JSON.stringify(inputObjects[oldVersionId]).replace(
regexOldVersion,
newVersion
)
previews[newVersionId] = previews[oldVersionId]
changes[newVersionId] = changes[oldVersionId]
objects[newVersionId] = JSON.parse(stringifiedObject)
inputObjects[newVersionId] = JSON.parse(stringifiedInputObject)
// check that it worked
if (!Object.keys(previews).includes(newVersionId)) {
@@ -95,21 +81,9 @@ if (!Object.keys(changes).includes(newVersionId)) {
process.exit(1)
}
if (!Object.keys(objects).includes(newVersionId)) {
console.log(`Error! Can't find ${newVersionId} in ${objectsFile}.`)
process.exit(1)
}
if (!Object.keys(inputObjects).includes(newVersionId)) {
console.log(`Error! Can't find ${newVersionId} in ${inputObjectsFile}.`)
process.exit(1)
}
// write the new files
await fs.writeFile(previewsFile, JSON.stringify(previews, null, 2))
await fs.writeFile(changesFile, JSON.stringify(changes, null, 2))
await fs.writeFile(objectsFile, JSON.stringify(objects, null, 2))
await fs.writeFile(inputObjectsFile, JSON.stringify(inputObjects, null, 2))
// now create the new version directory in data/graphql
const srcDir = path.join(graphqlDataDir, oldVersionId)