Skip to content

Commit

Permalink
feat: shadcn registry site (#1082)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Oct 26, 2024
1 parent b7a24df commit b61e6a5
Show file tree
Hide file tree
Showing 39 changed files with 260 additions and 128 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/changeset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ jobs:
version:
runs-on: ubuntu-latest
steps:
- name: checkout code repository
- name: Checkout code repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: setup node.js
- name: Setup node.js
uses: actions/setup-node@v4
with:
node-version: 20
Expand All @@ -40,10 +40,10 @@ jobs:
restore-keys: |
${{ runner.os }}-turbo-
- name: install dependencies
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: create and publish versions
- name: Create and publish versions
uses: changesets/action@v1
with:
commit: "chore: update versions"
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/registry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Deploy Shadcn Registry
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_REGISTRY_PROJECT_ID }}
on:
push:
branches:
- main
paths:
- apps/registry/**

jobs:
Deploy-Production:
runs-on: ubuntu-latest
steps:
- name: Checkout code repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Setup node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"

- name: Install Vercel CLI
run: npm install --global vercel@latest

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Pull Vercel Environment Information
working-directory: apps/registry
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
working-directory: apps/registry
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
working-directory: apps/registry
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ out/
# production
build
dist
apps/docs/public/b/
apps/shadcn-registry/dist/
generated

# turbo
Expand Down
3 changes: 1 addition & 2 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"version": "0.0.0",
"private": true,
"scripts": {
"build": "pnpm run build:registry && pnpm build:docs && next build",
"build": "pnpm build:docs && next build",
"build:docs": "tsx ./scripts/generate-docs.mts",
"build:registry": "pnpm --filter @assistant-ui/shadcn-registry run build:registry",
"dev": "next dev --turbo",
"start": "next start",
"lint": "next lint"
Expand Down
17 changes: 17 additions & 0 deletions apps/docs/public/b/assistant-ui.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "assistant-ui",
"type": "registry:component",
"registryDependencies": [],
"tailwind": {
"config": {
"plugins": [
"require(\"tailwindcss-animate\")",
"require(\"@assistant-ui/react/tailwindcss\")({ shadcn: true })"
]
}
},
"dependencies": [
"tailwindcss-animate",
"@assistant-ui/react"
]
}
16 changes: 16 additions & 0 deletions apps/docs/public/b/chat/quick-start.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "chat/quick-start",
"type": "registry:block",
"files": [
{
"content": "\"use client\";\n\nimport { useEdgeRuntime, Thread } from \"@assistant-ui/react\";\n\nexport const MyAssistant = () => {\n const runtime = useEdgeRuntime({\n api: \"/api/chat\",\n });\n\n return <Thread runtime={runtime} />;\n};\n",
"type": "registry:component",
"path": "components/assistant-ui/thread.tsx"
}
],
"registryDependencies": [
"https://assistant-ui.com/r/assistant-ui",
"https://assistant-ui.com/r/markdown",
"https://assistant-ui.com/r/edge-backend"
]
}
17 changes: 17 additions & 0 deletions apps/docs/public/b/edge-backend.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "edge-backend",
"type": "registry:block",
"files": [
{
"content": "import { openai } from \"@ai-sdk/openai\";\nimport { getEdgeRuntimeResponse } from \"@assistant-ui/react/edge\";\n\nexport const maxDuration = 30;\n\nexport const POST = async (request: Request) => {\n const requestData = await request.json();\n\n return getEdgeRuntimeResponse({\n options: {\n model: openai(\"gpt-4o\"),\n },\n requestData,\n abortSignal: request.signal,\n });\n};\n",
"type": "registry:page",
"path": "routes/api/chat/route.ts"
}
],
"registryDependencies": [
"https://assistant-ui.com/r/assistant-ui"
],
"dependencies": [
"@ai-sdk/openai"
]
}
17 changes: 17 additions & 0 deletions apps/docs/public/b/markdown.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "markdown",
"type": "registry:component",
"registryDependencies": [
"https://assistant-ui.com/r/assistant-ui"
],
"tailwind": {
"config": {
"plugins": [
"require(\"@assistant-ui/react-markdown/tailwindcss\")"
]
}
},
"dependencies": [
"@assistant-ui/react-markdown"
]
}
File renamed without changes.
1 change: 1 addition & 0 deletions apps/registry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vercel
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@assistant-ui/shadcn-registry",
"version": "0.0.2",
"version": "0.0.1",
"private": true,
"license": "MIT",
"type": "module",
Expand Down Expand Up @@ -37,6 +37,6 @@
"zod": "^3.23.8"
},
"scripts": {
"build:registry": "tsx ./scripts/build-registry.ts"
"build": "tsx ./scripts/build-registry.ts"
}
}
19 changes: 19 additions & 0 deletions apps/registry/registry/components/assistant-ui/thread.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use client";

import { useEdgeRuntime, Thread } from "@assistant-ui/react";
import { makeMarkdownText } from "@assistant-ui/react-markdown";

const MarkdownText = makeMarkdownText();

export const MyAssistant = () => {
const runtime = useEdgeRuntime({
api: "/api/chat",
});

return (
<Thread
runtime={runtime}
assistantMessage={{ components: { Text: MarkdownText } }}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,25 @@ export const registry: RegistryItem[] = [
{
name: "markdown",
type: "registry:component",
registryDependencies: ["https://assistant-ui.com/r/assistant-ui"],
registryDependencies: ["https://r.assistant-ui.com/assistant-ui"],
tailwind: {
config: {
plugins: [`require("@assistant-ui/react-markdown/tailwindcss")`],
},
},
dependencies: ["@assistant-ui/react-markdown"],
},
{
name: "trieve",
type: "registry:component",
registryDependencies: ["https://r.assistant-ui.com/assistant-ui"],
tailwind: {
config: {
plugins: [`require("@assistant-ui/react-trieve/tailwindcss")`],
},
},
dependencies: ["@assistant-ui/react-trieve"],
},
{
name: "edge-backend",
type: "registry:block",
Expand All @@ -35,11 +46,11 @@ export const registry: RegistryItem[] = [
path: "routes/api/chat/route.ts",
},
],
registryDependencies: ["https://assistant-ui.com/r/assistant-ui"],
registryDependencies: ["https://r.assistant-ui.com/assistant-ui"],
dependencies: ["@ai-sdk/openai"],
},
{
name: "chat/quick-start",
name: "quick-start",
type: "registry:block",
files: [
{
Expand All @@ -48,9 +59,9 @@ export const registry: RegistryItem[] = [
},
],
registryDependencies: [
"https://assistant-ui.com/r/assistant-ui",
"https://assistant-ui.com/r/markdown",
"https://assistant-ui.com/r/edge-backend",
"https://r.assistant-ui.com/assistant-ui",
"https://r.assistant-ui.com/markdown",
"https://r.assistant-ui.com/edge-backend",
],
},
];
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { promises as fs, readFileSync } from "node:fs";
import path from "node:path";
import * as path from "node:path";
import { registry } from "../registry/registry";
import { RegistryItem } from "@/registry/schema";

const REGISTRY_PATH = path.join(process.cwd(), "../../apps/docs/public/b");
const REGISTRY_PATH = path.join(process.cwd(), "dist");

async function buildRegistry(registry: RegistryItem[]) {
await fs.mkdir(REGISTRY_PATH, { recursive: true });
Expand Down
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions apps/registry/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"rewrites": [
{
"source": "/:name",
"destination": "/:name.json"
}
],
"outputDirectory": "dist"
}
7 changes: 0 additions & 7 deletions packages/shadcn-registry/CHANGELOG.md

This file was deleted.

This file was deleted.

Loading

0 comments on commit b61e6a5

Please sign in to comment.