Files
sim/apps/docs/scripts/fetch-git-history.ts
Emir KarabegandWaleed Latif 7860fbe8cc feat(docs): rebuild documentation with the shared Sim design system (#9459)
* feat(docs): rebuild documentation with the Paper design system

* fix(docs): verify nested tabs and fresh-checkout CI setup

* chore(docs): refresh preservation evidence against latest staging

* fix(docs): align shared navigation and controls with Paper

* fix(docs): share active heading across responsive outlines

* fix(docs): track the final section at the end of the page

* fix(docs): preserve sidebar scroll in a persistent layout

* fix(docs): restore live screenshot backgrounds and framing

* fix(docs): finish layout polish and clean implementation references

* fix(docs): align shared dark theme and overlay states

* fix(docs): remove dark borders from platform screenshots

* test(docs): benchmark production navigation and image delivery in CI

* fix(docs): preserve machine content and production reading contracts

* fix(docs): retain readable tabs without JavaScript and verify current staging

* fix(docs): expose root response schemas and generate clean-checkout types

* fix(docs): resolve no-script tabs in the preflight cascade layer

* perf(docs): import only the search schema constructors

* fix(docs): preserve retrieval excerpts and reduce reading overhead

* fix(docs): reuse in-flight intent prefetches during navigation

* docs: record production readiness evidence and release requirements

* docs: clarify optimizer measurement provenance

* docs: preserve latest staging Search assets and compatibility evidence

* fix(docs): polish responsive controls and keep search indexing current

* test(docs): select the visible API example in browser checks

* test(docs): execute native examples against streaming and binary responses

* fix(docs): stream native API responses without buffering

* test(docs): cover review regressions through public interfaces

* fix(docs): preserve accessible examples and gate index publication

* fix(docs): finish accessible controls and cached content validation

* fix(docs): validate integration parents and report partial search failures

* fix(docs): refine navigation and compact sample controls

* fix(docs): isolate synchronous corpus validation from HTTP readers

* fix(docs): restore Paper interaction styling and verify responsive controls

* fix(docs): score each search page once per retrieval source

* fix(docs): attribute benchmark metrics to their source document

---------

Co-authored-by: Waleed Latif <walif6@gmail.com>
2026-10-30 17:06:09 -07:00

74 lines
2.5 KiB
TypeScript

/**
* Vercel builds from a `--depth=10` clone, and `compile-content.ts` refuses to date pages from a
* shallow clone (every file untouched since the boundary commit would get that commit's date), so
* the docs sitemap shipped with no `lastModified` at all. Fetch the commit history before the
* build. `--filter=blob:none` skips file contents: `git log --name-only` needs commits and trees.
* Vercel's clone has no `origin` remote, so the history comes from the public repository URL its
* system environment names, pinned to the commit being built.
*
* A failed fetch leaves the clone shallow, so pages ship undated as before. That is logged rather
* than failing the deploy, because dates are an enhancement and the docs must still ship.
*/
import { execFileSync } from 'node:child_process'
import { createLogger } from '@sim/logger'
import { getErrorMessage } from '@sim/utils/errors'
/** A build step's outcome belongs in the build log, which the production default (errors only) would hide. */
const logger = createLogger('DocsGitHistory', { logLevel: 'INFO' })
/** Bounds the fetch so a stalled remote costs at most this much of the deployment, never all of it. */
const FETCH_TIMEOUT_MS = 120_000
function git(args: string[], timeout?: number): string {
return execFileSync('git', args, {
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'pipe'],
timeout,
}).trim()
}
const {
VERCEL,
VERCEL_GIT_PROVIDER,
VERCEL_GIT_REPO_OWNER,
VERCEL_GIT_REPO_SLUG,
VERCEL_GIT_COMMIT_SHA,
} = process.env
if (VERCEL) {
try {
if (git(['rev-parse', '--is-shallow-repository']) === 'true') {
if (
VERCEL_GIT_PROVIDER !== 'github' ||
!VERCEL_GIT_REPO_OWNER ||
!VERCEL_GIT_REPO_SLUG ||
!VERCEL_GIT_COMMIT_SHA
) {
throw new Error('Vercel did not provide the GitHub repository and commit for this build')
}
const repositoryUrl = `https://github.com/${VERCEL_GIT_REPO_OWNER}/${VERCEL_GIT_REPO_SLUG}.git`
git(
[
'fetch',
'--unshallow',
'--filter=blob:none',
'--no-tags',
repositoryUrl,
VERCEL_GIT_COMMIT_SHA,
],
FETCH_TIMEOUT_MS
)
logger.info('Fetched full commit history for docs last-modified dates')
} else {
logger.info('Clone already has full commit history')
}
} catch (error) {
logger.warn(
'Could not fetch commit history; docs pages will ship without last-modified dates',
{
error: getErrorMessage(error),
}
)
}
}