@vendure-io/docs-provider 0.8.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.
- package/dist/apply-dates.d.ts.map +1 -1
- package/dist/generate-dates.d.ts.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +149 -141
- package/docs/last-modified-dates.md +13 -14
- package/package.json +1 -1
|
@@ -1 +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,
|
|
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"}
|
|
@@ -1 +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,
|
|
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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";var
|
|
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
2
|
// Generated at: ${new Date().toISOString()}
|
|
3
3
|
// Warning: Git repository not available, no dates extracted
|
|
4
4
|
|
|
5
5
|
export const lastModifiedDates: Record<string, string> = {}
|
|
6
|
-
`;await k.writeFile(e,t,"utf-8")}function
|
|
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
7
|
`);return`// dates.generated.ts (auto-generated, do not edit)
|
|
8
8
|
// Generated at: ${new Date().toISOString()}
|
|
9
9
|
// Total files: ${t.length}
|
|
@@ -11,4 +11,4 @@ export const lastModifiedDates: Record<string, string> = {}
|
|
|
11
11
|
export const lastModifiedDates: Record<string, string> = {
|
|
12
12
|
${r}
|
|
13
13
|
}
|
|
14
|
-
`}function
|
|
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.js
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
1
|
var A = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { B as ye, D as Ne, a as Se, b as
|
|
5
|
-
import { e as
|
|
6
|
-
import { F as
|
|
7
|
-
import { s as
|
|
2
|
+
var U = (e, t, r) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var v = (e, t, r) => U(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { B as ye, D as Ne, a as Se, b as $e, c as xe, F as be, G as De, L as Pe, M as Me, N as ke, d as Ee, S as Ie, V as We, e as je, f as Ce, g as Ge, h as Le, i as Ve, j as Re, k as Te, v as Be } from "./manifest-DlSWyjsA.js";
|
|
5
|
+
import { e as I } from "./frontmatter-B5d9WZzh.js";
|
|
6
|
+
import { F as ze, h as Ae, p as Ue, v as He } from "./frontmatter-B5d9WZzh.js";
|
|
7
|
+
import { s as F, t as w } from "./slug-utils-DVKYe9h8.js";
|
|
8
8
|
import { f as qe, g as Je, a as Ke } from "./slug-utils-DVKYe9h8.js";
|
|
9
|
-
import { readdirSync as
|
|
10
|
-
import { join as
|
|
11
|
-
import { exec as
|
|
12
|
-
import { promisify as
|
|
13
|
-
import { writeFile as
|
|
14
|
-
import { join as
|
|
15
|
-
const
|
|
9
|
+
import { readdirSync as W, readFileSync as j, statSync as H } from "fs";
|
|
10
|
+
import { join as y } from "path";
|
|
11
|
+
import { exec as _ } from "node:child_process";
|
|
12
|
+
import { promisify as q } from "node:util";
|
|
13
|
+
import { writeFile as C, readdir as J } from "node:fs/promises";
|
|
14
|
+
import { join as G, relative as K } from "node:path";
|
|
15
|
+
const L = (e, t) => e.order !== t.order ? e.order - t.order : e.title.localeCompare(t.title);
|
|
16
16
|
function ue(e, t = {}) {
|
|
17
|
-
const { extensions: r = [".mdx", ".md"], filter: i, sort: n =
|
|
18
|
-
return (i ?
|
|
19
|
-
title:
|
|
20
|
-
slug:
|
|
21
|
-
file:
|
|
17
|
+
const { extensions: r = [".mdx", ".md"], filter: i, sort: n = L } = t, s = R(e, r);
|
|
18
|
+
return (i ? s.filter(i) : s).sort(n).map((l) => ({
|
|
19
|
+
title: l.title,
|
|
20
|
+
slug: l.slug,
|
|
21
|
+
file: l.path
|
|
22
22
|
}));
|
|
23
23
|
}
|
|
24
24
|
function he(e, t = {}) {
|
|
25
|
-
return
|
|
25
|
+
return V(e, t, 0);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function V(e, t, r) {
|
|
28
28
|
const {
|
|
29
29
|
extensions: i = [".mdx", ".md"],
|
|
30
30
|
filter: n,
|
|
31
|
-
sort:
|
|
32
|
-
maxDepth:
|
|
31
|
+
sort: s = L,
|
|
32
|
+
maxDepth: o = 1 / 0,
|
|
33
33
|
folderFilter: a
|
|
34
|
-
} = t,
|
|
35
|
-
for (const u of
|
|
36
|
-
|
|
34
|
+
} = t, l = W(e, { withFileTypes: !0 }), c = [], h = R(e, i), g = (n ? h.filter(n) : h).sort(s);
|
|
35
|
+
for (const u of g)
|
|
36
|
+
c.push({
|
|
37
37
|
title: u.title,
|
|
38
38
|
slug: u.slug,
|
|
39
39
|
file: u.path
|
|
40
40
|
});
|
|
41
|
-
if (r <
|
|
42
|
-
const u =
|
|
41
|
+
if (r < o) {
|
|
42
|
+
const u = l.filter((d) => d.isDirectory());
|
|
43
43
|
for (const d of u) {
|
|
44
44
|
if (a) {
|
|
45
|
-
const
|
|
46
|
-
if (!a(d.name,
|
|
45
|
+
const f = y(e, d.name);
|
|
46
|
+
if (!a(d.name, f))
|
|
47
47
|
continue;
|
|
48
48
|
}
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
title: (
|
|
54
|
-
slug:
|
|
55
|
-
file:
|
|
56
|
-
children:
|
|
49
|
+
const m = y(e, d.name), p = V(m, t, r + 1);
|
|
50
|
+
if (p.length > 0) {
|
|
51
|
+
const f = Q(m, i);
|
|
52
|
+
c.push({
|
|
53
|
+
title: (f == null ? void 0 : f.title) || w(d.name),
|
|
54
|
+
slug: F(d.name),
|
|
55
|
+
file: f == null ? void 0 : f.path,
|
|
56
|
+
children: p.filter((S) => !(f && S.file === f.path))
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
return
|
|
62
|
-
var
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
return
|
|
66
|
-
const
|
|
67
|
-
return
|
|
61
|
+
return c.sort((u, d) => {
|
|
62
|
+
var P, M;
|
|
63
|
+
const m = g.find(($) => $.slug === u.slug), p = g.find(($) => $.slug === d.slug);
|
|
64
|
+
if (m && p)
|
|
65
|
+
return s(m, p);
|
|
66
|
+
const f = !!u.file && !((P = u.children) != null && P.length), S = !!d.file && !((M = d.children) != null && M.length);
|
|
67
|
+
return f !== S ? f ? -1 : 1 : (u.title || "").localeCompare(d.title || "");
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function R(e, t) {
|
|
71
71
|
try {
|
|
72
|
-
const r =
|
|
72
|
+
const r = W(e, { withFileTypes: !0 }), i = [];
|
|
73
73
|
for (const n of r) {
|
|
74
74
|
if (!n.isFile()) continue;
|
|
75
|
-
const
|
|
76
|
-
if (!
|
|
77
|
-
const a =
|
|
78
|
-
i.push(
|
|
75
|
+
const s = t.find((c) => n.name.toLowerCase().endsWith(c));
|
|
76
|
+
if (!s || n.name.slice(0, -s.length).toLowerCase() === "index") continue;
|
|
77
|
+
const a = y(e, n.name), l = T(a, n.name, s);
|
|
78
|
+
i.push(l);
|
|
79
79
|
}
|
|
80
80
|
return i;
|
|
81
81
|
} catch {
|
|
82
82
|
return [];
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
function
|
|
86
|
-
let i = {}, n =
|
|
85
|
+
function T(e, t, r) {
|
|
86
|
+
let i = {}, n = w(t), s = 1 / 0;
|
|
87
87
|
try {
|
|
88
|
-
const
|
|
89
|
-
i =
|
|
88
|
+
const o = j(e, "utf-8");
|
|
89
|
+
i = I(o), i.title && typeof i.title == "string" && (n = i.title), typeof i.order == "number" && (s = i.order);
|
|
90
90
|
} catch {
|
|
91
91
|
}
|
|
92
92
|
return {
|
|
@@ -94,32 +94,32 @@ function V(e, t, r) {
|
|
|
94
94
|
filename: t,
|
|
95
95
|
extension: r,
|
|
96
96
|
frontmatter: i,
|
|
97
|
-
order:
|
|
97
|
+
order: s,
|
|
98
98
|
title: n,
|
|
99
|
-
slug:
|
|
99
|
+
slug: F(t)
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function Q(e, t) {
|
|
103
103
|
for (const r of t) {
|
|
104
|
-
const i =
|
|
104
|
+
const i = y(e, `index${r}`);
|
|
105
105
|
try {
|
|
106
|
-
if (
|
|
107
|
-
return
|
|
106
|
+
if (H(i).isFile())
|
|
107
|
+
return T(i, `index${r}`, r);
|
|
108
108
|
} catch {
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
class x extends Error {
|
|
113
|
-
constructor(r, i, n,
|
|
113
|
+
constructor(r, i, n, s) {
|
|
114
114
|
super(r);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.name = "ManifestResolutionError", this.nodePath = i, this.filePath = n, this.originalError =
|
|
115
|
+
v(this, "nodePath");
|
|
116
|
+
v(this, "filePath");
|
|
117
|
+
v(this, "originalError");
|
|
118
|
+
this.name = "ManifestResolutionError", this.nodePath = i, this.filePath = n, this.originalError = s;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
function ge(e, t = {}) {
|
|
122
|
-
const { strict: r = !0 } = t, i =
|
|
122
|
+
const { strict: r = !0 } = t, i = b(e.navigation, "", r);
|
|
123
123
|
return {
|
|
124
124
|
id: e.id,
|
|
125
125
|
name: e.name,
|
|
@@ -131,52 +131,52 @@ function ge(e, t = {}) {
|
|
|
131
131
|
basePath: e.basePath
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
function
|
|
135
|
-
return e.map((i, n) =>
|
|
134
|
+
function b(e, t, r) {
|
|
135
|
+
return e.map((i, n) => X(i, t, n, r));
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function X(e, t, r, i) {
|
|
138
138
|
const n = t ? `${t}[${r}]` : `navigation[${r}]`;
|
|
139
139
|
if (e.title && e.slug)
|
|
140
140
|
return {
|
|
141
141
|
title: e.title,
|
|
142
142
|
slug: e.slug,
|
|
143
143
|
file: e.file,
|
|
144
|
-
children: e.children ?
|
|
144
|
+
children: e.children ? b(e.children, `${n}.children`, i) : void 0,
|
|
145
145
|
badge: e.badge,
|
|
146
146
|
hidden: e.hidden
|
|
147
147
|
};
|
|
148
|
-
let
|
|
149
|
-
if (e.file && (
|
|
148
|
+
let s = e.title, o = e.slug;
|
|
149
|
+
if (e.file && (o || (o = F(e.file)), s || (s = Y(e.file, n, i))), !s) {
|
|
150
150
|
if (i)
|
|
151
151
|
throw new x(
|
|
152
152
|
`Navigation node at ${n} is missing title and has no file to derive it from`,
|
|
153
153
|
n,
|
|
154
154
|
e.file
|
|
155
155
|
);
|
|
156
|
-
|
|
156
|
+
s = o || `Unknown (${r})`;
|
|
157
157
|
}
|
|
158
|
-
if (!
|
|
158
|
+
if (!o) {
|
|
159
159
|
if (i)
|
|
160
160
|
throw new x(
|
|
161
161
|
`Navigation node at ${n} is missing slug and has no file to derive it from`,
|
|
162
162
|
n,
|
|
163
163
|
e.file
|
|
164
164
|
);
|
|
165
|
-
|
|
165
|
+
o = s ? F(s) : `node-${r}`;
|
|
166
166
|
}
|
|
167
167
|
return {
|
|
168
|
-
title:
|
|
169
|
-
slug:
|
|
168
|
+
title: s,
|
|
169
|
+
slug: o,
|
|
170
170
|
file: e.file,
|
|
171
|
-
children: e.children ?
|
|
171
|
+
children: e.children ? b(e.children, `${n}.children`, i) : void 0,
|
|
172
172
|
badge: e.badge,
|
|
173
173
|
hidden: e.hidden
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function Y(e, t, r) {
|
|
177
177
|
try {
|
|
178
|
-
const i =
|
|
179
|
-
return n.title && typeof n.title == "string" ? n.title :
|
|
178
|
+
const i = j(e, "utf-8"), n = I(i);
|
|
179
|
+
return n.title && typeof n.title == "string" ? n.title : w(e);
|
|
180
180
|
} catch (i) {
|
|
181
181
|
if (r)
|
|
182
182
|
throw new x(
|
|
@@ -185,77 +185,77 @@ function Q(e, t, r) {
|
|
|
185
185
|
e,
|
|
186
186
|
i
|
|
187
187
|
);
|
|
188
|
-
return
|
|
188
|
+
return w(e);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
function me(e) {
|
|
192
|
-
return
|
|
192
|
+
return B(e.navigation);
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function B(e) {
|
|
195
195
|
for (const t of e)
|
|
196
|
-
if (!t.title || !t.slug || t.children &&
|
|
196
|
+
if (!t.title || !t.slug || t.children && B(t.children))
|
|
197
197
|
return !0;
|
|
198
198
|
return !1;
|
|
199
199
|
}
|
|
200
|
-
const
|
|
201
|
-
async function
|
|
200
|
+
const O = q(_);
|
|
201
|
+
async function z(e = process.cwd()) {
|
|
202
202
|
try {
|
|
203
|
-
return await
|
|
203
|
+
return await O("git rev-parse --git-dir", { cwd: e }), !0;
|
|
204
204
|
} catch {
|
|
205
205
|
return !1;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
async function
|
|
208
|
+
async function Z(e, t = {}) {
|
|
209
209
|
const r = t.cwd ?? process.cwd();
|
|
210
210
|
try {
|
|
211
|
-
const { stdout: i } = await
|
|
211
|
+
const { stdout: i } = await O(`git log -1 --format=%cI -- "${e}"`, { cwd: r }), n = i.trim();
|
|
212
212
|
return n || null;
|
|
213
213
|
} catch {
|
|
214
214
|
return null;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
async function
|
|
217
|
+
async function ee(e, t = {}) {
|
|
218
218
|
const r = t.cwd ?? process.cwd(), i = {}, n = [];
|
|
219
|
-
return await
|
|
220
|
-
e.map(async (
|
|
221
|
-
const
|
|
222
|
-
|
|
219
|
+
return await z(r) ? (await Promise.all(
|
|
220
|
+
e.map(async (s) => {
|
|
221
|
+
const o = await Z(s, t);
|
|
222
|
+
o ? i[s] = o : n.push(s);
|
|
223
223
|
})
|
|
224
224
|
), { dates: i, skipped: n }) : {
|
|
225
225
|
dates: {},
|
|
226
226
|
skipped: e
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
|
-
async function
|
|
229
|
+
async function te(e, t) {
|
|
230
230
|
const r = [];
|
|
231
231
|
async function i(n) {
|
|
232
|
-
const
|
|
233
|
-
for (const
|
|
234
|
-
const a =
|
|
235
|
-
|
|
232
|
+
const s = await J(n, { withFileTypes: !0 });
|
|
233
|
+
for (const o of s) {
|
|
234
|
+
const a = G(n, o.name);
|
|
235
|
+
o.isDirectory() ? !o.name.startsWith(".") && o.name !== "node_modules" && await i(a) : o.isFile() && t.some((c) => o.name.endsWith(c)) && r.push(a);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
return await i(e), r;
|
|
239
239
|
}
|
|
240
240
|
async function pe(e) {
|
|
241
|
-
const { docsDir: t, outputPath: r, extensions: i = [".mdx", ".md"] } = e, n = e.gitCwd ??
|
|
242
|
-
if (!await
|
|
241
|
+
const { docsDir: t, outputPath: r, extensions: i = [".mdx", ".md"] } = e, n = e.gitCwd ?? G(t, "..");
|
|
242
|
+
if (!await z(n))
|
|
243
243
|
return console.warn("Warning: Not a git repository. Generating empty dates file."), await k(r), {
|
|
244
244
|
filesWithDates: 0,
|
|
245
245
|
filesSkipped: 0,
|
|
246
246
|
outputPath: r
|
|
247
247
|
};
|
|
248
|
-
const
|
|
249
|
-
if (
|
|
248
|
+
const s = await te(t, i);
|
|
249
|
+
if (s.length === 0)
|
|
250
250
|
return console.warn(`Warning: No files found in ${t} with extensions ${i.join(", ")}`), await k(r), {
|
|
251
251
|
filesWithDates: 0,
|
|
252
252
|
filesSkipped: 0,
|
|
253
253
|
outputPath: r
|
|
254
254
|
};
|
|
255
|
-
const
|
|
256
|
-
return await
|
|
255
|
+
const o = s.map((h) => K(n, h)), { dates: a, skipped: l } = await ee(o, { cwd: n }), c = ie(a);
|
|
256
|
+
return await C(r, c, "utf-8"), {
|
|
257
257
|
filesWithDates: Object.keys(a).length,
|
|
258
|
-
filesSkipped:
|
|
258
|
+
filesSkipped: l.length,
|
|
259
259
|
outputPath: r
|
|
260
260
|
};
|
|
261
261
|
}
|
|
@@ -266,9 +266,9 @@ async function k(e) {
|
|
|
266
266
|
|
|
267
267
|
export const lastModifiedDates: Record<string, string> = {}
|
|
268
268
|
`;
|
|
269
|
-
await
|
|
269
|
+
await C(e, t, "utf-8");
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function ie(e) {
|
|
272
272
|
const t = Object.entries(e).sort(([i], [n]) => i.localeCompare(n)), r = t.map(([i, n]) => ` '${i}': '${n}',`).join(`
|
|
273
273
|
`);
|
|
274
274
|
return `// dates.generated.ts (auto-generated, do not edit)
|
|
@@ -283,29 +283,37 @@ ${r}
|
|
|
283
283
|
function D(e) {
|
|
284
284
|
return e.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/\/$/, "");
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function E(...e) {
|
|
287
287
|
return D(e.filter(Boolean).join("/"));
|
|
288
288
|
}
|
|
289
289
|
function ve(e, t, r = {}) {
|
|
290
290
|
const { basePath: i } = r;
|
|
291
|
-
function n(
|
|
292
|
-
const
|
|
293
|
-
if (
|
|
294
|
-
const a =
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
291
|
+
function n(s) {
|
|
292
|
+
const o = { ...s };
|
|
293
|
+
if (s.file) {
|
|
294
|
+
const a = D(s.file), l = [];
|
|
295
|
+
if (i) {
|
|
296
|
+
const h = `/${D(i)}/`, N = a.indexOf(h);
|
|
297
|
+
if (N !== -1) {
|
|
298
|
+
const g = a.slice(N + 1);
|
|
299
|
+
l.push(g);
|
|
300
|
+
}
|
|
301
|
+
l.push(E(i, a)), l.push(E(i, a).replace(/^\//, ""));
|
|
302
|
+
}
|
|
303
|
+
if (l.push(a), l.push(a.replace(/^\//, "")), i) {
|
|
304
|
+
const c = a.split(`/${i}/`);
|
|
305
|
+
if (c.length > 1) {
|
|
306
|
+
const h = c[c.length - 1];
|
|
307
|
+
l.push(`${i}/${h}`), l.push(h);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
for (const c of l)
|
|
311
|
+
if (t[c]) {
|
|
312
|
+
o.lastModified = t[c];
|
|
305
313
|
break;
|
|
306
314
|
}
|
|
307
315
|
}
|
|
308
|
-
return
|
|
316
|
+
return s.children && s.children.length > 0 && (o.children = s.children.map(n)), o;
|
|
309
317
|
}
|
|
310
318
|
return e.map(n);
|
|
311
319
|
}
|
|
@@ -313,15 +321,15 @@ export {
|
|
|
313
321
|
ye as BreadcrumbItemSchema,
|
|
314
322
|
Ne as DocPageMetaSchema,
|
|
315
323
|
Se as DocPageSchema,
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
324
|
+
$e as DocsPackageManifestInputSchema,
|
|
325
|
+
xe as DocsPackageManifestSchema,
|
|
326
|
+
be as FlatNavigationNodeSchema,
|
|
327
|
+
ze as FrontmatterParseError,
|
|
328
|
+
De as GitHubConfigSchema,
|
|
329
|
+
Pe as LoadedDocsPackageSchema,
|
|
322
330
|
x as ManifestResolutionError,
|
|
323
|
-
|
|
324
|
-
|
|
331
|
+
Me as ManifestValidationError,
|
|
332
|
+
ke as NavigationNodeInputSchema,
|
|
325
333
|
Ee as NavigationNodeSchema,
|
|
326
334
|
Ie as SearchConfigSchema,
|
|
327
335
|
We as VendureVersionSchema,
|
|
@@ -329,25 +337,25 @@ export {
|
|
|
329
337
|
je as buildBreadcrumbs,
|
|
330
338
|
ue as createNavigationFromFolder,
|
|
331
339
|
he as createNestedNavigationFromFolder,
|
|
332
|
-
|
|
340
|
+
I as extractFrontmatterData,
|
|
333
341
|
qe as filterVisibleNavigation,
|
|
334
342
|
Ce as findNavigationNode,
|
|
335
343
|
Ge as flattenNavigation,
|
|
336
344
|
pe as generateDatesFile,
|
|
337
345
|
Je as getAllFilePaths,
|
|
338
|
-
|
|
339
|
-
|
|
346
|
+
Z as getGitLastModified,
|
|
347
|
+
ee as getGitLastModifiedBatch,
|
|
340
348
|
Le as getLeafNodes,
|
|
341
349
|
Ve as getNodesAtDepth,
|
|
342
350
|
Re as getPrevNextNodes,
|
|
343
|
-
|
|
344
|
-
|
|
351
|
+
Ae as hasFrontmatter,
|
|
352
|
+
z as isGitRepository,
|
|
345
353
|
Te as isNodeActive,
|
|
346
354
|
me as manifestNeedsResolution,
|
|
347
|
-
|
|
355
|
+
Ue as parseFrontmatter,
|
|
348
356
|
ge as resolveManifest,
|
|
349
|
-
|
|
350
|
-
|
|
357
|
+
F as slugFromFilename,
|
|
358
|
+
w as titleFromFilename,
|
|
351
359
|
Ke as toSlug,
|
|
352
360
|
He as validateFrontmatter,
|
|
353
361
|
Be as validateManifest
|
|
@@ -95,11 +95,9 @@ const resolvedManifest = resolveManifest(manifestInput)
|
|
|
95
95
|
// Apply dates from the generated file
|
|
96
96
|
export const manifest = {
|
|
97
97
|
...resolvedManifest,
|
|
98
|
-
navigation: applyLastModifiedDates(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
{ basePath: 'docs' }
|
|
102
|
-
),
|
|
98
|
+
navigation: applyLastModifiedDates(resolvedManifest.navigation, lastModifiedDates, {
|
|
99
|
+
basePath: 'docs',
|
|
100
|
+
}),
|
|
103
101
|
}
|
|
104
102
|
```
|
|
105
103
|
|
|
@@ -162,12 +160,12 @@ Applies dates from a map to navigation nodes. This function is browser-safe and
|
|
|
162
160
|
import { applyLastModifiedDates } from '@vendure-io/docs-provider'
|
|
163
161
|
|
|
164
162
|
const navigationWithDates = applyLastModifiedDates(
|
|
165
|
-
navigation,
|
|
166
|
-
lastModifiedDates,
|
|
163
|
+
navigation, // NavigationNode[]
|
|
164
|
+
lastModifiedDates, // Record<string, string>
|
|
167
165
|
{
|
|
168
166
|
// Optional: prefix to prepend to file paths when looking up dates
|
|
169
|
-
basePath: 'docs'
|
|
170
|
-
}
|
|
167
|
+
basePath: 'docs',
|
|
168
|
+
},
|
|
171
169
|
)
|
|
172
170
|
```
|
|
173
171
|
|
|
@@ -194,15 +192,14 @@ const isGit = await isGitRepository('/path/to/dir')
|
|
|
194
192
|
|
|
195
193
|
// Get date for a single file
|
|
196
194
|
const date = await getGitLastModified('docs/intro.mdx', {
|
|
197
|
-
cwd: '/path/to/repo'
|
|
195
|
+
cwd: '/path/to/repo',
|
|
198
196
|
})
|
|
199
197
|
// Returns: '2024-01-15T10:30:00+01:00' or null
|
|
200
198
|
|
|
201
199
|
// Get dates for multiple files efficiently
|
|
202
|
-
const result = await getGitLastModifiedBatch(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
)
|
|
200
|
+
const result = await getGitLastModifiedBatch(['docs/intro.mdx', 'docs/guide.mdx'], {
|
|
201
|
+
cwd: '/path/to/repo',
|
|
202
|
+
})
|
|
206
203
|
// Returns: { dates: { 'docs/intro.mdx': '2024-...' }, skipped: [] }
|
|
207
204
|
```
|
|
208
205
|
|
|
@@ -215,6 +212,7 @@ All dates use ISO 8601 format with timezone offset:
|
|
|
215
212
|
```
|
|
216
213
|
|
|
217
214
|
This format is:
|
|
215
|
+
|
|
218
216
|
- Human-readable
|
|
219
217
|
- Machine-parseable
|
|
220
218
|
- Timezone-aware
|
|
@@ -229,6 +227,7 @@ Files not yet committed to git will be skipped (no date assigned). This is inten
|
|
|
229
227
|
### Non-Git Directories
|
|
230
228
|
|
|
231
229
|
If `generateDatesFile` is run outside a git repository:
|
|
230
|
+
|
|
232
231
|
- A warning is logged
|
|
233
232
|
- An empty dates file is generated
|
|
234
233
|
- No errors are thrown
|