33const cvs = { }
44const origins = { }
55
6- module . exports . register = function ( ) {
7- // '8.0@docs-server' -> Set of '8.0@docs-devex'
8- this . once ( 'contentClassified' , ( { contentCatalog } ) => {
9- this . updateVariables ( { contentCatalog : trackingContentCatalog ( contentCatalog , record ) } )
6+ module . exports . register = async function ( { playbook} ) {
7+
8+ if ( 'quick-build' in playbook . asciidoc . attributes ) {
9+ await setup_quick_build ( this , playbook )
10+ }
11+ else {
12+ setup ( this )
13+ }
14+ }
15+
16+ async function setup_quick_build ( antora , playbook ) {
17+
18+ const full = await fetch ( `${ playbook . site . url } /site-dependencies.json` )
19+ const fullJson = await full . json ( )
20+
21+ antora . once ( 'contentAggregated' , ( { contentAggregate } ) => {
22+
23+ const collatedOrigins = new Set ( [ 'https://github.com/couchbase/docs-site@master:home' ] )
24+
25+ for ( const cv of contentAggregate ) {
26+ const cvKey = `${ cv . name } @${ cv . version } `
27+ for ( const o of cv . origins ) {
28+ const sha = o . refhash || null
29+ const oKey = repoKey ( o )
30+ const oV = fullJson . origins [ oKey ]
31+ if ( oV ) {
32+ const { cv, refhash} = oV
33+ if ( sha !== refhash ) {
34+ collatedOrigins . add ( oKey )
35+ const cvFull = fullJson . cvs [ cv ]
36+ if ( cvFull ) {
37+ console . log ( cvFull )
38+ for ( const addO of [ ...cvFull . origins , ...cvFull . dependencies ] ) {
39+ collatedOrigins . add ( addO )
40+ }
41+ }
42+ }
43+ }
44+ }
45+ }
46+ console . log ( collatedOrigins )
47+ const newContentAggregate = [ ]
48+ for ( const cv of contentAggregate ) {
49+ cv . origins = cv . origins . filter ( o => {
50+ const oKey = repoKey ( o )
51+ console . log ( "GOTS?" , oKey )
52+ console . log ( "GOTS?" , oKey )
53+ return collatedOrigins . has ( oKey )
54+ } )
55+
56+ if ( cv . origins . length ) {
57+ newContentAggregate . push ( cv )
58+ }
59+ }
60+ console . log ( { contentAggregate, newContentAggregate} )
61+ antora . updateVariables ( { contentAggregate : newContentAggregate } )
62+ } )
63+ }
64+
65+ function setup ( antora ) {
66+ // we are doing a full build, so need to attach all the handlers
67+ // to *generate* the dependencies file
68+ antora . once ( 'contentClassified' , ( { contentCatalog } ) => {
69+ antora . updateVariables ( { contentCatalog : trackingContentCatalog ( contentCatalog , record ) } )
1070 } )
1171
12- this . once ( 'beforePublish' , ( { siteCatalog } ) => {
72+ antora . once ( 'beforePublish' , ( { siteCatalog } ) => {
1373 const depsFile = createDependenciesFile ( { cvs, origins } )
1474 siteCatalog . addFile ( depsFile )
1575 } )
1676
17- this . once ( 'contentAggregated' , ( { contentAggregate } ) => {
77+ antora . once ( 'contentAggregated' , ( { contentAggregate } ) => {
1878
1979 for ( const cv of contentAggregate ) {
2080 const cvKey = `${ cv . name } @${ cv . version } `
@@ -39,7 +99,7 @@ module.exports.register = function () {
3999}
40100
41101function repoKey ( { url, refname, startPath } ) {
42- return `${ url } @${ refname } ${ startPath ? ':' + startPath : '' } `
102+ return `${ url } @${ refname } ${ startPath ? ':' + startPath : '' } ` . replace ( '.git' , '' )
43103}
44104
45105function record ( from , to ) {
0 commit comments