mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-21 06:54:08 -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 {
|
import {
|
||||||
writeStorkToml
|
writeStorkToml
|
||||||
} from './helpers/stork/toml.js'
|
} from './helpers/stork/toml.js'
|
||||||
|
import {
|
||||||
|
PaginatedList
|
||||||
|
} from '~/helpers/api/pagination.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
cliOptions
|
cliOptions
|
||||||
|
|
@ -36,6 +39,8 @@ import {
|
||||||
// Setup dotenv
|
// Setup dotenv
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
|
export const apiDirectory = './static/api'
|
||||||
|
|
||||||
|
|
||||||
function normalizeVersion ( rawVersion ) {
|
function normalizeVersion ( rawVersion ) {
|
||||||
const containsNumbers = /\d+/.test( rawVersion )
|
const containsNumbers = /\d+/.test( rawVersion )
|
||||||
|
|
@ -293,9 +298,27 @@ class BuildLists {
|
||||||
return
|
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 ) => {
|
saveApiEndpoints = async ( listOptions ) => {
|
||||||
|
|
||||||
const apiDirectory = './static/api'
|
|
||||||
const apiListDirectory = `${ apiDirectory }/${ listOptions.endpointPrefix }`
|
const apiListDirectory = `${ apiDirectory }/${ listOptions.endpointPrefix }`
|
||||||
|
|
||||||
const poolSize = 1000
|
const poolSize = 1000
|
||||||
|
|
@ -369,6 +392,10 @@ class BuildLists {
|
||||||
throw new Error( errors )
|
throw new Error( errors )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.saveKind( Array.from( this.lists[listOptions.name] ), listOptions.name )
|
||||||
|
|
||||||
|
// Array.from( this.lists[listOptions.name] )
|
||||||
|
|
||||||
// Count saved files
|
// Count saved files
|
||||||
const fileCount = fs.readdirSync( apiListDirectory ).length
|
const fileCount = fs.readdirSync( apiListDirectory ).length
|
||||||
|
|
||||||
|
|
@ -417,9 +444,12 @@ class BuildLists {
|
||||||
|
|
||||||
console.timeEnd(endpointMethodName)
|
console.timeEnd(endpointMethodName)
|
||||||
console.log( '\n\n' )
|
console.log( '\n\n' )
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
console.log('Save lists finished')
|
console.log('Save lists finished')
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue