@@ -14,6 +14,7 @@ const processPreviews = require('./utils/process-previews')
1414const processUpcomingChanges = require ( './utils/process-upcoming-changes' )
1515const processSchemas = require ( './utils/process-schemas' )
1616const prerenderObjects = require ( './utils/prerender-objects' )
17+ const { prependDatedEntry, createChangelogEntry } = require ( "./build-changelog" )
1718
1819// check for required PAT
1920if ( ! process . env . GITHUB_TOKEN ) {
@@ -57,13 +58,21 @@ async function main () {
5758
5859 // 2. UPDATE UPCOMING CHANGES
5960 const upcomingChangesPath = getDataFilepath ( 'upcomingChanges' , graphqlVersion )
61+ let previousUpcomingChanges = null
62+ if ( fs . existsSync ( upcomingChangesPath ) ) {
63+ previousUpcomingChanges = yaml . safeLoad ( fs . readFileSync ( upcomingChangesPath , "utf8" ) )
64+ }
6065 const safeForPublicChanges = await getRemoteRawContent ( upcomingChangesPath , graphqlVersion )
6166 updateFile ( upcomingChangesPath , safeForPublicChanges )
6267 upcomingChangesJson [ graphqlVersion ] = await processUpcomingChanges ( safeForPublicChanges )
6368
6469 // 3. UPDATE SCHEMAS
6570 // note: schemas live in separate files per version
6671 const schemaPath = getDataFilepath ( 'schemas' , graphqlVersion )
72+ let previousSchemaString = null
73+ if ( fs . existsSync ( upcomingChangesPath ) ) {
74+ previousSchemaString = fs . readFileSync ( schemaPath , "utf8" )
75+ }
6776 const latestSchema = await getRemoteRawContent ( schemaPath , graphqlVersion )
6877 const safeForPublicSchema = removeHiddenMembers ( schemaPath , latestSchema )
6978 updateFile ( schemaPath , safeForPublicSchema )
@@ -73,6 +82,20 @@ async function main () {
7382 // 4. PRERENDER OBJECTS HTML
7483 // because the objects page is too big to render on page load
7584 prerenderedObjects [ graphqlVersion ] = await prerenderObjects ( schemaJsonPerVersion )
85+
86+ if ( allVersions [ version ] . nonEnterpriseDefault ) {
87+ // The Changelog is only build for free-pro-team@latest
88+ const changelogEntry = createChangelogEntry (
89+ previousSchemaString ,
90+ safeForPublicSchema ,
91+ safeForPublicPreviews ,
92+ previousUpcomingChanges . upcoming_changes ,
93+ yaml . safeLoad ( safeForPublicChanges ) . upcoming_changes ,
94+ )
95+ if ( changelogEntry ) {
96+ prependDatedEntry ( changelogEntry , path . join ( process . cwd ( ) , 'lib/graphql/static/changelog.json' ) )
97+ }
98+ }
7699 }
77100
78101 updateStaticFile ( previewsJson , path . join ( graphqlStaticDir , 'previews.json' ) )
0 commit comments