mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-15 06:35:20 -07:00
Compare commits
19 commits
62869cef3d
...
b57b3550a0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b57b3550a0 | ||
|
|
411df75c52 | ||
|
|
87a7688947 | ||
|
|
48be5593d3 | ||
|
|
bff6fd4494 | ||
|
|
ae62aacbd6 | ||
|
|
07ae854dbb | ||
|
|
754f6b3920 | ||
|
|
bafb8717b2 | ||
|
|
2f488ee25c | ||
|
|
fddfa9d5a4 | ||
|
|
44d7393039 | ||
|
|
0a6038e316 | ||
|
|
f3ec9104f8 | ||
|
|
11ebfbad9b | ||
|
|
c8c1d5a911 | ||
|
|
d3c4f667fd | ||
|
|
857c88c529 | ||
|
|
1ef7eb5ff9 |
12 changed files with 9302 additions and 6521 deletions
129
.cursorrules
Normal file
129
.cursorrules
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
/**
|
||||
* Does It ARM Project Rules
|
||||
* Customized AI behavior for maintaining app compatibility database
|
||||
*/
|
||||
module.exports = {
|
||||
// Core project settings
|
||||
project: {
|
||||
name: 'doesitarm',
|
||||
type: 'astro',
|
||||
packageManager: 'pnpm',
|
||||
nodeVersion: '>=22'
|
||||
},
|
||||
|
||||
// Code style preferences
|
||||
style: {
|
||||
indentSize: 4,
|
||||
maxLineLength: 72,
|
||||
quotes: 'single',
|
||||
semicolons: false
|
||||
},
|
||||
|
||||
// Testing configuration
|
||||
testing: {
|
||||
framework: 'vitest',
|
||||
pattern: 'test/**/*.test.js',
|
||||
coverage: true
|
||||
},
|
||||
|
||||
// Documentation rules
|
||||
docs: {
|
||||
// Write comments as user stories instead of implementation details
|
||||
commentStyle: 'userStory',
|
||||
jsdoc: {
|
||||
required: true,
|
||||
params: true,
|
||||
returns: true
|
||||
}
|
||||
},
|
||||
|
||||
// Function patterns
|
||||
functions: {
|
||||
// Prefer options object for 2+ params
|
||||
preferOptionsObject: true,
|
||||
|
||||
// Always use named exports except for pages
|
||||
exports: 'named',
|
||||
|
||||
// Functional components only
|
||||
reactComponents: 'functional'
|
||||
},
|
||||
|
||||
// Variable naming
|
||||
naming: {
|
||||
// Avoid generic names
|
||||
forbidden: [
|
||||
'base64',
|
||||
'text',
|
||||
'data',
|
||||
'item',
|
||||
'content'
|
||||
],
|
||||
|
||||
// Prefer descriptive names
|
||||
preferred: {
|
||||
'base64': '*Base64',
|
||||
'text': '*Text',
|
||||
'data': '*Data',
|
||||
'content': '*Content'
|
||||
}
|
||||
},
|
||||
|
||||
// Search functionality rules
|
||||
search: {
|
||||
// Stork search configuration
|
||||
stork: {
|
||||
version: '1.6.0',
|
||||
indexPath: 'static/search-index.st',
|
||||
tomlPath: 'static/stork.toml'
|
||||
}
|
||||
},
|
||||
|
||||
// Build process
|
||||
build: {
|
||||
// Files to ignore
|
||||
ignore: [
|
||||
'node_modules',
|
||||
'dist',
|
||||
'.cache',
|
||||
'.DS_Store'
|
||||
],
|
||||
|
||||
// Required environment variables
|
||||
requiredEnv: [
|
||||
'PUBLIC_URL',
|
||||
'PUBLIC_API_DOMAIN',
|
||||
'COMMITS_SOURCE',
|
||||
'GAMES_SOURCE'
|
||||
]
|
||||
},
|
||||
|
||||
// Deployment configurations
|
||||
deployment: {
|
||||
platforms: ['netlify', 'vercel'],
|
||||
netlify: {
|
||||
buildCommand: 'pnpm run netlify-build',
|
||||
publishDir: 'dist/',
|
||||
functions: {
|
||||
directory: 'dist/functions',
|
||||
bundler: 'esbuild'
|
||||
},
|
||||
environment: {
|
||||
NPM_FLAGS: '--no-optional',
|
||||
CI: '1'
|
||||
}
|
||||
},
|
||||
vercel: {
|
||||
buildCommand: 'pnpm run vercel-build',
|
||||
distDir: 'static',
|
||||
buildSteps: [
|
||||
'test-prebuild',
|
||||
'build-lists-and-api',
|
||||
'test-postbuild-api'
|
||||
],
|
||||
github: {
|
||||
silent: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -353,7 +353,7 @@ Builds - [Java on M1 Benchmarks](https://docs.google.com/spreadsheets/d/1g4U7LAI
|
|||
* [Adobe Media Encoder](https://www.adobe.com/products/media-encoder.html) - ✳️ Yes, works via Rosetta 2 - [Official Adobe Status Page](https://helpx.adobe.com/download-install/kb/apple-silicon-m1-chip.html)
|
||||
* [After Effects](https://www.adobe.com/products/aftereffects.html) - ✳️ Yes, works via Rosetta 2 - [Official Adobe Status Page](https://helpx.adobe.com/download-install/kb/apple-silicon-m1-chip.html)
|
||||
* [Autodesk Fusion 360](https://www.autodesk.com/products/fusion-360/overview) - ✳️ Yes, it was shown at the November 10th event running via Rosetta 2 - [Apple Nov 10 Event](https://youtu.be/5AwdkGKmZ0I?t=1114)
|
||||
* [Autodesk Maya](https://www.autodesk.com/products/maya/overview) - ✳️ Yes, it was shown at WWDC running via Rosetta 2 - [WWDC Preview](https://youtu.be/GEZhD3J89ZE?t=6036)
|
||||
* [Autodesk Maya](https://www.autodesk.com/products/maya/overview) - ✅ Yes, Native Apple Silicon Support as of v2024 - [Source](https://help.autodesk.com/view/MAYAUL/2024/ENU/?guid=GUID-A7291217-7424-49C9-8CB3-3089E7F4909E)
|
||||
* [Autokroma AfterCodecs](https://www.autokroma.com/AfterCodecs/Download) - ✅ Yes, Native Apple Silicon Support as of v1.10.6 - [Official Article](https://www.autokroma.com/blog/Apple-Silicon-ARM-M1-Compatibility-with-Adobe-Creative-Cloud-Autokroma)
|
||||
* [Autokroma BRAW (BRAW_Studio)](https://www.autokroma.com/BRAW_Studio/Download/) - ✅ Yes, Native Apple Silicon Support as of v2.5.1 - [Official Article](https://www.autokroma.com/blog/Apple-Silicon-ARM-M1-Compatibility-with-Adobe-Creative-Cloud-Autokroma)
|
||||
* [Autokroma Influx](https://www.autokroma.com/Influx/) - 🚫 Not yet supported only works on Intel-based Macs - [Official Article](https://www.autokroma.com/blog/Apple-Silicon-ARM-M1-Compatibility-with-Adobe-Creative-Cloud-Autokroma)
|
||||
|
|
@ -374,7 +374,7 @@ Builds - [Java on M1 Benchmarks](https://docs.google.com/spreadsheets/d/1g4U7LAI
|
|||
* [GoPro Fusion Studio](https://gopro.com/en/us/news/fusion-end-of-life) - 🚫 No, not supported and no plans for support - [Verification](https://github.com/ThatGuySam/doesitarm/issues/349#issuecomment-869347313) [Official Article](https://gopro.com/en/us/news/fusion-end-of-life)
|
||||
* [GoPro VR Player](https://community.gopro.com/t5/en/GoPro-VR-Player-for-desktop-FAQ/ta-p/394345) - ✳️ Yes, works via Rosetta 2 translation - [Verification](https://github.com/ThatGuySam/doesitarm/issues/349#issuecomment-869347313)
|
||||
* [Handbrake](https://handbrake.fr/) - ✅ Yes, natively supported as of v1.4.0 - [Github Issue](https://github.com/HandBrake/HandBrake/issues/2951)
|
||||
* [Houdini](https://www.sidefx.com/products/houdini/) - ✳️ Yes, works via Rosetta 2 - [Source](https://www.reddit.com/r/Houdini/comments/jzg1wj/houdini_running_on_apple_silicon_m1_macs_demo/)
|
||||
* [Houdini](https://www.sidefx.com/products/houdini/) - ✅ Yes, natively supported as of v19.5.534 - [Source](https://www.sidefx.com/community/houdini-for-apple-silicon-now-gold/)
|
||||
* [Maxon Chromatic Displacement](https://www.maxon.net/en/red-giant-complete/vfx-suite/chromatic-displacement) - 🔶 App has not yet been reported to be native to Apple Silicon - [Requirements](https://www.maxon.net/en/requirements/chromatic-displacement-requirements)
|
||||
* [Maxon Cosmo](https://www.maxon.net/en/red-giant-complete/magic-bullet-suite/cosmo) - 🔶 App has not yet been reported to be native to Apple Silicon - [Requirements](https://www.maxon.net/en/requirements/cosmo-requirements)
|
||||
* [Maxon Denoiser](https://www.maxon.net/en/red-giant-complete/magic-bullet-suite/denoiser) - 🔶 App has not yet been reported to be native to Apple Silicon - [Requirements](https://www.maxon.net/en/requirements/denoiser-requirements)
|
||||
|
|
|
|||
20
package.json
20
package.json
|
|
@ -4,18 +4,18 @@
|
|||
"description": "Find out the latest app support for Apple Silicon and the Apple M3 Max and M2 Ultra Processors",
|
||||
"author": "Sam Carlton",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@8.6.12",
|
||||
"packageManager": "pnpm@9.15.1",
|
||||
"engines": {
|
||||
"pnpm": "^8.6.*",
|
||||
"node": ">=18",
|
||||
"pnpm": "^9.*",
|
||||
"node": ">=22",
|
||||
"yarn": "forbidden, this project uses pnpm",
|
||||
"npm": "forbidden, this project uses pnpm"
|
||||
},
|
||||
"config": {
|
||||
"verbiage": {
|
||||
"processors": "Apple M3 Max and M2 Ultra",
|
||||
"macs": "Apple M3 Max or M2 Ultra Mac",
|
||||
"description": "Find out the latest app support for Apple Silicon and the Apple M3 Max and M2 Ultra Processors"
|
||||
"processors": "Apple M4 Max and M3 Ultra",
|
||||
"macs": "Apple M4 Max or M3 Ultra Mac",
|
||||
"description": "Find out the latest app support for Apple Silicon and the Apple M4 Max and M3 Ultra Processors"
|
||||
},
|
||||
"stork": {
|
||||
"executable": "stork-executable",
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test-prebuild": "ava ./test/prebuild/**/*.js --verbose",
|
||||
"test-prebuild": "pnpm run with-env vitest ./test/prebuild",
|
||||
"test-api-client": "ava ./test/api/client.js --verbose",
|
||||
"test-listings": "ava ./test/listings/**/*.js --verbose",
|
||||
"test-postbuild-api": "pnpm test-listings",
|
||||
|
|
@ -51,6 +51,7 @@
|
|||
"precommit": "pnpm run lint",
|
||||
"clone-readme": "cp ./README.md README-temp.md",
|
||||
"scan-new-apps": "pnpm exec vite-node scripts/scan-new-apps.js",
|
||||
"with-env": "dotenv -e .env -- ",
|
||||
"cloudflare-deploy": "pnpm run build-api",
|
||||
"vercel-build": "npx vite-node scripts/vercel-build.js",
|
||||
"netlify-prebuild:download-sitemaps": "npx vite-node scripts/download-sitemaps.js",
|
||||
|
|
@ -125,10 +126,11 @@
|
|||
"@astrojs/tailwind": "^4.0.0",
|
||||
"@vitest/web-worker": "^0.20.3",
|
||||
"autoprefixer": "^10.0.2",
|
||||
"ava": "^3.15.0",
|
||||
"ava": "^6.2.0",
|
||||
"babel-eslint": "^8.2.1",
|
||||
"cssnano": "^4.1.10",
|
||||
"dotenv": "^8.2.0",
|
||||
"dotenv-cli": "^8.0.0",
|
||||
"eslint": "^8.14.0",
|
||||
"eslint-plugin-vue": "^8.7.1",
|
||||
"esm": "^3.2.25",
|
||||
|
|
@ -145,6 +147,6 @@
|
|||
"tailwindcss": "^3.2.6",
|
||||
"tsconfig-paths": "^3.14.1",
|
||||
"vite-tsconfig-paths": "^3.5.0",
|
||||
"vitest": "^0.18.1"
|
||||
"vitest": "^2.1.8"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
15105
pnpm-lock.yaml
generated
15105
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,67 +0,0 @@
|
|||
import test from 'ava'
|
||||
// import MarkdownIt from 'markdown-it'
|
||||
|
||||
// import { isValidHttpUrl } from '~/helpers/check-types.js'
|
||||
import { StorkFilters } from '~/helpers/stork/browser.js'
|
||||
|
||||
|
||||
require('dotenv').config()
|
||||
|
||||
|
||||
test('Can Toggle off existing filter' , async t => {
|
||||
const filters = new StorkFilters({
|
||||
initialFilters: {
|
||||
'test': 'yes'
|
||||
}
|
||||
})
|
||||
|
||||
filters.toggleFilter('test')
|
||||
|
||||
t.deepEqual(filters.has('test'), false)
|
||||
|
||||
filters.toggleFilter('test', 'yes')
|
||||
filters.toggleFilter('status', 'native')
|
||||
|
||||
t.deepEqual(filters.has('test'), true, 'Has test filter')
|
||||
|
||||
t.deepEqual(filters.asQuery, 'test_yes status_native', 'Has correct filters for query')
|
||||
|
||||
filters.toggleFilter('status_native')
|
||||
|
||||
t.deepEqual(filters.asQuery, 'test_yes', 'Has only test filter')
|
||||
})
|
||||
|
||||
|
||||
test('Can handle query values with multiple underscores', async t => {
|
||||
const filters = new StorkFilters({
|
||||
initialFilters: {
|
||||
'test': 'value_with_multiple_underscores'
|
||||
}
|
||||
})
|
||||
|
||||
t.log( 'filters.asQuery', filters.asQuery )
|
||||
|
||||
t.assert( filters.has( 'test_value_with_multiple_underscores' ) , 'Has correct filters for query' )
|
||||
})
|
||||
|
||||
|
||||
test( 'Can update existing filter', async t => {
|
||||
const filters = new StorkFilters({
|
||||
initialFilters: {
|
||||
'test': 'works_no'
|
||||
}
|
||||
})
|
||||
|
||||
filters.toggleFilter('test_works_yes')
|
||||
|
||||
t.deepEqual( filters.asQuery, 'test_works_yes', 'Has updated filter')
|
||||
})
|
||||
|
||||
|
||||
test( 'Can set filters from string', async t => {
|
||||
const filters = new StorkFilters()
|
||||
|
||||
filters.setFromString( 'test_works_yes' )
|
||||
|
||||
t.deepEqual( filters.asQuery, 'test_works_yes', 'Has updated filter')
|
||||
})
|
||||
88
test/prebuild/filters.test.js
Normal file
88
test/prebuild/filters.test.js
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
import { describe, it, expect, beforeEach } from 'vitest'
|
||||
import { StorkFilters } from '~/helpers/stork/browser.js'
|
||||
|
||||
/**
|
||||
* Tests for StorkFilters class which handles filter management and query string
|
||||
* generation for Stork search
|
||||
*/
|
||||
describe('StorkFilters', () => {
|
||||
// let filters
|
||||
|
||||
// beforeEach(() => {
|
||||
// filters = new StorkFilters()
|
||||
// })
|
||||
|
||||
// User Story: As a user, I want to toggle filters on/off so I can refine my search
|
||||
describe('filter toggling', () => {
|
||||
it('should toggle off an existing filter', () => {
|
||||
const filters = new StorkFilters({
|
||||
initialFilters: { test: 'yes' }
|
||||
})
|
||||
|
||||
filters.toggleFilter('test')
|
||||
expect(filters.has('test')).toBe(false)
|
||||
})
|
||||
|
||||
it('should toggle on multiple filters', () => {
|
||||
const filters = new StorkFilters({
|
||||
initialFilters: { test: 'yes' }
|
||||
})
|
||||
|
||||
// filters.toggleFilter('test', 'yes')
|
||||
filters.toggleFilter('status', 'native')
|
||||
|
||||
expect(filters.has('test')).toBe( true )
|
||||
expect(filters.asQuery).toBe('test_yes status_native')
|
||||
})
|
||||
|
||||
it('should remove a specific filter', () => {
|
||||
const filters = new StorkFilters({
|
||||
initialFilters: {
|
||||
test: 'yes',
|
||||
status: 'native'
|
||||
}
|
||||
})
|
||||
|
||||
filters.toggleFilter('status_native')
|
||||
expect(filters.asQuery).toBe('test_yes')
|
||||
})
|
||||
})
|
||||
|
||||
// User Story: As a user, I want to use complex filter values to enable detailed searching
|
||||
describe('complex filter values', () => {
|
||||
it('should handle values with multiple underscores', () => {
|
||||
const filters = new StorkFilters({
|
||||
initialFilters: {
|
||||
test: 'value_with_multiple_underscores'
|
||||
}
|
||||
})
|
||||
|
||||
expect(filters.has('test_value_with_multiple_underscores')).toBe(true)
|
||||
})
|
||||
|
||||
it('should update existing filter value', () => {
|
||||
const filters = new StorkFilters({
|
||||
initialFilters: {
|
||||
test: 'works_no'
|
||||
}
|
||||
})
|
||||
|
||||
filters.toggleFilter('test_works_yes')
|
||||
expect(filters.asQuery).toBe('test_works_yes')
|
||||
})
|
||||
})
|
||||
|
||||
// User Story: As a user, I want to set filters from a query string to restore search state
|
||||
describe('filter initialization', () => {
|
||||
it('should set filters from query string', () => {
|
||||
const filters = new StorkFilters({
|
||||
initialFilters: {
|
||||
test: 'works_no'
|
||||
}
|
||||
})
|
||||
|
||||
filters.setFromString('test_works_yes')
|
||||
expect(filters.asQuery).toBe('test_works_yes')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
@ -1,238 +0,0 @@
|
|||
import fs from 'fs-extra'
|
||||
import test from 'ava'
|
||||
// import MarkdownIt from 'markdown-it'
|
||||
|
||||
import { isValidHttpUrl } from '~/helpers/check-types.js'
|
||||
import { buildReadmeAppList } from '~/helpers/build-app-list.js'
|
||||
import {
|
||||
matchesWholeWord,
|
||||
fuzzyMatchesWholeWord,
|
||||
eitherMatches
|
||||
} from '~/helpers/matching.js'
|
||||
import {
|
||||
PaginatedList
|
||||
} from '~/helpers/api/pagination.js'
|
||||
|
||||
|
||||
require('dotenv').config()
|
||||
|
||||
const allowedTitleCharacters = new Set( 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 -+:_.®/\()音乐体验版'.split('') )
|
||||
|
||||
// Detect Emojis(Extended Pictograph) in string
|
||||
// https://stackoverflow.com/a/64007175/1397641
|
||||
function hasEmoji ( string ) {
|
||||
return /\p{Extended_Pictographic}/u.test( string )
|
||||
}
|
||||
|
||||
test.before(async t => {
|
||||
const readmeFileContent = await fs.readFile('./README.md', 'utf-8')
|
||||
|
||||
|
||||
// Store sitemap urls to context
|
||||
t.context.readmeFileContent = readmeFileContent
|
||||
t.context.readmeAppList = buildReadmeAppList({
|
||||
readmeContent: t.context.readmeFileContent,
|
||||
scanListMap: new Map(),
|
||||
commits: []
|
||||
})
|
||||
})
|
||||
|
||||
test('README Apps are formated correctly', (t) => {
|
||||
// console.log('t.context.sitemapUrls', t.context.sitemapUrls)
|
||||
|
||||
const {
|
||||
readmeAppList
|
||||
} = t.context
|
||||
|
||||
// Store found apps so we can check for duplicates
|
||||
const foundApps = new Set()
|
||||
|
||||
// Store found invalid apps so we can count and report them
|
||||
const invalidApps = new Set()
|
||||
|
||||
|
||||
for (const readmeApp of readmeAppList) {
|
||||
const cleanedAppName = readmeApp.name//.toLowerCase()
|
||||
|
||||
// Check that app has not already been found
|
||||
if (foundApps.has(cleanedAppName)) {
|
||||
t.fail(`Duplicate app found: ${readmeApp.name}`)
|
||||
invalidApps.add(cleanedAppName)
|
||||
}
|
||||
// Store this app so we can check for future duplicates
|
||||
foundApps.add(cleanedAppName)
|
||||
|
||||
// Check that all related links urls are valid
|
||||
for (const relatedLink of readmeApp.relatedLinks) {
|
||||
if ( !isValidHttpUrl( relatedLink.href ) ) {
|
||||
t.log('relatedLink.href', readmeApp.name, relatedLink.href)
|
||||
|
||||
t.fail(`README App ${readmeApp.name} does not have valid url`, readmeApp.url)
|
||||
invalidApps.add(cleanedAppName)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check that status text is free of markdown
|
||||
if ( readmeApp.text.includes('](') ) {
|
||||
t.fail(`README App ${readmeApp.name} markdown in status text`)
|
||||
invalidApps.add(cleanedAppName)
|
||||
}
|
||||
|
||||
// Check that status has an emoji
|
||||
if ( hasEmoji( readmeApp.text ) === false ) {
|
||||
t.fail(`README App ${readmeApp.name} does not have emoji`)
|
||||
invalidApps.add(cleanedAppName)
|
||||
}
|
||||
|
||||
// Check for not allowed characters in app name
|
||||
for ( const character of cleanedAppName ) {
|
||||
if ( !allowedTitleCharacters.has( character ) ) {
|
||||
|
||||
// badCharacter = readmeApp.name[firstBadCharacterIndex]
|
||||
|
||||
// t.log( readmeApp )
|
||||
t.fail(`README App Title ${readmeApp.name} has non-alphanumeric character ${character}(charCode ${character.charCodeAt(0)})`)
|
||||
invalidApps.add(cleanedAppName)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
t.log( readmeAppList.length - invalidApps.size, 'valid apps found' )
|
||||
t.log( readmeAppList.length, 'apps found in README' )
|
||||
|
||||
t.pass()
|
||||
})
|
||||
|
||||
|
||||
function sortAppsAlphabetically ( a, b ) {
|
||||
return a.name.localeCompare(b.name)
|
||||
}
|
||||
|
||||
|
||||
test('README Apps are in alphbetical order', (t) => {
|
||||
|
||||
const {
|
||||
readmeAppList
|
||||
} = t.context
|
||||
|
||||
const appsByCategory = new Map()
|
||||
|
||||
|
||||
|
||||
// Group apps by category
|
||||
for ( const readmeApp of readmeAppList ) {
|
||||
const category = readmeApp.category.slug
|
||||
|
||||
if ( !appsByCategory.has(category) ) {
|
||||
appsByCategory.set(category, [])
|
||||
}
|
||||
|
||||
appsByCategory.get( category ).push(readmeApp)
|
||||
}
|
||||
|
||||
// Sort apps in groups alphabetically
|
||||
for ( const [ category, apps ] of appsByCategory ) {
|
||||
|
||||
const unsortedApps = apps.slice()
|
||||
|
||||
// Sort apps in category in place
|
||||
apps.sort(sortAppsAlphabetically)
|
||||
|
||||
// Check sorted sorted apps against unsorted apps
|
||||
for ( const [ index, unsortedApp ] of unsortedApps.entries() ) {
|
||||
const sortedApp = apps[index]
|
||||
|
||||
if ( sortedApp.slug !== unsortedApp.slug ) {
|
||||
t.fail(`README App at index ${index} of ${category} is ${unsortedApp.name} but should be ${sortedApp.name}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t.pass()
|
||||
})
|
||||
|
||||
|
||||
|
||||
const namesWithPlusses = [
|
||||
'Xournal++',
|
||||
'Notepad++'
|
||||
]
|
||||
|
||||
test('Can match names with pluses', (t) => {
|
||||
|
||||
|
||||
|
||||
// Sort apps in groups alphabetically
|
||||
for ( const nameWithPluses of namesWithPlusses ) {
|
||||
|
||||
const haystack = `FDKLS:KF ${nameWithPluses}NDFLSKFLSJDK`
|
||||
|
||||
t.assert( matchesWholeWord( nameWithPluses, haystack ) )
|
||||
|
||||
t.assert( fuzzyMatchesWholeWord( nameWithPluses, haystack ) )
|
||||
|
||||
t.assert( eitherMatches( nameWithPluses, haystack ) )
|
||||
t.assert( eitherMatches( haystack, nameWithPluses ) )
|
||||
}
|
||||
|
||||
t.pass()
|
||||
})
|
||||
|
||||
|
||||
test('Can paginate', async (t) => {
|
||||
const cases = [
|
||||
{
|
||||
from: {
|
||||
list: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ],
|
||||
perPage: 2
|
||||
},
|
||||
expect: {
|
||||
pageCount: 5,
|
||||
pages: [
|
||||
{
|
||||
number: 1,
|
||||
hasNextPage: true,
|
||||
hasPreviousPage: false,
|
||||
items: [1, 2],
|
||||
json: '[1,2]'
|
||||
},
|
||||
{
|
||||
number: 2,
|
||||
hasNextPage: true,
|
||||
hasPreviousPage: true,
|
||||
items: [3, 4],
|
||||
json: '[3,4]'
|
||||
},
|
||||
|
||||
// Last page should have less than perPage items
|
||||
{
|
||||
number: 5,
|
||||
hasNextPage: false,
|
||||
hasPreviousPage: true,
|
||||
items: [9],
|
||||
json: '[9]'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
for ( const { from, expect } of cases ) {
|
||||
|
||||
const paginatedList = new PaginatedList( from )
|
||||
|
||||
// Assert that page count is correct
|
||||
t.is( paginatedList.pageCount, expect.pageCount, 'pageCount is incorrect' )
|
||||
|
||||
// Assert that the pages we're expecting are there
|
||||
for ( const expectedPage of expect.pages ) {
|
||||
// Get respective output page
|
||||
const outputPage = paginatedList.pages[ expectedPage.number - 1 ]
|
||||
|
||||
t.deepEqual( outputPage, expectedPage, `Page ${ expectedPage.number } is an unexpected structure` )
|
||||
}
|
||||
}
|
||||
|
||||
} )
|
||||
172
test/prebuild/index.test.js
Normal file
172
test/prebuild/index.test.js
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
import fs from 'fs-extra'
|
||||
import { describe, it, expect, beforeAll } from 'vitest'
|
||||
import { isValidHttpUrl } from '~/helpers/check-types.js'
|
||||
import { buildReadmeAppList } from '~/helpers/build-app-list.js'
|
||||
import {
|
||||
matchesWholeWord,
|
||||
fuzzyMatchesWholeWord,
|
||||
eitherMatches
|
||||
} from '~/helpers/matching.js'
|
||||
import { PaginatedList } from '~/helpers/api/pagination.js'
|
||||
|
||||
require('dotenv').config()
|
||||
|
||||
const allowedTitleCharacters = new Set(
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 -+:_.®/\()音乐体验版'.split('')
|
||||
)
|
||||
|
||||
/**
|
||||
* Detect Emojis(Extended Pictograph) in string
|
||||
* https://stackoverflow.com/a/64007175/1397641
|
||||
*/
|
||||
function hasEmoji(string) {
|
||||
return /\p{Extended_Pictographic}/u.test(string)
|
||||
}
|
||||
|
||||
describe('README Validation', () => {
|
||||
let readmeFileContent
|
||||
let readmeAppList
|
||||
|
||||
beforeAll(async () => {
|
||||
readmeFileContent = await fs.readFile('./README.md', 'utf-8')
|
||||
readmeAppList = buildReadmeAppList({
|
||||
readmeContent: readmeFileContent,
|
||||
scanListMap: new Map(),
|
||||
commits: []
|
||||
})
|
||||
})
|
||||
|
||||
// User Story: As a maintainer, I want to ensure README apps are properly formatted
|
||||
describe('app formatting', () => {
|
||||
it('should have correctly formatted apps', () => {
|
||||
const foundApps = new Set()
|
||||
const invalidApps = new Set()
|
||||
|
||||
for (const readmeApp of readmeAppList) {
|
||||
const cleanedAppName = readmeApp.name
|
||||
|
||||
// Check for duplicates
|
||||
if (foundApps.has(cleanedAppName)) {
|
||||
expect.fail(`Duplicate app found: ${readmeApp.name}`)
|
||||
invalidApps.add(cleanedAppName)
|
||||
}
|
||||
foundApps.add(cleanedAppName)
|
||||
|
||||
// Validate related links
|
||||
for (const relatedLink of readmeApp.relatedLinks) {
|
||||
expect(isValidHttpUrl(relatedLink.href))
|
||||
.toBe(true, `README App ${readmeApp.name} has invalid URL: ${relatedLink.href}`)
|
||||
}
|
||||
|
||||
// Check status text formatting
|
||||
expect(readmeApp.text.includes(']('))
|
||||
.toBe(false, `README App ${readmeApp.name} has markdown in status text`)
|
||||
|
||||
// Verify emoji presence
|
||||
expect(hasEmoji(readmeApp.text))
|
||||
.toBe(true, `README App ${readmeApp.name} does not have emoji`)
|
||||
|
||||
// Validate app name characters
|
||||
for (const character of cleanedAppName) {
|
||||
expect(allowedTitleCharacters.has(character))
|
||||
.toBe(true, `README App Title ${readmeApp.name} has invalid character ${character}`)
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`${readmeAppList.length - invalidApps.size} valid apps found`)
|
||||
console.log(`${readmeAppList.length} total apps found in README`)
|
||||
})
|
||||
})
|
||||
|
||||
// User Story: As a maintainer, I want apps sorted alphabetically within categories
|
||||
describe('app sorting', () => {
|
||||
it('should have apps in alphabetical order within categories', () => {
|
||||
const appsByCategory = new Map()
|
||||
|
||||
// Group apps by category
|
||||
for (const readmeApp of readmeAppList) {
|
||||
const category = readmeApp.category.slug
|
||||
if (!appsByCategory.has(category)) {
|
||||
appsByCategory.set(category, [])
|
||||
}
|
||||
appsByCategory.get(category).push(readmeApp)
|
||||
}
|
||||
|
||||
// Verify sorting within categories
|
||||
for (const [category, apps] of appsByCategory) {
|
||||
const unsortedApps = [...apps]
|
||||
const sortedApps = [...apps].sort((a, b) => a.name.localeCompare(b.name))
|
||||
|
||||
sortedApps.forEach((sortedApp, index) => {
|
||||
expect(sortedApp.slug)
|
||||
.toBe(unsortedApps[index].slug,
|
||||
`App at index ${index} of ${category} is out of order`)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// User Story: As a developer, I want to ensure special characters in names are handled correctly
|
||||
describe('Name Matching', () => {
|
||||
const namesWithPlusses = ['Xournal++', 'Notepad++']
|
||||
|
||||
it('should match names containing plus symbols', () => {
|
||||
for (const nameWithPlusses of namesWithPlusses) {
|
||||
const haystack = `FDKLS:KF ${nameWithPlusses}NDFLSKFLSJDK`
|
||||
|
||||
expect(matchesWholeWord(nameWithPlusses, haystack)).toBe(true)
|
||||
expect(fuzzyMatchesWholeWord(nameWithPlusses, haystack)).toBe(true)
|
||||
expect(eitherMatches(nameWithPlusses, haystack)).toBe(true)
|
||||
expect(eitherMatches(haystack, nameWithPlusses)).toBe(true)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// User Story: As a developer, I want to ensure pagination works correctly
|
||||
describe('Pagination', () => {
|
||||
it('should paginate lists correctly', () => {
|
||||
const testCase = {
|
||||
list: [1, 2, 3, 4, 5, 6, 7, 8, 9],
|
||||
perPage: 2,
|
||||
expectedPageCount: 5,
|
||||
expectedPages: [
|
||||
{
|
||||
number: 1,
|
||||
hasNextPage: true,
|
||||
hasPreviousPage: false,
|
||||
items: [1, 2],
|
||||
json: '[1,2]'
|
||||
},
|
||||
{
|
||||
number: 2,
|
||||
hasNextPage: true,
|
||||
hasPreviousPage: true,
|
||||
items: [3, 4],
|
||||
json: '[3,4]'
|
||||
},
|
||||
{
|
||||
number: 5,
|
||||
hasNextPage: false,
|
||||
hasPreviousPage: true,
|
||||
items: [9],
|
||||
json: '[9]'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const paginatedList = new PaginatedList({
|
||||
list: testCase.list,
|
||||
perPage: testCase.perPage
|
||||
})
|
||||
|
||||
expect(paginatedList.pageCount)
|
||||
.toBe(testCase.expectedPageCount, 'Incorrect page count')
|
||||
|
||||
testCase.expectedPages.forEach(expectedPage => {
|
||||
const actualPage = paginatedList.pages[expectedPage.number - 1]
|
||||
expect(actualPage)
|
||||
.toEqual(expectedPage, `Page ${expectedPage.number} has unexpected structure`)
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue