mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Enable saving endpoint data individually
This commit is contained in:
parent
2280100856
commit
c427ac91ee
2 changed files with 54 additions and 2 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { dirname } from 'path'
|
||||||
|
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import dotenv from 'dotenv'
|
import dotenv from 'dotenv'
|
||||||
|
|
||||||
|
|
@ -22,6 +24,9 @@ import { makeSearchableList } from './helpers/searchable-list.js'
|
||||||
// Setup dotenv
|
// Setup dotenv
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
|
const commandArguments = process.argv
|
||||||
|
const withApi = commandArguments.includes('--with-api')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BuildLists {
|
class BuildLists {
|
||||||
|
|
@ -185,6 +190,41 @@ class BuildLists {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveApiEndpoints = async function ( listOptions ) {
|
||||||
|
// Save each enpoint's data
|
||||||
|
for ( const listEntry of this.lists[listOptions.name] ) {
|
||||||
|
|
||||||
|
// console.log('listEntry', listEntry)
|
||||||
|
|
||||||
|
const {
|
||||||
|
// name,
|
||||||
|
// aliases,
|
||||||
|
// status,
|
||||||
|
// bundleIds,
|
||||||
|
endpoint,
|
||||||
|
|
||||||
|
} = listEntry
|
||||||
|
|
||||||
|
const endpointPath = `./static/api${endpoint}.json`
|
||||||
|
const endpointDirectory = dirname(endpointPath)
|
||||||
|
|
||||||
|
// Stop if the endpoint is already exists
|
||||||
|
if (fs.existsSync(endpointPath)) {
|
||||||
|
console.log(`Path "${endpointPath}" already exists`)
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log(`Saving endpoint "${endpoint}" to "${endpointPath}"`)
|
||||||
|
|
||||||
|
// Ensure the directory exists
|
||||||
|
await fs.ensureDir( endpointDirectory )
|
||||||
|
|
||||||
|
// Write the endpoint to JSON
|
||||||
|
await this.saveToJson( listEntry, endpointPath )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Save app lists to JSON
|
// Save app lists to JSON
|
||||||
saveAppLists = async function () {
|
saveAppLists = async function () {
|
||||||
|
|
||||||
|
|
@ -208,8 +248,18 @@ class BuildLists {
|
||||||
// Save a searchable list
|
// Save a searchable list
|
||||||
await this.saveToJson( Array.from(searchableList), `./static/${listOptions.name}-list-searchable.json` )
|
await this.saveToJson( Array.from(searchableList), `./static/${listOptions.name}-list-searchable.json` )
|
||||||
|
|
||||||
|
|
||||||
console.timeEnd(methodName)
|
console.timeEnd(methodName)
|
||||||
|
|
||||||
|
if ( withApi ) {
|
||||||
|
console.log('Saving individual endpoints...')
|
||||||
|
|
||||||
|
const endpointMethodName = `Saved /${ listOptions.name } endpoints`
|
||||||
|
console.time(endpointMethodName)
|
||||||
|
|
||||||
|
await this.saveApiEndpoints( listOptions )
|
||||||
|
|
||||||
|
console.timeEnd(endpointMethodName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Save lists finished')
|
console.log('Save lists finished')
|
||||||
|
|
@ -223,6 +273,8 @@ class BuildLists {
|
||||||
|
|
||||||
await this.saveAppLists()
|
await this.saveAppLists()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// console.log('appList', appList)
|
// console.log('appList', appList)
|
||||||
|
|
||||||
// console.log('this.allVideoAppsList', this.allVideoAppsList.length, this.allVideoAppsList[0])
|
// console.log('this.allVideoAppsList', this.allVideoAppsList.length, this.allVideoAppsList[0])
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
"test": "ava --timeout=1m --verbose",
|
"test": "ava --timeout=1m --verbose",
|
||||||
"dev": "nuxt",
|
"dev": "nuxt",
|
||||||
"build": "nuxt build",
|
"build": "nuxt build",
|
||||||
"build-api": "npm run clone-readme && npm run build-lists",
|
"build-api": "npm run clone-readme && npm run build-lists -- --with-api",
|
||||||
"start": "nuxt start",
|
"start": "nuxt start",
|
||||||
"generate-dev": "npm run generate && npm test",
|
"generate-dev": "npm run generate && npm test",
|
||||||
"generate": "npm run clone-readme && npm run build-lists && npm run generate-nuxt && npm run generate-eleventy",
|
"generate": "npm run clone-readme && npm run build-lists && npm run generate-nuxt && npm run generate-eleventy",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue