Skip to content

Commit

Permalink
refactor: Move plugins site to this repositroy (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Oct 22, 2024
2 parents 3dd72c0 + a1c5c9d commit 9d40060
Show file tree
Hide file tree
Showing 116 changed files with 11,388 additions and 247 deletions.
3 changes: 3 additions & 0 deletions apps/swc-plugins/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.d.ts
/lib/generated
/components/ui
8 changes: 8 additions & 0 deletions apps/swc-plugins/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "next/core-web-vitals",
"rules": {
"@typescript-eslint/no-unused-vars": "off",
"@next/next/no-server-import-in-page": "off",
"@typescript-eslint/ban-types": "off"
}
}
39 changes: 39 additions & 0 deletions apps/swc-plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# scripts
.cache/
36 changes: 36 additions & 0 deletions apps/swc-plugins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
33 changes: 33 additions & 0 deletions apps/swc-plugins/app/(home)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Logo } from "@/components/logo";
import { RuntimeVersionSelector } from "@/components/runtime-version-selector";
import { Button } from "@/components/ui/button";
import { Metadata } from "next";
import Link from "next/link";
import { FC } from "react";

export const metadata: Metadata = {
title: "SWC Plugins",
description: "A collection of SWC plugins, ready to use in your project.",
};

const Home: FC = () => (
<main className="flex h-screen w-full flex-col items-center justify-center align-middle">
<div className="flex flex-col items-center gap-8">
<Logo />
<div className="flex flex-col gap-2">
<h1 className="max-w-[330px] text-center text-3xl font-bold leading-tight tracking-tighter md:min-w-[540px] md:text-4xl lg:leading-[1.1]">
SWC Plugins
</h1>
<p className="text-muted-foreground max-w-[750px] text-center text-lg">
A collection of SWC plugins, ready to use in your project.
</p>
</div>
<RuntimeVersionSelector />
<Button variant="link" asChild>
<Link href="/versions/range">or see all versions</Link>
</Button>
</div>
</main>
);

export default Home;
38 changes: 38 additions & 0 deletions apps/swc-plugins/app/api-client-provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use client";

import { apiClient } from "@/lib/trpc/web-client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { httpBatchLink } from "@trpc/client";
import { PropsWithChildren, useState } from "react";
import superjson from "superjson";

export function ApiClientProvider({ children }: PropsWithChildren<{}>) {
const [queryClient] = useState(
() =>
new QueryClient({
defaultOptions: {
queries: {
queryKeyHashFn: (queryKey) =>
superjson.stringify(queryKey),
},
},
})
);
const [trpcClient] = useState(() =>
apiClient.createClient({
links: [
httpBatchLink({
url: "/api/trpc",
transformer: superjson,
}),
],
})
);
return (
<apiClient.Provider client={trpcClient} queryClient={queryClient}>
<QueryClientProvider client={queryClient}>
{children}
</QueryClientProvider>
</apiClient.Provider>
);
}
2 changes: 2 additions & 0 deletions apps/swc-plugins/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { handlers } from "@/lib/auth";
export const { GET, POST } = handlers;
3 changes: 3 additions & 0 deletions apps/swc-plugins/app/api/trpc/[trpc]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { handler } from "@/lib/api/server";

export { handler as GET, handler as POST };
13 changes: 13 additions & 0 deletions apps/swc-plugins/app/api/update/runtimes/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { UpdateRuntimesInputSchema } from "@/lib/api/updater/router";
import { createCaller } from "@/lib/server";
import { NextRequest, NextResponse } from "next/server";

export const POST = async (req: NextRequest) => {
const body = UpdateRuntimesInputSchema.parse(await req.json());

const api = await createCaller();

await api.updater.updateRuntimes(body);

return NextResponse.json({ ok: true });
};
13 changes: 13 additions & 0 deletions apps/swc-plugins/app/api/update/wasm-plugins/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { UpdateWasmPluginsInputSchema } from "@/lib/api/updater/router";
import { createCaller } from "@/lib/server";
import { NextRequest, NextResponse } from "next/server";

export const POST = async (req: NextRequest) => {
const body = UpdateWasmPluginsInputSchema.parse(await req.json());

const api = await createCaller();

await api.updater.updateWasmPlugins(body);

return NextResponse.json({ ok: true });
};
13 changes: 13 additions & 0 deletions apps/swc-plugins/app/client-providers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use client";

import { ThemeProvider } from "next-themes";
import { PropsWithChildren } from "react";
import { ApiClientProvider } from "./api-client-provider";

export function ClientProviders({ children }: PropsWithChildren) {
return (
<ThemeProvider attribute="class">
<ApiClientProvider>{children}</ApiClientProvider>
</ThemeProvider>
);
}
Binary file added apps/swc-plugins/app/favicon.ico
Binary file not shown.
69 changes: 69 additions & 0 deletions apps/swc-plugins/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;
--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;
--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;
--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;
--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 222.2 84% 4.9%;
--radius: 0.5rem;
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;
}

.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;
--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;
--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;
--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 11.2%;
--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;
--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;
--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 212.7 26.8% 83.9%;
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
46 changes: 46 additions & 0 deletions apps/swc-plugins/app/import/ranges/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { db } from "@/lib/prisma";
import fs from "node:fs/promises";

export default async function Page() {
if (process.env.NODE_ENV === "production") {
return <div>Not allowed</div>;
}

const ranges: { min: string; max: string }[] = JSON.parse(
await fs.readFile("./data/ranges.json", "utf8")
);

for (const { min, max } of ranges) {
await db.compatRange.upsert({
where: {
from_to: {
from: min,
to: max,
},
},
update: {},
create: {
from: min,
to: max,
},
});
}

const runtimes = ["@swc/core", "next", "rspack", "farm"];

for (const runtime of runtimes) {
await db.swcRuntime.upsert({
where: {
name: runtime,
},
update: {},
create: {
name: runtime,
},
});
}

return <div>Done</div>;
}

export const dynamic = "force-dynamic";
Loading

0 comments on commit 9d40060

Please sign in to comment.