Skip to content

Commit 47acc02

Browse files
author
abrulic
committed
generated docs updted
1 parent 3ce5129 commit 47acc02

1 file changed

Lines changed: 20 additions & 23 deletions

File tree

scripts/generate-docs.ts

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ let repoRoot = workspaceRoot
3838
let workspaceRelativePath = ""
3939
try {
4040
repoRoot = run("git rev-parse --show-toplevel")
41-
workspaceRelativePath = repoRoot === workspaceRoot ? "" : workspaceRoot.replace(`${repoRoot}/`, "")
41+
// biome-ignore lint/style/useTemplate: <explanation>
42+
workspaceRelativePath = repoRoot === workspaceRoot ? "" : workspaceRoot.replace(repoRoot + "/", "")
4243
} catch {
4344
repoRoot = workspaceRoot
4445
workspaceRelativePath = ""
@@ -178,26 +179,6 @@ function isOnDefaultBranch(defaultBranch: string): boolean {
178179
const currentBranch = getCurrentBranch()
179180
return currentBranch === defaultBranch
180181
}
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-
}
201182
;(async () => {
202183
const { values } = parseArgs({
203184
args: process.argv.slice(2),
@@ -235,11 +216,27 @@ function buildCurrentSnapshot(defaultBranch: string, onDefaultBranch: boolean, l
235216
console.log(chalk.cyan(`Building tags: ${tags.join(", ")}`))
236217
for (const t of tags) buildTag(t)
237218

238-
buildCurrentSnapshot(defaultBranch, onDefaultBranch, "current")
219+
if (onDefaultBranch) {
220+
// biome-ignore lint/suspicious/noConsole: keep for logging
221+
console.log(chalk.cyan(`Building default branch '${defaultBranch}' → current`))
222+
buildBranch(defaultBranch, "current")
223+
} else {
224+
// biome-ignore lint/suspicious/noConsole: keep for logging
225+
console.log(chalk.cyan("Building current workspace → current"))
226+
buildDocs(workspaceRoot, join(outputDir, "current"))
227+
}
239228

240229
builtVersions = ["current", ...tags]
241230
} else {
242-
buildCurrentSnapshot(defaultBranch, onDefaultBranch, "current")
231+
if (onDefaultBranch) {
232+
// biome-ignore lint/suspicious/noConsole: keep for logging
233+
console.log(chalk.cyan(`Building default branch '${defaultBranch}' → current`))
234+
buildBranch(defaultBranch, "current")
235+
} else {
236+
// biome-ignore lint/suspicious/noConsole: keep for logging
237+
console.log(chalk.cyan("Building current workspace → current"))
238+
buildDocs(workspaceRoot, join(outputDir, "current"))
239+
}
243240

244241
builtVersions = ["current"]
245242
}

0 commit comments

Comments
 (0)