@qualcomm-ui/mdx-vite 2.5.4 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -3565,6 +3565,11 @@ var configSchema = implement().with({
3565
3565
  hotUpdateIgnore: z2.instanceof(RegExp).optional(),
3566
3566
  navConfig: z2.array(z2.union([routeMetaSchema, navMetaSchema])).optional(),
3567
3567
  pageDirectory: z2.string().optional(),
3568
+ pageTimestampMetadata: z2.union([
3569
+ z2.literal("off"),
3570
+ z2.literal("timestamp"),
3571
+ z2.literal("user-and-timestamp")
3572
+ ]).optional(),
3568
3573
  routingStrategy: z2.union([
3569
3574
  z2.literal("vite-generouted"),
3570
3575
  z2.function(z2.tuple([z2.string()]), z2.array(z2.string()))
@@ -3590,7 +3595,9 @@ var frontmatterSchema = implement().with({
3590
3595
  id: z3.string().optional(),
3591
3596
  restricted: z3.boolean().optional(),
3592
3597
  sideNavTitle: z3.string().optional(),
3593
- title: z3.string()
3598
+ title: z3.string(),
3599
+ updatedBy: z3.string().optional(),
3600
+ updatedOn: z3.string().optional()
3594
3601
  });
3595
3602
  function fixPath(str) {
3596
3603
  return str.replaceAll("\\", "/");
@@ -3866,16 +3873,52 @@ var DocPropsIndexer = class {
3866
3873
 
3867
3874
  // src/docs-plugin/internal/services/markdown/markdown-file-reader.ts
3868
3875
  import chalk from "chalk";
3876
+ import { execSync } from "node:child_process";
3869
3877
  import { createHash } from "node:crypto";
3870
3878
  import { readFileSync } from "node:fs";
3879
+ import { relative } from "node:path";
3871
3880
  import remarkFrontmatter from "remark-frontmatter";
3872
3881
  import remarkParse2 from "remark-parse";
3873
3882
  import remarkParseFrontmatter from "remark-parse-frontmatter";
3874
3883
  import remarkStringify2 from "remark-stringify";
3875
3884
  import { unified as unified2 } from "unified";
3885
+ function getRepoRoot() {
3886
+ return execSync("git rev-parse --show-toplevel", {
3887
+ encoding: "utf-8"
3888
+ }).trim();
3889
+ }
3890
+ function getGitMetadata(filePath, mode) {
3891
+ if (mode === "off") {
3892
+ return {};
3893
+ }
3894
+ try {
3895
+ const repoRoot = getRepoRoot();
3896
+ const relativePath = relative(repoRoot, filePath);
3897
+ const format = mode === "user-and-timestamp" ? "%cI%n%aN" : "%cI";
3898
+ const result = execSync(
3899
+ `git log -1 --format=${format} -- "${relativePath}"`,
3900
+ {
3901
+ cwd: repoRoot,
3902
+ encoding: "utf-8",
3903
+ stdio: ["pipe", "pipe", "pipe"]
3904
+ }
3905
+ ).trim();
3906
+ if (!result) {
3907
+ return {};
3908
+ }
3909
+ if (mode === "user-and-timestamp") {
3910
+ const [updatedOn, updatedBy] = result.split("\n");
3911
+ return { updatedBy, updatedOn };
3912
+ }
3913
+ return { updatedOn: result };
3914
+ } catch {
3915
+ return {};
3916
+ }
3917
+ }
3876
3918
  var MarkdownFileReader = class {
3877
- constructor(enabled) {
3919
+ constructor(enabled, pageTimestampMetadata = "off") {
3878
3920
  this.enabled = enabled;
3921
+ this.pageTimestampMetadata = pageTimestampMetadata;
3879
3922
  }
3880
3923
  cachedFileCount = 0;
3881
3924
  logWarnings = true;
@@ -3941,6 +3984,15 @@ var MarkdownFileReader = class {
3941
3984
  console.debug(`- ${issue.path.join(".")}`);
3942
3985
  });
3943
3986
  }
3987
+ if (!frontmatter.updatedOn || !frontmatter.updatedBy) {
3988
+ const gitMetadata = getGitMetadata(filepath, this.pageTimestampMetadata);
3989
+ if (!frontmatter.updatedOn && gitMetadata.updatedOn) {
3990
+ frontmatter.updatedOn = gitMetadata.updatedOn;
3991
+ }
3992
+ if (!frontmatter.updatedBy && gitMetadata.updatedBy) {
3993
+ frontmatter.updatedBy = gitMetadata.updatedBy;
3994
+ }
3995
+ }
3944
3996
  return { cached, fileContents, frontmatter };
3945
3997
  }
3946
3998
  updateCache(filepath, fileContents, cacheData) {
@@ -4897,7 +4949,8 @@ var SearchIndexer = class {
4897
4949
  this.navBuilder = addons.navBuilder || new NavBuilder(this.metaJson, this.routeMetaNav);
4898
4950
  this.docPropsIndexer = addons.docPropsIndexer || new DocPropsIndexer(this.config.typeDocProps ?? {});
4899
4951
  this.fileCache = addons.fileCache || new MarkdownFileReader(
4900
- process.env.NODE_ENV === "development" && !this.config.disableCache
4952
+ process.env.NODE_ENV === "development" && !this.config.disableCache,
4953
+ this.config.pageTimestampMetadata
4901
4954
  );
4902
4955
  }
4903
4956
  docPropsIndexer;
@@ -4966,7 +5019,9 @@ var SearchIndexer = class {
4966
5019
  pathname,
4967
5020
  pathSegments,
4968
5021
  restricted: defined(routeMeta.restricted) ? routeMeta.restricted : frontmatter.restricted,
4969
- title: defined(routeMeta.title) ? routeMeta.title || "" : frontmatter.title || ""
5022
+ title: defined(routeMeta.title) ? routeMeta.title || "" : frontmatter.title || "",
5023
+ updatedBy: frontmatter.updatedBy,
5024
+ updatedOn: frontmatter.updatedOn
4970
5025
  };
4971
5026
  }
4972
5027
  /**
@@ -6894,11 +6949,11 @@ import { dedent as dedent2 } from "@qualcomm-ui/utils/dedent";
6894
6949
  // src/react-demo-plugin/demo-plugin-utils.ts
6895
6950
  import chalk4 from "chalk";
6896
6951
  import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
6897
- import { dirname as dirname2, join as join4, relative, resolve as resolve7, sep } from "node:path";
6952
+ import { dirname as dirname2, join as join4, relative as relative2, resolve as resolve7, sep } from "node:path";
6898
6953
  import * as ts from "typescript";
6899
6954
  import { pascalCase } from "@qualcomm-ui/utils/change-case";
6900
6955
  function extractPageId(filePath, routesDir) {
6901
- const relativePath = relative(routesDir, filePath);
6956
+ const relativePath = relative2(routesDir, filePath);
6902
6957
  const pathParts = relativePath.split(sep);
6903
6958
  if (pathParts.includes("demos")) {
6904
6959
  const demosIndex = pathParts.indexOf("demos");