mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Update app name and add video building scripts
This commit is contained in:
parent
fa5bac334a
commit
f02460759f
4 changed files with 193 additions and 32 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -86,5 +86,6 @@ dist
|
|||
/README-temp.md
|
||||
/static/game-list.json
|
||||
/static/homebrew-list.json
|
||||
.DS_Store
|
||||
/static/video-list.json
|
||||
/commits-data.json
|
||||
.DS_Store
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Any comments, suggestions? [Let us know!](https://github.com/ThatGuySam/doesitar
|
|||
* [Fork](https://git-fork.com/) - ✳️ Yes, works via Rosetta 2 - [Release notes](https://git-fork.com/releasenotes)
|
||||
* [Git Version Control](https://git-scm.com/download/mac) - ✅ Yes, Full Native Apple Silicon Support - [Source](https://github.com/ThatGuySam/doesitarm/issues/54#issuecomment-730568063)
|
||||
* [GitHub Desktop](https://desktop.github.com/) - ✳️ Yes, works via Rosetta 2 as of v2.6.0 with native support in development - [GitHub issue](https://github.com/ThatGuySam/doesitarm/issues/293)
|
||||
* [Go](https://golang.org/) - ✳️ Runs via Rosetta with native builds being tested - [Issue](https://github.com/golang/go/issues/38485)
|
||||
* [Golang](https://golang.org/) - ✳️ Runs via Rosetta with native builds being tested - [Issue](https://github.com/golang/go/issues/38485)
|
||||
* [Godot Engine](https://godotengine.org/) - ⏹ No official binaries yet, but can be compiled from source - [Master PR](https://github.com/godotengine/godot/pull/39788), [v3.2 PR](https://github.com/godotengine/godot/pull/39943)
|
||||
* [Haskell](https://www.haskell.org/platform/mac.html) - 🚫 Not yet supported only works on Intel-based Macs - [Gitlab Issue](https://gitlab.haskell.org/ghc/ghc/-/issues/18664)
|
||||
* [Homebrew](https://brew.sh/) - ✳️ Yes, with caveats and some troubleshooting. - [Issue](https://github.com/Homebrew/brew/issues/7857).
|
||||
|
|
|
|||
142
helpers/build-video-list.js
Normal file
142
helpers/build-video-list.js
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
|
||||
import { promises as fs } from 'fs'
|
||||
import MarkdownIt from 'markdown-it'
|
||||
import slugify from 'slugify'
|
||||
import axios from 'axios'
|
||||
|
||||
import statuses from './statuses'
|
||||
import parseGithubDate from './parse-github-date'
|
||||
|
||||
|
||||
const md = new MarkdownIt()
|
||||
|
||||
|
||||
|
||||
const getTokenLinks = function ( childTokens ) {
|
||||
|
||||
const tokenList = []
|
||||
|
||||
let isLink = false
|
||||
|
||||
for (const token of childTokens) {
|
||||
|
||||
// On link_ switch link mode
|
||||
// link_open = true
|
||||
// link_close = false
|
||||
if (token.type.includes('link_')) isLink = !isLink
|
||||
|
||||
// For link_open create a new related link in our list
|
||||
// and store thee attributes into it
|
||||
if ( isLink && token.type === 'link_open' ) {
|
||||
tokenList.push({
|
||||
...Object.fromEntries(token.attrs)
|
||||
})
|
||||
}
|
||||
|
||||
// For the text inside the link
|
||||
// store that text as the label for the link we're inside
|
||||
if ( isLink && token.type === 'text' ) {
|
||||
// Get the last pushed link
|
||||
const currentLink = tokenList[tokenList.length-1]
|
||||
|
||||
// Add our text to it as a label
|
||||
tokenList[tokenList.length-1] = {
|
||||
...currentLink,
|
||||
label: token.content
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return tokenList
|
||||
}
|
||||
|
||||
|
||||
const lookForLastUpdated = function (app, commits) {
|
||||
|
||||
for (const { node: commit } of commits) {
|
||||
|
||||
// console.log('commit', commit)
|
||||
|
||||
// $$ If message body contains endpoint
|
||||
if (commit.messageBody.includes(app.endpoint)) {
|
||||
// console.log('Found', app.name ,commit.committedDate)
|
||||
return commit.committedDate
|
||||
}
|
||||
|
||||
// $$ If message body contains App Name
|
||||
if (commit.messageBody.includes(app.name)) {
|
||||
// console.log('Found', app.name ,commit.committedDate)
|
||||
return commit.committedDate
|
||||
}
|
||||
|
||||
// $$ If message headline contains App Name
|
||||
if (commit.messageHeadline.includes(app.name)) {
|
||||
// console.log('Found', app.name ,commit.committedDate)
|
||||
return commit.committedDate
|
||||
}
|
||||
|
||||
// $$$ If commits comments contains endpoint
|
||||
for (const { node: comment } of commit.comments.edges) {
|
||||
if (comment.body.includes(app.endpoint)) {
|
||||
// console.log('Found', app.name ,commit.committedDate)
|
||||
return commit.committedDate
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
const videoFeaturesApp = function (app, video) {
|
||||
const appFuzzyName = app.name.toLowerCase()
|
||||
if (video.title.toLowerCase().includes(appFuzzyName)) return true
|
||||
|
||||
const appIsInTimestamps = video.timestamps.map( timestamp => timestamp.fullText.toLowerCase()).includes(appFuzzyName)
|
||||
|
||||
if (appIsInTimestamps) return true
|
||||
|
||||
if (video.description.toLowerCase().includes(appFuzzyName)) return true
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
export default async function ( applist ) {
|
||||
|
||||
console.log('applist', applist.length)
|
||||
|
||||
// Fetch Commits
|
||||
const response = await axios.get(process.env.VIDEO_SOURCE)
|
||||
// Extract commit from response data
|
||||
const fetchedVideos = response.data
|
||||
// console.log('commits', commits)
|
||||
|
||||
const videos = []
|
||||
|
||||
for (const videoId in fetchedVideos) {
|
||||
// Build video slug
|
||||
const slug = slugify(`${fetchedVideos[videoId].title}-${videoId}`, {
|
||||
lower: true,
|
||||
strict: true
|
||||
})
|
||||
|
||||
const apps = []
|
||||
|
||||
for ( const app of applist ) {
|
||||
if (videoFeaturesApp(app, fetchedVideos[videoId])) {
|
||||
apps.push(app.slug)
|
||||
}
|
||||
}
|
||||
|
||||
videos.push({
|
||||
apps,
|
||||
slug,
|
||||
timestamps: fetchedVideos[videoId].timestamps,
|
||||
endpoint: `/tv/${slug}`
|
||||
})
|
||||
}
|
||||
|
||||
return videos
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import pkg from './package'
|
|||
import buildAppList from './helpers/build-app-list.js'
|
||||
import buildGamesList from './helpers/build-game-list.js'
|
||||
import buildHomebrewList from './helpers/build-homebrew-list.js'
|
||||
import buildVideoList from './helpers/build-video-list.js'
|
||||
|
||||
import { categories } from './helpers/categories.js'
|
||||
|
||||
|
|
@ -24,40 +25,51 @@ const listsOptions = [
|
|||
}
|
||||
]
|
||||
|
||||
const videoListOptions = {
|
||||
buildMethod: buildVideoList,
|
||||
path: '/static/video-list.json',
|
||||
}
|
||||
|
||||
|
||||
const saveList = async function ( list, buildArgs = null ) {
|
||||
const methodName = `Building ${list.path}`
|
||||
console.time(methodName)
|
||||
|
||||
// Run the build method
|
||||
const builtList = await list.buildMethod(buildArgs)
|
||||
|
||||
// Make the relative path for our new JSON file
|
||||
const listFullPath = `.${list.path}`
|
||||
|
||||
// console.log('listFullPath', listFullPath)
|
||||
|
||||
// Write the list to JSON
|
||||
await fs.writeFile(listFullPath, JSON.stringify(builtList))
|
||||
|
||||
// Read back the JSON we just wrote to ensure it exists
|
||||
const savedListJSON = await fs.readFile(listFullPath, 'utf-8')
|
||||
|
||||
// console.log('savedListJSON', savedListJSON)
|
||||
|
||||
const savedList = JSON.parse(savedListJSON)
|
||||
|
||||
|
||||
console.timeEnd(methodName)
|
||||
|
||||
// Import the created JSON File
|
||||
return savedList
|
||||
}
|
||||
|
||||
|
||||
const storeAppLists = async function (builder) {
|
||||
|
||||
console.log('Build Lists started')
|
||||
|
||||
const savedLists = await Promise.all(listsOptions.map(async list => {
|
||||
|
||||
const methodName = `Building ${list.path}`
|
||||
console.time(methodName)
|
||||
|
||||
// Run the build method
|
||||
const builtList = await list.buildMethod()
|
||||
|
||||
// Make the relative path for our new JSON file
|
||||
const listFullPath = `.${list.path}`
|
||||
|
||||
// console.log('listFullPath', listFullPath)
|
||||
|
||||
// Write the list to JSON
|
||||
await fs.writeFile(listFullPath, JSON.stringify(builtList))
|
||||
|
||||
// Read back the JSON we just wrote to ensure it exists
|
||||
const savedListJSON = await fs.readFile(listFullPath, 'utf-8')
|
||||
|
||||
// console.log('savedListJSON', savedListJSON)
|
||||
|
||||
const savedList = JSON.parse(savedListJSON)
|
||||
|
||||
|
||||
console.timeEnd(methodName)
|
||||
|
||||
// Import the created JSON File
|
||||
return savedList
|
||||
}))
|
||||
const savedLists = await Promise.all(listsOptions.map(saveList))
|
||||
// Build and save list of videos based on app lists
|
||||
.then(async lists => {
|
||||
return saveList(videoListOptions, lists.flat(1))
|
||||
})
|
||||
|
||||
console.log('Build Lists finished')
|
||||
|
||||
|
|
@ -93,7 +105,10 @@ export default {
|
|||
]
|
||||
},
|
||||
routes() {
|
||||
return Promise.all(listsOptions.map(async list => {
|
||||
return Promise.all([
|
||||
...listsOptions,
|
||||
videoListOptions
|
||||
].map(async list => {
|
||||
const methodName = `Reading ${list.path}`
|
||||
console.time(methodName)
|
||||
|
||||
|
|
@ -116,8 +131,10 @@ export default {
|
|||
const [
|
||||
appRoutes,
|
||||
gameRoutes,
|
||||
videoRoutes,
|
||||
homebrewRoutes
|
||||
] = lists.map((list, listI) => {
|
||||
|
||||
return list.map( app => {
|
||||
return app.endpoint
|
||||
})
|
||||
|
|
@ -134,6 +151,7 @@ export default {
|
|||
...appRoutes,
|
||||
...gameRoutes,
|
||||
...homebrewRoutes,
|
||||
...videoRoutes,
|
||||
...categoryRoutes
|
||||
]
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue