mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-15 06:35:20 -07:00
Save appType as kinds
This commit is contained in:
parent
a23b0c02db
commit
cad326b1b8
1 changed files with 31 additions and 1 deletions
|
|
@ -28,6 +28,9 @@ import { makeSearchableList } from './helpers/searchable-list.js'
|
|||
import {
|
||||
writeStorkToml
|
||||
} from './helpers/stork/toml.js'
|
||||
import {
|
||||
PaginatedList
|
||||
} from '~/helpers/api/pagination.js'
|
||||
|
||||
import {
|
||||
cliOptions
|
||||
|
|
@ -36,6 +39,8 @@ import {
|
|||
// Setup dotenv
|
||||
dotenv.config()
|
||||
|
||||
export const apiDirectory = './static/api'
|
||||
|
||||
|
||||
function normalizeVersion ( rawVersion ) {
|
||||
const containsNumbers = /\d+/.test( rawVersion )
|
||||
|
|
@ -293,9 +298,27 @@ class BuildLists {
|
|||
return
|
||||
}
|
||||
|
||||
saveKind = async function ( list, kindSlug ) {
|
||||
const apiKindListDirectory = `${ apiDirectory }/kind/${ kindSlug }`
|
||||
|
||||
const paginatedList = new PaginatedList({
|
||||
list,
|
||||
})
|
||||
|
||||
// Ensure the directory exists
|
||||
await fs.ensureDir( apiKindListDirectory )
|
||||
|
||||
for ( const kindPage of paginatedList.pages ) {
|
||||
const kindPagePath = `${ apiKindListDirectory }/${ kindPage.number }.json`
|
||||
|
||||
// console.log('kindPage.items', kindPage)
|
||||
|
||||
await this.saveToJson( kindPage.items, kindPagePath )
|
||||
}
|
||||
}
|
||||
|
||||
saveApiEndpoints = async ( listOptions ) => {
|
||||
|
||||
const apiDirectory = './static/api'
|
||||
const apiListDirectory = `${ apiDirectory }/${ listOptions.endpointPrefix }`
|
||||
|
||||
const poolSize = 1000
|
||||
|
|
@ -369,6 +392,10 @@ class BuildLists {
|
|||
throw new Error( errors )
|
||||
}
|
||||
|
||||
await this.saveKind( Array.from( this.lists[listOptions.name] ), listOptions.name )
|
||||
|
||||
// Array.from( this.lists[listOptions.name] )
|
||||
|
||||
// Count saved files
|
||||
const fileCount = fs.readdirSync( apiListDirectory ).length
|
||||
|
||||
|
|
@ -417,9 +444,12 @@ class BuildLists {
|
|||
|
||||
console.timeEnd(endpointMethodName)
|
||||
console.log( '\n\n' )
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
console.log('Save lists finished')
|
||||
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue