') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); GitHub - UseTrey/trey: npm install 전에 미리 써보는 오픈소스 플레이그라운드 | Open source playground try before npm install · GitHub
Skip to content

Repository files navigation

Trey

CI

Open Source Library Comparison & Discovery Platform

🇰🇷 한국어

📦 Development Environment Setup

This project uses mise to manage development tool versions.

Install mise (one-time setup)

curl https://mise.run | sh
echo'eval "$(~/.local/bin/mise activate zsh)"'>>~/.zshrc

Project Setup

# Navigate to project folder (tool versions are applied automatically)cd trey
# Install tools (one-time setup)
mise install
# Check currently active tools
mise current

Tool Versions

ToolVersion
Node.js20
Bunlatest

🔐 Environment Variables

Copy .env.example to .env and configure the required values:

cp .env.example .env
VariableRequiredDescription
NEXT_PUBLIC_SUPABASE_URLSupabase project URL
NEXT_PUBLIC_SUPABASE_ANON_KEYSupabase anonymous key
SUPABASE_SERVICE_ROLE_KEYSupabase service role key (for admin operations)
GITHUB_TOKENGitHub API token (increases rate limit to 5000/hr)
ANTHROPIC_API_KEYAnthropic API key for Claude AI content generation

⚡ Required for production deployment and AI features

🚀 Getting Started

# Install dependencies
bun install
# Start development server
mise run dev
# or
bun run dev

📋 Available Commands

CommandDescription
mise run devStart development server
mise run buildProduction build
mise run testRun tests
mise run lintLint check
mise run formatCode formatting
mise run typecheckTypeScript type check
mise run checkLint + format combined check
mise run validateFull validation (typecheck + lint + test)

💡 All commands can also be run using bun run <script> format.

🪝 Git Hooks

This project uses Husky and lint-staged for automatic code quality checks.

Pre-commit

Automatically runs lint and format checks on staged files:

  • *.ts, *.tsx, *.js, *.jsx → Biome lint + format check with auto-fix
  • *.json, *.css, *.md → Biome format check with auto-fix

Pre-push

Runs full project validation before push:

  1. TypeScript type check
  2. Lint check
  3. Test execution

Push is blocked if any check fails.

🔄 CI/CD

GitHub Actions automatically runs CI pipeline on push or PR to main, dev, epic/** branches.

🔍 Lint & Format ──┐
📘 TypeScript ──┼──→ 🏗️ Build
🧪 Test ──┘
JobDescription
Lint & FormatBiome lint/format check
TypeScriptType check (tsc --noEmit)
TestVitest test execution
BuildProduction build after all checks pass

Workflow file: .github/workflows/ci.yml

Trust Metrics Sync (Cron Job)

GitHub Actions automatically syncs trust metrics (GitHub stars, npm downloads) daily at 00:00 UTC (09:00 KST).

Required GitHub Secrets:

SecretDescription
SITE_URLProduction site URL (e.g., https://your-site.netlify.app)
CRON_SECRETSecret key for API authentication

You can also trigger the sync manually from the Actions tab.

Workflow file: .github/workflows/sync-metrics.yml

Library Auto-Discovery (Weekly)

GitHub Actions automatically discovers new popular libraries weekly (Mondays at 09:00 UTC / 18:00 KST).

Scripts:

# Discover new libraries (dry-run mode)
bun run scripts/discover-libraries.ts --dry-run
# Discover and save to database
bun run scripts/discover-libraries.ts --limit 30

Options:

FlagDescription
--dry-runPreview results without saving to DB
--github-onlySearch only GitHub
--npm-onlySearch only npm
--limit NMaximum number of libraries (default: 30)
--min-stars NMinimum GitHub stars (default: 5000)

Workflow file: .github/workflows/discover-libraries.yml

AI Content Generation (Manual/Webhook)

Generate AI-powered content summaries and playground code using Claude AI.

Scripts:

# Generate content for specific library
bun run scripts/generate-content.ts framer-motion
# Generate content for all libraries
bun run scripts/generate-content.ts --all
# Generate playground code
bun run scripts/generate-playground.ts --all
# Force regenerate (overwrites existing)
bun run scripts/generate-content.ts --all --force

AI Models Used:

TaskModelPurpose
Content (Summary, Pros/Cons)Claude 4.5 SonnetBalanced quality/cost
Playground CodeClaude 4.5 OpusBest coding performance
Classification/TaggingClaude 4.5 HaikuFast, low cost

Workflow file: .github/workflows/generate-content.yml

🏗️ Building For Production

mise run build
# or
bun run build

🧪 Testing

This project uses Vitest.

mise run test# or
bun run test

🎨 Styling

This project uses Tailwind CSS for styling.

🛣️ Routing

This project uses TanStack Router. The initial setup is a file based router, which means routes are managed as files in src/routes.

Adding A Route

To add a new route to your application, just add a new file in the ./src/routes directory.

TanStack will automatically generate the content of the route file for you.

Now that you have two routes you can use a Link component to navigate between them.

Adding Links

To use SPA (Single Page Application) navigation, import the Link component from @tanstack/react-router.

import{Link}from"@tanstack/react-router";

Then anywhere in your JSX you can use it like so:

<Linkto="/about">About</Link>

This will create a link that will navigate to the /about route.

More information on the Link component can be found in the Link documentation.

Using A Layout

In the File Based Routing setup, the layout is located in src/routes/__root.tsx. Anything you add to the root route will appear in all routes. The route content will appear in the JSX where you use the <Outlet /> component.

Here is an example layout that includes a header:

import{Outlet,createRootRoute}from"@tanstack/react-router";import{TanStackRouterDevtools}from"@tanstack/react-router-devtools";import{Link}from"@tanstack/react-router";exportconstRoute=createRootRoute({component: ()=>(<><header><nav><Linkto="/">Home</Link><Linkto="/about">About</Link></nav></header><Outlet/><TanStackRouterDevtools/></>),});

The <TanStackRouterDevtools /> component is not required, so you can remove it if you don't want it in your layout.

More information on layouts can be found in the Layouts documentation.

📡 Data Fetching

There are multiple ways to fetch data in your application. You can use TanStack Query to fetch data from a server. But you can also use the loader functionality built into TanStack Router to load the data for a route before it's rendered.

For example:

constpeopleRoute=createRoute({getParentRoute: ()=>rootRoute,path: "/people",loader: async()=>{constresponse=awaitfetch("https://swapi.dev/api/people");returnresponse.json()asPromise<{results: {name: string;}[];}>;},component: ()=>{constdata=peopleRoute.useLoaderData();return(<ul>{data.results.map((person)=>(<likey={person.name}>{person.name}</li>))}</ul>);},});

Loaders simplify your data fetching logic dramatically. Check out more information in the Loader documentation.

React-Query

React-Query is an excellent addition or alternative to route loading and integrating it into your application is a breeze.

First add your dependencies:

bun install @tanstack/react-query @tanstack/react-query-devtools

Next, create a query client and provider. We recommend putting those in main.tsx.

import{QueryClient,QueryClientProvider}from"@tanstack/react-query";// ...constqueryClient=newQueryClient();// ...if(!rootElement.innerHTML){constroot=ReactDOM.createRoot(rootElement);root.render(<QueryClientProviderclient={queryClient}><RouterProviderrouter={router}/></QueryClientProvider>);}

You can also add TanStack Query Devtools to the root route (optional).

import{ReactQueryDevtools}from"@tanstack/react-query-devtools";constrootRoute=createRootRoute({component: ()=>(<><Outlet/><ReactQueryDevtoolsbuttonPosition="top-right"/><TanStackRouterDevtools/></>),});

Now you can use useQuery to fetch your data.

import{useQuery}from"@tanstack/react-query";import"./App.css";functionApp(){const{ data }=useQuery({queryKey: ["people"],queryFn: ()=>fetch("https://swapi.dev/api/people").then((res)=>res.json()).then((data)=>data.resultsas{name: string}[]),initialData: [],});return(<div><ul>{data.map((person)=>(<likey={person.name}>{person.name}</li>))}</ul></div>);}exportdefaultApp;

You can find out everything you need to know on how to use React-Query in the React-Query documentation.

🗃️ State Management

Another common requirement for React applications is state management. There are many options for state management in React. TanStack Store provides a great starting point for your project.

First you need to add TanStack Store as a dependency:

bun install @tanstack/store

Now let's create a simple counter in the src/App.tsx file as a demonstration.

import{useStore}from"@tanstack/react-store";import{Store}from"@tanstack/store";import"./App.css";constcountStore=newStore(0);functionApp(){constcount=useStore(countStore);return(<div><buttononClick={()=>countStore.setState((n)=>n+1)}>
Increment - {count}</button></div>);}exportdefaultApp;

One of the many nice features of TanStack Store is the ability to derive state from other state. That derived state will update when the base state updates.

Let's check this out by doubling the count using derived state.

import{useStore}from"@tanstack/react-store";import{Store,Derived}from"@tanstack/store";import"./App.css";constcountStore=newStore(0);constdoubledStore=newDerived({fn: ()=>countStore.state*2,deps: [countStore],});doubledStore.mount();functionApp(){constcount=useStore(countStore);constdoubledCount=useStore(doubledStore);return(<div><buttononClick={()=>countStore.setState((n)=>n+1)}>
Increment - {count}</button><div>Doubled - {doubledCount}</div></div>);}exportdefaultApp;

We use the Derived class to create a new store that is derived from another store. The Derived class has a mount method that will start the derived store updating.

Once we've created the derived store we can use it in the App component just like we would any other store using the useStore hook.

You can find out everything you need to know on how to use TanStack Store in the TanStack Store documentation.

📁 Demo Files

Files prefixed with demo can be safely deleted. They are there to provide a starting point for you to play around with the features you've installed.

📚 Learn More

You can learn more about all of the offerings from TanStack in the TanStack documentation.

About

npm install 전에 미리 써보는 오픈소스 플레이그라운드 | Open source playground try before npm install

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages