@vendure-io/docs-provider 0.8.0 → 0.9.0

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.
@@ -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,CAqClB"}
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,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA6CvG"}
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 T=Object.defineProperty;var O=(e,t,r)=>t in e?T(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var w=(e,t,r)=>O(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./manifest-BkO3d77g.cjs"),h=require("./frontmatter-QFErVd9b.cjs"),d=require("./slug-utils-DUQgikEz.cjs"),N=require("fs"),y=require("path"),_=require("node:child_process"),U=require("node:util"),k=require("node:fs/promises"),x=require("node:path"),G=(e,t)=>e.order!==t.order?e.order-t.order:e.title.localeCompare(t.title);function H(e,t={}){const{extensions:r=[".mdx",".md"],filter:i,sort:n=G}=t,a=V(e,r);return(i?a.filter(i):a).sort(n).map(f=>({title:f.title,slug:f.slug,file:f.path}))}function z(e,t={}){return L(e,t,0)}function L(e,t,r){const{extensions:i=[".mdx",".md"],filter:n,sort:a=G,maxDepth:o=1/0,folderFilter:l}=t,f=N.readdirSync(e,{withFileTypes:!0}),u=[],p=V(e,i),D=(n?p.filter(n):p).sort(a);for(const m of D)u.push({title:m.title,slug:m.slug,file:m.path});if(r<o){const m=f.filter(g=>g.isDirectory());for(const g of m){if(l){const c=y.join(e,g.name);if(!l(g.name,c))continue}const F=y.join(e,g.name),v=L(F,t,r+1);if(v.length>0){const c=J(F,i);u.push({title:(c==null?void 0:c.title)||d.titleFromFilename(g.name),slug:d.slugFromFilename(g.name),file:c==null?void 0:c.path,children:v.filter(M=>!(c&&M.file===c.path))})}}}return u.sort((m,g)=>{var I,j;const F=D.find(b=>b.slug===m.slug),v=D.find(b=>b.slug===g.slug);if(F&&v)return a(F,v);const c=!!m.file&&!((I=m.children)!=null&&I.length),M=!!g.file&&!((j=g.children)!=null&&j.length);return c!==M?c?-1:1:(m.title||"").localeCompare(g.title||"")})}function V(e,t){try{const r=N.readdirSync(e,{withFileTypes:!0}),i=[];for(const n of r){if(!n.isFile())continue;const a=t.find(u=>n.name.toLowerCase().endsWith(u));if(!a||n.name.slice(0,-a.length).toLowerCase()==="index")continue;const l=y.join(e,n.name),f=W(l,n.name,a);i.push(f)}return i}catch{return[]}}function W(e,t,r){let i={},n=d.titleFromFilename(t),a=1/0;try{const o=N.readFileSync(e,"utf-8");i=h.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:d.slugFromFilename(t)}}function J(e,t){for(const r of t){const i=y.join(e,`index${r}`);try{if(N.statSync(i).isFile())return W(i,`index${r}`,r)}catch{}}}class S extends Error{constructor(r,i,n,a){super(r);w(this,"nodePath");w(this,"filePath");w(this,"originalError");this.name="ManifestResolutionError",this.nodePath=i,this.filePath=n,this.originalError=a}}function K(e,t={}){const{strict:r=!0}=t,i=$(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 $(e,t,r){return e.map((i,n)=>Q(i,t,n,r))}function Q(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?$(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=d.slugFromFilename(e.file)),a||(a=X(e.file,n,i))),!a){if(i)throw new S(`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 S(`Navigation node at ${n} is missing slug and has no file to derive it from`,n,e.file);o=a?d.slugFromFilename(a):`node-${r}`}return{title:a,slug:o,file:e.file,children:e.children?$(e.children,`${n}.children`,i):void 0,badge:e.badge,hidden:e.hidden}}function X(e,t,r){try{const i=N.readFileSync(e,"utf-8"),n=h.extractFrontmatterData(i);return n.title&&typeof n.title=="string"?n.title:d.titleFromFilename(e)}catch(i){if(r)throw new S(`Failed to read file for title derivation at ${t}: ${e}`,t,e,i);return d.titleFromFilename(e)}}function Y(e){return R(e.navigation)}function R(e){for(const t of e)if(!t.title||!t.slug||t.children&&R(t.children))return!0;return!1}const q=U.promisify(_.exec);async function E(e=process.cwd()){try{return await q("git rev-parse --git-dir",{cwd:e}),!0}catch{return!1}}async function A(e,t={}){const r=t.cwd??process.cwd();try{const{stdout:i}=await q(`git log -1 --format=%cI -- "${e}"`,{cwd:r}),n=i.trim();return n||null}catch{return null}}async function B(e,t={}){const r=t.cwd??process.cwd(),i={},n=[];return await E(r)?(await Promise.all(e.map(async a=>{const o=await A(a,t);o?i[a]=o:n.push(a)})),{dates:i,skipped:n}):{dates:{},skipped:e}}async function Z(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(u=>o.name.endsWith(u))&&r.push(l)}}return await i(e),r}async function ee(e){const{docsDir:t,outputPath:r,extensions:i=[".mdx",".md"]}=e,n=e.gitCwd??x.join(t,"..");if(!await E(n))return console.warn("Warning: Not a git repository. Generating empty dates file."),await C(r),{filesWithDates:0,filesSkipped:0,outputPath:r};const a=await Z(t,i);if(a.length===0)return console.warn(`Warning: No files found in ${t} with extensions ${i.join(", ")}`),await C(r),{filesWithDates:0,filesSkipped:0,outputPath:r};const o=a.map(p=>x.relative(n,p)),{dates:l,skipped:f}=await B(o,{cwd:n}),u=te(l);return await k.writeFile(r,u,"utf-8"),{filesWithDates:Object.keys(l).length,filesSkipped:f.length,outputPath:r}}async function C(e){const t=`// dates.generated.ts (auto-generated, do not edit)
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 te(e){const t=Object.entries(e).sort(([i],[n])=>i.localeCompare(n)),r=t.map(([i,n])=>` '${i}': '${n}',`).join(`
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 P(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/\/$/,"")}function ie(...e){return P(e.filter(Boolean).join("/"))}function ne(e,t,r={}){const{basePath:i}=r;function n(a){const o={...a};if(a.file){const l=i?ie(i,a.file):a.file,f=[P(l),P(l).replace(/^\//,""),a.file,a.file.replace(/^\//,"")];for(const u of f)if(t[u]){o.lastModified=t[u];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=h.FrontmatterParseError;exports.extractFrontmatterData=h.extractFrontmatterData;exports.hasFrontmatter=h.hasFrontmatter;exports.parseFrontmatter=h.parseFrontmatter;exports.validateFrontmatter=h.validateFrontmatter;exports.filterVisibleNavigation=d.filterVisibleNavigation;exports.getAllFilePaths=d.getAllFilePaths;exports.slugFromFilename=d.slugFromFilename;exports.titleFromFilename=d.titleFromFilename;exports.toSlug=d.toSlug;exports.ManifestResolutionError=S;exports.applyLastModifiedDates=ne;exports.createNavigationFromFolder=H;exports.createNestedNavigationFromFolder=z;exports.generateDatesFile=ee;exports.getGitLastModified=A;exports.getGitLastModifiedBatch=B;exports.isGitRepository=E;exports.manifestNeedsResolution=Y;exports.resolveManifest=K;
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 O = (e, t, r) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var p = (e, t, r) => O(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { B as ye, D as Ne, a as Se, b as xe, c as $e, F as De, G as be, L as Me, M as ke, N as Pe, 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 P } from "./frontmatter-B5d9WZzh.js";
6
- import { F as Oe, h as Ue, p as ze, v as He } from "./frontmatter-B5d9WZzh.js";
7
- import { s as v, t as F } from "./slug-utils-DVKYe9h8.js";
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 E, readFileSync as I, statSync as U } from "fs";
10
- import { join as w } from "path";
11
- import { exec as z } from "node:child_process";
12
- import { promisify as H } from "node:util";
13
- import { writeFile as W, readdir as _ } from "node:fs/promises";
14
- import { join as j, relative as q } from "node:path";
15
- const C = (e, t) => e.order !== t.order ? e.order - t.order : e.title.localeCompare(t.title);
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 = C } = t, o = L(e, r);
18
- return (i ? o.filter(i) : o).sort(n).map((c) => ({
19
- title: c.title,
20
- slug: c.slug,
21
- file: c.path
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 G(e, t, 0);
25
+ return V(e, t, 0);
26
26
  }
27
- function G(e, t, r) {
27
+ function V(e, t, r) {
28
28
  const {
29
29
  extensions: i = [".mdx", ".md"],
30
30
  filter: n,
31
- sort: o = C,
32
- maxDepth: s = 1 / 0,
31
+ sort: s = L,
32
+ maxDepth: o = 1 / 0,
33
33
  folderFilter: a
34
- } = t, c = E(e, { withFileTypes: !0 }), f = [], m = L(e, i), y = (n ? m.filter(n) : m).sort(o);
35
- for (const u of y)
36
- f.push({
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 < s) {
42
- const u = c.filter((d) => d.isDirectory());
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 l = w(e, d.name);
46
- if (!a(d.name, l))
45
+ const f = y(e, d.name);
46
+ if (!a(d.name, f))
47
47
  continue;
48
48
  }
49
- const h = w(e, d.name), g = G(h, t, r + 1);
50
- if (g.length > 0) {
51
- const l = J(h, i);
52
- f.push({
53
- title: (l == null ? void 0 : l.title) || F(d.name),
54
- slug: v(d.name),
55
- file: l == null ? void 0 : l.path,
56
- children: g.filter((N) => !(l && N.file === l.path))
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 f.sort((u, d) => {
62
- var b, M;
63
- const h = y.find((S) => S.slug === u.slug), g = y.find((S) => S.slug === d.slug);
64
- if (h && g)
65
- return o(h, g);
66
- const l = !!u.file && !((b = u.children) != null && b.length), N = !!d.file && !((M = d.children) != null && M.length);
67
- return l !== N ? l ? -1 : 1 : (u.title || "").localeCompare(d.title || "");
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 L(e, t) {
70
+ function R(e, t) {
71
71
  try {
72
- const r = E(e, { withFileTypes: !0 }), i = [];
72
+ const r = W(e, { withFileTypes: !0 }), i = [];
73
73
  for (const n of r) {
74
74
  if (!n.isFile()) continue;
75
- const o = t.find((f) => n.name.toLowerCase().endsWith(f));
76
- if (!o || n.name.slice(0, -o.length).toLowerCase() === "index") continue;
77
- const a = w(e, n.name), c = V(a, n.name, o);
78
- i.push(c);
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 V(e, t, r) {
86
- let i = {}, n = F(t), o = 1 / 0;
85
+ function T(e, t, r) {
86
+ let i = {}, n = w(t), s = 1 / 0;
87
87
  try {
88
- const s = I(e, "utf-8");
89
- i = P(s), i.title && typeof i.title == "string" && (n = i.title), typeof i.order == "number" && (o = i.order);
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: o,
97
+ order: s,
98
98
  title: n,
99
- slug: v(t)
99
+ slug: F(t)
100
100
  };
101
101
  }
102
- function J(e, t) {
102
+ function Q(e, t) {
103
103
  for (const r of t) {
104
- const i = w(e, `index${r}`);
104
+ const i = y(e, `index${r}`);
105
105
  try {
106
- if (U(i).isFile())
107
- return V(i, `index${r}`, r);
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, o) {
113
+ constructor(r, i, n, s) {
114
114
  super(r);
115
- p(this, "nodePath");
116
- p(this, "filePath");
117
- p(this, "originalError");
118
- this.name = "ManifestResolutionError", this.nodePath = i, this.filePath = n, this.originalError = o;
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 = $(e.navigation, "", r);
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 $(e, t, r) {
135
- return e.map((i, n) => K(i, t, n, r));
134
+ function b(e, t, r) {
135
+ return e.map((i, n) => X(i, t, n, r));
136
136
  }
137
- function K(e, t, r, i) {
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 ? $(e.children, `${n}.children`, i) : void 0,
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 o = e.title, s = e.slug;
149
- if (e.file && (s || (s = v(e.file)), o || (o = Q(e.file, n, i))), !o) {
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
- o = s || `Unknown (${r})`;
156
+ s = o || `Unknown (${r})`;
157
157
  }
158
- if (!s) {
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
- s = o ? v(o) : `node-${r}`;
165
+ o = s ? F(s) : `node-${r}`;
166
166
  }
167
167
  return {
168
- title: o,
169
- slug: s,
168
+ title: s,
169
+ slug: o,
170
170
  file: e.file,
171
- children: e.children ? $(e.children, `${n}.children`, i) : void 0,
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 Q(e, t, r) {
176
+ function Y(e, t, r) {
177
177
  try {
178
- const i = I(e, "utf-8"), n = P(i);
179
- return n.title && typeof n.title == "string" ? n.title : F(e);
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 F(e);
188
+ return w(e);
189
189
  }
190
190
  }
191
191
  function me(e) {
192
- return R(e.navigation);
192
+ return B(e.navigation);
193
193
  }
194
- function R(e) {
194
+ function B(e) {
195
195
  for (const t of e)
196
- if (!t.title || !t.slug || t.children && R(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 T = H(z);
201
- async function B(e = process.cwd()) {
200
+ const O = q(_);
201
+ async function z(e = process.cwd()) {
202
202
  try {
203
- return await T("git rev-parse --git-dir", { cwd: e }), !0;
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 X(e, t = {}) {
208
+ async function Z(e, t = {}) {
209
209
  const r = t.cwd ?? process.cwd();
210
210
  try {
211
- const { stdout: i } = await T(`git log -1 --format=%cI -- "${e}"`, { cwd: r }), n = i.trim();
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 Y(e, t = {}) {
217
+ async function ee(e, t = {}) {
218
218
  const r = t.cwd ?? process.cwd(), i = {}, n = [];
219
- return await B(r) ? (await Promise.all(
220
- e.map(async (o) => {
221
- const s = await X(o, t);
222
- s ? i[o] = s : n.push(o);
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 Z(e, t) {
229
+ async function te(e, t) {
230
230
  const r = [];
231
231
  async function i(n) {
232
- const o = await _(n, { withFileTypes: !0 });
233
- for (const s of o) {
234
- const a = j(n, s.name);
235
- s.isDirectory() ? !s.name.startsWith(".") && s.name !== "node_modules" && await i(a) : s.isFile() && t.some((f) => s.name.endsWith(f)) && r.push(a);
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 ?? j(t, "..");
242
- if (!await B(n))
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 o = await Z(t, i);
249
- if (o.length === 0)
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 s = o.map((m) => q(n, m)), { dates: a, skipped: c } = await Y(s, { cwd: n }), f = ee(a);
256
- return await W(r, f, "utf-8"), {
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: c.length,
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 W(e, t, "utf-8");
269
+ await C(e, t, "utf-8");
270
270
  }
271
- function ee(e) {
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 te(...e) {
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(o) {
292
- const s = { ...o };
293
- if (o.file) {
294
- const a = i ? te(i, o.file) : o.file, c = [
295
- D(a),
296
- // Try without leading slash
297
- D(a).replace(/^\//, ""),
298
- // Try the file path as-is
299
- o.file,
300
- o.file.replace(/^\//, "")
301
- ];
302
- for (const f of c)
303
- if (t[f]) {
304
- s.lastModified = t[f];
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 o.children && o.children.length > 0 && (s.children = o.children.map(n)), s;
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
- xe as DocsPackageManifestInputSchema,
317
- $e as DocsPackageManifestSchema,
318
- De as FlatNavigationNodeSchema,
319
- Oe as FrontmatterParseError,
320
- be as GitHubConfigSchema,
321
- Me as LoadedDocsPackageSchema,
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
- ke as ManifestValidationError,
324
- Pe as NavigationNodeInputSchema,
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
- P as extractFrontmatterData,
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
- X as getGitLastModified,
339
- Y as getGitLastModifiedBatch,
346
+ Z as getGitLastModified,
347
+ ee as getGitLastModifiedBatch,
340
348
  Le as getLeafNodes,
341
349
  Ve as getNodesAtDepth,
342
350
  Re as getPrevNextNodes,
343
- Ue as hasFrontmatter,
344
- B as isGitRepository,
351
+ Ae as hasFrontmatter,
352
+ z as isGitRepository,
345
353
  Te as isNodeActive,
346
354
  me as manifestNeedsResolution,
347
- ze as parseFrontmatter,
355
+ Ue as parseFrontmatter,
348
356
  ge as resolveManifest,
349
- v as slugFromFilename,
350
- F as titleFromFilename,
357
+ F as slugFromFilename,
358
+ w as titleFromFilename,
351
359
  Ke as toSlug,
352
360
  He as validateFrontmatter,
353
361
  Be as validateManifest
@@ -1,7 +1,8 @@
1
1
  import { MdxCompilationResult, MdxTestReport } from './types';
2
- export type { CompileMdxOptions, MdxCompilationResult, MdxTestReport, TestManifestOptions, } from './types';
2
+ export type { AdmonitionError, AdmonitionValidationReport, CompileMdxOptions, MdxCompilationResult, MdxTestReport, TestManifestOptions, ValidateAdmonitionsOptions, } from './types';
3
3
  export { compileMdx, getDefaultRehypePlugins, getDefaultRemarkPlugins } from './mdx-compiler';
4
4
  export { testManifestMdx } from './test-manifest';
5
+ export { ADMONITION_TYPES, formatAdmonitionReport, INVALID_ADMONITION_PATTERN, validateAdmonitions, } from './validate-admonitions';
5
6
  /**
6
7
  * Format a test report for console output.
7
8
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAGlE,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,mBAAmB,GACpB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,UAAQ,GAAG,MAAM,CAgE/E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,IAAI,CACxC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,oBAAoB,KACzB,IAAI,CAcR"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAGlE,YAAY,EACV,eAAe,EACf,0BAA0B,EAC1B,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,UAAQ,GAAG,MAAM,CAgE/E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,IAAI,CACxC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,oBAAoB,KACzB,IAAI,CAcR"}
@@ -73,4 +73,53 @@ export interface CompileMdxOptions {
73
73
  */
74
74
  rehypePlugins?: PluggableList;
75
75
  }
76
+ /**
77
+ * Error found during admonition syntax validation
78
+ */
79
+ export interface AdmonitionError {
80
+ /** Relative path to the file from the manifest basePath */
81
+ file: string;
82
+ /** Absolute path to the file */
83
+ absolutePath: string;
84
+ /** Line number where the error was found (1-indexed) */
85
+ line: number;
86
+ /** Column number where the error was found (1-indexed) */
87
+ column: number;
88
+ /** The full content of the line containing the error */
89
+ content: string;
90
+ /** The type of admonition (warning, info, tip, etc.) */
91
+ admonitionType: string;
92
+ /** The label that was incorrectly space-separated */
93
+ label: string;
94
+ /** Suggested fix using bracket syntax */
95
+ suggestion: string;
96
+ }
97
+ /**
98
+ * Report from validating admonition syntax in a manifest
99
+ */
100
+ export interface AdmonitionValidationReport {
101
+ /** Package ID from the manifest */
102
+ packageId: string;
103
+ /** Number of files that were scanned */
104
+ filesScanned: number;
105
+ /** List of validation errors found */
106
+ errors: AdmonitionError[];
107
+ /** Total time taken for validation in milliseconds */
108
+ totalTime: number;
109
+ }
110
+ /**
111
+ * Options for validating admonition syntax
112
+ */
113
+ export interface ValidateAdmonitionsOptions {
114
+ /**
115
+ * Stop on first error.
116
+ * @default false
117
+ */
118
+ failFast?: boolean;
119
+ /**
120
+ * Callback invoked for each error found.
121
+ * Useful for real-time reporting.
122
+ */
123
+ onError?: (error: AdmonitionError) => void;
124
+ }
76
125
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/testing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAA;IAChB,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAA;IAChB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qDAAqD;IACrD,eAAe,EAAE,MAAM,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAA;IACd,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAA;IACd,uCAAuC;IACvC,OAAO,EAAE,oBAAoB,EAAE,CAAA;IAC/B,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAA;CACpF;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/testing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAA;IAChB,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAA;IAChB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qDAAqD;IACrD,eAAe,EAAE,MAAM,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAA;IACd,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAA;IACd,uCAAuC;IACvC,OAAO,EAAE,oBAAoB,EAAE,CAAA;IAC/B,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAA;CACpF;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAA;IACZ,gCAAgC;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAA;IACZ,0DAA0D;IAC1D,MAAM,EAAE,MAAM,CAAA;IACd,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAA;IACf,wDAAwD;IACxD,cAAc,EAAE,MAAM,CAAA;IACtB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAA;IACb,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAA;IACpB,sCAAsC;IACtC,MAAM,EAAE,eAAe,EAAE,CAAA;IACzB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAA;CAC3C"}
@@ -0,0 +1,59 @@
1
+ import { DocsPackageManifest } from '../types';
2
+ import { AdmonitionValidationReport, ValidateAdmonitionsOptions } from './types';
3
+ /**
4
+ * Supported admonition types in remark-directive
5
+ */
6
+ export declare const ADMONITION_TYPES: readonly ["warning", "info", "tip", "note", "caution", "danger"];
7
+ /**
8
+ * Pattern that matches invalid admonition syntax with space-separated labels.
9
+ *
10
+ * Valid: :::warning[Deprecated]
11
+ * Invalid: :::warning Deprecated
12
+ *
13
+ * This pattern captures:
14
+ * - Group 1: The admonition type (warning, info, tip, etc.)
15
+ * - Group 2: The label text (everything after the space until end of line)
16
+ */
17
+ export declare const INVALID_ADMONITION_PATTERN: RegExp;
18
+ /**
19
+ * Validate admonition syntax in all MDX files of a manifest.
20
+ *
21
+ * The remark-directive v4 plugin requires square bracket syntax for labels:
22
+ * - Valid: `:::warning[Deprecated]`
23
+ * - Invalid: `:::warning Deprecated`
24
+ *
25
+ * This function scans all MDX files in the manifest and reports any
26
+ * admonitions using the invalid space-separated label syntax.
27
+ *
28
+ * @param manifest - The documentation package manifest to validate
29
+ * @param options - Optional configuration for validation
30
+ * @returns A report containing all validation errors
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * import { manifest } from '../src/manifest'
35
+ * import { validateAdmonitions, formatAdmonitionReport } from '@vendure-io/docs-provider/testing'
36
+ *
37
+ * const report = validateAdmonitions(manifest)
38
+ *
39
+ * if (report.errors.length > 0) {
40
+ * console.error(formatAdmonitionReport(report))
41
+ * process.exit(1)
42
+ * }
43
+ * ```
44
+ */
45
+ export declare function validateAdmonitions(manifest: DocsPackageManifest, options?: ValidateAdmonitionsOptions): AdmonitionValidationReport;
46
+ /**
47
+ * Format an admonition validation report for console output.
48
+ *
49
+ * @param report - The validation report to format
50
+ * @returns A formatted string suitable for console output
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const report = validateAdmonitions(manifest)
55
+ * console.log(formatAdmonitionReport(report))
56
+ * ```
57
+ */
58
+ export declare function formatAdmonitionReport(report: AdmonitionValidationReport): string;
59
+ //# sourceMappingURL=validate-admonitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-admonitions.d.ts","sourceRoot":"","sources":["../../src/testing/validate-admonitions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAEnD,OAAO,KAAK,EAAmB,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAEtG;;GAEG;AACH,eAAO,MAAM,gBAAgB,kEAAmE,CAAA;AAEhG;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,QAEtC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,CAAC,EAAE,0BAA0B,GACnC,0BAA0B,CAuD5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,0BAA0B,GAAG,MAAM,CAsCjF"}
package/dist/testing.cjs CHANGED
@@ -1,4 +1,7 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("@mdx-js/mdx"),F=require("rehype-slug"),w=require("remark-directive"),M=require("remark-gfm"),p=require("unist-util-visit"),x=require("fs/promises"),R=require("./manifest-BkO3d77g.cjs"),$={info:"info",note:"note",tip:"tip",warning:"warning",caution:"caution",danger:"danger"},D={info:"Info",note:"Note",tip:"Tip",warning:"Warning",caution:"Caution",danger:"Danger"},I=()=>s=>{p.visit(s,"containerDirective",t=>{var a;const e=t.name.toLowerCase();if(!(e in $))return;const i=$[e];let r;if(t.children.length>0){const l=t.children[0];if(l.type==="paragraph"&&"data"in l&&((a=l.data)==null?void 0:a.directiveLabel)===!0){const u=[];for(const o of l.children)o.type==="text"&&u.push(o.value);u.length>0&&(r=u.join("")),t.children=t.children.slice(1)}}const n=r||D[e],c=t.data||(t.data={});c.hName="Callout",c.hProperties={type:i,title:n}})};function E(){return s=>{p.visit(s,"code",t=>{if(!t.meta)return;const e=t.meta.match(/(?:title|filename)=["']([^"']+)["']/);if(!e)return;const i=e[1];t.value.trim().startsWith("// filename:")||(t.value=`// filename: ${i}
2
- ${t.value}`)})}}const S=()=>s=>{const t=[];p.visit(s,"html",(e,i,r)=>{i!==void 0&&r&&typeof e.value=="string"&&e.value.trim().startsWith("<!--")&&e.value.trim().endsWith("-->")&&t.push(i)});for(const e of t.reverse())s.children.splice(e,1)},b=["@theme/Tabs","@theme/TabItem"],C=()=>s=>{const t=[];p.visit(s,"mdxjsEsm",e=>{const i=e.value;b.some(n=>i.includes(`from '${n}'`)||i.includes(`from "${n}"`))&&t.push(e)});for(const e of t){const i=s.children.indexOf(e);i!==-1&&s.children.splice(i,1)}};function v(){return[M,w,I,E,C,S]}function T(){return[F]}async function y(s,t,e){var c,a,l,u;const i=performance.now(),r=(e==null?void 0:e.remarkPlugins)??v(),n=(e==null?void 0:e.rehypePlugins)??T();try{return await k.compile(s,{remarkPlugins:r,rehypePlugins:n,outputFormat:"function-body",development:!1}),{filePath:t,success:!0,compilationTime:performance.now()-i}}catch(o){const f=performance.now()-i;let h="Unknown compilation error",d,g;if(o instanceof Error){h=o.message;const m=o;if(m.line!==void 0?d=m.line:((a=(c=m.position)==null?void 0:c.start)==null?void 0:a.line)!==void 0&&(d=m.position.start.line),m.column!==void 0?g=m.column:((u=(l=m.position)==null?void 0:l.start)==null?void 0:u.column)!==void 0&&(g=m.position.start.column),d===void 0){const P=h.match(/\((\d+):(\d+)\)/);P&&(d=parseInt(P[1],10),g=parseInt(P[2],10))}}return{filePath:t,success:!1,error:h,line:d,column:g,compilationTime:f}}}async function L(s,t){const e=performance.now(),i=R.getLeafNodes(s),r=[];let n=0,c=0;for(let a=0;a<i.length;a++){const l=i[a];if(!l.file)continue;const u=l.file;try{const o=await x.readFile(u,"utf-8"),f=await y(o,l.file,{remarkPlugins:t==null?void 0:t.remarkPlugins,rehypePlugins:t==null?void 0:t.rehypePlugins});if(r.push(f),f.success?n++:c++,t!=null&&t.onProgress&&t.onProgress(a+1,i.length,f),t!=null&&t.failFast&&!f.success)break}catch(o){const f=o instanceof Error?o.message:"Unknown error reading file",h={filePath:l.file,success:!1,error:`Failed to read file: ${f}`,compilationTime:0};if(r.push(h),c++,t!=null&&t.onProgress&&t.onProgress(a+1,i.length,h),t!=null&&t.failFast)break}}return{packageId:s.id,totalFiles:r.length,passed:n,failed:c,results:r,totalTime:performance.now()-e}}function q(s,t=!1){const e=[];e.push(""),e.push(`MDX Compilation Report: ${s.packageId}`),e.push("=".repeat(50)),e.push("");const i=s.totalFiles>0?(s.passed/s.totalFiles*100).toFixed(1):"0";if(e.push(`Total files: ${s.totalFiles}`),e.push(`Passed: ${s.passed} (${i}%)`),e.push(`Failed: ${s.failed}`),e.push(`Total time: ${s.totalTime.toFixed(2)}ms`),e.push(""),t){e.push("Results:"),e.push("-".repeat(50));for(const r of s.results){const n=r.success?"[PASS]":"[FAIL]",c=`(${r.compilationTime.toFixed(2)}ms)`;if(e.push(`${n} ${r.filePath} ${c}`),!r.success&&r.error){const a=r.line?` (line ${r.line}${r.column?`:${r.column}`:""})`:"";e.push(` Error${a}: ${r.error}`)}}}else if(s.failed>0){e.push("Failures:"),e.push("-".repeat(50));for(const r of s.results.filter(n=>!n.success))if(e.push(`[FAIL] ${r.filePath}`),r.error){const n=r.line?` (line ${r.line}${r.column?`:${r.column}`:""})`:"";e.push(` Error${n}: ${r.error}`)}}return e.push(""),s.failed===0?e.push("All MDX files compiled successfully!"):e.push(`${s.failed} file(s) failed to compile.`),e.push(""),e.join(`
3
- `)}function A(){return(s,t,e)=>{const i=e.success?"":"",r=(s/t*100).toFixed(0);process.stdout.write(`\r[${s}/${t}] (${r}%) ${i} ${e.filePath}`),process.stdout.write("\x1B[K"),s===t&&process.stdout.write(`
4
- `)}}exports.compileMdx=y;exports.createProgressReporter=A;exports.formatTestReport=q;exports.getDefaultRehypePlugins=T;exports.getDefaultRemarkPlugins=v;exports.testManifestMdx=L;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("@mdx-js/mdx"),F=require("rehype-slug"),x=require("remark-directive"),D=require("remark-gfm"),g=require("unist-util-visit"),E=require("fs/promises"),P=require("./manifest-BkO3d77g.cjs"),R=require("node:fs"),M=require("node:path"),$={info:"info",note:"note",tip:"tip",warning:"warning",caution:"caution",danger:"danger"},N={info:"Info",note:"Note",tip:"Tip",warning:"Warning",caution:"Caution",danger:"Danger"},S=()=>s=>{g.visit(s,"containerDirective",e=>{var c;const t=e.name.toLowerCase();if(!(t in $))return;const i=$[t];let r;if(e.children.length>0){const l=e.children[0];if(l.type==="paragraph"&&"data"in l&&((c=l.data)==null?void 0:c.directiveLabel)===!0){const u=[];for(const o of l.children)o.type==="text"&&u.push(o.value);u.length>0&&(r=u.join("")),e.children=e.children.slice(1)}}const n=r||N[t],a=e.data||(e.data={});a.hName="Callout",a.hProperties={type:i,title:n}})};function b(){return s=>{g.visit(s,"code",e=>{if(!e.meta)return;const t=e.meta.match(/(?:title|filename)=["']([^"']+)["']/);if(!t)return;const i=t[1];e.value.trim().startsWith("// filename:")||(e.value=`// filename: ${i}
2
+ ${e.value}`)})}}const _=()=>s=>{const e=[];g.visit(s,"html",(t,i,r)=>{i!==void 0&&r&&typeof t.value=="string"&&t.value.trim().startsWith("<!--")&&t.value.trim().endsWith("-->")&&e.push(i)});for(const t of e.reverse())s.children.splice(t,1)},L=["@theme/Tabs","@theme/TabItem"],O=()=>s=>{const e=[];g.visit(s,"mdxjsEsm",t=>{const i=t.value;L.some(n=>i.includes(`from '${n}'`)||i.includes(`from "${n}"`))&&e.push(t)});for(const t of e){const i=s.children.indexOf(t);i!==-1&&s.children.splice(i,1)}};function v(){return[D,x,S,b,O,_]}function I(){return[F]}async function y(s,e,t){var a,c,l,u;const i=performance.now(),r=(t==null?void 0:t.remarkPlugins)??v(),n=(t==null?void 0:t.rehypePlugins)??I();try{return await A.compile(s,{remarkPlugins:r,rehypePlugins:n,outputFormat:"function-body",development:!1}),{filePath:e,success:!0,compilationTime:performance.now()-i}}catch(o){const f=performance.now()-i;let m="Unknown compilation error",h,p;if(o instanceof Error){m=o.message;const d=o;if(d.line!==void 0?h=d.line:((c=(a=d.position)==null?void 0:a.start)==null?void 0:c.line)!==void 0&&(h=d.position.start.line),d.column!==void 0?p=d.column:((u=(l=d.position)==null?void 0:l.start)==null?void 0:u.column)!==void 0&&(p=d.position.start.column),h===void 0){const T=m.match(/\((\d+):(\d+)\)/);T&&(h=parseInt(T[1],10),p=parseInt(T[2],10))}}return{filePath:e,success:!1,error:m,line:h,column:p,compilationTime:f}}}async function q(s,e){const t=performance.now(),i=P.getLeafNodes(s),r=[];let n=0,a=0;for(let c=0;c<i.length;c++){const l=i[c];if(!l.file)continue;const u=l.file;try{const o=await E.readFile(u,"utf-8"),f=await y(o,l.file,{remarkPlugins:e==null?void 0:e.remarkPlugins,rehypePlugins:e==null?void 0:e.rehypePlugins});if(r.push(f),f.success?n++:a++,e!=null&&e.onProgress&&e.onProgress(c+1,i.length,f),e!=null&&e.failFast&&!f.success)break}catch(o){const f=o instanceof Error?o.message:"Unknown error reading file",m={filePath:l.file,success:!1,error:`Failed to read file: ${f}`,compilationTime:0};if(r.push(m),a++,e!=null&&e.onProgress&&e.onProgress(c+1,i.length,m),e!=null&&e.failFast)break}}return{packageId:s.id,totalFiles:r.length,passed:n,failed:a,results:r,totalTime:performance.now()-t}}const k=["warning","info","tip","note","caution","danger"],w=new RegExp(`^:::(${k.join("|")}) ([A-Z].*)$`);function j(s,e){const t=performance.now(),i=[],r=P.getLeafNodes(s);let n=0;for(const a of r){if(!a.file)continue;n++;const l=R.readFileSync(a.file,"utf-8").split(`
3
+ `);for(let u=0;u<l.length;u++){const o=l[u],f=o.match(w);if(f){const[,m,h]=f,p={file:s.basePath?M.relative(s.basePath,a.file):a.file,absolutePath:a.file,line:u+1,column:1,content:o.trim(),admonitionType:m,label:h,suggestion:`:::${m}[${h}]`};if(i.push(p),e!=null&&e.onError&&e.onError(p),e!=null&&e.failFast&&i.length>0)return{packageId:s.id,filesScanned:n,errors:i,totalTime:performance.now()-t}}}}return{packageId:s.id,filesScanned:n,errors:i,totalTime:performance.now()-t}}function C(s){const e=[];if(e.push(""),e.push(`Admonition Syntax Report: ${s.packageId}`),e.push("=".repeat(50)),e.push(""),e.push(`Files scanned: ${s.filesScanned}`),e.push(`Errors found: ${s.errors.length}`),e.push(`Total time: ${s.totalTime.toFixed(2)}ms`),e.push(""),s.errors.length===0)return e.push("All admonitions use correct bracket syntax!"),e.push(""),e.join(`
4
+ `);e.push("Errors:"),e.push("-".repeat(50)),e.push("");for(const t of s.errors)e.push(` ${t.file}:${t.line}`),e.push(` ${t.content}`),e.push(` Fix: ${t.suggestion}`),e.push("");return e.push("Admonitions with custom titles must use bracket syntax:"),e.push(" Before: :::warning Deprecated"),e.push(" After: :::warning[Deprecated]"),e.push(""),e.push("See: https://github.com/remarkjs/remark-directive"),e.push(""),e.join(`
5
+ `)}function U(s,e=!1){const t=[];t.push(""),t.push(`MDX Compilation Report: ${s.packageId}`),t.push("=".repeat(50)),t.push("");const i=s.totalFiles>0?(s.passed/s.totalFiles*100).toFixed(1):"0";if(t.push(`Total files: ${s.totalFiles}`),t.push(`Passed: ${s.passed} (${i}%)`),t.push(`Failed: ${s.failed}`),t.push(`Total time: ${s.totalTime.toFixed(2)}ms`),t.push(""),e){t.push("Results:"),t.push("-".repeat(50));for(const r of s.results){const n=r.success?"[PASS]":"[FAIL]",a=`(${r.compilationTime.toFixed(2)}ms)`;if(t.push(`${n} ${r.filePath} ${a}`),!r.success&&r.error){const c=r.line?` (line ${r.line}${r.column?`:${r.column}`:""})`:"";t.push(` Error${c}: ${r.error}`)}}}else if(s.failed>0){t.push("Failures:"),t.push("-".repeat(50));for(const r of s.results.filter(n=>!n.success))if(t.push(`[FAIL] ${r.filePath}`),r.error){const n=r.line?` (line ${r.line}${r.column?`:${r.column}`:""})`:"";t.push(` Error${n}: ${r.error}`)}}return t.push(""),s.failed===0?t.push("All MDX files compiled successfully!"):t.push(`${s.failed} file(s) failed to compile.`),t.push(""),t.join(`
6
+ `)}function W(){return(s,e,t)=>{const i=t.success?"✓":"✗",r=(s/e*100).toFixed(0);process.stdout.write(`\r[${s}/${e}] (${r}%) ${i} ${t.filePath}`),process.stdout.write("\x1B[K"),s===e&&process.stdout.write(`
7
+ `)}}exports.ADMONITION_TYPES=k;exports.INVALID_ADMONITION_PATTERN=w;exports.compileMdx=y;exports.createProgressReporter=W;exports.formatAdmonitionReport=C;exports.formatTestReport=U;exports.getDefaultRehypePlugins=I;exports.getDefaultRemarkPlugins=v;exports.testManifestMdx=q;exports.validateAdmonitions=j;
package/dist/testing.js CHANGED
@@ -1,98 +1,100 @@
1
- import { compile as T } from "@mdx-js/mdx";
2
- import v from "rehype-slug";
3
- import F from "remark-directive";
4
- import k from "remark-gfm";
1
+ import { compile as v } from "@mdx-js/mdx";
2
+ import w from "rehype-slug";
3
+ import k from "remark-directive";
4
+ import y from "remark-gfm";
5
5
  import { visit as g } from "unist-util-visit";
6
- import { readFile as w } from "fs/promises";
7
- import { h as y } from "./manifest-DlSWyjsA.js";
8
- const P = {
6
+ import { readFile as F } from "fs/promises";
7
+ import { h as P } from "./manifest-DlSWyjsA.js";
8
+ import { readFileSync as I } from "node:fs";
9
+ import { relative as x } from "node:path";
10
+ const T = {
9
11
  info: "info",
10
12
  note: "note",
11
13
  tip: "tip",
12
14
  warning: "warning",
13
15
  caution: "caution",
14
16
  danger: "danger"
15
- }, x = {
17
+ }, E = {
16
18
  info: "Info",
17
19
  note: "Note",
18
20
  tip: "Tip",
19
21
  warning: "Warning",
20
22
  caution: "Caution",
21
23
  danger: "Danger"
22
- }, I = () => (r) => {
23
- g(r, "containerDirective", (t) => {
24
- var a;
25
- const e = t.name.toLowerCase();
26
- if (!(e in P))
24
+ }, A = () => (r) => {
25
+ g(r, "containerDirective", (e) => {
26
+ var o;
27
+ const t = e.name.toLowerCase();
28
+ if (!(t in T))
27
29
  return;
28
- const i = P[e];
30
+ const i = T[t];
29
31
  let s;
30
- if (t.children.length > 0) {
31
- const l = t.children[0];
32
- if (l.type === "paragraph" && "data" in l && ((a = l.data) == null ? void 0 : a.directiveLabel) === !0) {
32
+ if (e.children.length > 0) {
33
+ const l = e.children[0];
34
+ if (l.type === "paragraph" && "data" in l && ((o = l.data) == null ? void 0 : o.directiveLabel) === !0) {
33
35
  const u = [];
34
- for (const o of l.children)
35
- o.type === "text" && u.push(o.value);
36
- u.length > 0 && (s = u.join("")), t.children = t.children.slice(1);
36
+ for (const c of l.children)
37
+ c.type === "text" && u.push(c.value);
38
+ u.length > 0 && (s = u.join("")), e.children = e.children.slice(1);
37
39
  }
38
40
  }
39
- const n = s || x[e], c = t.data || (t.data = {});
40
- c.hName = "Callout", c.hProperties = {
41
+ const n = s || E[t], a = e.data || (e.data = {});
42
+ a.hName = "Callout", a.hProperties = {
41
43
  type: i,
42
44
  title: n
43
45
  };
44
46
  });
45
47
  };
46
- function E() {
48
+ function D() {
47
49
  return (r) => {
48
- g(r, "code", (t) => {
49
- if (!t.meta) return;
50
- const e = t.meta.match(/(?:title|filename)=["']([^"']+)["']/);
51
- if (!e) return;
52
- const i = e[1];
53
- t.value.trim().startsWith("// filename:") || (t.value = `// filename: ${i}
54
- ${t.value}`);
50
+ g(r, "code", (e) => {
51
+ if (!e.meta) return;
52
+ const t = e.meta.match(/(?:title|filename)=["']([^"']+)["']/);
53
+ if (!t) return;
54
+ const i = t[1];
55
+ e.value.trim().startsWith("// filename:") || (e.value = `// filename: ${i}
56
+ ${e.value}`);
55
57
  });
56
58
  };
57
59
  }
58
- const M = () => (r) => {
59
- const t = [];
60
- g(r, "html", (e, i, s) => {
61
- i !== void 0 && s && typeof e.value == "string" && e.value.trim().startsWith("<!--") && e.value.trim().endsWith("-->") && t.push(i);
60
+ const S = () => (r) => {
61
+ const e = [];
62
+ g(r, "html", (t, i, s) => {
63
+ i !== void 0 && s && typeof t.value == "string" && t.value.trim().startsWith("<!--") && t.value.trim().endsWith("-->") && e.push(i);
62
64
  });
63
- for (const e of t.reverse())
64
- r.children.splice(e, 1);
65
- }, D = ["@theme/Tabs", "@theme/TabItem"], R = () => (r) => {
66
- const t = [];
67
- g(r, "mdxjsEsm", (e) => {
68
- const i = e.value;
69
- D.some(
65
+ for (const t of e.reverse())
66
+ r.children.splice(t, 1);
67
+ }, R = ["@theme/Tabs", "@theme/TabItem"], b = () => (r) => {
68
+ const e = [];
69
+ g(r, "mdxjsEsm", (t) => {
70
+ const i = t.value;
71
+ R.some(
70
72
  (n) => i.includes(`from '${n}'`) || i.includes(`from "${n}"`)
71
- ) && t.push(e);
73
+ ) && e.push(t);
72
74
  });
73
- for (const e of t) {
74
- const i = r.children.indexOf(e);
75
+ for (const t of e) {
76
+ const i = r.children.indexOf(t);
75
77
  i !== -1 && r.children.splice(i, 1);
76
78
  }
77
79
  };
78
- function S() {
80
+ function M() {
79
81
  return [
82
+ y,
80
83
  k,
81
- F,
82
- I,
83
- E,
84
- R,
85
- M
84
+ A,
85
+ D,
86
+ b,
87
+ S
86
88
  ];
87
89
  }
88
- function C() {
89
- return [v];
90
+ function N() {
91
+ return [w];
90
92
  }
91
- async function L(r, t, e) {
92
- var c, a, l, u;
93
- const i = performance.now(), s = (e == null ? void 0 : e.remarkPlugins) ?? S(), n = (e == null ? void 0 : e.rehypePlugins) ?? C();
93
+ async function L(r, e, t) {
94
+ var a, o, l, u;
95
+ const i = performance.now(), s = (t == null ? void 0 : t.remarkPlugins) ?? M(), n = (t == null ? void 0 : t.rehypePlugins) ?? N();
94
96
  try {
95
- return await T(r, {
97
+ return await v(r, {
96
98
  remarkPlugins: s,
97
99
  rehypePlugins: n,
98
100
  // Don't output to JS, just compile to check for errors
@@ -100,54 +102,54 @@ async function L(r, t, e) {
100
102
  // Suppress development warnings about missing 'development' option
101
103
  development: !1
102
104
  }), {
103
- filePath: t,
105
+ filePath: e,
104
106
  success: !0,
105
107
  compilationTime: performance.now() - i
106
108
  };
107
- } catch (o) {
109
+ } catch (c) {
108
110
  const f = performance.now() - i;
109
- let h = "Unknown compilation error", d, p;
110
- if (o instanceof Error) {
111
- h = o.message;
112
- const m = o;
113
- if (m.line !== void 0 ? d = m.line : ((a = (c = m.position) == null ? void 0 : c.start) == null ? void 0 : a.line) !== void 0 && (d = m.position.start.line), m.column !== void 0 ? p = m.column : ((u = (l = m.position) == null ? void 0 : l.start) == null ? void 0 : u.column) !== void 0 && (p = m.position.start.column), d === void 0) {
114
- const $ = h.match(/\((\d+):(\d+)\)/);
115
- $ && (d = parseInt($[1], 10), p = parseInt($[2], 10));
111
+ let m = "Unknown compilation error", h, p;
112
+ if (c instanceof Error) {
113
+ m = c.message;
114
+ const d = c;
115
+ if (d.line !== void 0 ? h = d.line : ((o = (a = d.position) == null ? void 0 : a.start) == null ? void 0 : o.line) !== void 0 && (h = d.position.start.line), d.column !== void 0 ? p = d.column : ((u = (l = d.position) == null ? void 0 : l.start) == null ? void 0 : u.column) !== void 0 && (p = d.position.start.column), h === void 0) {
116
+ const $ = m.match(/\((\d+):(\d+)\)/);
117
+ $ && (h = parseInt($[1], 10), p = parseInt($[2], 10));
116
118
  }
117
119
  }
118
120
  return {
119
- filePath: t,
121
+ filePath: e,
120
122
  success: !1,
121
- error: h,
122
- line: d,
123
+ error: m,
124
+ line: h,
123
125
  column: p,
124
126
  compilationTime: f
125
127
  };
126
128
  }
127
129
  }
128
- async function O(r, t) {
129
- const e = performance.now(), i = y(r), s = [];
130
- let n = 0, c = 0;
131
- for (let a = 0; a < i.length; a++) {
132
- const l = i[a];
130
+ async function H(r, e) {
131
+ const t = performance.now(), i = P(r), s = [];
132
+ let n = 0, a = 0;
133
+ for (let o = 0; o < i.length; o++) {
134
+ const l = i[o];
133
135
  if (!l.file)
134
136
  continue;
135
137
  const u = l.file;
136
138
  try {
137
- const o = await w(u, "utf-8"), f = await L(o, l.file, {
138
- remarkPlugins: t == null ? void 0 : t.remarkPlugins,
139
- rehypePlugins: t == null ? void 0 : t.rehypePlugins
139
+ const c = await F(u, "utf-8"), f = await L(c, l.file, {
140
+ remarkPlugins: e == null ? void 0 : e.remarkPlugins,
141
+ rehypePlugins: e == null ? void 0 : e.rehypePlugins
140
142
  });
141
- if (s.push(f), f.success ? n++ : c++, t != null && t.onProgress && t.onProgress(a + 1, i.length, f), t != null && t.failFast && !f.success)
143
+ if (s.push(f), f.success ? n++ : a++, e != null && e.onProgress && e.onProgress(o + 1, i.length, f), e != null && e.failFast && !f.success)
142
144
  break;
143
- } catch (o) {
144
- const f = o instanceof Error ? o.message : "Unknown error reading file", h = {
145
+ } catch (c) {
146
+ const f = c instanceof Error ? c.message : "Unknown error reading file", m = {
145
147
  filePath: l.file,
146
148
  success: !1,
147
149
  error: `Failed to read file: ${f}`,
148
150
  compilationTime: 0
149
151
  };
150
- if (s.push(h), c++, t != null && t.onProgress && t.onProgress(a + 1, i.length, h), t != null && t.failFast)
152
+ if (s.push(m), a++, e != null && e.onProgress && e.onProgress(o + 1, i.length, m), e != null && e.failFast)
151
153
  break;
152
154
  }
153
155
  }
@@ -155,47 +157,103 @@ async function O(r, t) {
155
157
  packageId: r.id,
156
158
  totalFiles: s.length,
157
159
  passed: n,
158
- failed: c,
160
+ failed: a,
159
161
  results: s,
160
- totalTime: performance.now() - e
162
+ totalTime: performance.now() - t
163
+ };
164
+ }
165
+ const C = ["warning", "info", "tip", "note", "caution", "danger"], j = new RegExp(
166
+ `^:::(${C.join("|")}) ([A-Z].*)$`
167
+ );
168
+ function K(r, e) {
169
+ const t = performance.now(), i = [], s = P(r);
170
+ let n = 0;
171
+ for (const a of s) {
172
+ if (!a.file) continue;
173
+ n++;
174
+ const l = I(a.file, "utf-8").split(`
175
+ `);
176
+ for (let u = 0; u < l.length; u++) {
177
+ const c = l[u], f = c.match(j);
178
+ if (f) {
179
+ const [, m, h] = f, p = {
180
+ file: r.basePath ? x(r.basePath, a.file) : a.file,
181
+ absolutePath: a.file,
182
+ line: u + 1,
183
+ column: 1,
184
+ content: c.trim(),
185
+ admonitionType: m,
186
+ label: h,
187
+ suggestion: `:::${m}[${h}]`
188
+ };
189
+ if (i.push(p), e != null && e.onError && e.onError(p), e != null && e.failFast && i.length > 0)
190
+ return {
191
+ packageId: r.id,
192
+ filesScanned: n,
193
+ errors: i,
194
+ totalTime: performance.now() - t
195
+ };
196
+ }
197
+ }
198
+ }
199
+ return {
200
+ packageId: r.id,
201
+ filesScanned: n,
202
+ errors: i,
203
+ totalTime: performance.now() - t
161
204
  };
162
205
  }
163
- function X(r, t = !1) {
206
+ function Z(r) {
164
207
  const e = [];
165
- e.push(""), e.push(`MDX Compilation Report: ${r.packageId}`), e.push("=".repeat(50)), e.push("");
208
+ if (e.push(""), e.push(`Admonition Syntax Report: ${r.packageId}`), e.push("=".repeat(50)), e.push(""), e.push(`Files scanned: ${r.filesScanned}`), e.push(`Errors found: ${r.errors.length}`), e.push(`Total time: ${r.totalTime.toFixed(2)}ms`), e.push(""), r.errors.length === 0)
209
+ return e.push("All admonitions use correct bracket syntax!"), e.push(""), e.join(`
210
+ `);
211
+ e.push("Errors:"), e.push("-".repeat(50)), e.push("");
212
+ for (const t of r.errors)
213
+ e.push(` ${t.file}:${t.line}`), e.push(` ${t.content}`), e.push(` Fix: ${t.suggestion}`), e.push("");
214
+ return e.push("Admonitions with custom titles must use bracket syntax:"), e.push(" Before: :::warning Deprecated"), e.push(" After: :::warning[Deprecated]"), e.push(""), e.push("See: https://github.com/remarkjs/remark-directive"), e.push(""), e.join(`
215
+ `);
216
+ }
217
+ function q(r, e = !1) {
218
+ const t = [];
219
+ t.push(""), t.push(`MDX Compilation Report: ${r.packageId}`), t.push("=".repeat(50)), t.push("");
166
220
  const i = r.totalFiles > 0 ? (r.passed / r.totalFiles * 100).toFixed(1) : "0";
167
- if (e.push(`Total files: ${r.totalFiles}`), e.push(`Passed: ${r.passed} (${i}%)`), e.push(`Failed: ${r.failed}`), e.push(`Total time: ${r.totalTime.toFixed(2)}ms`), e.push(""), t) {
168
- e.push("Results:"), e.push("-".repeat(50));
221
+ if (t.push(`Total files: ${r.totalFiles}`), t.push(`Passed: ${r.passed} (${i}%)`), t.push(`Failed: ${r.failed}`), t.push(`Total time: ${r.totalTime.toFixed(2)}ms`), t.push(""), e) {
222
+ t.push("Results:"), t.push("-".repeat(50));
169
223
  for (const s of r.results) {
170
- const n = s.success ? "[PASS]" : "[FAIL]", c = `(${s.compilationTime.toFixed(2)}ms)`;
171
- if (e.push(`${n} ${s.filePath} ${c}`), !s.success && s.error) {
172
- const a = s.line ? ` (line ${s.line}${s.column ? `:${s.column}` : ""})` : "";
173
- e.push(` Error${a}: ${s.error}`);
224
+ const n = s.success ? "[PASS]" : "[FAIL]", a = `(${s.compilationTime.toFixed(2)}ms)`;
225
+ if (t.push(`${n} ${s.filePath} ${a}`), !s.success && s.error) {
226
+ const o = s.line ? ` (line ${s.line}${s.column ? `:${s.column}` : ""})` : "";
227
+ t.push(` Error${o}: ${s.error}`);
174
228
  }
175
229
  }
176
230
  } else if (r.failed > 0) {
177
- e.push("Failures:"), e.push("-".repeat(50));
231
+ t.push("Failures:"), t.push("-".repeat(50));
178
232
  for (const s of r.results.filter((n) => !n.success))
179
- if (e.push(`[FAIL] ${s.filePath}`), s.error) {
233
+ if (t.push(`[FAIL] ${s.filePath}`), s.error) {
180
234
  const n = s.line ? ` (line ${s.line}${s.column ? `:${s.column}` : ""})` : "";
181
- e.push(` Error${n}: ${s.error}`);
235
+ t.push(` Error${n}: ${s.error}`);
182
236
  }
183
237
  }
184
- return e.push(""), r.failed === 0 ? e.push("All MDX files compiled successfully!") : e.push(`${r.failed} file(s) failed to compile.`), e.push(""), e.join(`
238
+ return t.push(""), r.failed === 0 ? t.push("All MDX files compiled successfully!") : t.push(`${r.failed} file(s) failed to compile.`), t.push(""), t.join(`
185
239
  `);
186
240
  }
187
- function B() {
188
- return (r, t, e) => {
189
- const i = e.success ? "✓" : "✗", s = (r / t * 100).toFixed(0);
190
- process.stdout.write(`\r[${r}/${t}] (${s}%) ${i} ${e.filePath}`), process.stdout.write("\x1B[K"), r === t && process.stdout.write(`
241
+ function z() {
242
+ return (r, e, t) => {
243
+ const i = t.success ? "✓" : "✗", s = (r / e * 100).toFixed(0);
244
+ process.stdout.write(`\r[${r}/${e}] (${s}%) ${i} ${t.filePath}`), process.stdout.write("\x1B[K"), r === e && process.stdout.write(`
191
245
  `);
192
246
  };
193
247
  }
194
248
  export {
249
+ C as ADMONITION_TYPES,
250
+ j as INVALID_ADMONITION_PATTERN,
195
251
  L as compileMdx,
196
- B as createProgressReporter,
197
- X as formatTestReport,
198
- C as getDefaultRehypePlugins,
199
- S as getDefaultRemarkPlugins,
200
- O as testManifestMdx
252
+ z as createProgressReporter,
253
+ Z as formatAdmonitionReport,
254
+ q as formatTestReport,
255
+ N as getDefaultRehypePlugins,
256
+ M as getDefaultRemarkPlugins,
257
+ H as testManifestMdx,
258
+ K as validateAdmonitions
201
259
  };
@@ -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
- resolvedManifest.navigation,
100
- lastModifiedDates,
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, // NavigationNode[]
166
- lastModifiedDates, // Record<string, string>
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
- ['docs/intro.mdx', 'docs/guide.mdx'],
204
- { cwd: '/path/to/repo' }
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendure-io/docs-provider",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Contract types and utilities for Vendure documentation packages",
5
5
  "private": false,
6
6
  "publishConfig": {