@@ -2,7 +2,7 @@ require('dotenv').config()
22
33import { readJsonSync } from 'fs-extra'
44import { difference } from 'lodash-es'
5- import { compare as compareSemVers } from 'semver'
5+ import { gt , compare as compareSemVers } from 'semver'
66import downloadApiDocs from './api-docs-sync'
77import algoliaDriver from './drivers/algolia'
88import jsonDriver from './drivers/json'
@@ -42,9 +42,11 @@ async function processDocs(driver, project) {
4242 }
4343
4444 try {
45- console . log ( `Processing ${ project } for versions: ${ versionsToProcess } ` )
46-
47- await versionsToProcess
45+ // iterate versions and drop latest minor of each major in buckets
46+ // make an array of the latest minors you get
47+ let latestPatches = Object . values ( versionsToProcess . reduce ( addIfLatestPatch , { } ) ) ;
48+ console . log ( `Processing ${ project } for versions: ${ latestPatches } ` )
49+ await latestPatches
4850 . filter ( version => filterMissingRevs ( version , project ) )
4951 . map ( version => readIndexFileForVersion ( version , project ) )
5052 // Fetch all public modules and public classes
@@ -54,7 +56,6 @@ async function processDocs(driver, project) {
5456 // Run the schema against all data stored
5557 . map ( mapDataForVersion )
5658 . map ( content => writeToDriver ( driver , content ) )
57-
5859 let versions = [ ...prevIndexedVersions , ...versionsToProcess ] . sort (
5960 compareSemVers
6061 )
@@ -69,6 +70,19 @@ async function processDocs(driver, project) {
6970 }
7071}
7172
73+ function addIfLatestPatch ( latestPatches , version ) {
74+ let semvers = version . split ( '.' )
75+ let major = semvers [ 0 ] ;
76+ let minor = semvers [ 1 ] ;
77+ let minorVersion = `${ major } .${ minor } ` ;
78+ if ( minorVersion in latestPatches && gt ( version , latestPatches [ minorVersion ] ) ) {
79+ latestPatches [ minorVersion ] = version ;
80+ } else if ( ! ( minorVersion in latestPatches ) ) {
81+ latestPatches [ minorVersion ] = version ;
82+ }
83+ return latestPatches ;
84+ }
85+
7286function filterMissingRevs ( version , libName ) {
7387 const emberVersionJSONPath = `./tmp/rev-index/${ libName } -${ version } .json`
7488 let isIncluded = true
0 commit comments