1
- require ( 'dotenv' ) . config ( )
1
+ import 'dotenv/ config'
2
2
3
- import { readJsonSync } from 'fs-extra'
3
+ import fsExtra from 'fs-extra'
4
4
import { difference } from 'lodash-es'
5
5
import { gt , compare as compareSemVers } from 'semver'
6
- import downloadApiDocs from './api-docs-sync'
7
- import algoliaDriver from './drivers/algolia'
8
- import jsonDriver from './drivers/json'
9
- import schemas from './schemas'
6
+
7
+ import algoliaDriver from './drivers/algolia.js'
8
+ import jsonDriver from './drivers/json.js'
9
+ import schemas from './schemas/index.js'
10
+
11
+ const { readJsonSync } = fsExtra ;
10
12
11
13
const apiIndexes = [ 'modules' , 'classes' , 'methods' , 'versions' ]
12
14
13
15
export async function runApi ( clearIndex = false , useJsonDriver = false ) {
14
16
let driver = useJsonDriver ? jsonDriver : algoliaDriver
15
17
16
- await downloadApiDocs ( )
17
-
18
18
apiIndexes . map ( driver . init )
19
19
20
20
if ( clearIndex ) {
@@ -32,7 +32,7 @@ async function processDocs(driver, project) {
32
32
33
33
const {
34
34
meta : { availableVersions } ,
35
- } = readJsonSync ( `./tmp /rev-index/${ project } .json` )
35
+ } = readJsonSync ( `../ember-api-docs-data /rev-index/${ project } .json` )
36
36
37
37
let versionsToProcess = difference ( availableVersions , prevIndexedVersions )
38
38
@@ -89,7 +89,7 @@ function addIfLatestPatch(latestPatches, version) {
89
89
}
90
90
91
91
function filterMissingRevs ( version , libName ) {
92
- const emberVersionJSONPath = `./tmp /rev-index/${ libName } -${ version } .json`
92
+ const emberVersionJSONPath = `../ember-api-docs-data /rev-index/${ libName } -${ version } .json`
93
93
let isIncluded = true
94
94
try {
95
95
readJsonSync ( emberVersionJSONPath )
@@ -100,7 +100,7 @@ function filterMissingRevs(version, libName) {
100
100
}
101
101
102
102
function readIndexFileForVersion ( version , libName ) {
103
- const emberVersionJSONPath = `./tmp /rev-index/${ libName } -${ version } .json`
103
+ const emberVersionJSONPath = `../ember-api-docs-data /rev-index/${ libName } -${ version } .json`
104
104
console . debug ( `OPENING:: ${ emberVersionJSONPath } ` )
105
105
return readJsonSync ( emberVersionJSONPath )
106
106
}
@@ -111,20 +111,24 @@ function fetchPublicModuleClassesForVersion(versionIndexObject, libName) {
111
111
] . data . map ( module => {
112
112
// Module names are uri encoded
113
113
const id = encodeURIComponent ( module . id )
114
- const modulePath = `./tmp/json-docs/${ libName } /${
114
+ if ( ! versionIndexObject . meta . module [ id ] ) {
115
+ console . warn ( `Skipping processing module ${ id } because it's missing a meta entry` ) ;
116
+ return null ;
117
+ }
118
+ const modulePath = `../ember-api-docs-data/json-docs/${ libName } /${
115
119
versionIndexObject . data . attributes . version
116
120
} /modules/${ versionIndexObject . meta . module [ id ] } .json`
117
121
118
122
console . debug ( `OPENING:: ${ modulePath } ` )
119
123
return readJsonSync ( modulePath )
120
- } )
124
+ } ) . filter ( Boolean )
121
125
122
126
const publicClasses = versionIndexObject . data . relationships [
123
127
'public-classes'
124
128
] . data . map ( classObj => {
125
129
// Class names are uri encoded
126
130
const id = encodeURIComponent ( classObj . id )
127
- const classPath = `./tmp /json-docs/${ libName } /${
131
+ const classPath = `../ember-api-docs-data /json-docs/${ libName } /${
128
132
versionIndexObject . data . attributes . version
129
133
} /classes/${ versionIndexObject . meta . class [ id ] } .json`
130
134
0 commit comments