Skip to content

Commit 0b4f46d

Browse files
authored
Merge pull request #187 from qualcomm/chore/deps-cleanup
Batch git metadata lookups and update dependencies
2 parents 2682afa + 5ea20a8 commit 0b4f46d

17 files changed

Lines changed: 1296 additions & 1175 deletions

File tree

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ dist/
22
build/
33
.dockerignore
44
node_modules
5-
**/.git
65
**/.DS_Store
76
*.md
87
.gitignore

.github/workflows/reusable-docs-deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
environment: prod
2727
steps:
2828
- uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0 # full history for docs site builds
2931

3032
- name: Log in to ECR
3133
run: |

context7.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"execa": "^9.6.0",
9090
"glob": "catalog:",
9191
"ignore": "^7.0.5",
92-
"npm-check-updates": "^19.1.2",
92+
"npm-check-updates": "^19.6.3",
9393
"npm-run-all2": "^8.0.4",
9494
"playwright": "1.56.1",
9595
"prettier": "^3.6.2",

packages/common/mdx-vite/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @qualcomm-ui/mdx-vite Changelog
22

3+
## 2.17.2 (2026/03/02)
4+
5+
### Performance Improvements
6+
7+
- [mdx-vite]: batch git metadata lookups into a single command ([dbb2b9b](https://github.com/qualcomm/qualcomm-ui/commit/dbb2b9b))
8+
39
## 2.17.1 (2026/02/26)
410

511
### Bug Fixes

packages/common/mdx-vite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@qualcomm-ui/mdx-vite",
3-
"version": "2.17.1",
3+
"version": "2.17.2",
44
"description": "Vite documentation plugin for applications that use MDX",
55
"author": "Ryan Bower",
66
"license": "BSD-3-Clause-Clear",

packages/common/mdx-vite/src/docs-plugin/internal/search-indexer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type {
1818
} from "../types"
1919

2020
import {
21+
buildGitMetadataMap,
2122
type CompiledMdxFile,
2223
type CompiledMdxFileMetadata,
2324
DocPropsIndexer,
@@ -362,6 +363,10 @@ export class SearchIndexer {
362363
)
363364

364365
this._mdxFileCount = mdxFileGlob.length
366+
this.fileCache.gitMetadataMap = buildGitMetadataMap(
367+
this.config.srcDir,
368+
this.fileCache.pageTimestampMetadata,
369+
)
365370
const compiledFiles = mdxFileGlob.map((file) => this.compileMdxFile(file))
366371

367372
const mdxIndex = compiledFiles

packages/common/mdx-vite/src/docs-plugin/internal/services/markdown/markdown-file-reader.ts

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import chalk from "chalk"
55
import {execSync} from "node:child_process"
66
import {createHash} from "node:crypto"
77
import {readFileSync} from "node:fs"
8-
import {relative} from "node:path"
8+
import {resolve} from "node:path"
99
import remarkFrontmatter from "remark-frontmatter"
1010
import remarkParse from "remark-parse"
1111
import remarkParseFrontmatter from "remark-parse-frontmatter"
@@ -25,50 +25,51 @@ export interface GitMetadata {
2525
updatedOn?: string
2626
}
2727

28-
function getRepoRoot(): string {
29-
return execSync("git rev-parse --show-toplevel", {
30-
encoding: "utf-8",
31-
}).trim()
32-
}
33-
3428
/**
35-
* Gets the last git commit metadata for a file.
36-
* Returns undefined values if the file is not tracked by git or if git is
37-
* unavailable.
29+
* Runs a single git log command to collect the last commit metadata for all
30+
* MDX files under srcDir. Returns a map keyed by absolute file path.
3831
*/
39-
export function getGitMetadata(
40-
filePath: string,
32+
export function buildGitMetadataMap(
33+
srcDir: string,
4134
mode: PageTimestampMetadataMode,
42-
): GitMetadata {
35+
): Map<string, GitMetadata> {
36+
const map = new Map<string, GitMetadata>()
4337
if (mode === "off") {
44-
return {}
38+
return map
4539
}
4640

4741
try {
48-
const repoRoot = getRepoRoot()
49-
const relativePath = relative(repoRoot, filePath)
50-
const format = mode === "user-and-timestamp" ? "%cI%n%aN" : "%cI"
51-
const result = execSync(
52-
`git log -1 --format=${format} -- "${relativePath}"`,
53-
{
54-
encoding: "utf-8",
55-
stdio: ["pipe", "pipe", "pipe"],
56-
},
57-
).trim()
58-
59-
if (!result) {
60-
return {}
61-
}
62-
63-
if (mode === "user-and-timestamp") {
64-
const [updatedOn, updatedBy] = result.split("\n")
65-
return {updatedBy, updatedOn}
42+
const repoRoot = execSync("git rev-parse --show-toplevel", {
43+
encoding: "utf-8",
44+
}).trim()
45+
46+
const format = mode === "user-and-timestamp" ? "%cI%x09%aN" : "%cI"
47+
const output = execSync(
48+
`git log --format="COMMIT%x09${format}" --name-only -- "${srcDir}/**/*.mdx"`,
49+
{encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"]},
50+
)
51+
52+
let currentMetadata: GitMetadata = {}
53+
54+
for (const line of output.split("\n")) {
55+
if (line.startsWith("COMMIT\t")) {
56+
const parts = line.split("\t")
57+
currentMetadata =
58+
mode === "user-and-timestamp"
59+
? {updatedBy: parts[2], updatedOn: parts[1]}
60+
: {updatedOn: parts[1]}
61+
} else if (line.trim()) {
62+
const absolutePath = resolve(repoRoot, line.trim())
63+
if (!map.has(absolutePath)) {
64+
map.set(absolutePath, currentMetadata)
65+
}
66+
}
6667
}
67-
68-
return {updatedOn: result}
6968
} catch {
70-
return {}
69+
// git unavailable — return empty map
7170
}
71+
72+
return map
7273
}
7374

7475
interface PageCache {
@@ -81,6 +82,7 @@ interface PageCache {
8182

8283
export class MarkdownFileReader {
8384
cachedFileCount = 0
85+
gitMetadataMap: Map<string, GitMetadata> = new Map()
8486
logWarnings = true
8587
private mdxCache: Record<string, PageCache> = {}
8688

@@ -189,7 +191,7 @@ export class MarkdownFileReader {
189191
const shouldFetchGitMetadata = !this.enabled || !existingCache
190192

191193
if (shouldFetchGitMetadata) {
192-
const gitMetadata = getGitMetadata(filepath, this.pageTimestampMetadata)
194+
const gitMetadata = this.gitMetadataMap.get(filepath) ?? {}
193195
if (!frontmatter.updatedOn && gitMetadata.updatedOn) {
194196
frontmatter.updatedOn = gitMetadata.updatedOn
195197
}

packages/frameworks/react-mdx/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# @qualcomm-ui/react-mdx Changelog
22

3+
## 1.13.2 (2026/03/02)
4+
5+
### Styles
6+
7+
- [react-mdx]: update updated-on typography to use heading font with italic ([d534f3c](https://github.com/qualcomm/qualcomm-ui/commit/d534f3c))
8+
9+
### Code Refactoring
10+
11+
- [react-mdx]: extract UpdatedOnDate into its own component ([7d4f5e4](https://github.com/qualcomm/qualcomm-ui/commit/7d4f5e4))
12+
313
## 1.13.1 (2026/02/27)
414

515
### Miscellaneous Chores

packages/frameworks/react-mdx/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@qualcomm-ui/react-mdx",
3-
"version": "1.13.1",
3+
"version": "1.13.2",
44
"description": "React components and utilities for MDX documentation sites based on QUI Docs",
55
"author": "Ryan Bower",
66
"license": "BSD-3-Clause-Clear",

0 commit comments

Comments
 (0)