@@ -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'
@@ -42,9 +42,11 @@ async function processDocs(driver, project) {
42
42
}
43
43
44
44
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
48
50
. filter ( version => filterMissingRevs ( version , project ) )
49
51
. map ( version => readIndexFileForVersion ( version , project ) )
50
52
// Fetch all public modules and public classes
@@ -54,7 +56,6 @@ async function processDocs(driver, project) {
54
56
// Run the schema against all data stored
55
57
. map ( mapDataForVersion )
56
58
. map ( content => writeToDriver ( driver , content ) )
57
-
58
59
let versions = [ ...prevIndexedVersions , ...versionsToProcess ] . sort (
59
60
compareSemVers
60
61
)
@@ -69,6 +70,19 @@ async function processDocs(driver, project) {
69
70
}
70
71
}
71
72
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
+
72
86
function filterMissingRevs ( version , libName ) {
73
87
const emberVersionJSONPath = `./tmp/rev-index/${ libName } -${ version } .json`
74
88
let isIncluded = true
0 commit comments