()
| 401 | } |
| 402 | |
| 403 | async saveKinds () { |
| 404 | |
| 405 | const kindLists = this.makeKindLists() |
| 406 | |
| 407 | // Save the lists |
| 408 | for ( const kindSlug in kindLists ) { |
| 409 | |
| 410 | console.log('\n', `-- Starting kind lists for ${ kindSlug }`) |
| 411 | |
| 412 | const endpointMethodName = `Finished kind lists for ${ kindSlug }` |
| 413 | console.time(endpointMethodName) |
| 414 | |
| 415 | |
| 416 | const kindList = kindLists[ kindSlug ] |
| 417 | |
| 418 | // Ensure the base directory exists |
| 419 | await fs.ensureDir( kindList.basePath ) |
| 420 | |
| 421 | for ( const file of kindList.apiFiles ) { |
| 422 | // console.log('kindPage.items', kindPage) |
| 423 | |
| 424 | await this.saveToJson( file.content, file.path ) |
| 425 | } |
| 426 | |
| 427 | console.timeEnd(endpointMethodName) |
| 428 | console.log( '\n\n' ) |
| 429 | } |
| 430 | |
| 431 | const kindIndex = categories |
| 432 | |
| 433 | // Delete no-category |
| 434 | delete kindIndex['no-category'] |
| 435 | |
| 436 | // Store sample names into kindIndex as description |
| 437 | for ( const categorySlug in kindIndex ) { |
| 438 | const kindName = getCategoryKindName( categorySlug ) |
| 439 | |
| 440 | // Skip empty categories |
| 441 | if ( kindLists[ kindName ].list.length === 0 ) continue |
| 442 | |
| 443 | kindIndex[ categorySlug ].description = kindLists[ kindName ].summary.sampleNames |
| 444 | // Save kindName |
| 445 | kindIndex[ categorySlug ].kindName = kindName |
| 446 | } |
| 447 | |
| 448 | // Save the index |
| 449 | await this.saveToJson( kindIndex, `${ apiDirectory }/kind/index.json` ) |
| 450 | |
| 451 | } |
| 452 | |
| 453 | saveApiEndpoints = async ( listOptions ) => { |
| 454 |
no test coverage detected