diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5fb2562..a523113 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Deploy tweaks to GitHub Pages +name: Deploy App to GitHub Pages on: push: @@ -31,10 +31,6 @@ jobs: bun-version: latest - run: bun ci - - - name: Validate Tweaks - run: bun test - - run: bun run build - name: Setup Pages diff --git a/.gitignore b/.gitignore index c09d625..71e9ea6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,3 @@ node_modules/ -tweaks/schema.json -tweaks/tweaks.json -tweaks/*.md -# Ignore any sub directories under tweaks -tweaks/*/ dist/ *.py diff --git a/src/index.tsx b/src/index.tsx index 66e369c..ff09da9 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -13,11 +13,11 @@ const router = createHashRouter([ children: [ { path: '/', - lazy: () => import('./pages/Dashboard'), + lazy: () => import('./pages/DashboardPage'), }, { - path: '/tweaks/:id', - lazy: () => import('./pages/Tweak'), + path: '/apps/:id', + lazy: () => import('./pages/AppPage'), }, ], }, diff --git a/src/pages/Tweak.tsx b/src/pages/AppPage.tsx similarity index 82% rename from src/pages/Tweak.tsx rename to src/pages/AppPage.tsx index 8f2a9e4..4160229 100644 --- a/src/pages/Tweak.tsx +++ b/src/pages/AppPage.tsx @@ -1,13 +1,12 @@ -import type { Tweak } from '@/types'; import { type FC } from 'react'; import type { LoaderFunctionArgs } from 'react-router-dom'; -import { fetch } from '../utils/fetch'; import { useLoaderData } from '@rain-cafe/react-utils/react-router'; import { AppImage } from '../components/AppImage'; import { Label } from '../components/Label'; import { Pill } from '../components/Pill'; import { Card } from '../components/Card'; import { Code } from '../components/Code'; +import { getApp } from '@/service/protontweaks'; const ALIASES: Record = { esync: 'PROTON_NO_ESYNC', @@ -15,26 +14,28 @@ const ALIASES: Record = { }; export async function loader({ params }: LoaderFunctionArgs) { - return await fetch(`https://api.protontweaks.com/v2/${params.id}.json`); + if (!params.id) throw new Error('No app id available.'); + + return await getApp(params.id); } export const Component: FC = () => { - const tweak = useLoaderData(); - const environmentVariables = Object.entries(tweak.tweaks.env); - const settings = Object.entries(tweak.tweaks.settings); + const app = useLoaderData(); + const environmentVariables = Object.entries(app.tweaks.env); + const settings = Object.entries(app.tweaks.settings); return ( <>
- +
- {tweak.name} ({tweak.id}) + {app.name} ({app.id})
diff --git a/src/pages/Dashboard.tsx b/src/pages/DashboardPage.tsx similarity index 56% rename from src/pages/Dashboard.tsx rename to src/pages/DashboardPage.tsx index 930aee6..60d0b8b 100644 --- a/src/pages/Dashboard.tsx +++ b/src/pages/DashboardPage.tsx @@ -1,22 +1,19 @@ import { type FC, useMemo, useEffect } from 'react'; -import { fetch } from '../utils/fetch'; -import type { Tweaks } from '@/types'; import { useLoaderData } from '@rain-cafe/react-utils/react-router'; import { useSearch } from '../context/search'; import { AppImage } from '../components/AppImage'; +import { getApps } from '@/service/protontweaks'; export async function loader() { - return { - tweaks: await fetch('https://api.protontweaks.com/v2/tweaks.json'), - }; + return await getApps(); } export const Component: FC = () => { - const { tweaks } = useLoaderData(); + const apps = useLoaderData(); const search = useSearch(); - const filteredTweaks = useMemo(() => { - return tweaks.tweaks.filter((tweak) => tweak.name.toLowerCase().includes(search.toLowerCase())); - }, [tweaks, search]); + const filteredApps = useMemo(() => { + return apps.filter((app) => app.name.toLowerCase().includes(search.toLowerCase())); + }, [apps, search]); useEffect(() => { const listener = () => {}; @@ -31,8 +28,8 @@ export const Component: FC = () => { return (
- {filteredTweaks?.map((tweak) => ( - + {filteredApps?.map((app) => ( + ))}
); diff --git a/src/service/protontweaks.ts b/src/service/protontweaks.ts new file mode 100644 index 0000000..8de6e96 --- /dev/null +++ b/src/service/protontweaks.ts @@ -0,0 +1,16 @@ +import type { App, AppsList } from '@/types'; +import { fetch } from '@/utils/fetch'; + +export async function getAppsList() { + return await fetch('https://api.protontweaks.com/v3/apps.json'); +} + +export async function getApps() { + const appsList = await getAppsList(); + + return appsList.apps; +} + +export async function getApp(id: string) { + return await fetch(`https://api.protontweaks.com/v3/${id}.json`); +} diff --git a/src/types/tweaks.ts b/src/types/apps.ts similarity index 77% rename from src/types/tweaks.ts rename to src/types/apps.ts index 28bd600..2f7349b 100644 --- a/src/types/tweaks.ts +++ b/src/types/apps.ts @@ -1,10 +1,10 @@ -export type Tweaks = { +export type AppsList = { sha: string; short_sha: string; - tweaks: Pick[]; + apps: Pick[]; }; -export type Tweak = { +export type App = { id: string; name: string; tweaks: { diff --git a/src/types/index.ts b/src/types/index.ts index 521df74..dccfd19 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1 +1 @@ -export * from './tweaks'; +export * from './apps';