@@ -2,7 +2,7 @@ require('dotenv').config()
2
2
3
3
import { readJsonSync } from 'fs-extra'
4
4
import { difference } from 'lodash-es'
5
- import { compare as compareSemVers } from 'semver'
5
+ import { gt , compare as compareSemVers } from 'semver'
6
6
import downloadApiDocs from './api-docs-sync'
7
7
import algoliaDriver from './drivers/algolia'
8
8
import jsonDriver from './drivers/json'
@@ -43,8 +43,12 @@ async function processDocs(driver, project) {
43
43
44
44
try {
45
45
console . log ( `Processing ${ project } for versions: ${ versionsToProcess } ` )
46
-
47
- await versionsToProcess
46
+ // iterate versions and drop latest minor of each major in buckets
47
+ let latestPatchesObj = versionsToProcess . sort ( compareSemVers ) . reduce ( addIfLatestPatch , { } ) ;
48
+ // make an array of the latest minors you get
49
+ let latestPatches = Object . values ( latestPatchesObj ) ;
50
+ console . log ( 'latest patches' , latestPatches ) ;
51
+ await latestPatches
48
52
. filter ( version => filterMissingRevs ( version , project ) )
49
53
. map ( version => readIndexFileForVersion ( version , project ) )
50
54
// Fetch all public modules and public classes
@@ -54,7 +58,6 @@ async function processDocs(driver, project) {
54
58
// Run the schema against all data stored
55
59
. map ( mapDataForVersion )
56
60
. map ( content => writeToDriver ( driver , content ) )
57
-
58
61
let versions = [ ...prevIndexedVersions , ...versionsToProcess ] . sort (
59
62
compareSemVers
60
63
)
@@ -69,6 +72,19 @@ async function processDocs(driver, project) {
69
72
}
70
73
}
71
74
75
+ function addIfLatestPatch ( latestPatches , version ) {
76
+ let semvers = version . split ( '.' )
77
+ let major = semvers [ 0 ] ;
78
+ let minor = semvers [ 1 ] ;
79
+ let minorVersion = `${ major } .${ minor } ` ;
80
+ if ( minorVersion in latestPatches && gt ( version , latestPatches [ minorVersion ] ) ) {
81
+ latestPatches [ minorVersion ] = version ;
82
+ } else if ( ! ( minorVersion in latestPatches ) ) {
83
+ latestPatches [ minorVersion ] = version ;
84
+ }
85
+ return latestPatches ;
86
+ }
87
+
72
88
function filterMissingRevs ( version , libName ) {
73
89
const emberVersionJSONPath = `./tmp/rev-index/${ libName } -${ version } .json`
74
90
let isIncluded = true
0 commit comments