mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Merge branch 'feat/scans-source'
This commit is contained in:
commit
cd41bb4cd1
12 changed files with 174 additions and 33 deletions
|
|
@ -241,10 +241,15 @@ class BuildLists {
|
|||
|
||||
// Add benchmark endpoints for apps and games
|
||||
if ( appType === 'app' || appType === 'game' ) {
|
||||
this.endpointSets.nuxt.add({
|
||||
route: `${getAppEndpoint(app)}/benchmarks`,
|
||||
payload: buildAppBenchmarkPayload( app, this.allVideoAppsList, this.lists.video )
|
||||
})
|
||||
const payload = buildAppBenchmarkPayload( app, this.allVideoAppsList, this.lists.video )
|
||||
|
||||
// Only add a benchmarks endpoint if it has any videos
|
||||
if ( payload.allVideos.length > 0 ) {
|
||||
this.endpointSets.nuxt.add({
|
||||
route: `${getAppEndpoint(app)}/benchmarks`,
|
||||
payload: buildAppBenchmarkPayload( app, this.allVideoAppsList, this.lists.video )
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Add app or game endpoint
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import parseGithubDate from '~/helpers/parse-github-date'
|
||||
import parseDate from '~/helpers/parse-date'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
|
|
@ -16,7 +16,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
relativeTime () {
|
||||
return parseGithubDate(this.timestamp).relative
|
||||
return parseDate(this.timestamp).relative
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,20 @@ import MarkdownIt from 'markdown-it'
|
|||
import slugify from 'slugify'
|
||||
import axios from 'axios'
|
||||
|
||||
import statuses from './statuses'
|
||||
import parseGithubDate from './parse-github-date'
|
||||
import statuses, { getStatusName } from './statuses'
|
||||
import parseDate from './parse-date'
|
||||
import { eitherMatches } from './matching.js'
|
||||
import { getAppEndpoint } from './app-derived'
|
||||
|
||||
|
||||
const md = new MarkdownIt()
|
||||
|
||||
|
||||
const makeSlug = name => slugify(name, {
|
||||
lower: true,
|
||||
strict: true
|
||||
})
|
||||
|
||||
|
||||
const getTokenLinks = function ( childTokens ) {
|
||||
|
||||
|
|
@ -108,6 +114,70 @@ export default async function () {
|
|||
// await fs.writeFile('./commits-data.json', JSON.stringify(commits))
|
||||
|
||||
|
||||
const scanListMap = new Map()
|
||||
|
||||
// Store app scans
|
||||
await axios
|
||||
.get(process.env.SCANS_SOURCE)
|
||||
.then(function (response) {
|
||||
|
||||
response.data.appList.forEach( appScan => {
|
||||
|
||||
const appName = appScan.aliases[0]
|
||||
|
||||
// 'native' or 'unreported'
|
||||
const statusName = getStatusName( appScan['Result'] )
|
||||
|
||||
const statusText = (statusName === 'native') ? `✅ Yes, Full Native Apple Silicon Support reported as of v${appScan['App Version']}` : '🔶 App has not yet been reported to be native to Apple Silicon'
|
||||
|
||||
const appSlug = makeSlug( appName )
|
||||
|
||||
// Skip empty slugs
|
||||
if (appSlug.trim().length === 0) {
|
||||
console.log('Empty slug', appScan)
|
||||
return
|
||||
}
|
||||
|
||||
const relatedLinks = []
|
||||
|
||||
// If downloadUrl is not empty then add it as the download link
|
||||
if ( appScan['downloadUrl'] !== null ) {
|
||||
relatedLinks.push({
|
||||
href: appScan['downloadUrl'],
|
||||
label: 'View',
|
||||
})
|
||||
}
|
||||
|
||||
// Add to scanned app list
|
||||
scanListMap.set( appSlug, {
|
||||
name: appName,
|
||||
aliases: appScan['aliases'],
|
||||
status: statusName,
|
||||
lastUpdated: parseDate( appScan['Date'] ),
|
||||
// url,
|
||||
text: statusText,
|
||||
slug: appSlug,
|
||||
endpoint: getAppEndpoint({
|
||||
category: {
|
||||
slug: null
|
||||
},
|
||||
slug: appSlug
|
||||
}),
|
||||
category: {
|
||||
slug: 'uncategorized'
|
||||
},
|
||||
relatedLinks
|
||||
})
|
||||
})
|
||||
|
||||
return
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.warn(error)
|
||||
})
|
||||
|
||||
|
||||
// Parse markdown
|
||||
const result = md.parse(readmeContent)
|
||||
|
||||
|
|
@ -143,8 +213,6 @@ export default async function () {
|
|||
// On heading close switch off heading mode
|
||||
if (token.type.includes('paragraph_')) isParagraph = !isParagraph
|
||||
|
||||
|
||||
|
||||
if (isHeading && token.type === 'inline') {
|
||||
categoryTitle = token.content
|
||||
categorySlug = slugify(token.content, {
|
||||
|
|
@ -157,17 +225,28 @@ export default async function () {
|
|||
|
||||
|
||||
if ( isParagraph && token.type === 'inline' && token.content.includes(' - ') ) {
|
||||
const [ link, text ] = token.content.split(' - ').map(string => string.trim())
|
||||
|
||||
const relatedLinks = getTokenLinks(token.children)
|
||||
const [ link, text ] = token.content.split(' - ').map(string => string.trim())
|
||||
|
||||
const [ name, url ] = link.substring(1, link.length-1).split('](')
|
||||
|
||||
const appSlug = slugify(name, {
|
||||
lower: true,
|
||||
strict: true
|
||||
// Search for this app in the scanList and remove duplicates
|
||||
scanListMap.forEach( ( scannedApp, key ) => {
|
||||
|
||||
for ( const alias of scannedApp.aliases) {
|
||||
// console.log( key, alias, name, eitherMatches(alias, name) )
|
||||
|
||||
if ( eitherMatches(alias, name) ) {
|
||||
console.log(`Removing ${alias} from scanned apps`)
|
||||
scanListMap.delete( key )
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const relatedLinks = getTokenLinks(token.children)
|
||||
|
||||
const appSlug = makeSlug( name )
|
||||
|
||||
const endpoint = getAppEndpoint({
|
||||
category: {
|
||||
slug: null
|
||||
|
|
@ -192,7 +271,7 @@ export default async function () {
|
|||
|
||||
const lastUpdated = (lastUpdatedRaw) ? {
|
||||
raw: lastUpdatedRaw,
|
||||
timestamp: parseGithubDate(lastUpdatedRaw).timestamp,
|
||||
timestamp: parseDate(lastUpdatedRaw).timestamp,
|
||||
} : null
|
||||
|
||||
|
||||
|
|
@ -219,7 +298,10 @@ export default async function () {
|
|||
// console.log('appList', appList)
|
||||
|
||||
|
||||
return appList
|
||||
return [
|
||||
...appList,
|
||||
...Array.from( scanListMap, ([name, value]) => value )
|
||||
]
|
||||
|
||||
// fs.readFile('../README.md', 'utf8')
|
||||
// .then((err, data) => {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
import axios from 'axios'
|
||||
|
||||
// import statuses from './statuses'
|
||||
// import parseGithubDate from './parse-github-date'
|
||||
// import parseDate from './parse-github-date'
|
||||
|
||||
const marked = require('marked')
|
||||
const HTMLParser = require(`node-html-parser`)
|
||||
|
|
|
|||
|
|
@ -2,13 +2,10 @@
|
|||
import slugify from 'slugify'
|
||||
import axios from 'axios'
|
||||
|
||||
import { matchesWholeWord } from './matching.js'
|
||||
import { byTimeThenNull } from './sort-list.js'
|
||||
import { getVideoEndpoint } from './app-derived.js'
|
||||
import parseGithubDate from './parse-github-date'
|
||||
|
||||
export function matchesWholeWord (needle, haystack) {
|
||||
return new RegExp('\\b' + needle + '\\b').test(haystack)
|
||||
}
|
||||
import parseDate from './parse-date'
|
||||
|
||||
const videoFeaturesApp = function (app, video) {
|
||||
const appFuzzyName = app.name.toLowerCase()
|
||||
|
|
@ -152,7 +149,7 @@ export default async function ( applist ) {
|
|||
|
||||
const lastUpdated = {
|
||||
raw: fetchedVideos[videoId].rawData.snippet.publishedAt,
|
||||
timestamp: parseGithubDate(fetchedVideos[videoId].rawData.snippet.publishedAt).timestamp,
|
||||
timestamp: parseDate(fetchedVideos[videoId].rawData.snippet.publishedAt).timestamp,
|
||||
}
|
||||
|
||||
// console.log('fetchedVideos[videoId].thumbnails', fetchedVideos[videoId].thumbnails)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ export const categoryTemplate = {
|
|||
export const categories = {
|
||||
|
||||
'no-category': {
|
||||
id: 0
|
||||
id: 0,
|
||||
label: ''
|
||||
},
|
||||
|
||||
// App lists
|
||||
|
|
@ -121,6 +122,16 @@ export const categories = {
|
|||
slug: 'homebrew',
|
||||
icon: '🍺'
|
||||
},
|
||||
|
||||
|
||||
// Uncategorized
|
||||
'uncategorized': {
|
||||
id: 1000,
|
||||
...categoryTemplate,
|
||||
label: 'Uncategorized',
|
||||
pluralLabel: 'Uncategorized Software',
|
||||
slug: 'uncategorized',
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
30
helpers/matching.js
Normal file
30
helpers/matching.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
// Match whole word
|
||||
export function matchesWholeWord (needle, haystack) {
|
||||
return new RegExp('\\b' + needle + '\\b').test(haystack)
|
||||
}
|
||||
|
||||
|
||||
export function eitherMatches (stringA, stringB) {
|
||||
const stringALength = stringA.length
|
||||
const stringBLength = stringB.length
|
||||
|
||||
// If string lengths are equal
|
||||
// then just compare the equality of the strings
|
||||
if (stringALength === stringBLength) {
|
||||
// console.log('Strings are equal length', stringA, stringB)
|
||||
return (stringA === stringB)
|
||||
}
|
||||
|
||||
// If string A is larger
|
||||
// then find string B within it
|
||||
if (stringALength > stringBLength) {
|
||||
// console.log('String A is bigger', stringA, stringB)
|
||||
return matchesWholeWord( stringB, stringA )
|
||||
}
|
||||
|
||||
// If string B is larger
|
||||
// then find string A within it
|
||||
// console.log('String B is bigger', stringA, stringB)
|
||||
return matchesWholeWord( stringA, stringB )
|
||||
}
|
||||
|
|
@ -1,10 +1,6 @@
|
|||
// import { allVideoAppsListSet } from '~/helpers/get-list.js'
|
||||
// import videoList from '~/static/video-list.json'
|
||||
|
||||
export function matchesWholeWord (needle, haystack) {
|
||||
return new RegExp('\\b' + needle + '\\b').test(haystack)
|
||||
}
|
||||
|
||||
export function appsRelatedToVideo ( video, allVideoAppsListSet ) {
|
||||
// console.log('allVideoAppsListSet', allVideoAppsListSet.length)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,20 @@
|
|||
export default {
|
||||
|
||||
|
||||
|
||||
const statuses = {
|
||||
'✅': 'native',
|
||||
'✳️': 'rosetta',
|
||||
'⏹': 'no-in-progress',
|
||||
'🚫': 'no',
|
||||
'🔶': 'unreported',
|
||||
}
|
||||
|
||||
export function getStatusName ( status ) {
|
||||
for (const key in statuses) {
|
||||
if (status.trim().startsWith( key )) return statuses[key]
|
||||
}
|
||||
|
||||
throw new Error('Non status matched')
|
||||
}
|
||||
|
||||
export default statuses
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import parseGithubDate from '~/helpers/parse-github-date'
|
||||
import parseDate from '~/helpers/parse-date'
|
||||
import { getAppEndpoint } from '~/helpers/app-derived.js'
|
||||
|
||||
import LinkButton from '~/components/link-button.vue'
|
||||
|
|
|
|||
|
|
@ -52,10 +52,17 @@ export default {
|
|||
const { allList } = await import('~/helpers/get-list.js')
|
||||
const { categories } = await import('~/helpers/categories.js')
|
||||
|
||||
const categoryList = {}
|
||||
// Map Categories into category list
|
||||
const categoryList = Object.fromEntries(Object.entries(categories).map( ( entry ) => {
|
||||
entry[1].appNamesList = []
|
||||
return entry
|
||||
} ))
|
||||
|
||||
// Delete no-category
|
||||
delete categoryList['no-category']
|
||||
|
||||
allList.forEach( app => {
|
||||
// Find and store all categorys
|
||||
// Find and store all categories
|
||||
|
||||
// console.log('app.category.slug', app.category.slug)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue