mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Add game endpoints
This commit is contained in:
parent
474c06738d
commit
61268576e1
4 changed files with 241 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -84,3 +84,4 @@ dist
|
||||||
# Other
|
# Other
|
||||||
/app-list.json
|
/app-list.json
|
||||||
/README-temp.md
|
/README-temp.md
|
||||||
|
/game-list.json
|
||||||
|
|
|
||||||
123
helpers/build-game-list.js
Normal file
123
helpers/build-game-list.js
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
|
||||||
|
import { promises as fs } from 'fs'
|
||||||
|
import slugify from 'slugify'
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
|
import { statuses } from './build-app-list'
|
||||||
|
|
||||||
|
|
||||||
|
// console.log('process.env.GAMES_SOURCE', process.env.GAMES_SOURCE)
|
||||||
|
|
||||||
|
// export const statuses = {
|
||||||
|
// '✅': 'native',
|
||||||
|
// '✳️': 'rosetta',
|
||||||
|
// '⏹': 'no-in-progress',
|
||||||
|
// '🚫': 'no'
|
||||||
|
// }
|
||||||
|
|
||||||
|
const statusesTranslations = {
|
||||||
|
'Native': 'native',
|
||||||
|
'Rosetta': 'rosetta',
|
||||||
|
// '': 'no'
|
||||||
|
}
|
||||||
|
|
||||||
|
const statusesMessages = {
|
||||||
|
'native': '✅ Yes, Full Native Apple Silicon Support',
|
||||||
|
'rosetta': '✳️ Yes, works via Rosetta 2',
|
||||||
|
'no': '🚫 No, not yet supported only works on Intel-based Macs'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function parseStatus(game) {
|
||||||
|
if (game.Playable === 'no') return 'no'
|
||||||
|
|
||||||
|
// Match status to Sheet Status
|
||||||
|
return statusesTranslations[game['Native/Rosetta']]
|
||||||
|
// for (const statusKey in statusesTranslations) {
|
||||||
|
// console.log("game['Native/Rosetta']", game['Native/Rosetta'])
|
||||||
|
// console.log('statuses[statusKey]', statusesTranslations[game['Native/Rosetta']])
|
||||||
|
// if (game['Native/Rosetta'].includes(statusKey)) {
|
||||||
|
// return statusesTranslations[statusKey]
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function () {
|
||||||
|
|
||||||
|
// Fetch Sheet data
|
||||||
|
const gamesSheet = await axios
|
||||||
|
.get(process.env.GAMES_SOURCE)
|
||||||
|
.then(function (response) {
|
||||||
|
// handle success
|
||||||
|
return response.data.records
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
// handle error
|
||||||
|
console.log(error);
|
||||||
|
})
|
||||||
|
|
||||||
|
const gameList = []
|
||||||
|
|
||||||
|
// console.log('gamesSheet', gamesSheet)
|
||||||
|
|
||||||
|
for (const game of gamesSheet) {
|
||||||
|
|
||||||
|
// If there's no title
|
||||||
|
// then stop
|
||||||
|
if (game.Games.length === 0) continue
|
||||||
|
|
||||||
|
// If there's no 'Native/Rosetta' status
|
||||||
|
// then stop
|
||||||
|
if (game['Native/Rosetta'].length === 0) continue
|
||||||
|
|
||||||
|
// Generate slug
|
||||||
|
const slug = slugify(game.Games, {
|
||||||
|
lower: true,
|
||||||
|
strict: true
|
||||||
|
})
|
||||||
|
|
||||||
|
// Find index of game is list so far
|
||||||
|
const gameIndex = gameList.findIndex(game => {
|
||||||
|
return game.slug === slug
|
||||||
|
})
|
||||||
|
|
||||||
|
// Game already has entry
|
||||||
|
if (gameIndex !== -1) continue
|
||||||
|
|
||||||
|
|
||||||
|
const status = parseStatus(game)
|
||||||
|
|
||||||
|
// console.log('status', status)
|
||||||
|
|
||||||
|
gameList.push({
|
||||||
|
name: game.Games,
|
||||||
|
status,
|
||||||
|
url: `https://rawg.io/search?query=${encodeURIComponent(game.Games)}`,
|
||||||
|
text: statusesMessages[status],
|
||||||
|
slug,
|
||||||
|
section: {
|
||||||
|
label: 'Games',
|
||||||
|
slug: 'games'
|
||||||
|
},
|
||||||
|
content: '',
|
||||||
|
relatedLinks: [],
|
||||||
|
reports: [
|
||||||
|
game
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log('gameList', gameList)
|
||||||
|
|
||||||
|
|
||||||
|
return gameList
|
||||||
|
|
||||||
|
// fs.readFile('../README.md', 'utf8')
|
||||||
|
// .then((err, data) => {
|
||||||
|
// const result = md.parse(data)
|
||||||
|
// console.log('result', result)
|
||||||
|
|
||||||
|
// return result
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
|
@ -3,22 +3,35 @@ import path from 'path'
|
||||||
|
|
||||||
import pkg from './package'
|
import pkg from './package'
|
||||||
import buildAppList from './helpers/build-app-list.js'
|
import buildAppList from './helpers/build-app-list.js'
|
||||||
|
import buildGamesList from './helpers/build-game-list.js'
|
||||||
|
|
||||||
|
|
||||||
const storeAppList = async function (builder) {
|
const storeAppList = async function (builder) {
|
||||||
|
// TODO: Make DRY
|
||||||
|
|
||||||
const appListPath = path.join(
|
const appListPath = path.join(
|
||||||
// builder.nuxt.options.buildDir,
|
// builder.nuxt.options.buildDir,
|
||||||
builder.nuxt.options.srcDir,
|
builder.nuxt.options.srcDir,
|
||||||
'/app-list.json'
|
'/app-list.json'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const gamesListPath = path.join(
|
||||||
|
// builder.nuxt.options.buildDir,
|
||||||
|
builder.nuxt.options.srcDir,
|
||||||
|
'/game-list.json'
|
||||||
|
)
|
||||||
|
|
||||||
const appList = await buildAppList()
|
const appList = await buildAppList()
|
||||||
|
const gamesList = await buildGamesList()
|
||||||
|
|
||||||
// console.log('builder.nuxt.options', builder.nuxt.options)
|
// console.log('builder.nuxt.options', builder.nuxt.options)
|
||||||
await fs.writeFile(appListPath, JSON.stringify(appList))
|
await fs.writeFile(appListPath, JSON.stringify(appList))
|
||||||
|
await fs.writeFile(gamesListPath, JSON.stringify(gamesList))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// console.log('process.env.GAMES_SOURCE', process.env.GAMES_SOURCE)
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
target: 'static',
|
target: 'static',
|
||||||
|
|
||||||
|
|
@ -43,9 +56,16 @@ export default {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
routes() {
|
routes() {
|
||||||
return import('./app-list.json')//buildAppList()
|
return Promise.all([
|
||||||
.then((importedAppList) => {
|
import('./app-list.json'),
|
||||||
|
import('./game-list.json')
|
||||||
|
])
|
||||||
|
.then(([
|
||||||
|
importedAppList,
|
||||||
|
importedGameList
|
||||||
|
]) => {
|
||||||
const appList = importedAppList.default
|
const appList = importedAppList.default
|
||||||
|
const gameList = importedGameList.default
|
||||||
// console.log('appList', appList)
|
// console.log('appList', appList)
|
||||||
|
|
||||||
const appRoutes = appList.map(app => ({
|
const appRoutes = appList.map(app => ({
|
||||||
|
|
@ -53,6 +73,11 @@ export default {
|
||||||
// payload: appList
|
// payload: appList
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
const gameRoutes = gameList.map(game => ({
|
||||||
|
route: '/game/' + game.slug,
|
||||||
|
// payload: appList
|
||||||
|
}))
|
||||||
|
|
||||||
const sectionList = []
|
const sectionList = []
|
||||||
|
|
||||||
appList.forEach(app => {
|
appList.forEach(app => {
|
||||||
|
|
@ -68,6 +93,7 @@ export default {
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...appRoutes,
|
...appRoutes,
|
||||||
|
...gameRoutes,
|
||||||
...sectionRoutes
|
...sectionRoutes
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
|
||||||
89
pages/game/_slug.vue
Normal file
89
pages/game/_slug.vue
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
<template>
|
||||||
|
<section class="container py-32">
|
||||||
|
<div class="flex flex-col items-center text-center">
|
||||||
|
<h1 class="title text-sm md:text-2xl font-semibold">
|
||||||
|
Does {{ app.name }} work on Apple Silicon?
|
||||||
|
</h1>
|
||||||
|
<h2 class="subtitle text-2xl md:text-5xl font-bold py-6">
|
||||||
|
{{ app.text }}
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<!-- <div class="subscribe space-y-6 sm:space-x-6 mb-4">
|
||||||
|
<EmailSubscribe
|
||||||
|
:app-name="app.name"
|
||||||
|
/>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
<div class="links space-y-6 sm:space-x-6">
|
||||||
|
<LinkButton
|
||||||
|
v-for="(link, i) in app.relatedLinks"
|
||||||
|
:key="i"
|
||||||
|
:href="link.href"
|
||||||
|
target="_blank"
|
||||||
|
class=""
|
||||||
|
>{{ (i === 0) ? 'View' : link.label }}</LinkButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<small>
|
||||||
|
<span>Data generously provided by </span>
|
||||||
|
<span>
|
||||||
|
<a
|
||||||
|
href="https://twitter.com/__tosh"
|
||||||
|
class="font-bold"
|
||||||
|
>Thomas Schranz</a>
|
||||||
|
</span>
|
||||||
|
<span>via</span>
|
||||||
|
<span>
|
||||||
|
<a
|
||||||
|
href="https://docs.google.com/spreadsheets/d/1er-NivvuIheDmIKBVRu3S_BzA_lZT5z3Z-CxQZ-uPVs/edit#gid=0"
|
||||||
|
class="font-bold"
|
||||||
|
>Games and Apps on Apple Silicon</a>
|
||||||
|
</span>
|
||||||
|
</small>
|
||||||
|
|
||||||
|
<div class="report-links py-24 shadow-none">
|
||||||
|
<!-- https://eric.blog/2016/01/08/prefilling-github-issues/ -->
|
||||||
|
<a
|
||||||
|
:href="`https://docs.google.com/spreadsheets/d/1er-NivvuIheDmIKBVRu3S_BzA_lZT5z3Z-CxQZ-uPVs/edit#gid=0`"
|
||||||
|
target="_blank"
|
||||||
|
class="text-xs"
|
||||||
|
rel="noopener"
|
||||||
|
>Report Update</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import LinkButton from '~/components/link-button.vue'
|
||||||
|
import EmailSubscribe from '~/components/email-subscribe.vue'
|
||||||
|
import gameList from '~/game-list.json'
|
||||||
|
// import buildAppList from '~/helpers/build-app-list'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
LinkButton,
|
||||||
|
EmailSubscribe
|
||||||
|
},
|
||||||
|
async asyncData ({ params: { slug } }) {
|
||||||
|
|
||||||
|
return {
|
||||||
|
slug,
|
||||||
|
app: gameList.find(app => (app.slug === slug))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
head() {
|
||||||
|
return {
|
||||||
|
title: `Does ${this.app.name} work on Apple Silicon?`,
|
||||||
|
// meta: [
|
||||||
|
// // hid is used as unique identifier. Do not use `vmid` for it as it will not work
|
||||||
|
// {
|
||||||
|
// hid: 'description',
|
||||||
|
// name: 'description',
|
||||||
|
// content: 'My custom description'
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue