@vendure-io/docs-provider 0.7.0 → 0.8.2

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.
@@ -0,0 +1,44 @@
1
+ import { NavigationNode } from './types';
2
+ /**
3
+ * Options for applying last modified dates
4
+ */
5
+ export interface ApplyLastModifiedDatesOptions {
6
+ /**
7
+ * Base path to prepend to file paths when looking up dates.
8
+ * Use this when the dates map uses paths relative to a different root
9
+ * than the navigation nodes' file paths.
10
+ *
11
+ * @example
12
+ * If dates map has: 'docs/getting-started.mdx'
13
+ * And navigation has: 'getting-started.mdx'
14
+ * Set basePath to 'docs'
15
+ */
16
+ basePath?: string;
17
+ }
18
+ /**
19
+ * Apply last modified dates from a pre-computed map to navigation nodes.
20
+ *
21
+ * This function recursively walks the navigation tree and adds `lastModified`
22
+ * to each node that has a `file` property matching a key in the dates map.
23
+ *
24
+ * The function does not mutate the original nodes; it returns a new tree with
25
+ * the dates applied.
26
+ *
27
+ * @param navigation - Array of navigation nodes to process
28
+ * @param dates - Map of file paths to ISO 8601 date strings
29
+ * @param options - Optional configuration
30
+ * @returns New navigation array with lastModified dates applied
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * import { lastModifiedDates } from './dates.generated'
35
+ *
36
+ * const navigationWithDates = applyLastModifiedDates(
37
+ * navigation,
38
+ * lastModifiedDates,
39
+ * { basePath: 'docs' }
40
+ * )
41
+ * ```
42
+ */
43
+ export declare function applyLastModifiedDates(navigation: NavigationNode[], dates: Record<string, string>, options?: ApplyLastModifiedDatesOptions): NavigationNode[];
44
+ //# sourceMappingURL=apply-dates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-dates.d.ts","sourceRoot":"","sources":["../src/apply-dates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAgB7C;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,cAAc,EAAE,EAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,OAAO,GAAE,6BAAkC,GAC1C,cAAc,EAAE,CAkElB"}
package/dist/browser.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./manifest-D-EWZlSh.cjs"),a=require("./slug-utils-DUQgikEz.cjs");exports.BreadcrumbItemSchema=e.BreadcrumbItemSchema;exports.DocPageMetaSchema=e.DocPageMetaSchema;exports.DocPageSchema=e.DocPageSchema;exports.DocsPackageManifestInputSchema=e.DocsPackageManifestInputSchema;exports.DocsPackageManifestSchema=e.DocsPackageManifestSchema;exports.FlatNavigationNodeSchema=e.FlatNavigationNodeSchema;exports.GitHubConfigSchema=e.GitHubConfigSchema;exports.LoadedDocsPackageSchema=e.LoadedDocsPackageSchema;exports.ManifestValidationError=e.ManifestValidationError;exports.NavigationNodeInputSchema=e.NavigationNodeInputSchema;exports.NavigationNodeSchema=e.NavigationNodeSchema;exports.SearchConfigSchema=e.SearchConfigSchema;exports.VendureVersionSchema=e.VendureVersionSchema;exports.buildBreadcrumbs=e.buildBreadcrumbs;exports.findNavigationNode=e.findNavigationNode;exports.flattenNavigation=e.flattenNavigation;exports.getLeafNodes=e.getLeafNodes;exports.getNodesAtDepth=e.getNodesAtDepth;exports.getPrevNextNodes=e.getPrevNextNodes;exports.isNodeActive=e.isNodeActive;exports.validateManifest=e.validateManifest;exports.filterVisibleNavigation=a.filterVisibleNavigation;exports.getAllFilePaths=a.getAllFilePaths;exports.slugFromFilename=a.slugFromFilename;exports.titleFromFilename=a.titleFromFilename;exports.toSlug=a.toSlug;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./manifest-BkO3d77g.cjs"),a=require("./slug-utils-DUQgikEz.cjs");exports.BreadcrumbItemSchema=e.BreadcrumbItemSchema;exports.DocPageMetaSchema=e.DocPageMetaSchema;exports.DocPageSchema=e.DocPageSchema;exports.DocsPackageManifestInputSchema=e.DocsPackageManifestInputSchema;exports.DocsPackageManifestSchema=e.DocsPackageManifestSchema;exports.FlatNavigationNodeSchema=e.FlatNavigationNodeSchema;exports.GitHubConfigSchema=e.GitHubConfigSchema;exports.LoadedDocsPackageSchema=e.LoadedDocsPackageSchema;exports.ManifestValidationError=e.ManifestValidationError;exports.NavigationNodeInputSchema=e.NavigationNodeInputSchema;exports.NavigationNodeSchema=e.NavigationNodeSchema;exports.SearchConfigSchema=e.SearchConfigSchema;exports.VendureVersionSchema=e.VendureVersionSchema;exports.buildBreadcrumbs=e.buildBreadcrumbs;exports.findNavigationNode=e.findNavigationNode;exports.flattenNavigation=e.flattenNavigation;exports.getLeafNodes=e.getLeafNodes;exports.getNodesAtDepth=e.getNodesAtDepth;exports.getPrevNextNodes=e.getPrevNextNodes;exports.isNodeActive=e.isNodeActive;exports.validateManifest=e.validateManifest;exports.filterVisibleNavigation=a.filterVisibleNavigation;exports.getAllFilePaths=a.getAllFilePaths;exports.slugFromFilename=a.slugFromFilename;exports.titleFromFilename=a.titleFromFilename;exports.toSlug=a.toSlug;
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- import { B as s, D as t, a as i, b as o, c, F as g, G as m, L as n, M as d, N as r, d as h, S as N, V as l, e as S, f, g as v, h as u, i as D, j as F, k as P, v as b } from "./manifest-ZCrzbFSf.js";
1
+ import { B as s, D as t, a as i, b as o, c, F as g, G as m, L as n, M as d, N as r, d as h, S as N, V as l, e as S, f, g as v, h as u, i as D, j as F, k as P, v as b } from "./manifest-DlSWyjsA.js";
2
2
  import { f as p, g as V, s as k, t as x, a as A } from "./slug-utils-DVKYe9h8.js";
3
3
  export {
4
4
  s as BreadcrumbItemSchema,
@@ -2,7 +2,7 @@ var c = Object.defineProperty;
2
2
  var m = (a, t, r) => t in a ? c(a, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[t] = r;
3
3
  var o = (a, t, r) => m(a, typeof t != "symbol" ? t + "" : t, r);
4
4
  import i from "gray-matter";
5
- import { D as u } from "./manifest-ZCrzbFSf.js";
5
+ import { D as u } from "./manifest-DlSWyjsA.js";
6
6
  class s extends Error {
7
7
  constructor(r, e, n) {
8
8
  super(r);
@@ -1,3 +1,3 @@
1
- "use strict";var m=Object.defineProperty;var u=(a,t,r)=>t in a?m(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r;var s=(a,t,r)=>u(a,typeof t!="symbol"?t+"":t,r);const i=require("gray-matter"),d=require("./manifest-D-EWZlSh.cjs");class o extends Error{constructor(r,e,n){super(r);s(this,"filePath");s(this,"originalError");this.name="FrontmatterParseError",this.filePath=e,this.originalError=n}}function F(a,t){try{const{data:r,content:e}=i(a);return{meta:c(r,t),content:e.trim()}}catch(r){throw r instanceof o?r:new o(`Failed to parse frontmatter${t?` in ${t}`:""}`,t,r)}}function c(a,t){const r=d.DocPageMetaSchema.safeParse(a);if(!r.success){const e=r.error.issues.map(n=>` - ${n.path.join(".")}: ${n.message}`).join(`
1
+ "use strict";var m=Object.defineProperty;var u=(a,t,r)=>t in a?m(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r;var s=(a,t,r)=>u(a,typeof t!="symbol"?t+"":t,r);const i=require("gray-matter"),d=require("./manifest-BkO3d77g.cjs");class o extends Error{constructor(r,e,n){super(r);s(this,"filePath");s(this,"originalError");this.name="FrontmatterParseError",this.filePath=e,this.originalError=n}}function F(a,t){try{const{data:r,content:e}=i(a);return{meta:c(r,t),content:e.trim()}}catch(r){throw r instanceof o?r:new o(`Failed to parse frontmatter${t?` in ${t}`:""}`,t,r)}}function c(a,t){const r=d.DocPageMetaSchema.safeParse(a);if(!r.success){const e=r.error.issues.map(n=>` - ${n.path.join(".")}: ${n.message}`).join(`
2
2
  `);throw new o(`Invalid frontmatter${t?` in ${t}`:""}:
3
3
  ${e}`,t,r.error)}return r.data}function h(a){return a.trimStart().startsWith("---")}function f(a){const{data:t}=i(a);return t}exports.FrontmatterParseError=o;exports.extractFrontmatterData=f;exports.hasFrontmatter=h;exports.parseFrontmatter=F;exports.validateFrontmatter=c;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Options for generating a dates file
3
+ */
4
+ export interface GenerateDatesFileOptions {
5
+ /** Directory containing MDX files to scan */
6
+ docsDir: string;
7
+ /** Output path for the generated TypeScript file */
8
+ outputPath: string;
9
+ /** Git working directory (defaults to parent of docsDir) */
10
+ gitCwd?: string;
11
+ /** File extensions to include (defaults to ['.mdx', '.md']) */
12
+ extensions?: string[];
13
+ }
14
+ /**
15
+ * Result of date file generation
16
+ */
17
+ export interface GenerateDatesResult {
18
+ /** Number of files with dates extracted */
19
+ filesWithDates: number;
20
+ /** Number of files skipped (untracked, etc.) */
21
+ filesSkipped: number;
22
+ /** Path to the generated file */
23
+ outputPath: string;
24
+ }
25
+ /**
26
+ * Generate a TypeScript file containing last modified dates for all MDX files.
27
+ *
28
+ * This function:
29
+ * 1. Scans the docsDir for MDX files
30
+ * 2. Extracts git last-modified dates for each file
31
+ * 3. Writes a TypeScript file with the date mappings
32
+ *
33
+ * The generated file exports a `lastModifiedDates` object mapping relative file paths
34
+ * to ISO 8601 date strings.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * await generateDatesFile({
39
+ * docsDir: join(process.cwd(), 'docs'),
40
+ * outputPath: join(process.cwd(), 'src/dates.generated.ts'),
41
+ * gitCwd: process.cwd(),
42
+ * })
43
+ * ```
44
+ */
45
+ export declare function generateDatesFile(options: GenerateDatesFileOptions): Promise<GenerateDatesResult>;
46
+ //# sourceMappingURL=generate-dates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-dates.d.ts","sourceRoot":"","sources":["../src/generate-dates.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAA;IACf,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAA;IAClB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,cAAc,EAAE,MAAM,CAAA;IACtB,gDAAgD;IAChD,YAAY,EAAE,MAAM,CAAA;IACpB,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAA;CACnB;AAgCD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,mBAAmB,CAAC,CA6C9B"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Options for git operations
3
+ */
4
+ export interface GitOptions {
5
+ /** Working directory for git commands (defaults to process.cwd()) */
6
+ cwd?: string;
7
+ }
8
+ /**
9
+ * Check if the given directory is inside a git repository
10
+ */
11
+ export declare function isGitRepository(cwd?: string): Promise<boolean>;
12
+ /**
13
+ * Get the last modified date for a file from git history.
14
+ * Returns the committer date of the most recent commit that modified the file.
15
+ *
16
+ * @param filePath - Path to the file (relative to git root or absolute)
17
+ * @param options - Git options including working directory
18
+ * @returns ISO 8601 date string, or null if the file is untracked or git is unavailable
19
+ */
20
+ export declare function getGitLastModified(filePath: string, options?: GitOptions): Promise<string | null>;
21
+ /**
22
+ * Result from batch git date extraction
23
+ */
24
+ export interface GitDateResult {
25
+ /** Map of file path to ISO 8601 date string */
26
+ dates: Record<string, string>;
27
+ /** Files that could not be dated (untracked, not in git, etc.) */
28
+ skipped: string[];
29
+ }
30
+ /**
31
+ * Get last modified dates for multiple files in a single efficient operation.
32
+ * Uses git log with --name-only to batch the extraction.
33
+ *
34
+ * @param filePaths - Array of file paths (relative to git root or absolute)
35
+ * @param options - Git options including working directory
36
+ * @returns Object with dates map and list of skipped files
37
+ */
38
+ export declare function getGitLastModifiedBatch(filePaths: string[], options?: GitOptions): Promise<GitDateResult>;
39
+ //# sourceMappingURL=git-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-utils.d.ts","sourceRoot":"","sources":["../src/git-utils.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnF;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkBxB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,kEAAkE;IAClE,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,MAAM,EAAE,EACnB,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,aAAa,CAAC,CA4BxB"}
package/dist/index.cjs CHANGED
@@ -1 +1,14 @@
1
- "use strict";var L=Object.defineProperty;var R=(e,t,r)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var S=(e,t,r)=>R(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./manifest-D-EWZlSh.cjs"),g=require("./frontmatter-CJYZSUYM.cjs"),l=require("./slug-utils-DUQgikEz.cjs"),N=require("fs"),y=require("path"),I=(e,t)=>e.order!==t.order?e.order-t.order:e.title.localeCompare(t.title);function j(e,t={}){const{extensions:r=[".mdx",".md"],filter:i,sort:o=I}=t,n=C(e,r);return(i?n.filter(i):n).sort(o).map(m=>({title:m.title,slug:m.slug,file:m.path}))}function q(e,t={}){return V(e,t,0)}function V(e,t,r){const{extensions:i=[".mdx",".md"],filter:o,sort:n=I,maxDepth:c=1/0,folderFilter:u}=t,m=N.readdirSync(e,{withFileTypes:!0}),h=[],$=C(e,i),D=(o?$.filter(o):$).sort(n);for(const f of D)h.push({title:f.title,slug:f.slug,file:f.path});if(r<c){const f=m.filter(d=>d.isDirectory());for(const d of f){if(u){const s=y.join(e,d.name);if(!u(d.name,s))continue}const F=y.join(e,d.name),v=V(F,t,r+1);if(v.length>0){const s=B(F,i);h.push({title:(s==null?void 0:s.title)||l.titleFromFilename(d.name),slug:l.slugFromFilename(d.name),file:s==null?void 0:s.path,children:v.filter(P=>!(s&&P.file===s.path))})}}}return h.sort((f,d)=>{var E,w;const F=D.find(M=>M.slug===f.slug),v=D.find(M=>M.slug===d.slug);if(F&&v)return n(F,v);const s=!!f.file&&!((E=f.children)!=null&&E.length),P=!!d.file&&!((w=d.children)!=null&&w.length);return s!==P?s?-1:1:(f.title||"").localeCompare(d.title||"")})}function C(e,t){try{const r=N.readdirSync(e,{withFileTypes:!0}),i=[];for(const o of r){if(!o.isFile())continue;const n=t.find(h=>o.name.toLowerCase().endsWith(h));if(!n||o.name.slice(0,-n.length).toLowerCase()==="index")continue;const u=y.join(e,o.name),m=k(u,o.name,n);i.push(m)}return i}catch{return[]}}function k(e,t,r){let i={},o=l.titleFromFilename(t),n=1/0;try{const c=N.readFileSync(e,"utf-8");i=g.extractFrontmatterData(c),i.title&&typeof i.title=="string"&&(o=i.title),typeof i.order=="number"&&(n=i.order)}catch{}return{path:e,filename:t,extension:r,frontmatter:i,order:n,title:o,slug:l.slugFromFilename(t)}}function B(e,t){for(const r of t){const i=y.join(e,`index${r}`);try{if(N.statSync(i).isFile())return k(i,`index${r}`,r)}catch{}}}class b extends Error{constructor(r,i,o,n){super(r);S(this,"nodePath");S(this,"filePath");S(this,"originalError");this.name="ManifestResolutionError",this.nodePath=i,this.filePath=o,this.originalError=n}}function T(e,t={}){const{strict:r=!0}=t,i=x(e.navigation,"",r);return{id:e.id,name:e.name,version:e.version,vendureVersion:e.vendureVersion,navigation:i,search:e.search,github:e.github,basePath:e.basePath}}function x(e,t,r){return e.map((i,o)=>U(i,t,o,r))}function U(e,t,r,i){const o=t?`${t}[${r}]`:`navigation[${r}]`;if(e.title&&e.slug)return{title:e.title,slug:e.slug,file:e.file,children:e.children?x(e.children,`${o}.children`,i):void 0,badge:e.badge,hidden:e.hidden};let n=e.title,c=e.slug;if(e.file&&(c||(c=l.slugFromFilename(e.file)),n||(n=W(e.file,o,i))),!n){if(i)throw new b(`Navigation node at ${o} is missing title and has no file to derive it from`,o,e.file);n=c||`Unknown (${r})`}if(!c){if(i)throw new b(`Navigation node at ${o} is missing slug and has no file to derive it from`,o,e.file);c=n?l.slugFromFilename(n):`node-${r}`}return{title:n,slug:c,file:e.file,children:e.children?x(e.children,`${o}.children`,i):void 0,badge:e.badge,hidden:e.hidden}}function W(e,t,r){try{const i=N.readFileSync(e,"utf-8"),o=g.extractFrontmatterData(i);return o.title&&typeof o.title=="string"?o.title:l.titleFromFilename(e)}catch(i){if(r)throw new b(`Failed to read file for title derivation at ${t}: ${e}`,t,e,i);return l.titleFromFilename(e)}}function G(e){return A(e.navigation)}function A(e){for(const t of e)if(!t.title||!t.slug||t.children&&A(t.children))return!0;return!1}exports.BreadcrumbItemSchema=a.BreadcrumbItemSchema;exports.DocPageMetaSchema=a.DocPageMetaSchema;exports.DocPageSchema=a.DocPageSchema;exports.DocsPackageManifestInputSchema=a.DocsPackageManifestInputSchema;exports.DocsPackageManifestSchema=a.DocsPackageManifestSchema;exports.FlatNavigationNodeSchema=a.FlatNavigationNodeSchema;exports.GitHubConfigSchema=a.GitHubConfigSchema;exports.LoadedDocsPackageSchema=a.LoadedDocsPackageSchema;exports.ManifestValidationError=a.ManifestValidationError;exports.NavigationNodeInputSchema=a.NavigationNodeInputSchema;exports.NavigationNodeSchema=a.NavigationNodeSchema;exports.SearchConfigSchema=a.SearchConfigSchema;exports.VendureVersionSchema=a.VendureVersionSchema;exports.buildBreadcrumbs=a.buildBreadcrumbs;exports.findNavigationNode=a.findNavigationNode;exports.flattenNavigation=a.flattenNavigation;exports.getLeafNodes=a.getLeafNodes;exports.getNodesAtDepth=a.getNodesAtDepth;exports.getPrevNextNodes=a.getPrevNextNodes;exports.isNodeActive=a.isNodeActive;exports.validateManifest=a.validateManifest;exports.FrontmatterParseError=g.FrontmatterParseError;exports.extractFrontmatterData=g.extractFrontmatterData;exports.hasFrontmatter=g.hasFrontmatter;exports.parseFrontmatter=g.parseFrontmatter;exports.validateFrontmatter=g.validateFrontmatter;exports.filterVisibleNavigation=l.filterVisibleNavigation;exports.getAllFilePaths=l.getAllFilePaths;exports.slugFromFilename=l.slugFromFilename;exports.titleFromFilename=l.titleFromFilename;exports.toSlug=l.toSlug;exports.ManifestResolutionError=b;exports.createNavigationFromFolder=j;exports.createNestedNavigationFromFolder=q;exports.manifestNeedsResolution=G;exports.resolveManifest=T;
1
+ "use strict";var _=Object.defineProperty;var z=(e,t,r)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var y=(e,t,r)=>z(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./manifest-BkO3d77g.cjs"),F=require("./frontmatter-QFErVd9b.cjs"),u=require("./slug-utils-DUQgikEz.cjs"),w=require("fs"),S=require("path"),U=require("node:child_process"),H=require("node:util"),k=require("node:fs/promises"),x=require("node:path"),V=(e,t)=>e.order!==t.order?e.order-t.order:e.title.localeCompare(t.title);function J(e,t={}){const{extensions:r=[".mdx",".md"],filter:i,sort:n=V}=t,a=R(e,r);return(i?a.filter(i):a).sort(n).map(c=>({title:c.title,slug:c.slug,file:c.path}))}function K(e,t={}){return W(e,t,0)}function W(e,t,r){const{extensions:i=[".mdx",".md"],filter:n,sort:a=V,maxDepth:o=1/0,folderFilter:l}=t,c=w.readdirSync(e,{withFileTypes:!0}),d=[],m=R(e,i),p=(n?m.filter(n):m).sort(a);for(const h of p)d.push({title:h.title,slug:h.slug,file:h.path});if(r<o){const h=c.filter(g=>g.isDirectory());for(const g of h){if(l){const f=S.join(e,g.name);if(!l(g.name,f))continue}const v=S.join(e,g.name),N=W(v,t,r+1);if(N.length>0){const f=Q(v,i);d.push({title:(f==null?void 0:f.title)||u.titleFromFilename(g.name),slug:u.slugFromFilename(g.name),file:f==null?void 0:f.path,children:N.filter(b=>!(f&&b.file===f.path))})}}}return d.sort((h,g)=>{var j,C;const v=p.find(P=>P.slug===h.slug),N=p.find(P=>P.slug===g.slug);if(v&&N)return a(v,N);const f=!!h.file&&!((j=h.children)!=null&&j.length),b=!!g.file&&!((C=g.children)!=null&&C.length);return f!==b?f?-1:1:(h.title||"").localeCompare(g.title||"")})}function R(e,t){try{const r=w.readdirSync(e,{withFileTypes:!0}),i=[];for(const n of r){if(!n.isFile())continue;const a=t.find(d=>n.name.toLowerCase().endsWith(d));if(!a||n.name.slice(0,-a.length).toLowerCase()==="index")continue;const l=S.join(e,n.name),c=q(l,n.name,a);i.push(c)}return i}catch{return[]}}function q(e,t,r){let i={},n=u.titleFromFilename(t),a=1/0;try{const o=w.readFileSync(e,"utf-8");i=F.extractFrontmatterData(o),i.title&&typeof i.title=="string"&&(n=i.title),typeof i.order=="number"&&(a=i.order)}catch{}return{path:e,filename:t,extension:r,frontmatter:i,order:a,title:n,slug:u.slugFromFilename(t)}}function Q(e,t){for(const r of t){const i=S.join(e,`index${r}`);try{if(w.statSync(i).isFile())return q(i,`index${r}`,r)}catch{}}}class D extends Error{constructor(r,i,n,a){super(r);y(this,"nodePath");y(this,"filePath");y(this,"originalError");this.name="ManifestResolutionError",this.nodePath=i,this.filePath=n,this.originalError=a}}function X(e,t={}){const{strict:r=!0}=t,i=M(e.navigation,"",r);return{id:e.id,name:e.name,version:e.version,vendureVersion:e.vendureVersion,navigation:i,search:e.search,github:e.github,basePath:e.basePath}}function M(e,t,r){return e.map((i,n)=>Y(i,t,n,r))}function Y(e,t,r,i){const n=t?`${t}[${r}]`:`navigation[${r}]`;if(e.title&&e.slug)return{title:e.title,slug:e.slug,file:e.file,children:e.children?M(e.children,`${n}.children`,i):void 0,badge:e.badge,hidden:e.hidden};let a=e.title,o=e.slug;if(e.file&&(o||(o=u.slugFromFilename(e.file)),a||(a=Z(e.file,n,i))),!a){if(i)throw new D(`Navigation node at ${n} is missing title and has no file to derive it from`,n,e.file);a=o||`Unknown (${r})`}if(!o){if(i)throw new D(`Navigation node at ${n} is missing slug and has no file to derive it from`,n,e.file);o=a?u.slugFromFilename(a):`node-${r}`}return{title:a,slug:o,file:e.file,children:e.children?M(e.children,`${n}.children`,i):void 0,badge:e.badge,hidden:e.hidden}}function Z(e,t,r){try{const i=w.readFileSync(e,"utf-8"),n=F.extractFrontmatterData(i);return n.title&&typeof n.title=="string"?n.title:u.titleFromFilename(e)}catch(i){if(r)throw new D(`Failed to read file for title derivation at ${t}: ${e}`,t,e,i);return u.titleFromFilename(e)}}function ee(e){return A(e.navigation)}function A(e){for(const t of e)if(!t.title||!t.slug||t.children&&A(t.children))return!0;return!1}const B=H.promisify(U.exec);async function I(e=process.cwd()){try{return await B("git rev-parse --git-dir",{cwd:e}),!0}catch{return!1}}async function T(e,t={}){const r=t.cwd??process.cwd();try{const{stdout:i}=await B(`git log -1 --format=%cI -- "${e}"`,{cwd:r}),n=i.trim();return n||null}catch{return null}}async function O(e,t={}){const r=t.cwd??process.cwd(),i={},n=[];return await I(r)?(await Promise.all(e.map(async a=>{const o=await T(a,t);o?i[a]=o:n.push(a)})),{dates:i,skipped:n}):{dates:{},skipped:e}}async function te(e,t){const r=[];async function i(n){const a=await k.readdir(n,{withFileTypes:!0});for(const o of a){const l=x.join(n,o.name);o.isDirectory()?!o.name.startsWith(".")&&o.name!=="node_modules"&&await i(l):o.isFile()&&t.some(d=>o.name.endsWith(d))&&r.push(l)}}return await i(e),r}async function ie(e){const{docsDir:t,outputPath:r,extensions:i=[".mdx",".md"]}=e,n=e.gitCwd??x.join(t,"..");if(!await I(n))return console.warn("Warning: Not a git repository. Generating empty dates file."),await G(r),{filesWithDates:0,filesSkipped:0,outputPath:r};const a=await te(t,i);if(a.length===0)return console.warn(`Warning: No files found in ${t} with extensions ${i.join(", ")}`),await G(r),{filesWithDates:0,filesSkipped:0,outputPath:r};const o=a.map(m=>x.relative(n,m)),{dates:l,skipped:c}=await O(o,{cwd:n}),d=ne(l);return await k.writeFile(r,d,"utf-8"),{filesWithDates:Object.keys(l).length,filesSkipped:c.length,outputPath:r}}async function G(e){const t=`// dates.generated.ts (auto-generated, do not edit)
2
+ // Generated at: ${new Date().toISOString()}
3
+ // Warning: Git repository not available, no dates extracted
4
+
5
+ export const lastModifiedDates: Record<string, string> = {}
6
+ `;await k.writeFile(e,t,"utf-8")}function ne(e){const t=Object.entries(e).sort(([i],[n])=>i.localeCompare(n)),r=t.map(([i,n])=>` '${i}': '${n}',`).join(`
7
+ `);return`// dates.generated.ts (auto-generated, do not edit)
8
+ // Generated at: ${new Date().toISOString()}
9
+ // Total files: ${t.length}
10
+
11
+ export const lastModifiedDates: Record<string, string> = {
12
+ ${r}
13
+ }
14
+ `}function E(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/\/$/,"")}function L(...e){return E(e.filter(Boolean).join("/"))}function re(e,t,r={}){const{basePath:i}=r;function n(a){const o={...a};if(a.file){const l=E(a.file),c=[];if(i){const m=`/${E(i)}/`,$=l.indexOf(m);if($!==-1){const p=l.slice($+1);c.push(p)}c.push(L(i,l)),c.push(L(i,l).replace(/^\//,""))}if(c.push(l),c.push(l.replace(/^\//,"")),i){const d=l.split(`/${i}/`);if(d.length>1){const m=d[d.length-1];c.push(`${i}/${m}`),c.push(m)}}for(const d of c)if(t[d]){o.lastModified=t[d];break}}return a.children&&a.children.length>0&&(o.children=a.children.map(n)),o}return e.map(n)}exports.BreadcrumbItemSchema=s.BreadcrumbItemSchema;exports.DocPageMetaSchema=s.DocPageMetaSchema;exports.DocPageSchema=s.DocPageSchema;exports.DocsPackageManifestInputSchema=s.DocsPackageManifestInputSchema;exports.DocsPackageManifestSchema=s.DocsPackageManifestSchema;exports.FlatNavigationNodeSchema=s.FlatNavigationNodeSchema;exports.GitHubConfigSchema=s.GitHubConfigSchema;exports.LoadedDocsPackageSchema=s.LoadedDocsPackageSchema;exports.ManifestValidationError=s.ManifestValidationError;exports.NavigationNodeInputSchema=s.NavigationNodeInputSchema;exports.NavigationNodeSchema=s.NavigationNodeSchema;exports.SearchConfigSchema=s.SearchConfigSchema;exports.VendureVersionSchema=s.VendureVersionSchema;exports.buildBreadcrumbs=s.buildBreadcrumbs;exports.findNavigationNode=s.findNavigationNode;exports.flattenNavigation=s.flattenNavigation;exports.getLeafNodes=s.getLeafNodes;exports.getNodesAtDepth=s.getNodesAtDepth;exports.getPrevNextNodes=s.getPrevNextNodes;exports.isNodeActive=s.isNodeActive;exports.validateManifest=s.validateManifest;exports.FrontmatterParseError=F.FrontmatterParseError;exports.extractFrontmatterData=F.extractFrontmatterData;exports.hasFrontmatter=F.hasFrontmatter;exports.parseFrontmatter=F.parseFrontmatter;exports.validateFrontmatter=F.validateFrontmatter;exports.filterVisibleNavigation=u.filterVisibleNavigation;exports.getAllFilePaths=u.getAllFilePaths;exports.slugFromFilename=u.slugFromFilename;exports.titleFromFilename=u.titleFromFilename;exports.toSlug=u.toSlug;exports.ManifestResolutionError=D;exports.applyLastModifiedDates=re;exports.createNavigationFromFolder=J;exports.createNestedNavigationFromFolder=K;exports.generateDatesFile=ie;exports.getGitLastModified=T;exports.getGitLastModifiedBatch=O;exports.isGitRepository=I;exports.manifestNeedsResolution=ee;exports.resolveManifest=X;
package/dist/index.d.ts CHANGED
@@ -10,4 +10,10 @@ export { createNavigationFromFolder, createNestedNavigationFromFolder } from './
10
10
  export type { CreateNavigationFromFolderOptions, CreateNestedNavigationFromFolderOptions, FileInfo, } from './folder-utils';
11
11
  export { ManifestResolutionError, manifestNeedsResolution, resolveManifest, } from './manifest-resolver';
12
12
  export type { ResolveManifestOptions } from './manifest-resolver';
13
+ export { getGitLastModified, getGitLastModifiedBatch, isGitRepository } from './git-utils';
14
+ export type { GitDateResult, GitOptions } from './git-utils';
15
+ export { generateDatesFile } from './generate-dates';
16
+ export type { GenerateDatesFileOptions, GenerateDatesResult } from './generate-dates';
17
+ export { applyLastModifiedDates } from './apply-dates';
18
+ export type { ApplyLastModifiedDatesOptions } from './apply-dates';
13
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,cAAc,EACd,OAAO,EACP,WAAW,EACX,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,cAAc,GACf,MAAM,SAAS,CAAA;AAGhB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,8BAA8B,EAC9B,yBAAyB,EACzB,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,UAAU,CAAA;AAGjB,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAGtD,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,GACjB,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAG7E,YAAY,EACV,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,eAAe,GAChB,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAG1E,OAAO,EAAE,0BAA0B,EAAE,gCAAgC,EAAE,MAAM,gBAAgB,CAAA;AAC7F,YAAY,EACV,iCAAiC,EACjC,uCAAuC,EACvC,QAAQ,GACT,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,eAAe,GAChB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,cAAc,EACd,OAAO,EACP,WAAW,EACX,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,cAAc,GACf,MAAM,SAAS,CAAA;AAGhB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,8BAA8B,EAC9B,yBAAyB,EACzB,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,UAAU,CAAA;AAGjB,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAGtD,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,GACjB,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAG7E,YAAY,EACV,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,eAAe,GAChB,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAG1E,OAAO,EAAE,0BAA0B,EAAE,gCAAgC,EAAE,MAAM,gBAAgB,CAAA;AAC7F,YAAY,EACV,iCAAiC,EACjC,uCAAuC,EACvC,QAAQ,GACT,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,eAAe,GAChB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAGjE,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC1F,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,YAAY,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAGrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,YAAY,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAA"}