Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"dependencies": {
"@ai-sdk/gateway": "^4.0.116",
"@ai-sdk/vue": "^4.0.143",
"@comark/nuxt": "^0.7.0",
"@comark/nuxt": "^0.8.1",
"@iconify-json/logos": "^1.2.16",
"@iconify-json/lucide": "^1.2.145",
"@iconify-json/simple-icons": "^1.2.100",
Expand All @@ -68,10 +68,11 @@
"@vueuse/core": "^15.0.0",
"ai": "^7.0.143",
"beautiful-mermaid": "^1.1.3",
"comark": "^0.7.0",
"comark-content": "^0.4.1",
"comark": "^0.8.1",
"comark-content": "https://pkg.pr.new/comark-content@71b7837",
"defu": "^6.1.7",
"exsolve": "^1.1.3",
"forges": "https://pkg.pr.new/forges@1aba0ce",
"js-yaml": "^5.5.0",
"motion-v": "^2.8.0",
"nuxt-agent-discovery": "^0.7.1",
Expand Down
209 changes: 112 additions & 97 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

13 changes: 3 additions & 10 deletions server/api/code-explorer/[...path].get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { resolve } from 'node:path'
import { parseMarkdown, type MarkdownDocument } from 'comark'
import rangi from 'comark/plugins/rangi'
import fs from 'comark-content/sources/fs'
import github from 'comark-content/sources/github'
import forge from 'comark-content/sources/forge'
import { geistTheme } from '../../../utils/geist.ts'

// A read source for one example directory. Dev: working tree. Prod: authenticated GitHub — the repo may be
// private, so jsDelivr / unauthenticated raw are out. Mirrors {@link contentSource}'s dev/prod split.
// private, so the provider carries the token. Mirrors {@link contentSource}'s dev/prod split.
function exampleSource(repo: string, branch: string, dirPath: string) {
const { docs } = useRuntimeConfig()

Expand All @@ -15,14 +15,7 @@ function exampleSource(repo: string, branch: string, dirPath: string) {
return fs(resolve(docs.repoRoot, dirPath))
}

return github({
repo,
branch,
path: dirPath,
token: githubToken(),
// `branch` is typically an immutable commit SHA => cache hard.
ttl: 60 * 60 * 24,
})
return forge({ provider: githubProvider(), repo, ref: branch, path: dirPath })
}

const CONCURRENCY = 10
Expand Down
10 changes: 4 additions & 6 deletions server/utils/content.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type ContentSource, DEFAULT_CONTENT_NAME } from 'comark-content'
import fs from 'comark-content/sources/fs'
import github from 'comark-content/sources/github'
import forge from 'comark-content/sources/forge'
import { withSnapshot } from 'comark-content/sources/snapshot'
import { createRuntimeContentInstance } from '../../utils/factory.ts'

Expand Down Expand Up @@ -151,13 +151,11 @@ function contentSource(): ContentSource {
}
}

const source = github({
const source = forge({
provider: githubProvider(),
repo: githubRepo(),
branch: targetBranch(),
ref: targetBranch(),
path: docs.contentDir,
token: githubToken(),
// Reads happen through `withRef(<sha>)`, an immutable commit => cache hard.
ttl: 60 * 60 * 24,
})

// Snaphot build during build time by `modules/snapshot/` is used.
Expand Down
7 changes: 7 additions & 0 deletions server/utils/github.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createHash, timingSafeEqual } from 'node:crypto'
import { createStorage } from 'unstorage'
import { github } from 'forges/github'
import { fetchLastContentCommit } from '../../utils/github'

export interface GitHubCommit {
Expand Down Expand Up @@ -41,6 +42,12 @@ export function githubToken(): string | undefined {
return docs.githubToken || process.env.GITHUB_TOKEN || undefined
}

/** A forges GitHub provider, authenticated with {@link githubToken} when one is set. */
export function githubProvider() {
const token = githubToken()
return github(token ? { auth: { type: 'token', token } } : {})
}

/** Production branch, resolved per request: content pushes skip redeploys (`vercel.json` `ignoreCommand`). */
export function targetBranch(): string {
return process.env.VERCEL_GIT_COMMIT_REF || useRuntimeConfig().docs.github.branch || 'main'
Expand Down
4 changes: 2 additions & 2 deletions test/content-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { describe, expect, it } from 'vitest'
import { comarkContent, DEFAULT_CONTENT_NAME, readArtifact } from 'comark-content'
import { writeSnapshots } from 'comark-content/build'
import fsSource from 'comark-content/sources/fs'
import githubSource from 'comark-content/sources/github'
import forgeSource from 'comark-content/sources/forge'
import snapshot, { withSnapshot } from 'comark-content/sources/snapshot'
import { createContentClient } from 'comark-content/client'
import { comarkContent as runtimeComarkContent, DEFAULT_CONTENT_NAME as RUNTIME_CONTENT_NAME, readArtifact as runtimeReadArtifact } from 'comark-content/runtime'
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('comark-content contract', () => {
comarkContent,
readArtifact,
fsSource,
githubSource,
forgeSource,
createContentClient,
runtimeComarkContent,
runtimeReadArtifact,
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/consumer/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ minimumReleaseAgeExclude:
- comark
- comark-content
- nuxt-agent-discovery

# TEMPORARY: the layer depends on pkg.pr.new builds of comark-content and forges, which pnpm
# rejects as exotic subdependencies. Remove once comark-content 0.5 and forges 0.3.0 are released.
blockExoticSubdeps: false
Loading