Skip to content

Commit 4589ab1

Browse files
author
abrulic
committed
updates
1 parent 1b4b793 commit 4589ab1

4 files changed

Lines changed: 61 additions & 11 deletions

File tree

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ RUN apt-get update -qq && \
1818
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 && \
1919
rm -rf /var/lib/apt/lists/*
2020

21-
COPY .npmrc package.json ./
22-
RUN pnpm install --prod=false
21+
COPY .npmrc package.json pnpm-lock.yaml ./
22+
RUN pnpm install --prod=false --frozen-lockfile
2323

2424

2525
COPY . .

app/components/code-block/code-block-syntax-highlighter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const MASTER_REGEX = new RegExp(
1010
// whitespace
1111
"\\s+",
1212
// single-line comment
13-
"\\/\\/[^\\n\\r]*",
13+
"\\/\\/[^\\n\\r]*(?=\\n|$)",
1414
// multi-line comment
1515
"\\/\\*[\\s\\S]*?\\*\\/",
1616
// hash comment at start of line

app/ui/list-item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const ListItem = (props: ComponentPropsWithoutRef<"li">) => {
66
<li
77
{...props}
88
className={cn(
9-
"space-y-1 pl-1 text-[var(--color-text-normal)] text-base leading-7 md:text-lg md:leading-8 xl:leading-8 xl:leading-9 [&>li]:ml-2 [&>li]:marker:font-medium",
9+
"space-y-1 pl-1 text-[var(--color-text-normal)] text-base leading-7 md:text-lg md:leading-8 xl:leading-8 [&>li]:ml-2 [&>li]:marker:font-medium",
1010
props.className
1111
)}
1212
/>

scripts/generate-docs.ts

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ function resolveTagsFromSpec(spec: string) {
6363
return matched.sort(semver.rcompare)
6464
}
6565

66+
function hasLocalRef(ref: string) {
67+
try {
68+
run(`git show-ref --verify --quiet ${ref}`)
69+
return true
70+
} catch {
71+
return false
72+
}
73+
}
74+
6675
function buildDocs(sourceDir: string, outDir: string) {
6776
if (!existsSync(sourceDir)) {
6877
throw new Error(
@@ -143,6 +152,16 @@ function buildRef(ref: string, labelForOutDir: string) {
143152
}
144153
}
145154

155+
function buildBranch(branch: string, labelForOutDir: string) {
156+
run(`git fetch --tags --prune origin ${branch}`, {
157+
cwd: workspaceRoot,
158+
inherit: true,
159+
})
160+
const localRef = `refs/heads/${branch}`
161+
const targetRef = hasLocalRef(localRef) ? localRef : `origin/${branch}`
162+
return buildRef(targetRef, labelForOutDir)
163+
}
164+
146165
function buildTag(tag: string) {
147166
return buildRef(`refs/tags/${tag}`, tag)
148167
}
@@ -154,6 +173,31 @@ function getCurrentBranch(): string {
154173
throw new Error("Failed to get current branch")
155174
}
156175
}
176+
177+
function isOnDefaultBranch(defaultBranch: string): boolean {
178+
const currentBranch = getCurrentBranch()
179+
return currentBranch === defaultBranch
180+
}
181+
182+
/**
183+
* Build the current workspace snapshot labelled `labelForOutDir`.
184+
* If we're on the default branch, fetch and build that branch; otherwise
185+
* build the working tree in-place (useful for PR/feature branches).
186+
*/
187+
function buildCurrentSnapshot(defaultBranch: string, onDefaultBranch: boolean, labelForOutDir = "current") {
188+
if (onDefaultBranch) {
189+
// build from the remote/default branch so the snapshot exactly matches the
190+
// default branch state (not the local working tree)
191+
// biome-ignore lint/suspicious/noConsole: keep for logging
192+
console.log(chalk.cyan(`Building default branch '${defaultBranch}' → ${labelForOutDir}`))
193+
buildBranch(defaultBranch, labelForOutDir)
194+
} else {
195+
// build the current workspace directly
196+
// biome-ignore lint/suspicious/noConsole: keep for logging
197+
console.log(chalk.cyan(`Building current workspace → ${labelForOutDir}`))
198+
buildDocs(workspaceRoot, join(outputDir, labelForOutDir))
199+
}
200+
}
157201
;(async () => {
158202
const { values } = parseArgs({
159203
args: process.argv.slice(2),
@@ -163,12 +207,22 @@ function getCurrentBranch(): string {
163207
},
164208
})
165209

210+
const defaultBranch = (values.branch as string | undefined)?.trim()
211+
if (!defaultBranch) {
212+
throw new Error(
213+
`❌ Missing required --branch flag.
214+
Please specify the default branch name (e.g., --branch main)
215+
Example: pnpm run generate:docs --branch main`
216+
)
217+
}
218+
166219
const rawVersions = (values.versions as string | undefined)?.trim() ?? ""
167220
const hasVersionsArg = rawVersions.length > 0
168221

169222
let builtVersions: string[] = []
170223

171-
const currentBranchToBuild = getCurrentBranch()
224+
const onDefaultBranch = isOnDefaultBranch(defaultBranch)
225+
const currentBranchToBuild = onDefaultBranch ? defaultBranch : getCurrentBranch()
172226

173227
// biome-ignore lint/suspicious/noConsole: keep for logging
174228
console.log(chalk.cyan(`Building from branch: ${currentBranchToBuild}`))
@@ -181,15 +235,11 @@ function getCurrentBranch(): string {
181235
console.log(chalk.cyan(`Building tags: ${tags.join(", ")}`))
182236
for (const t of tags) buildTag(t)
183237

184-
// biome-ignore lint/suspicious/noConsole: keep for logging
185-
console.log(chalk.cyan("Building current workspace → current"))
186-
buildDocs(workspaceRoot, join(outputDir, "current"))
238+
buildCurrentSnapshot(defaultBranch, onDefaultBranch, "current")
187239

188240
builtVersions = ["current", ...tags]
189241
} else {
190-
// biome-ignore lint/suspicious/noConsole: keep for logging
191-
console.log(chalk.cyan("Building current workspace → current"))
192-
buildDocs(workspaceRoot, join(outputDir, "current"))
242+
buildCurrentSnapshot(defaultBranch, onDefaultBranch, "current")
193243

194244
builtVersions = ["current"]
195245
}

0 commit comments

Comments
 (0)