mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Merge branch 'feat/single-app-json'
This commit is contained in:
commit
f133724af0
4 changed files with 66 additions and 3 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
import { promises as fs } from 'fs'
|
import { dirname } from 'path'
|
||||||
|
|
||||||
|
import fs from 'fs-extra'
|
||||||
import dotenv from 'dotenv'
|
import dotenv from 'dotenv'
|
||||||
|
|
||||||
import buildAppList from './helpers/build-app-list.js'
|
import buildAppList from './helpers/build-app-list.js'
|
||||||
|
|
@ -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,6 +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 -- --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",
|
||||||
|
|
@ -29,7 +30,8 @@
|
||||||
"lint:fix": "eslint --fix --ext .js,.vue --ignore-path .gitignore .",
|
"lint:fix": "eslint --fix --ext .js,.vue --ignore-path .gitignore .",
|
||||||
"precommit": "npm run lint",
|
"precommit": "npm run lint",
|
||||||
"clone-readme": "cp ./README.md README-temp.md",
|
"clone-readme": "cp ./README.md README-temp.md",
|
||||||
"cloudflare-deploy": "npm run generate"
|
"cloudflare-deploy": "npm run generate",
|
||||||
|
"vercel-build": "npm run build-api"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@11ty/eleventy-assets": "^1.0.5",
|
"@11ty/eleventy-assets": "^1.0.5",
|
||||||
|
|
|
||||||
2
static/api/.gitignore
vendored
Normal file
2
static/api/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
||||||
|
|
@ -1,4 +1,11 @@
|
||||||
{
|
{
|
||||||
|
"builds": [
|
||||||
|
{
|
||||||
|
"src": "package.json",
|
||||||
|
"use": "@vercel/static-build",
|
||||||
|
"config": { "distDir": "static" }
|
||||||
|
}
|
||||||
|
],
|
||||||
"github": {
|
"github": {
|
||||||
"silent": true
|
"silent": true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue