Skip to content

Commit 15657bd

Browse files
authored
chore: convert project to a pnpm workspace (#26)
1 parent d4a0040 commit 15657bd

33 files changed

+1011
-71
lines changed

.github/workflows/autofix.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/setup-node@v4
2020
with:
2121
node-version: 20
22-
cache: "pnpm"
22+
cache: pnpm
2323

2424
- name: 📦 Install dependencies
2525
run: pnpm install

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Note the URL under `Forwarding`. It should look something like `https://<GUID>.n
5858
- **GitHub App name**: Pick any name at all. I normally add `[dev]` at the end of any apps I'm using in development only.
5959
- **Homepage URL**: Doesn't matter; just pick a URL: `https://unsight.dev` would be fine.
6060
- **Setup URL**: `http://localhost:3000`. Tick the 'Redirect on update' checkbox underneath.
61-
- **Webhook URL**: Put the URL you got when starting ngrok, plus `/github/webhook`: `https://<GUID>.ngrok-free.app/github/webhook`. For the 'Secret' field underneath the URL, create a random GUID or password and make a note of it.
61+
- **Webhook URL**: Put the URL you got when starting ngrok, plus `/github/webhook`: `https://<GUID>.ngrok-free.app/github/webhook`. For the 'Secret' field underneath the URL, create a random GUID or password and make a note of it.
6262
- **Repository permissions**: Select 'Issues': 'Read-only'.
6363
- **Subscribe to events**: Select 'Installation target', 'Issues', 'Meta' and 'Repository'.
6464

app/composables/repos.ts

-5
This file was deleted.

eslint.config.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
// @ts-check
2-
import withNuxt from './.nuxt/eslint.config.mjs'
2+
import antfu from '@antfu/eslint-config'
3+
import withNuxt from './packages/web/.nuxt/eslint.config.mjs'
34

4-
export default withNuxt()
5+
export default withNuxt(antfu()).append(
6+
{
7+
rules: {
8+
'no-console': 'off',
9+
},
10+
},
11+
{
12+
files: ['**/*.yml'],
13+
rules: {
14+
'@stylistic/spaced-comment': 'off',
15+
},
16+
},
17+
)

package.json

+9-36
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,19 @@
11
{
2-
"name": "nuxt-app",
3-
"private": true,
2+
"name": "unsight-dev",
43
"type": "module",
4+
"private": true,
5+
"packageManager": "[email protected]",
56
"scripts": {
6-
"build": "nuxt build",
7-
"dev": "nuxt dev",
8-
"generate": "nuxt generate",
9-
"preview": "nuxt preview",
10-
"postinstall": "nuxt prepare && simple-git-hooks",
117
"lint": "eslint .",
12-
"test:types": "vue-tsc --noEmit"
13-
},
14-
"dependencies": {
15-
"@iconify-json/ri": "1.2.3",
16-
"@iconify-json/tabler": "1.2.11",
17-
"@nuxthub/core": "^0.8.7",
18-
"@nuxtjs/html-validator": "1.8.2",
19-
"@octokit/auth-app": "^7.1.3",
20-
"@octokit/rest": "^21.0.2",
21-
"@octokit/webhooks-types": "^7.6.1",
22-
"@unocss/nuxt": "^0.65.1",
23-
"@unocss/reset": "^0.65.1",
24-
"hex-rgb": "^5.0.0",
25-
"ml-distance": "^4.0.1",
26-
"ml-kmeans": "^6.0.0",
27-
"nuxt": "latest",
28-
"nuxt-time": "1.0.3",
29-
"nuxt-webhook-validators": "0.1.5",
30-
"ohash": "^1.1.4",
31-
"rgb-to-hsl": "^0.0.3",
32-
"universal-github-app-jwt": "^2.2.0",
33-
"unocss": "^0.65.1",
34-
"unplugin-vue-router": "^0.10.9"
8+
"test:types": "pnpm -r test:types",
9+
"postinstall": "simple-git-hooks"
3510
},
3611
"devDependencies": {
37-
"@nuxt/eslint": "0.7.3",
12+
"@antfu/eslint-config": "^3.12.0",
13+
"eslint": "^9.17.0",
3814
"lint-staged": "15.2.11",
3915
"simple-git-hooks": "2.11.1",
40-
"typescript": "5.6.3",
41-
"vue-tsc": "2.1.10",
42-
"wrangler": "3.95.0"
16+
"typescript": "~5.6"
4317
},
4418
"simple-git-hooks": {
4519
"pre-commit": "npx lint-staged"
@@ -48,6 +22,5 @@
4822
"*.{js,ts,mjs,cjs,json,.*rc}": [
4923
"npx eslint --fix"
5024
]
51-
},
52-
"packageManager": "[email protected]"
25+
}
5326
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

packages/web/app/composables/repos.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function useRepos() {
2+
return useFetch('/api/repos', {
3+
baseURL: useRuntimeConfig().public.remote,
4+
getCachedData: (key, nuxtApp) => nuxtApp.payload.data[key] || nuxtApp.static.data[key],
5+
default: () => [],
6+
})
7+
}
File renamed without changes.
File renamed without changes.

modules/local.ts packages/web/modules/local.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { defineNuxtModule, updateRuntimeConfig } from 'nuxt/kit'
1+
import process from 'node:process'
22
import consola from 'consola'
3+
import { defineNuxtModule, updateRuntimeConfig } from 'nuxt/kit'
34

45
export default defineNuxtModule({
56
meta: {

nuxt.config.ts packages/web/nuxt.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export default defineNuxtConfig({
6767
},
6868
eslint: {
6969
config: {
70+
standalone: false,
7071
stylistic: true,
7172
},
7273
},

packages/web/package.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "web",
3+
"type": "module",
4+
"private": true,
5+
"scripts": {
6+
"build": "nuxt build",
7+
"dev": "nuxt dev",
8+
"generate": "nuxt generate",
9+
"preview": "nuxt preview",
10+
"postinstall": "nuxt prepare",
11+
"test:types": "vue-tsc --noEmit"
12+
},
13+
"dependencies": {
14+
"@iconify-json/ri": "1.2.3",
15+
"@iconify-json/tabler": "1.2.11",
16+
"@nuxthub/core": "^0.8.7",
17+
"@nuxtjs/html-validator": "1.8.2",
18+
"@octokit/auth-app": "^7.1.3",
19+
"@octokit/rest": "^21.0.2",
20+
"@octokit/webhooks-types": "^7.6.1",
21+
"@unocss/nuxt": "^0.65.1",
22+
"@unocss/reset": "^0.65.1",
23+
"hex-rgb": "^5.0.0",
24+
"ml-distance": "^4.0.1",
25+
"ml-kmeans": "^6.0.0",
26+
"nuxt": "latest",
27+
"nuxt-time": "1.0.3",
28+
"nuxt-webhook-validators": "0.1.5",
29+
"ohash": "^1.1.4",
30+
"rgb-to-hsl": "^0.0.3",
31+
"universal-github-app-jwt": "^2.2.0",
32+
"unocss": "^0.65.1",
33+
"unplugin-vue-router": "^0.10.9"
34+
},
35+
"devDependencies": {
36+
"@nuxt/eslint": "0.7.3",
37+
"vue-tsc": "2.1.10",
38+
"wrangler": "3.95.0"
39+
}
40+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

server/api/similarity/[owner]/[repo]/[number].get.ts packages/web/server/api/similarity/[owner]/[repo]/[number].get.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { IssueMetadata } from '~~/server/utils/embeddings'
12
import { defineCachedCorsEventHandler } from '~~/server/utils/cached-cors'
23
import { storageKeyForIssue } from '~~/server/utils/embeddings'
3-
import type { IssueMetadata } from '~~/server/utils/embeddings'
44

55
export default defineCachedCorsEventHandler(async (event) => {
66
const { owner, repo, number } = getRouterParams(event)

server/routes/github/webhook.post.ts packages/web/server/routes/github/webhook.post.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type { H3Event } from 'h3'
33
import { createAppAuth } from '@octokit/auth-app'
44
import { Octokit } from '@octokit/rest'
55

6+
import { getMetadataForRepo, type InstallationRepo, removeMetadataForRepo, setMetadataForRepo } from '~~/server/utils/metadata'
67
import { indexIssue, removeIssue, storagePrefixForRepo } from '../../utils/embeddings'
7-
import { getMetadataForRepo, removeMetadataForRepo, setMetadataForRepo, type InstallationRepo } from '~~/server/utils/metadata'
88

99
export default defineEventHandler(async (event) => {
1010
const isValidWebhook = await isValidGithubWebhook(event)
@@ -82,7 +82,7 @@ async function addRepos(event: H3Event, installation: Installation | Installatio
8282

8383
event.waitUntil(Promise.all(repos.map((repo) => {
8484
if (repo.private) {
85-
return
85+
return undefined
8686
}
8787
const [owner, name] = repo.full_name.split('/')
8888
return setMetadataForRepo(owner!, name!, { ...repo, indexed: false })
@@ -120,8 +120,8 @@ export async function indexRepo(octokit: Octokit, repo: InstallationRepo) {
120120
for (const issue of response.data) {
121121
promises.push(indexIssue(issue, { owner: { login: owner! }, name: name! }))
122122
}
123-
if (parseInt(response.headers['x-ratelimit-remaining'] || '999') < 100) {
124-
console.info(parseInt(response.headers['x-ratelimit-remaining']!), 'requests remaining')
123+
if (Number.parseInt(response.headers['x-ratelimit-remaining'] || '999') < 100) {
124+
console.info(Number.parseInt(response.headers['x-ratelimit-remaining']!), 'requests remaining')
125125
}
126126
return []
127127
})

server/tasks/index-repo.ts packages/web/server/tasks/index-repo.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ export default defineTask({
1414
const indexed: string[] = []
1515
let count = 1
1616
for (const repo of repos) {
17-
if (repo.indexed) continue
17+
if (repo.indexed)
18+
continue
1819

1920
try {
2021
const [owner, name] = repo.repo.split('/')
2122
const meta = await getMetadataForRepo(owner!, name!)
22-
if (!meta) continue
23+
if (!meta)
24+
continue
2325

2426
await indexRepo(octokit, meta)
2527
indexed.push(repo.repo)

server/tasks/populate-vectorize.ts packages/web/server/tasks/populate-vectorize.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { defineTask } from 'nitropack/runtime'
21
import type { StoredEmbeddings } from '~~/server/utils/embeddings'
2+
import { defineTask } from 'nitropack/runtime'
33

44
export default defineTask({
55
meta: {
File renamed without changes.

server/utils/cluster.ts packages/web/server/utils/cluster.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { kmeans } from 'ml-kmeans'
21
import { similarity } from 'ml-distance'
2+
import { kmeans } from 'ml-kmeans'
33

44
export function clusterEmbeddings<T extends { number: number, title: string }>(issues: T[], embeddings: number[][]) {
55
for (let i = issues.length - 1; i >= 0; i--) {

server/utils/embeddings.ts packages/web/server/utils/embeddings.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { hash } from 'ohash'
2-
import type { Repository, Issue } from '@octokit/webhooks-types'
31
import type { RestEndpointMethodTypes } from '@octokit/rest'
2+
import type { Issue, Repository } from '@octokit/webhooks-types'
3+
import { hash } from 'ohash'
44

55
type RestIssue = RestEndpointMethodTypes['issues']['get']['response']['data']
66

@@ -97,7 +97,7 @@ export async function indexIssue(issue: Issue | RestIssue, repository: { owner:
9797
return embeddings
9898
}
9999

100-
export type IssueMetadata = {
100+
export interface IssueMetadata {
101101
owner: string
102102
repository: string
103103
number: number
@@ -107,7 +107,7 @@ export type IssueMetadata = {
107107
labels?: string[]
108108
}
109109

110-
export type StoredEmbeddings = {
110+
export interface StoredEmbeddings {
111111
mtime: number
112112
hash: string
113113
metadata: IssueMetadata

server/utils/metadata.ts packages/web/server/utils/metadata.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type InstallationRepo = {
1+
export interface InstallationRepo {
22
id: number
33
node_id: string
44
name: string
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"files": [],
32
"references": [
43
{
54
"path": "./.nuxt/tsconfig.json"
65
},
76
{
87
"path": "./.nuxt/tsconfig.server.json"
98
}
10-
]
9+
],
10+
"files": []
1111
}
File renamed without changes.

0 commit comments

Comments
 (0)