MCPcopy Index your code
hub / github.com/github/docs / main

Function main

src/graphql/scripts/update-files.js:29–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27main()
28
29async function main() {
30 const previewsJson = {}
31 const upcomingChangesJson = {}
32
33 for (const version of versionsToBuild) {
34 // Get the relevant GraphQL name for the current version
35 // For example, free-pro-team@latest corresponds to dotcom,
36 // enterprise-server@2.22 corresponds to ghes-2.22,
37 // and github-ae@latest corresponds to ghae
38 const graphqlVersion = allVersions[version].miscVersionName
39
40 // 1. UPDATE PREVIEWS
41 const previewsPath = getDataFilepath('previews', graphqlVersion)
42 const safeForPublicPreviews = yaml.load(await getRemoteRawContent(previewsPath, graphqlVersion))
43 await updateFile(previewsPath, yaml.dump(safeForPublicPreviews))
44 previewsJson[graphqlVersion] = processPreviews(safeForPublicPreviews)
45
46 // 2. UPDATE UPCOMING CHANGES
47 const upcomingChangesPath = getDataFilepath('upcomingChanges', graphqlVersion)
48 const previousUpcomingChanges = yaml.load(await fs.readFile(upcomingChangesPath, 'utf8'))
49 const safeForPublicChanges = await getRemoteRawContent(upcomingChangesPath, graphqlVersion)
50 await updateFile(upcomingChangesPath, safeForPublicChanges)
51 upcomingChangesJson[graphqlVersion] = await processUpcomingChanges(safeForPublicChanges)
52
53 // 3. UPDATE SCHEMAS
54 // note: schemas live in separate files per version
55 const schemaPath = getDataFilepath('schemas', graphqlVersion)
56 const previousSchemaString = await fs.readFile(schemaPath, 'utf8')
57 const latestSchema = await getRemoteRawContent(schemaPath, graphqlVersion)
58 await updateFile(schemaPath, latestSchema)
59 const schemaJsonPerVersion = await processSchemas(latestSchema, safeForPublicPreviews)
60 await updateStaticFile(
61 schemaJsonPerVersion,
62 path.join(graphqlStaticDir, `schema-${graphqlVersion}.json`)
63 )
64
65 // 4. UPDATE CHANGELOG
66 if (allVersions[version].nonEnterpriseDefault) {
67 // The Changelog is only build for free-pro-team@latest
68 const changelogEntry = await createChangelogEntry(
69 previousSchemaString,
70 latestSchema,
71 safeForPublicPreviews,
72 previousUpcomingChanges.upcoming_changes,
73 yaml.load(safeForPublicChanges).upcoming_changes
74 )
75 if (changelogEntry) {
76 prependDatedEntry(
77 changelogEntry,
78 path.join(process.cwd(), 'src/graphql/data/changelog.json')
79 )
80 }
81 }
82 }
83
84 await updateStaticFile(previewsJson, path.join(graphqlStaticDir, 'previews.json'))
85 await updateStaticFile(upcomingChangesJson, path.join(graphqlStaticDir, 'upcoming-changes.json'))
86

Callers 1

update-files.jsFile · 0.70

Calls 9

createChangelogEntryFunction · 0.90
prependDatedEntryFunction · 0.90
getDataFilepathFunction · 0.85
getRemoteRawContentFunction · 0.85
updateFileFunction · 0.85
processPreviewsFunction · 0.85
processUpcomingChangesFunction · 0.85
processSchemasFunction · 0.85
updateStaticFileFunction · 0.85

Tested by

no test coverage detected