Skip to content

Commit

Permalink
Commit that solved the bind issue
Browse files Browse the repository at this point in the history
  • Loading branch information
xdotli committed Dec 3, 2023
1 parent 494e958 commit 98958ac
Show file tree
Hide file tree
Showing 23 changed files with 803 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/sum-pr/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
36 changes: 36 additions & 0 deletions examples/sum-pr/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 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
36 changes: 36 additions & 0 deletions examples/sum-pr/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.
16 changes: 16 additions & 0 deletions examples/sum-pr/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "app/globals.css",
"baseColor": "slate",
"cssVariables": true
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
4 changes: 4 additions & 0 deletions examples/sum-pr/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {}

module.exports = nextConfig
38 changes: 38 additions & 0 deletions examples/sum-pr/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "sum-pr",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-slot": "^1.0.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"lucide-react": "^0.294.0",
"next": "14.0.3",
"react": "^18",
"react-dom": "^18",
"tailwind-merge": "^2.1.0",
"tailwindcss-animate": "^1.0.7",
"@opensdks/core": "workspace:*",
"@opensdks/sdk-github": "workspace:*",
"@opensdks/sdk-openai": "workspace:*"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.0.3",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^5"
}
}
6 changes: 6 additions & 0 deletions examples/sum-pr/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
1 change: 1 addition & 0 deletions examples/sum-pr/public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/sum-pr/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/sum-pr/src/app/favicon.ico
Binary file not shown.
80 changes: 80 additions & 0 deletions examples/sum-pr/src/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
@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;
}

.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%;
}
}

.border-border {
border-color: hsl(var(--border));
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
22 changes: 22 additions & 0 deletions examples/sum-pr/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { Metadata } from 'next'

Check failure on line 1 in examples/sum-pr/src/app/layout.tsx

View workflow job for this annotation

GitHub Actions / Run type checks, lint, and tests

Cannot find module 'next' or its corresponding type declarations.
import { Inter } from 'next/font/google'

Check failure on line 2 in examples/sum-pr/src/app/layout.tsx

View workflow job for this annotation

GitHub Actions / Run type checks, lint, and tests

Cannot find module 'next/font/google' or its corresponding type declarations.
import './globals.css'

const inter = Inter({ subsets: ['latin'] })

export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
}

export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">

Check failure on line 18 in examples/sum-pr/src/app/layout.tsx

View workflow job for this annotation

GitHub Actions / Run type checks, lint, and tests

Cannot find module 'react/jsx-runtime' or its corresponding type declarations.
<body className={inter.className}>{children}</body>
</html>
)
}
124 changes: 124 additions & 0 deletions examples/sum-pr/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
'use client'

/**
* v0 by Vercel.
* @see https://v0.dev/t/yL79BMw9qDt
*/
import Link from 'next/link'

Check failure on line 7 in examples/sum-pr/src/app/page.tsx

View workflow job for this annotation

GitHub Actions / Run type checks, lint, and tests

'Link' is declared but its value is never read.

Check failure on line 7 in examples/sum-pr/src/app/page.tsx

View workflow job for this annotation

GitHub Actions / Run type checks, lint, and tests

Cannot find module 'next/link' or its corresponding type declarations.
import {ChangeEvent, useState} from 'react'

Check failure on line 8 in examples/sum-pr/src/app/page.tsx

View workflow job for this annotation

GitHub Actions / Run type checks, lint, and tests

Cannot find module 'react' or its corresponding type declarations.
import {initSDK} from '@opensdks/core'
import {githubSdkDef} from '@opensdks/sdk-github'

Check failure on line 10 in examples/sum-pr/src/app/page.tsx

View workflow job for this annotation

GitHub Actions / Run type checks, lint, and tests

Cannot find module '@opensdks/sdk-github' or its corresponding type declarations.
import {openaiSdkDef} from '@opensdks/sdk-openai'

Check failure on line 11 in examples/sum-pr/src/app/page.tsx

View workflow job for this annotation

GitHub Actions / Run type checks, lint, and tests

Cannot find module '@opensdks/sdk-openai' or its corresponding type declarations.
import CommitsList from '@/components/CommitsList'

Check failure on line 12 in examples/sum-pr/src/app/page.tsx

View workflow job for this annotation

GitHub Actions / Run type checks, lint, and tests

Cannot find module '@/components/CommitsList' or its corresponding type declarations.
// shadcn imports
import {Button} from '@/components/ui/button'

Check failure on line 14 in examples/sum-pr/src/app/page.tsx

View workflow job for this annotation

GitHub Actions / Run type checks, lint, and tests

Cannot find module '@/components/ui/button' or its corresponding type declarations.
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from '@/components/ui/card'
import {Input} from '@/components/ui/input'
import {Label} from '@/components/ui/label'

const apiKey = process.env['OPENAI_API_KEY']

export const github = initSDK(githubSdkDef, {
headers: {
Authorization: `Bearer ${process.env['GITHUB_TOKEN']}`,
'X-GitHub-Api-Version': '2022-11-28',
},
})

export const openai = initSDK(openaiSdkDef, {
// headers: {
// 'Content-Type': 'application/json',
// Authorization: `Bearer ${apiKey}`,
// },
})

export default function Component() {
const [prLink, setPrLink] = useState('')
const [commits, setCommits] = useState([])
const [summary, setSummary] = useState('')

const handlePRLinkChange = (event: ChangeEvent<HTMLInputElement>) => {
setPrLink(event.target.value)
}

const fetchCommits = async () => {
const prUrl = new URL(prLink)
const pathParts = prUrl.pathname.split('/') // Splitting the pathname to extract owner, repo, and PR number
const owner = pathParts[1]
const repo = pathParts[2]
const prNumber = pathParts[4]
// "/repos/{owner}/{repo}/pulls/{pull_number}/comments"
try {
const response = await github.GET(
'/repos/{owner}/{repo}/pulls/{pull_number}/commits',
{
params: {
path: {owner, repo, pull_number: Number(prNumber)},
},
},
)
setCommits(response.data as never)
} catch (err) {
console.error('Error fetching commits:', err)
}
}

return (
<div className="flex flex-col w-full min-h-screen p-10">
<div className="max-w-3xl mx-auto">
<h1 className="text-3xl font-bold mb-6">GitHub PR Summary</h1>
<p className="text-gray-500 dark:text-gray-400 mb-6">
Enter a GitHub PR link to view a summary of the commits.
</p>
<div className="space-y-4">
<div className="space-y-2">
<Label htmlFor="pr-link">Pull Request Link</Label>
<Input
id="pr-link"
placeholder="https://github.com/user/repo/pull/123"
value={prLink}
onChange={handlePRLinkChange}
required
/>
</div>
<Button
className="w-full bg-primary text-primary-foreground hover:bg-primary/90"
type="submit"
onClick={fetchCommits}>
Analyze
</Button>
</div>
<Card className="mt-8">
<CardHeader>
<CardTitle className="text-xl">Summarized Commits</CardTitle>
<CardDescription>
A brief summary of all commits generated by OpenAI
</CardDescription>
</CardHeader>
<CardContent>
<p className="text-gray-500 dark:text-gray-400 text-sm">
OpenAI generated commit summary goes here...
</p>
</CardContent>
</Card>
<Card className="mt-8">
<CardHeader>
<CardTitle className="text-xl">Commits Summary</CardTitle>
<CardDescription>
List of commits for the provided GitHub PR
</CardDescription>
</CardHeader>
<CardContent>
<CommitsList commits={commits} />
</CardContent>
</Card>
</div>
</div>
)
}
Loading

1 comment on commit 98958ac

@vercel
Copy link

@vercel vercel bot commented on 98958ac Dec 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

opensdks – ./

opensdks-git-main-venice.vercel.app
opensdks-venice.vercel.app
opensdks.org
opensdks.vercel.app

Please sign in to comment.