@vendure-io/docs-provider 0.5.0 → 0.6.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.
- package/dist/browser.cjs +1 -1
- package/dist/browser.js +1 -1
- package/dist/{frontmatter-8Bwpoi8r.js → frontmatter-C0Wmtdep.js} +1 -1
- package/dist/{frontmatter-_wRoVeyd.cjs → frontmatter-CJYZSUYM.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/loader.cjs +1 -1
- package/dist/loader.js +2 -2
- package/dist/{manifest-D8kEDc9X.cjs → manifest-D-EWZlSh.cjs} +1 -1
- package/dist/{manifest-B_cvT6F9.js → manifest-ZCrzbFSf.js} +10 -9
- package/dist/manifest.d.ts.map +1 -1
- package/dist/remark-plugins/index.d.ts +11 -0
- package/dist/remark-plugins/index.d.ts.map +1 -0
- package/dist/remark-plugins/remark-admonitions.d.ts +18 -0
- package/dist/remark-plugins/remark-admonitions.d.ts.map +1 -0
- package/dist/remark-plugins/remark-code-meta.d.ts +15 -0
- package/dist/remark-plugins/remark-code-meta.d.ts.map +1 -0
- package/dist/remark-plugins/remark-strip-html-comments.d.ts +8 -0
- package/dist/remark-plugins/remark-strip-html-comments.d.ts.map +1 -0
- package/dist/remark-plugins/remark-strip-imports.d.ts +8 -0
- package/dist/remark-plugins/remark-strip-imports.d.ts.map +1 -0
- package/dist/testing/index.d.ts +32 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/mdx-compiler.d.ts +49 -0
- package/dist/testing/mdx-compiler.d.ts.map +1 -0
- package/dist/testing/test-manifest.d.ts +31 -0
- package/dist/testing/test-manifest.d.ts.map +1 -0
- package/dist/testing/types.d.ts +81 -0
- package/dist/testing/types.d.ts.map +1 -0
- package/dist/testing.cjs +4 -0
- package/dist/testing.js +202 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/getting-started.md +1 -0
- package/docs/mdx-components-reference.md +4 -4
- package/docs/mdx-testing.md +437 -0
- package/docs/publishing.md +1 -0
- package/package.json +20 -1
package/dist/browser.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./manifest-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./manifest-D-EWZlSh.cjs"),a=require("./slug-utils-DUQgikEz.cjs");exports.BreadcrumbItemSchema=e.BreadcrumbItemSchema;exports.DocPageMetaSchema=e.DocPageMetaSchema;exports.DocPageSchema=e.DocPageSchema;exports.DocsPackageManifestInputSchema=e.DocsPackageManifestInputSchema;exports.DocsPackageManifestSchema=e.DocsPackageManifestSchema;exports.FlatNavigationNodeSchema=e.FlatNavigationNodeSchema;exports.GitHubConfigSchema=e.GitHubConfigSchema;exports.LoadedDocsPackageSchema=e.LoadedDocsPackageSchema;exports.ManifestValidationError=e.ManifestValidationError;exports.NavigationNodeInputSchema=e.NavigationNodeInputSchema;exports.NavigationNodeSchema=e.NavigationNodeSchema;exports.SearchConfigSchema=e.SearchConfigSchema;exports.VendureVersionSchema=e.VendureVersionSchema;exports.buildBreadcrumbs=e.buildBreadcrumbs;exports.findNavigationNode=e.findNavigationNode;exports.flattenNavigation=e.flattenNavigation;exports.getLeafNodes=e.getLeafNodes;exports.getNodesAtDepth=e.getNodesAtDepth;exports.getPrevNextNodes=e.getPrevNextNodes;exports.isNodeActive=e.isNodeActive;exports.validateManifest=e.validateManifest;exports.filterVisibleNavigation=a.filterVisibleNavigation;exports.getAllFilePaths=a.getAllFilePaths;exports.slugFromFilename=a.slugFromFilename;exports.titleFromFilename=a.titleFromFilename;exports.toSlug=a.toSlug;
|
package/dist/browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as s, D as t, a as i, b as o, c, F as g, G as m, L as n, M as d, N as r, d as h, S as N, V as l, e as S, f, g as v, h as u, i as D, j as F, k as P, v as b } from "./manifest-
|
|
1
|
+
import { B as s, D as t, a as i, b as o, c, F as g, G as m, L as n, M as d, N as r, d as h, S as N, V as l, e as S, f, g as v, h as u, i as D, j as F, k as P, v as b } from "./manifest-ZCrzbFSf.js";
|
|
2
2
|
import { f as p, g as V, s as k, t as x, a as A } from "./slug-utils-DVKYe9h8.js";
|
|
3
3
|
export {
|
|
4
4
|
s as BreadcrumbItemSchema,
|
|
@@ -2,7 +2,7 @@ var c = Object.defineProperty;
|
|
|
2
2
|
var m = (a, t, r) => t in a ? c(a, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[t] = r;
|
|
3
3
|
var o = (a, t, r) => m(a, typeof t != "symbol" ? t + "" : t, r);
|
|
4
4
|
import i from "gray-matter";
|
|
5
|
-
import { D as u } from "./manifest-
|
|
5
|
+
import { D as u } from "./manifest-ZCrzbFSf.js";
|
|
6
6
|
class s extends Error {
|
|
7
7
|
constructor(r, e, n) {
|
|
8
8
|
super(r);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var m=Object.defineProperty;var u=(a,t,r)=>t in a?m(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r;var s=(a,t,r)=>u(a,typeof t!="symbol"?t+"":t,r);const i=require("gray-matter"),d=require("./manifest-
|
|
1
|
+
"use strict";var m=Object.defineProperty;var u=(a,t,r)=>t in a?m(a,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[t]=r;var s=(a,t,r)=>u(a,typeof t!="symbol"?t+"":t,r);const i=require("gray-matter"),d=require("./manifest-D-EWZlSh.cjs");class o extends Error{constructor(r,e,n){super(r);s(this,"filePath");s(this,"originalError");this.name="FrontmatterParseError",this.filePath=e,this.originalError=n}}function F(a,t){try{const{data:r,content:e}=i(a);return{meta:c(r,t),content:e.trim()}}catch(r){throw r instanceof o?r:new o(`Failed to parse frontmatter${t?` in ${t}`:""}`,t,r)}}function c(a,t){const r=d.DocPageMetaSchema.safeParse(a);if(!r.success){const e=r.error.issues.map(n=>` - ${n.path.join(".")}: ${n.message}`).join(`
|
|
2
2
|
`);throw new o(`Invalid frontmatter${t?` in ${t}`:""}:
|
|
3
3
|
${e}`,t,r.error)}return r.data}function h(a){return a.trimStart().startsWith("---")}function f(a){const{data:t}=i(a);return t}exports.FrontmatterParseError=o;exports.extractFrontmatterData=f;exports.hasFrontmatter=h;exports.parseFrontmatter=F;exports.validateFrontmatter=c;
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var L=Object.defineProperty;var R=(e,t,r)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var S=(e,t,r)=>R(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./manifest-
|
|
1
|
+
"use strict";var L=Object.defineProperty;var R=(e,t,r)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var S=(e,t,r)=>R(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./manifest-D-EWZlSh.cjs"),g=require("./frontmatter-CJYZSUYM.cjs"),l=require("./slug-utils-DUQgikEz.cjs"),N=require("fs"),y=require("path"),I=(e,t)=>e.order!==t.order?e.order-t.order:e.title.localeCompare(t.title);function j(e,t={}){const{extensions:r=[".mdx",".md"],filter:i,sort:o=I}=t,n=C(e,r);return(i?n.filter(i):n).sort(o).map(m=>({title:m.title,slug:m.slug,file:m.path}))}function q(e,t={}){return V(e,t,0)}function V(e,t,r){const{extensions:i=[".mdx",".md"],filter:o,sort:n=I,maxDepth:c=1/0,folderFilter:u}=t,m=N.readdirSync(e,{withFileTypes:!0}),h=[],$=C(e,i),D=(o?$.filter(o):$).sort(n);for(const f of D)h.push({title:f.title,slug:f.slug,file:f.path});if(r<c){const f=m.filter(d=>d.isDirectory());for(const d of f){if(u){const s=y.join(e,d.name);if(!u(d.name,s))continue}const F=y.join(e,d.name),v=V(F,t,r+1);if(v.length>0){const s=B(F,i);h.push({title:(s==null?void 0:s.title)||l.titleFromFilename(d.name),slug:l.slugFromFilename(d.name),file:s==null?void 0:s.path,children:v.filter(P=>!(s&&P.file===s.path))})}}}return h.sort((f,d)=>{var E,w;const F=D.find(M=>M.slug===f.slug),v=D.find(M=>M.slug===d.slug);if(F&&v)return n(F,v);const s=!!f.file&&!((E=f.children)!=null&&E.length),P=!!d.file&&!((w=d.children)!=null&&w.length);return s!==P?s?-1:1:(f.title||"").localeCompare(d.title||"")})}function C(e,t){try{const r=N.readdirSync(e,{withFileTypes:!0}),i=[];for(const o of r){if(!o.isFile())continue;const n=t.find(h=>o.name.toLowerCase().endsWith(h));if(!n||o.name.slice(0,-n.length).toLowerCase()==="index")continue;const u=y.join(e,o.name),m=k(u,o.name,n);i.push(m)}return i}catch{return[]}}function k(e,t,r){let i={},o=l.titleFromFilename(t),n=1/0;try{const c=N.readFileSync(e,"utf-8");i=g.extractFrontmatterData(c),i.title&&typeof i.title=="string"&&(o=i.title),typeof i.order=="number"&&(n=i.order)}catch{}return{path:e,filename:t,extension:r,frontmatter:i,order:n,title:o,slug:l.slugFromFilename(t)}}function B(e,t){for(const r of t){const i=y.join(e,`index${r}`);try{if(N.statSync(i).isFile())return k(i,`index${r}`,r)}catch{}}}class b extends Error{constructor(r,i,o,n){super(r);S(this,"nodePath");S(this,"filePath");S(this,"originalError");this.name="ManifestResolutionError",this.nodePath=i,this.filePath=o,this.originalError=n}}function T(e,t={}){const{strict:r=!0}=t,i=x(e.navigation,"",r);return{id:e.id,name:e.name,version:e.version,vendureVersion:e.vendureVersion,navigation:i,search:e.search,github:e.github,basePath:e.basePath}}function x(e,t,r){return e.map((i,o)=>U(i,t,o,r))}function U(e,t,r,i){const o=t?`${t}[${r}]`:`navigation[${r}]`;if(e.title&&e.slug)return{title:e.title,slug:e.slug,file:e.file,children:e.children?x(e.children,`${o}.children`,i):void 0,badge:e.badge,hidden:e.hidden};let n=e.title,c=e.slug;if(e.file&&(c||(c=l.slugFromFilename(e.file)),n||(n=W(e.file,o,i))),!n){if(i)throw new b(`Navigation node at ${o} is missing title and has no file to derive it from`,o,e.file);n=c||`Unknown (${r})`}if(!c){if(i)throw new b(`Navigation node at ${o} is missing slug and has no file to derive it from`,o,e.file);c=n?l.slugFromFilename(n):`node-${r}`}return{title:n,slug:c,file:e.file,children:e.children?x(e.children,`${o}.children`,i):void 0,badge:e.badge,hidden:e.hidden}}function W(e,t,r){try{const i=N.readFileSync(e,"utf-8"),o=g.extractFrontmatterData(i);return o.title&&typeof o.title=="string"?o.title:l.titleFromFilename(e)}catch(i){if(r)throw new b(`Failed to read file for title derivation at ${t}: ${e}`,t,e,i);return l.titleFromFilename(e)}}function G(e){return A(e.navigation)}function A(e){for(const t of e)if(!t.title||!t.slug||t.children&&A(t.children))return!0;return!1}exports.BreadcrumbItemSchema=a.BreadcrumbItemSchema;exports.DocPageMetaSchema=a.DocPageMetaSchema;exports.DocPageSchema=a.DocPageSchema;exports.DocsPackageManifestInputSchema=a.DocsPackageManifestInputSchema;exports.DocsPackageManifestSchema=a.DocsPackageManifestSchema;exports.FlatNavigationNodeSchema=a.FlatNavigationNodeSchema;exports.GitHubConfigSchema=a.GitHubConfigSchema;exports.LoadedDocsPackageSchema=a.LoadedDocsPackageSchema;exports.ManifestValidationError=a.ManifestValidationError;exports.NavigationNodeInputSchema=a.NavigationNodeInputSchema;exports.NavigationNodeSchema=a.NavigationNodeSchema;exports.SearchConfigSchema=a.SearchConfigSchema;exports.VendureVersionSchema=a.VendureVersionSchema;exports.buildBreadcrumbs=a.buildBreadcrumbs;exports.findNavigationNode=a.findNavigationNode;exports.flattenNavigation=a.flattenNavigation;exports.getLeafNodes=a.getLeafNodes;exports.getNodesAtDepth=a.getNodesAtDepth;exports.getPrevNextNodes=a.getPrevNextNodes;exports.isNodeActive=a.isNodeActive;exports.validateManifest=a.validateManifest;exports.FrontmatterParseError=g.FrontmatterParseError;exports.extractFrontmatterData=g.extractFrontmatterData;exports.hasFrontmatter=g.hasFrontmatter;exports.parseFrontmatter=g.parseFrontmatter;exports.validateFrontmatter=g.validateFrontmatter;exports.filterVisibleNavigation=l.filterVisibleNavigation;exports.getAllFilePaths=l.getAllFilePaths;exports.slugFromFilename=l.slugFromFilename;exports.titleFromFilename=l.titleFromFilename;exports.toSlug=l.toSlug;exports.ManifestResolutionError=b;exports.createNavigationFromFolder=j;exports.createNestedNavigationFromFolder=q;exports.manifestNeedsResolution=G;exports.resolveManifest=T;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var A = Object.defineProperty;
|
|
2
2
|
var B = (e, t, i) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
3
3
|
var m = (e, t, i) => B(e, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
-
import { B as _, D as ee, a as te, b as re, c as ie, F as oe, G as ne, L as se, M as ae, N as le, d as ce, S as fe, V as de, e as he, f as ue, g as ge, h as me, i as ve, j as Fe, k as Ne, v as Se } from "./manifest-
|
|
5
|
-
import { e as M } from "./frontmatter-
|
|
6
|
-
import { F as xe, h as be, p as $e, v as we } from "./frontmatter-
|
|
4
|
+
import { B as _, D as ee, a as te, b as re, c as ie, F as oe, G as ne, L as se, M as ae, N as le, d as ce, S as fe, V as de, e as he, f as ue, g as ge, h as me, i as ve, j as Fe, k as Ne, v as Se } from "./manifest-ZCrzbFSf.js";
|
|
5
|
+
import { e as M } from "./frontmatter-C0Wmtdep.js";
|
|
6
|
+
import { F as xe, h as be, p as $e, v as we } from "./frontmatter-C0Wmtdep.js";
|
|
7
7
|
import { s as v, t as F } from "./slug-utils-DVKYe9h8.js";
|
|
8
8
|
import { f as Ee, g as Me, a as Ie } from "./slug-utils-DVKYe9h8.js";
|
|
9
9
|
import { readdirSync as I, readFileSync as P, statSync as T } from "fs";
|
package/dist/loader.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var g=(e,r,t)=>r in e?f(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var i=(e,r,t)=>g(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("fs/promises"),P=require("module"),m=require("./frontmatter-
|
|
1
|
+
"use strict";var f=Object.defineProperty;var g=(e,r,t)=>r in e?f(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var i=(e,r,t)=>g(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("fs/promises"),P=require("module"),m=require("./frontmatter-CJYZSUYM.cjs"),p=require("./manifest-D-EWZlSh.cjs");var c=typeof document<"u"?document.currentScript:null;class a extends Error{constructor(t,n){super(t);i(this,"packageName");this.name="DocsPackageLoadError",this.packageName=n}}async function $(e,r={}){try{const t=r.resolver?await r.resolver(e):u(e),n=await import(e);if(!n.manifest)throw new a(`Package "${e}" does not export a manifest`,e);return{manifest:p.validateManifest(n.manifest),basePath:t}}catch(t){throw t instanceof a?t:new a(`Failed to load docs package "${e}": ${t instanceof Error?t.message:String(t)}`,e)}}function u(e){try{return P.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:c&&c.tagName.toUpperCase()==="SCRIPT"&&c.src||new URL("loader.cjs",document.baseURI).href).resolve(`${e}/package.json`).replace(/\/package\.json$/,"")}catch{throw new a(`Cannot resolve package "${e}". Make sure it is installed.`,e)}}async function l(e,r){try{const t=`${e.basePath}/${r}`,n=await h.readFile(t,"utf-8"),{meta:o,content:s}=m.parseFrontmatter(n,r);return{meta:o,content:s,filePath:r}}catch(t){throw new a(`Failed to load doc page "${r}": ${t instanceof Error?t.message:String(t)}`,e.manifest.id)}}async function v(e,r){const t=d(e.manifest.navigation,r.split("/"));if(t!=null&&t.file)return l(e,t.file)}function d(e,r){if(r.length===0)return;const[t,...n]=r,o=e.find(s=>s.slug===t);if(o){if(n.length===0)return o;if(o.children)return d(o.children,n)}}function y(e,r){if(r.file)return`${e.basePath}/${r.file}`}function w(e){try{return u(e),!0}catch{return!1}}exports.DocsPackageLoadError=a;exports.isDocsPackageInstalled=w;exports.loadDocPage=l;exports.loadDocPageBySlug=v;exports.loadDocsPackage=$;exports.resolveFilePath=y;
|
package/dist/loader.js
CHANGED
|
@@ -3,8 +3,8 @@ var l = (t, e, r) => e in t ? u(t, e, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var i = (t, e, r) => l(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
4
|
import { readFile as d } from "fs/promises";
|
|
5
5
|
import { createRequire as h } from "module";
|
|
6
|
-
import { p as g } from "./frontmatter-
|
|
7
|
-
import { v as m } from "./manifest-
|
|
6
|
+
import { p as g } from "./frontmatter-C0Wmtdep.js";
|
|
7
|
+
import { v as m } from "./manifest-ZCrzbFSf.js";
|
|
8
8
|
class a extends Error {
|
|
9
9
|
constructor(r, n) {
|
|
10
10
|
super(r);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var D=Object.defineProperty;var j=(i,t,n)=>t in i?D(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n;var f=(i,t,n)=>j(i,typeof t!="symbol"?t+"":t,n);const e=require("zod"),g=e.z.enum(["v1","v2","v3"]),d=e.z.object({indexFields:e.z.array(e.z.enum(["title","description","content","keywords"])),boosts:e.z.record(e.z.string(),e.z.number()).optional()}),u=e.z.object({repository:e.z.string().regex(/^[^/]+\/[^/]+$/,'Repository must be in format "owner/repo"'),branch:e.z.string().optional(),docsPath:e.z.string().optional()}),l=e.z.lazy(()=>e.z.object({title:e.z.string().min(1,"Navigation title is required"),slug:e.z.string().min(1,"Navigation slug is required"),file:e.z.string().optional(),children:e.z.array(l).optional(),badge:e.z.string().optional(),hidden:e.z.boolean().optional()})),h=e.z.object({id:e.z.string().min(1,"Package ID is required"),name:e.z.string().min(1,"Package name is required"),version:e.z.string().regex(/^\d+\.\d+\.\d+/,"Version must be valid semver"),vendureVersion:g,navigation:e.z.array(l),search:d.optional(),github:u.optional(),basePath:e.z.string().optional()}),p=e.z.object({title:e.z.string().min(1,"Page title is required"),description:e.z.string().optional(),keywords:e.z.array(e.z.string()).optional(),sidebarLabel:e.z.string().optional(),hidden:e.z.boolean().optional(),order:e.z.number().int().optional()}),k=e.z.object({meta:p,content:e.z.string(),filePath:e.z.string()}),I=e.z.object({manifest:h,basePath:e.z.string()}),M=e.z.object({title:e.z.string(),slug:e.z.string(),path:e.z.string()}),V=e.z.object({title:e.z.string(),slug:e.z.string(),file:e.z.string().optional(),children:e.z.array(e.z.lazy(()=>l)).optional(),badge:e.z.string().optional(),hidden:e.z.boolean().optional(),path:e.z.string(),depth:e.z.number().int().min(0),parentPath:e.z.string().optional()}),z=e.z.lazy(()=>e.z.object({title:e.z.string().min(1).optional(),slug:e.z.string().min(1).optional(),file:e.z.string().optional(),children:e.z.array(z).optional(),badge:e.z.string().optional(),hidden:e.z.boolean().optional()})),x=e.z.object({id:e.z.string().min(1,"Package ID is required"),name:e.z.string().min(1,"Package name is required"),version:e.z.string().regex(/^\d+\.\d+\.\d+/,"Version must be valid semver"),vendureVersion:g,navigation:e.z.array(z),search:d.optional(),github:u.optional(),basePath:e.z.string().optional()});class b extends Error{constructor(n,o){super(n);f(this,"issues");this.name="ManifestValidationError",this.issues=o}}function q(i){const t=h.safeParse(i);if(!t.success){const n=t.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`);throw new b("Invalid manifest",n)}return t.data}function B(i,t){const n=t.split("/").filter(Boolean);return v(i.navigation,n)}function v(i,t){if(t.length===0)return;const[n,...o]=t,a=i.find(r=>r.slug===n);if(a){if(o.length===0)return a;if(a.children)return v(a.children,o)}}function m(i){const t=[];return N(i.navigation,"",0,void 0,t),t}function N(i,t,n,o,a){for(const r of i){const s=t?`${t}/${r.slug}`:r.slug;a.push({...r,path:s,depth:n,parentPath:o}),r.children&&r.children.length>0&&N(r.children,s,n+1,s,a)}}function $(i,t){const n=t.split("/").filter(Boolean),o=[];let a=i.navigation,r="";for(const s of n){const c=a.find(y=>y.slug===s);if(!c)break;r=r?`${r}/${s}`:s,o.push({title:c.title,slug:c.slug,path:r}),a=c.children??[]}return o}function S(i){return m(i).filter(t=>t.file!==void 0)}function w(i,t){const n=S(i),o=n.findIndex(a=>a.path===t);return o===-1?{}:{prev:o>0?n[o-1]:void 0,next:o<n.length-1?n[o+1]:void 0}}function P(i,t){const n=t.split("/").filter(Boolean);if(n.length===0)return!1;if(i.slug===n[0]){if(n.length===1)return!0;if(i.children){const o=n.slice(1).join("/");return i.children.some(a=>P(a,o))}}return!1}function L(i,t){return m(i).filter(n=>n.depth===t)}exports.BreadcrumbItemSchema=M;exports.DocPageMetaSchema=p;exports.DocPageSchema=k;exports.DocsPackageManifestInputSchema=x;exports.DocsPackageManifestSchema=h;exports.FlatNavigationNodeSchema=V;exports.GitHubConfigSchema=u;exports.LoadedDocsPackageSchema=I;exports.ManifestValidationError=b;exports.NavigationNodeInputSchema=z;exports.NavigationNodeSchema=l;exports.SearchConfigSchema=d;exports.VendureVersionSchema=g;exports.buildBreadcrumbs=$;exports.findNavigationNode=B;exports.flattenNavigation=m;exports.getLeafNodes=S;exports.getNodesAtDepth=L;exports.getPrevNextNodes=w;exports.isNodeActive=P;exports.validateManifest=q;
|
|
1
|
+
"use strict";var D=Object.defineProperty;var j=(i,t,n)=>t in i?D(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n;var f=(i,t,n)=>j(i,typeof t!="symbol"?t+"":t,n);const e=require("zod"),g=e.z.enum(["v1","v2","v3"]),d=e.z.object({indexFields:e.z.array(e.z.enum(["title","description","content","keywords"])),boosts:e.z.record(e.z.string(),e.z.number()).optional()}),u=e.z.object({repository:e.z.string().regex(/^[^/]+\/[^/]+$/,'Repository must be in format "owner/repo"'),branch:e.z.string().optional(),docsPath:e.z.string().optional()}),l=e.z.lazy(()=>e.z.object({title:e.z.string().min(1,"Navigation title is required"),slug:e.z.string().min(1,"Navigation slug is required"),file:e.z.string().optional(),children:e.z.array(l).optional(),badge:e.z.string().optional(),hidden:e.z.boolean().optional()})),h=e.z.object({id:e.z.string().min(1,"Package ID is required"),name:e.z.string().min(1,"Package name is required"),version:e.z.string().regex(/^\d+\.\d+\.\d+/,"Version must be valid semver"),vendureVersion:g,navigation:e.z.array(l),search:d.optional(),github:u.optional(),basePath:e.z.string().optional()}),p=e.z.object({title:e.z.string().min(1,"Page title is required"),description:e.z.string().optional(),keywords:e.z.array(e.z.string()).optional(),sidebarLabel:e.z.string().optional(),hidden:e.z.boolean().optional(),order:e.z.number().int().optional()}),k=e.z.object({meta:p,content:e.z.string(),filePath:e.z.string()}),I=e.z.object({manifest:h,basePath:e.z.string()}),M=e.z.object({title:e.z.string(),slug:e.z.string(),path:e.z.string()}),V=e.z.object({title:e.z.string(),slug:e.z.string(),file:e.z.string().optional(),children:e.z.array(e.z.lazy(()=>l)).optional(),badge:e.z.string().optional(),hidden:e.z.boolean().optional(),path:e.z.string(),depth:e.z.number().int().min(0),parentPath:e.z.string().optional()}),z=e.z.lazy(()=>e.z.object({title:e.z.string().min(1).optional(),slug:e.z.string().min(1).optional(),file:e.z.string().optional(),children:e.z.array(z).optional(),badge:e.z.string().optional(),hidden:e.z.boolean().optional()})),x=e.z.object({id:e.z.string().min(1,"Package ID is required"),name:e.z.string().min(1,"Package name is required"),version:e.z.string().regex(/^\d+\.\d+\.\d+/,"Version must be valid semver"),vendureVersion:g,navigation:e.z.array(z),search:d.optional(),github:u.optional(),basePath:e.z.string().optional()});class b extends Error{constructor(n,o){super(n);f(this,"issues");this.name="ManifestValidationError",this.issues=o}}function q(i){const t=h.safeParse(i);if(!t.success){const n=t.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`);throw new b("Invalid manifest",n)}return t.data}function B(i,t){const n=t.split("/").filter(Boolean);return v(i.navigation,n)}function v(i,t){if(t.length===0)return;const[n,...o]=t,a=i.find(r=>r.slug===n);if(a){if(o.length===0)return a;if(a.children)return v(a.children,o)}}function m(i){const t=[];return N(i.navigation,"",0,void 0,t),t}function N(i,t,n,o,a){for(const r of i){const s=t?`${t}/${r.slug}`:r.slug;a.push({...r,path:s,depth:n,parentPath:o}),r.children&&r.children.length>0&&N(r.children,s,n+1,s,a)}}function $(i,t){const n=t.split("/").filter(Boolean),o=[];let a=i.navigation,r="";for(const s of n){const c=a.find(y=>y.slug===s);if(!c)break;r=r?`${r}/${s}`:s,o.push({title:c.title,slug:c.slug,path:r,file:c.file}),a=c.children??[]}return o}function S(i){return m(i).filter(t=>t.file!==void 0)}function w(i,t){const n=S(i),o=n.findIndex(a=>a.path===t);return o===-1?{}:{prev:o>0?n[o-1]:void 0,next:o<n.length-1?n[o+1]:void 0}}function P(i,t){const n=t.split("/").filter(Boolean);if(n.length===0)return!1;if(i.slug===n[0]){if(n.length===1)return!0;if(i.children){const o=n.slice(1).join("/");return i.children.some(a=>P(a,o))}}return!1}function L(i,t){return m(i).filter(n=>n.depth===t)}exports.BreadcrumbItemSchema=M;exports.DocPageMetaSchema=p;exports.DocPageSchema=k;exports.DocsPackageManifestInputSchema=x;exports.DocsPackageManifestSchema=h;exports.FlatNavigationNodeSchema=V;exports.GitHubConfigSchema=u;exports.LoadedDocsPackageSchema=I;exports.ManifestValidationError=b;exports.NavigationNodeInputSchema=z;exports.NavigationNodeSchema=l;exports.SearchConfigSchema=d;exports.VendureVersionSchema=g;exports.buildBreadcrumbs=$;exports.findNavigationNode=B;exports.flattenNavigation=m;exports.getLeafNodes=S;exports.getNodesAtDepth=L;exports.getPrevNextNodes=w;exports.isNodeActive=P;exports.validateManifest=q;
|
|
@@ -5,7 +5,7 @@ import { z as n } from "zod";
|
|
|
5
5
|
const d = n.enum(["v1", "v2", "v3"]), u = n.object({
|
|
6
6
|
indexFields: n.array(n.enum(["title", "description", "content", "keywords"])),
|
|
7
7
|
boosts: n.record(n.string(), n.number()).optional()
|
|
8
|
-
}),
|
|
8
|
+
}), f = n.object({
|
|
9
9
|
repository: n.string().regex(/^[^/]+\/[^/]+$/, 'Repository must be in format "owner/repo"'),
|
|
10
10
|
branch: n.string().optional(),
|
|
11
11
|
docsPath: n.string().optional()
|
|
@@ -18,14 +18,14 @@ const d = n.enum(["v1", "v2", "v3"]), u = n.object({
|
|
|
18
18
|
badge: n.string().optional(),
|
|
19
19
|
hidden: n.boolean().optional()
|
|
20
20
|
})
|
|
21
|
-
),
|
|
21
|
+
), h = n.object({
|
|
22
22
|
id: n.string().min(1, "Package ID is required"),
|
|
23
23
|
name: n.string().min(1, "Package name is required"),
|
|
24
24
|
version: n.string().regex(/^\d+\.\d+\.\d+/, "Version must be valid semver"),
|
|
25
25
|
vendureVersion: d,
|
|
26
26
|
navigation: n.array(c),
|
|
27
27
|
search: u.optional(),
|
|
28
|
-
github:
|
|
28
|
+
github: f.optional(),
|
|
29
29
|
basePath: n.string().optional()
|
|
30
30
|
}), y = n.object({
|
|
31
31
|
title: n.string().min(1, "Page title is required"),
|
|
@@ -39,7 +39,7 @@ const d = n.enum(["v1", "v2", "v3"]), u = n.object({
|
|
|
39
39
|
content: n.string(),
|
|
40
40
|
filePath: n.string()
|
|
41
41
|
}), q = n.object({
|
|
42
|
-
manifest:
|
|
42
|
+
manifest: h,
|
|
43
43
|
basePath: n.string()
|
|
44
44
|
}), B = n.object({
|
|
45
45
|
title: n.string(),
|
|
@@ -71,7 +71,7 @@ const d = n.enum(["v1", "v2", "v3"]), u = n.object({
|
|
|
71
71
|
vendureVersion: d,
|
|
72
72
|
navigation: n.array(m),
|
|
73
73
|
search: u.optional(),
|
|
74
|
-
github:
|
|
74
|
+
github: f.optional(),
|
|
75
75
|
basePath: n.string().optional()
|
|
76
76
|
});
|
|
77
77
|
class j extends Error {
|
|
@@ -82,7 +82,7 @@ class j extends Error {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
function w(i) {
|
|
85
|
-
const t =
|
|
85
|
+
const t = h.safeParse(i);
|
|
86
86
|
if (!t.success) {
|
|
87
87
|
const e = t.error.issues.map((o) => `${o.path.join(".")}: ${o.message}`);
|
|
88
88
|
throw new j("Invalid manifest", e);
|
|
@@ -126,7 +126,8 @@ function L(i, t) {
|
|
|
126
126
|
r = r ? `${r}/${s}` : s, o.push({
|
|
127
127
|
title: l.title,
|
|
128
128
|
slug: l.slug,
|
|
129
|
-
path: r
|
|
129
|
+
path: r,
|
|
130
|
+
file: l.file
|
|
130
131
|
}), a = l.children ?? [];
|
|
131
132
|
}
|
|
132
133
|
return o;
|
|
@@ -160,7 +161,7 @@ export {
|
|
|
160
161
|
B,
|
|
161
162
|
y as D,
|
|
162
163
|
M as F,
|
|
163
|
-
|
|
164
|
+
f as G,
|
|
164
165
|
q as L,
|
|
165
166
|
j as M,
|
|
166
167
|
m as N,
|
|
@@ -168,7 +169,7 @@ export {
|
|
|
168
169
|
d as V,
|
|
169
170
|
I as a,
|
|
170
171
|
$ as b,
|
|
171
|
-
|
|
172
|
+
h as c,
|
|
172
173
|
c as d,
|
|
173
174
|
L as e,
|
|
174
175
|
z as f,
|
package/dist/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACf,MAAM,SAAS,CAAA;AAEhB;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,SAAgB,MAAM,EAAE,MAAM,EAAE,CAAA;gBAEpB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;CAK9C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,mBAAmB,CAWvE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,MAAM,GAC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,QAAQ,EAAE,MAAM,GACf;IAAE,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAAC,IAAI,CAAC,EAAE,kBAAkB,CAAA;CAAE,CAY1D;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAc/E;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,mBAAmB,EAC7B,KAAK,EAAE,MAAM,GACZ,kBAAkB,EAAE,CAEtB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remark plugins for MDX processing
|
|
3
|
+
*
|
|
4
|
+
* These plugins are used by the MDX compiler to transform
|
|
5
|
+
* documentation content during compilation.
|
|
6
|
+
*/
|
|
7
|
+
export { remarkAdmonitions, default as remarkAdmonitionsDefault } from './remark-admonitions';
|
|
8
|
+
export { remarkCodeMeta } from './remark-code-meta';
|
|
9
|
+
export { remarkStripImports, default as remarkStripImportsDefault } from './remark-strip-imports';
|
|
10
|
+
export { remarkStripHtmlComments, default as remarkStripHtmlCommentsDefault, } from './remark-strip-html-comments';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/remark-plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AACjG,OAAO,EACL,uBAAuB,EACvB,OAAO,IAAI,8BAA8B,GAC1C,MAAM,8BAA8B,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Root } from 'mdast';
|
|
2
|
+
import { Plugin } from 'unified';
|
|
3
|
+
/**
|
|
4
|
+
* Remark plugin that transforms container directives into Callout JSX components.
|
|
5
|
+
*
|
|
6
|
+
* This plugin works with remark-directive to convert markdown like:
|
|
7
|
+
*
|
|
8
|
+
* ```md
|
|
9
|
+
* :::caution
|
|
10
|
+
* Some warning content
|
|
11
|
+
* :::
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Into a Callout component that can be rendered by MDX.
|
|
15
|
+
*/
|
|
16
|
+
export declare const remarkAdmonitions: Plugin<[], Root>;
|
|
17
|
+
export default remarkAdmonitions;
|
|
18
|
+
//# sourceMappingURL=remark-admonitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remark-admonitions.d.ts","sourceRoot":"","sources":["../../src/remark-plugins/remark-admonitions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAuBrC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,CAwD9C,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Root } from 'mdast';
|
|
2
|
+
/**
|
|
3
|
+
* Remark plugin that extracts title/filename from code fence meta strings
|
|
4
|
+
* and converts them to `// filename:` comments that CodeBlock can parse.
|
|
5
|
+
*
|
|
6
|
+
* Supports:
|
|
7
|
+
* - ```ts title="path/to/file.ts"
|
|
8
|
+
* - ```ts filename="path/to/file.ts"
|
|
9
|
+
*
|
|
10
|
+
* Converts to:
|
|
11
|
+
* // filename: path/to/file.ts
|
|
12
|
+
* <code content>
|
|
13
|
+
*/
|
|
14
|
+
export declare function remarkCodeMeta(): (tree: Root) => void;
|
|
15
|
+
//# sourceMappingURL=remark-code-meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remark-code-meta.d.ts","sourceRoot":"","sources":["../../src/remark-plugins/remark-code-meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,IAAI,EAAE,MAAM,OAAO,CAAA;AAGvC;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,KACpB,MAAM,IAAI,UAkBnB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Root } from 'mdast';
|
|
2
|
+
import { Plugin } from 'unified';
|
|
3
|
+
/**
|
|
4
|
+
* Remark plugin that removes HTML comment nodes from the AST.
|
|
5
|
+
*/
|
|
6
|
+
export declare const remarkStripHtmlComments: Plugin<[], Root>;
|
|
7
|
+
export default remarkStripHtmlComments;
|
|
8
|
+
//# sourceMappingURL=remark-strip-html-comments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remark-strip-html-comments.d.ts","sourceRoot":"","sources":["../../src/remark-plugins/remark-strip-html-comments.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAGrC;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,CAsBpD,CAAA;AAED,eAAe,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Root } from 'mdast';
|
|
2
|
+
import { Plugin } from 'unified';
|
|
3
|
+
/**
|
|
4
|
+
* Remark plugin that removes import statements for specified modules.
|
|
5
|
+
*/
|
|
6
|
+
export declare const remarkStripImports: Plugin<[], Root>;
|
|
7
|
+
export default remarkStripImports;
|
|
8
|
+
//# sourceMappingURL=remark-strip-imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remark-strip-imports.d.ts","sourceRoot":"","sources":["../../src/remark-plugins/remark-strip-imports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAQrC;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,CA0B/C,CAAA;AAED,eAAe,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MdxCompilationResult, MdxTestReport } from './types';
|
|
2
|
+
export type { CompileMdxOptions, MdxCompilationResult, MdxTestReport, TestManifestOptions, } from './types';
|
|
3
|
+
export { compileMdx, getDefaultRehypePlugins, getDefaultRemarkPlugins } from './mdx-compiler';
|
|
4
|
+
export { testManifestMdx } from './test-manifest';
|
|
5
|
+
/**
|
|
6
|
+
* Format a test report for console output.
|
|
7
|
+
*
|
|
8
|
+
* @param report - The test report to format
|
|
9
|
+
* @param verbose - If true, show details for all files. If false, only show failures.
|
|
10
|
+
* @returns A formatted string suitable for console output
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const report = await testManifestMdx(manifest)
|
|
15
|
+
* console.log(formatTestReport(report, true))
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatTestReport(report: MdxTestReport, verbose?: boolean): string;
|
|
19
|
+
/**
|
|
20
|
+
* Create a simple progress reporter for console output.
|
|
21
|
+
*
|
|
22
|
+
* @returns A progress callback function for use with testManifestMdx
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const report = await testManifestMdx(manifest, {
|
|
27
|
+
* onProgress: createProgressReporter(),
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function createProgressReporter(): (current: number, total: number, result: MdxCompilationResult) => void;
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,CA2D/E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,IAAI,CACxC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,oBAAoB,KACzB,IAAI,CAcR"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { PluggableList } from 'unified';
|
|
2
|
+
import { CompileMdxOptions, MdxCompilationResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Get the default remark plugins used for MDX compilation.
|
|
5
|
+
*
|
|
6
|
+
* These plugins match those used in @apps/docs and provide:
|
|
7
|
+
* - GitHub Flavored Markdown support
|
|
8
|
+
* - Directive support (for admonitions)
|
|
9
|
+
* - Admonition transformation
|
|
10
|
+
* - Code fence metadata handling
|
|
11
|
+
* - Import stripping (Docusaurus compatibility)
|
|
12
|
+
* - HTML comment stripping
|
|
13
|
+
*
|
|
14
|
+
* @returns Array of remark plugins
|
|
15
|
+
*/
|
|
16
|
+
export declare function getDefaultRemarkPlugins(): PluggableList;
|
|
17
|
+
/**
|
|
18
|
+
* Get the default rehype plugins used for MDX compilation.
|
|
19
|
+
*
|
|
20
|
+
* These plugins provide:
|
|
21
|
+
* - Automatic slug generation for headings
|
|
22
|
+
*
|
|
23
|
+
* @returns Array of rehype plugins
|
|
24
|
+
*/
|
|
25
|
+
export declare function getDefaultRehypePlugins(): PluggableList;
|
|
26
|
+
/**
|
|
27
|
+
* Compile an MDX string and return the compilation result.
|
|
28
|
+
*
|
|
29
|
+
* This function uses the same plugin configuration as @apps/docs,
|
|
30
|
+
* allowing documentation packages to validate their MDX content
|
|
31
|
+
* before publishing.
|
|
32
|
+
*
|
|
33
|
+
* @param content - The MDX content to compile
|
|
34
|
+
* @param filePath - The file path (used for error reporting)
|
|
35
|
+
* @param options - Optional compilation options
|
|
36
|
+
* @returns The compilation result with success status and any errors
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const result = await compileMdx('# Hello World', 'example.mdx')
|
|
41
|
+
* if (result.success) {
|
|
42
|
+
* console.log('Compilation successful!')
|
|
43
|
+
* } else {
|
|
44
|
+
* console.error(`Error at line ${result.line}: ${result.error}`)
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function compileMdx(content: string, filePath: string, options?: CompileMdxOptions): Promise<MdxCompilationResult>;
|
|
49
|
+
//# sourceMappingURL=mdx-compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdx-compiler.d.ts","sourceRoot":"","sources":["../../src/testing/mdx-compiler.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAO5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEtE;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,IAAI,aAAa,CASvD;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,IAAI,aAAa,CAEvD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CAuE/B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DocsPackageManifest } from '../types';
|
|
2
|
+
import { MdxTestReport, TestManifestOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Test all MDX files in a manifest by compiling them.
|
|
5
|
+
*
|
|
6
|
+
* This function iterates through all leaf nodes (pages with files) in the
|
|
7
|
+
* manifest's navigation tree and attempts to compile each MDX file using
|
|
8
|
+
* the same plugins as @apps/docs.
|
|
9
|
+
*
|
|
10
|
+
* @param manifest - The documentation package manifest to test
|
|
11
|
+
* @param options - Optional configuration for testing
|
|
12
|
+
* @returns A report containing results for each file
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { manifest } from '../src/manifest'
|
|
17
|
+
* import { testManifestMdx, formatTestReport } from '@vendure-io/docs-provider/testing'
|
|
18
|
+
*
|
|
19
|
+
* const report = await testManifestMdx(manifest, {
|
|
20
|
+
* basePath: __dirname,
|
|
21
|
+
* onProgress: (current, total, result) => {
|
|
22
|
+
* console.log(`[${current}/${total}] ${result.success ? '✓' : '✗'} ${result.filePath}`)
|
|
23
|
+
* },
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* console.log(formatTestReport(report))
|
|
27
|
+
* process.exit(report.failed > 0 ? 1 : 0)
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function testManifestMdx(manifest: DocsPackageManifest, options?: TestManifestOptions): Promise<MdxTestReport>;
|
|
31
|
+
//# sourceMappingURL=test-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-manifest.d.ts","sourceRoot":"","sources":["../../src/testing/test-manifest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAGnD,OAAO,KAAK,EAAwB,aAAa,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,aAAa,CAAC,CA6ExB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { PluggableList } from 'unified';
|
|
2
|
+
/**
|
|
3
|
+
* Result of compiling a single MDX file
|
|
4
|
+
*/
|
|
5
|
+
export interface MdxCompilationResult {
|
|
6
|
+
/** Path to the MDX file that was compiled */
|
|
7
|
+
filePath: string;
|
|
8
|
+
/** Whether compilation was successful */
|
|
9
|
+
success: boolean;
|
|
10
|
+
/** Error message if compilation failed */
|
|
11
|
+
error?: string;
|
|
12
|
+
/** Line number where the error occurred (if available) */
|
|
13
|
+
line?: number;
|
|
14
|
+
/** Column number where the error occurred (if available) */
|
|
15
|
+
column?: number;
|
|
16
|
+
/** Time taken to compile the file in milliseconds */
|
|
17
|
+
compilationTime: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Report from testing all MDX files in a manifest
|
|
21
|
+
*/
|
|
22
|
+
export interface MdxTestReport {
|
|
23
|
+
/** Package ID from the manifest */
|
|
24
|
+
packageId: string;
|
|
25
|
+
/** Total number of MDX files tested */
|
|
26
|
+
totalFiles: number;
|
|
27
|
+
/** Number of files that compiled successfully */
|
|
28
|
+
passed: number;
|
|
29
|
+
/** Number of files that failed to compile */
|
|
30
|
+
failed: number;
|
|
31
|
+
/** Individual results for each file */
|
|
32
|
+
results: MdxCompilationResult[];
|
|
33
|
+
/** Total time taken for all compilations in milliseconds */
|
|
34
|
+
totalTime: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Options for testing a manifest's MDX files
|
|
38
|
+
*/
|
|
39
|
+
export interface TestManifestOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Base path for resolving file paths.
|
|
42
|
+
* If not provided, uses the manifest's basePath or current working directory.
|
|
43
|
+
*/
|
|
44
|
+
basePath?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Stop on first failure.
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
failFast?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Custom remark plugins to use instead of defaults.
|
|
52
|
+
* If not provided, uses the standard docs-provider plugins.
|
|
53
|
+
*/
|
|
54
|
+
remarkPlugins?: PluggableList;
|
|
55
|
+
/**
|
|
56
|
+
* Custom rehype plugins to use instead of defaults.
|
|
57
|
+
* If not provided, uses the standard docs-provider plugins.
|
|
58
|
+
*/
|
|
59
|
+
rehypePlugins?: PluggableList;
|
|
60
|
+
/**
|
|
61
|
+
* Callback invoked after each file is processed.
|
|
62
|
+
* Useful for progress reporting.
|
|
63
|
+
*/
|
|
64
|
+
onProgress?: (current: number, total: number, result: MdxCompilationResult) => void;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Options for compiling a single MDX file
|
|
68
|
+
*/
|
|
69
|
+
export interface CompileMdxOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Custom remark plugins to use.
|
|
72
|
+
* If not provided, uses the standard docs-provider plugins.
|
|
73
|
+
*/
|
|
74
|
+
remarkPlugins?: PluggableList;
|
|
75
|
+
/**
|
|
76
|
+
* Custom rehype plugins to use.
|
|
77
|
+
* If not provided, uses the standard docs-provider plugins.
|
|
78
|
+
*/
|
|
79
|
+
rehypePlugins?: PluggableList;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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;AAE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strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("@mdx-js/mdx"),F=require("rehype-slug"),M=require("remark-directive"),x=require("remark-gfm"),p=require("unist-util-visit"),R=require("fs/promises"),$=require("path"),D=require("./manifest-D-EWZlSh.cjs"),v={info:"info",note:"note",tip:"tip",warning:"warning",caution:"caution",danger:"danger"},I={info:"Info",note:"Note",tip:"Tip",warning:"Warning",caution:"Caution",danger:"Danger"},b=()=>s=>{p.visit(s,"containerDirective",e=>{var l;const t=e.name.toLowerCase();if(!(t in v))return;const i=v[t];let r;if(e.children.length>0){const a=e.children[0];if(a.type==="paragraph"&&"data"in a&&((l=a.data)==null?void 0:l.directiveLabel)===!0){const c=[];for(const f of a.children)f.type==="text"&&c.push(f.value);c.length>0&&(r=c.join("")),e.children=e.children.slice(1)}}const n=r||I[t],u=e.data||(e.data={});u.hName="Callout",u.hProperties={type:i,title:n}})};function E(){return s=>{p.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=()=>s=>{const e=[];p.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)},q=["@theme/Tabs","@theme/TabItem"],C=()=>s=>{const e=[];p.visit(s,"mdxjsEsm",t=>{const i=t.value;q.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 T(){return[x,M,b,E,C,S]}function y(){return[F]}async function k(s,e,t){var u,l,a,c;const i=performance.now(),r=(t==null?void 0:t.remarkPlugins)??T(),n=(t==null?void 0:t.rehypePlugins)??y();try{return await w.compile(s,{remarkPlugins:r,rehypePlugins:n,outputFormat:"function-body",development:!1}),{filePath:e,success:!0,compilationTime:performance.now()-i}}catch(f){const d=performance.now()-i;let o="Unknown compilation error",m,g;if(f instanceof Error){o=f.message;const h=f;if(h.line!==void 0?m=h.line:((l=(u=h.position)==null?void 0:u.start)==null?void 0:l.line)!==void 0&&(m=h.position.start.line),h.column!==void 0?g=h.column:((c=(a=h.position)==null?void 0:a.start)==null?void 0:c.column)!==void 0&&(g=h.position.start.column),m===void 0){const P=o.match(/\((\d+):(\d+)\)/);P&&(m=parseInt(P[1],10),g=parseInt(P[2],10))}}return{filePath:e,success:!1,error:o,line:m,column:g,compilationTime:d}}}async function L(s,e){const t=performance.now(),i=$.resolve((e==null?void 0:e.basePath)??s.basePath??process.cwd()),r=D.getLeafNodes(s),n=[];let u=0,l=0;for(let a=0;a<r.length;a++){const c=r[a];if(!c.file)continue;const f=$.join(i,c.file);try{const d=await R.readFile(f,"utf-8"),o=await k(d,c.file,{remarkPlugins:e==null?void 0:e.remarkPlugins,rehypePlugins:e==null?void 0:e.rehypePlugins});if(n.push(o),o.success?u++:l++,e!=null&&e.onProgress&&e.onProgress(a+1,r.length,o),e!=null&&e.failFast&&!o.success)break}catch(d){const o=d instanceof Error?d.message:"Unknown error reading file",m={filePath:c.file,success:!1,error:`Failed to read file: ${o}`,compilationTime:0};if(n.push(m),l++,e!=null&&e.onProgress&&e.onProgress(a+1,r.length,m),e!=null&&e.failFast)break}}return{packageId:s.id,totalFiles:n.length,passed:u,failed:l,results:n,totalTime:performance.now()-t}}function A(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]",u=`(${r.compilationTime.toFixed(2)}ms)`;if(t.push(`${n} ${r.filePath} ${u}`),!r.success&&r.error){const l=r.line?` (line ${r.line}${r.column?`:${r.column}`:""})`:"";t.push(` Error${l}: ${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(`
|
|
3
|
+
`)}function j(){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(`
|
|
4
|
+
`)}}exports.compileMdx=k;exports.createProgressReporter=j;exports.formatTestReport=A;exports.getDefaultRehypePlugins=y;exports.getDefaultRemarkPlugins=T;exports.testManifestMdx=L;
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { compile as v } from "@mdx-js/mdx";
|
|
2
|
+
import T from "rehype-slug";
|
|
3
|
+
import w from "remark-directive";
|
|
4
|
+
import F from "remark-gfm";
|
|
5
|
+
import { visit as g } from "unist-util-visit";
|
|
6
|
+
import { readFile as k } from "fs/promises";
|
|
7
|
+
import { resolve as y, join as x } from "path";
|
|
8
|
+
import { h as I } from "./manifest-ZCrzbFSf.js";
|
|
9
|
+
const P = {
|
|
10
|
+
info: "info",
|
|
11
|
+
note: "note",
|
|
12
|
+
tip: "tip",
|
|
13
|
+
warning: "warning",
|
|
14
|
+
caution: "caution",
|
|
15
|
+
danger: "danger"
|
|
16
|
+
}, E = {
|
|
17
|
+
info: "Info",
|
|
18
|
+
note: "Note",
|
|
19
|
+
tip: "Tip",
|
|
20
|
+
warning: "Warning",
|
|
21
|
+
caution: "Caution",
|
|
22
|
+
danger: "Danger"
|
|
23
|
+
}, M = () => (r) => {
|
|
24
|
+
g(r, "containerDirective", (e) => {
|
|
25
|
+
var l;
|
|
26
|
+
const t = e.name.toLowerCase();
|
|
27
|
+
if (!(t in P))
|
|
28
|
+
return;
|
|
29
|
+
const i = P[t];
|
|
30
|
+
let s;
|
|
31
|
+
if (e.children.length > 0) {
|
|
32
|
+
const n = e.children[0];
|
|
33
|
+
if (n.type === "paragraph" && "data" in n && ((l = n.data) == null ? void 0 : l.directiveLabel) === !0) {
|
|
34
|
+
const c = [];
|
|
35
|
+
for (const f of n.children)
|
|
36
|
+
f.type === "text" && c.push(f.value);
|
|
37
|
+
c.length > 0 && (s = c.join("")), e.children = e.children.slice(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const a = s || E[t], o = e.data || (e.data = {});
|
|
41
|
+
o.hName = "Callout", o.hProperties = {
|
|
42
|
+
type: i,
|
|
43
|
+
title: a
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
function D() {
|
|
48
|
+
return (r) => {
|
|
49
|
+
g(r, "code", (e) => {
|
|
50
|
+
if (!e.meta) return;
|
|
51
|
+
const t = e.meta.match(/(?:title|filename)=["']([^"']+)["']/);
|
|
52
|
+
if (!t) return;
|
|
53
|
+
const i = t[1];
|
|
54
|
+
e.value.trim().startsWith("// filename:") || (e.value = `// filename: ${i}
|
|
55
|
+
${e.value}`);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const R = () => (r) => {
|
|
60
|
+
const e = [];
|
|
61
|
+
g(r, "html", (t, i, s) => {
|
|
62
|
+
i !== void 0 && s && typeof t.value == "string" && t.value.trim().startsWith("<!--") && t.value.trim().endsWith("-->") && e.push(i);
|
|
63
|
+
});
|
|
64
|
+
for (const t of e.reverse())
|
|
65
|
+
r.children.splice(t, 1);
|
|
66
|
+
}, b = ["@theme/Tabs", "@theme/TabItem"], S = () => (r) => {
|
|
67
|
+
const e = [];
|
|
68
|
+
g(r, "mdxjsEsm", (t) => {
|
|
69
|
+
const i = t.value;
|
|
70
|
+
b.some(
|
|
71
|
+
(a) => i.includes(`from '${a}'`) || i.includes(`from "${a}"`)
|
|
72
|
+
) && e.push(t);
|
|
73
|
+
});
|
|
74
|
+
for (const t of e) {
|
|
75
|
+
const i = r.children.indexOf(t);
|
|
76
|
+
i !== -1 && r.children.splice(i, 1);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
function C() {
|
|
80
|
+
return [
|
|
81
|
+
F,
|
|
82
|
+
w,
|
|
83
|
+
M,
|
|
84
|
+
D,
|
|
85
|
+
S,
|
|
86
|
+
R
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
function L() {
|
|
90
|
+
return [T];
|
|
91
|
+
}
|
|
92
|
+
async function A(r, e, t) {
|
|
93
|
+
var o, l, n, c;
|
|
94
|
+
const i = performance.now(), s = (t == null ? void 0 : t.remarkPlugins) ?? C(), a = (t == null ? void 0 : t.rehypePlugins) ?? L();
|
|
95
|
+
try {
|
|
96
|
+
return await v(r, {
|
|
97
|
+
remarkPlugins: s,
|
|
98
|
+
rehypePlugins: a,
|
|
99
|
+
// Don't output to JS, just compile to check for errors
|
|
100
|
+
outputFormat: "function-body",
|
|
101
|
+
// Suppress development warnings about missing 'development' option
|
|
102
|
+
development: !1
|
|
103
|
+
}), {
|
|
104
|
+
filePath: e,
|
|
105
|
+
success: !0,
|
|
106
|
+
compilationTime: performance.now() - i
|
|
107
|
+
};
|
|
108
|
+
} catch (f) {
|
|
109
|
+
const d = performance.now() - i;
|
|
110
|
+
let u = "Unknown compilation error", m, p;
|
|
111
|
+
if (f instanceof Error) {
|
|
112
|
+
u = f.message;
|
|
113
|
+
const h = f;
|
|
114
|
+
if (h.line !== void 0 ? m = h.line : ((l = (o = h.position) == null ? void 0 : o.start) == null ? void 0 : l.line) !== void 0 && (m = h.position.start.line), h.column !== void 0 ? p = h.column : ((c = (n = h.position) == null ? void 0 : n.start) == null ? void 0 : c.column) !== void 0 && (p = h.position.start.column), m === void 0) {
|
|
115
|
+
const $ = u.match(/\((\d+):(\d+)\)/);
|
|
116
|
+
$ && (m = parseInt($[1], 10), p = parseInt($[2], 10));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
filePath: e,
|
|
121
|
+
success: !1,
|
|
122
|
+
error: u,
|
|
123
|
+
line: m,
|
|
124
|
+
column: p,
|
|
125
|
+
compilationTime: d
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function G(r, e) {
|
|
130
|
+
const t = performance.now(), i = y((e == null ? void 0 : e.basePath) ?? r.basePath ?? process.cwd()), s = I(r), a = [];
|
|
131
|
+
let o = 0, l = 0;
|
|
132
|
+
for (let n = 0; n < s.length; n++) {
|
|
133
|
+
const c = s[n];
|
|
134
|
+
if (!c.file)
|
|
135
|
+
continue;
|
|
136
|
+
const f = x(i, c.file);
|
|
137
|
+
try {
|
|
138
|
+
const d = await k(f, "utf-8"), u = await A(d, c.file, {
|
|
139
|
+
remarkPlugins: e == null ? void 0 : e.remarkPlugins,
|
|
140
|
+
rehypePlugins: e == null ? void 0 : e.rehypePlugins
|
|
141
|
+
});
|
|
142
|
+
if (a.push(u), u.success ? o++ : l++, e != null && e.onProgress && e.onProgress(n + 1, s.length, u), e != null && e.failFast && !u.success)
|
|
143
|
+
break;
|
|
144
|
+
} catch (d) {
|
|
145
|
+
const u = d instanceof Error ? d.message : "Unknown error reading file", m = {
|
|
146
|
+
filePath: c.file,
|
|
147
|
+
success: !1,
|
|
148
|
+
error: `Failed to read file: ${u}`,
|
|
149
|
+
compilationTime: 0
|
|
150
|
+
};
|
|
151
|
+
if (a.push(m), l++, e != null && e.onProgress && e.onProgress(n + 1, s.length, m), e != null && e.failFast)
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
packageId: r.id,
|
|
157
|
+
totalFiles: a.length,
|
|
158
|
+
passed: o,
|
|
159
|
+
failed: l,
|
|
160
|
+
results: a,
|
|
161
|
+
totalTime: performance.now() - t
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function H(r, e = !1) {
|
|
165
|
+
const t = [];
|
|
166
|
+
t.push(""), t.push(`MDX Compilation Report: ${r.packageId}`), t.push("=".repeat(50)), t.push("");
|
|
167
|
+
const i = r.totalFiles > 0 ? (r.passed / r.totalFiles * 100).toFixed(1) : "0";
|
|
168
|
+
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) {
|
|
169
|
+
t.push("Results:"), t.push("-".repeat(50));
|
|
170
|
+
for (const s of r.results) {
|
|
171
|
+
const a = s.success ? "[PASS]" : "[FAIL]", o = `(${s.compilationTime.toFixed(2)}ms)`;
|
|
172
|
+
if (t.push(`${a} ${s.filePath} ${o}`), !s.success && s.error) {
|
|
173
|
+
const l = s.line ? ` (line ${s.line}${s.column ? `:${s.column}` : ""})` : "";
|
|
174
|
+
t.push(` Error${l}: ${s.error}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
} else if (r.failed > 0) {
|
|
178
|
+
t.push("Failures:"), t.push("-".repeat(50));
|
|
179
|
+
for (const s of r.results.filter((a) => !a.success))
|
|
180
|
+
if (t.push(`[FAIL] ${s.filePath}`), s.error) {
|
|
181
|
+
const a = s.line ? ` (line ${s.line}${s.column ? `:${s.column}` : ""})` : "";
|
|
182
|
+
t.push(` Error${a}: ${s.error}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
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(`
|
|
186
|
+
`);
|
|
187
|
+
}
|
|
188
|
+
function K() {
|
|
189
|
+
return (r, e, t) => {
|
|
190
|
+
const i = t.success ? "✓" : "✗", s = (r / e * 100).toFixed(0);
|
|
191
|
+
process.stdout.write(`\r[${r}/${e}] (${s}%) ${i} ${t.filePath}`), process.stdout.write("\x1B[K"), r === e && process.stdout.write(`
|
|
192
|
+
`);
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
export {
|
|
196
|
+
A as compileMdx,
|
|
197
|
+
K as createProgressReporter,
|
|
198
|
+
H as formatTestReport,
|
|
199
|
+
L as getDefaultRehypePlugins,
|
|
200
|
+
C as getDefaultRemarkPlugins,
|
|
201
|
+
G as testManifestMdx
|
|
202
|
+
};
|
package/dist/types.d.ts
CHANGED
|
@@ -107,6 +107,8 @@ export interface BreadcrumbItem {
|
|
|
107
107
|
slug: string;
|
|
108
108
|
/** Full path from root */
|
|
109
109
|
path: string;
|
|
110
|
+
/** Path to MDX file (indicates this item has an actual page) */
|
|
111
|
+
file?: string;
|
|
110
112
|
}
|
|
111
113
|
/**
|
|
112
114
|
* Flattened navigation node with full path information
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAE/C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,wCAAwC;IACxC,WAAW,EAAE,CAAC,OAAO,GAAG,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC,EAAE,CAAA;IACjE,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAA;IAClB,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;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AI,EAAE,MAAM,CAAA;IACZ,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAA;IACZ,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAA;IACb,iCAAiC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,oCAAoC;IACpC,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAA;IAChC,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,wEAAwE;IACxE,EAAE,EAAE,MAAM,CAAA;IACV,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,iDAAiD;IACjD,cAAc,EAAE,cAAc,CAAA;IAC9B,sEAAsE;IACtE,UAAU,EAAE,mBAAmB,EAAE,CAAA;IACjC,0CAA0C;IAC1C,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,kFAAkF;IAClF,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB"}
|
package/docs/getting-started.md
CHANGED
|
@@ -153,4 +153,5 @@ Welcome to My Plugin documentation!
|
|
|
153
153
|
- [Creating a Docs Package](./creating-a-docs-package.md) - Complete guide to building a documentation package
|
|
154
154
|
- [Manifest Reference](./manifest-reference.md) - Full API documentation for manifest configuration
|
|
155
155
|
- [Frontmatter Reference](./frontmatter-reference.md) - All available frontmatter options
|
|
156
|
+
- [MDX Testing](./mdx-testing.md) - Validate MDX files before publishing
|
|
156
157
|
- [Publishing](./publishing.md) - How to publish and integrate with vendure.io
|
|
@@ -88,10 +88,10 @@ An inline link component that automatically prefixes relative URLs with the curr
|
|
|
88
88
|
|
|
89
89
|
#### Props
|
|
90
90
|
|
|
91
|
-
| Prop | Type | Required | Description
|
|
92
|
-
| ---------- | ----------- | -------- |
|
|
93
|
-
| `href` | `string` | Yes | URL to navigate to (relative paths will be prefixed)
|
|
94
|
-
| `children` | `ReactNode` | Yes | Link text content
|
|
91
|
+
| Prop | Type | Required | Description |
|
|
92
|
+
| ---------- | ----------- | -------- | ---------------------------------------------------- |
|
|
93
|
+
| `href` | `string` | Yes | URL to navigate to (relative paths will be prefixed) |
|
|
94
|
+
| `children` | `ReactNode` | Yes | Link text content |
|
|
95
95
|
|
|
96
96
|
#### Example
|
|
97
97
|
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
# MDX Compilation Testing
|
|
2
|
+
|
|
3
|
+
`@vendure-io/docs-provider` includes a testing module that allows you to validate MDX files **before publishing** your documentation package. This catches compilation errors early, reducing the feedback loop between publishing and discovering issues.
|
|
4
|
+
|
|
5
|
+
## Why Test MDX Files?
|
|
6
|
+
|
|
7
|
+
MDX compilation errors only surface when the documentation website attempts to render your pages. Without pre-publish testing, this creates a slow feedback loop:
|
|
8
|
+
|
|
9
|
+
1. Write MDX content
|
|
10
|
+
2. Publish package to npm
|
|
11
|
+
3. Update docs website dependency
|
|
12
|
+
4. Build docs website
|
|
13
|
+
5. Discover compilation errors
|
|
14
|
+
6. Fix and repeat
|
|
15
|
+
|
|
16
|
+
The testing module lets you catch errors at step 1, before any publishing occurs.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
The testing module is included in `@vendure-io/docs-provider`. No additional installation is required, but ensure you have the package installed:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @vendure-io/docs-provider
|
|
24
|
+
# or
|
|
25
|
+
bun add @vendure-io/docs-provider
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
### Testing Your Manifest
|
|
31
|
+
|
|
32
|
+
The simplest way to test all MDX files in your documentation package:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { manifest } from './src/manifest'
|
|
36
|
+
import { testManifestMdx, formatTestReport } from '@vendure-io/docs-provider/testing'
|
|
37
|
+
|
|
38
|
+
async function main() {
|
|
39
|
+
const report = await testManifestMdx(manifest, {
|
|
40
|
+
basePath: __dirname,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
console.log(formatTestReport(report))
|
|
44
|
+
process.exit(report.failed > 0 ? 1 : 0)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
main()
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Save this as `scripts/test-mdx.ts` and run it:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx tsx scripts/test-mdx.ts
|
|
54
|
+
# or with bun
|
|
55
|
+
bun run scripts/test-mdx.ts
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Adding to package.json
|
|
59
|
+
|
|
60
|
+
Add a script to your `package.json` for easy execution:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"scripts": {
|
|
65
|
+
"test:mdx": "tsx scripts/test-mdx.ts",
|
|
66
|
+
"prepublishOnly": "npm run test:mdx"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The `prepublishOnly` script ensures MDX validation runs before every npm publish.
|
|
72
|
+
|
|
73
|
+
## API Reference
|
|
74
|
+
|
|
75
|
+
### testManifestMdx
|
|
76
|
+
|
|
77
|
+
Tests all MDX files referenced in a manifest's navigation tree.
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
async function testManifestMdx(
|
|
81
|
+
manifest: DocsPackageManifest,
|
|
82
|
+
options?: TestManifestOptions
|
|
83
|
+
): Promise<MdxTestReport>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Parameters:**
|
|
87
|
+
|
|
88
|
+
- `manifest` - The documentation package manifest to test
|
|
89
|
+
- `options` - Optional configuration (see below)
|
|
90
|
+
|
|
91
|
+
**Options:**
|
|
92
|
+
|
|
93
|
+
| Option | Type | Default | Description |
|
|
94
|
+
|--------|------|---------|-------------|
|
|
95
|
+
| `basePath` | `string` | `manifest.basePath` or `cwd()` | Base path for resolving file paths |
|
|
96
|
+
| `failFast` | `boolean` | `false` | Stop on first failure |
|
|
97
|
+
| `remarkPlugins` | `PluggableList` | Default plugins | Custom remark plugins |
|
|
98
|
+
| `rehypePlugins` | `PluggableList` | Default plugins | Custom rehype plugins |
|
|
99
|
+
| `onProgress` | `Function` | `undefined` | Progress callback |
|
|
100
|
+
|
|
101
|
+
**Example with progress reporting:**
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
const report = await testManifestMdx(manifest, {
|
|
105
|
+
basePath: __dirname,
|
|
106
|
+
onProgress: (current, total, result) => {
|
|
107
|
+
const status = result.success ? '✓' : '✗'
|
|
108
|
+
console.log(`[${current}/${total}] ${status} ${result.filePath}`)
|
|
109
|
+
},
|
|
110
|
+
})
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### compileMdx
|
|
114
|
+
|
|
115
|
+
Compiles a single MDX string and returns the result.
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
async function compileMdx(
|
|
119
|
+
content: string,
|
|
120
|
+
filePath: string,
|
|
121
|
+
options?: CompileMdxOptions
|
|
122
|
+
): Promise<MdxCompilationResult>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Example:**
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { compileMdx } from '@vendure-io/docs-provider/testing'
|
|
129
|
+
|
|
130
|
+
const content = `
|
|
131
|
+
---
|
|
132
|
+
title: Test Page
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
# Hello World
|
|
136
|
+
|
|
137
|
+
This is a test.
|
|
138
|
+
`
|
|
139
|
+
|
|
140
|
+
const result = await compileMdx(content, 'test.mdx')
|
|
141
|
+
|
|
142
|
+
if (result.success) {
|
|
143
|
+
console.log('Compilation successful!')
|
|
144
|
+
} else {
|
|
145
|
+
console.error(`Error at line ${result.line}: ${result.error}`)
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### formatTestReport
|
|
150
|
+
|
|
151
|
+
Formats a test report for console output.
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
function formatTestReport(report: MdxTestReport, verbose?: boolean): string
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Parameters:**
|
|
158
|
+
|
|
159
|
+
- `report` - The test report to format
|
|
160
|
+
- `verbose` - If `true`, shows all results. If `false`, only shows failures.
|
|
161
|
+
|
|
162
|
+
**Example output (verbose):**
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
MDX Compilation Report: my-plugin
|
|
166
|
+
==================================================
|
|
167
|
+
|
|
168
|
+
Total files: 5
|
|
169
|
+
Passed: 4 (80.0%)
|
|
170
|
+
Failed: 1
|
|
171
|
+
Total time: 156.32ms
|
|
172
|
+
|
|
173
|
+
Results:
|
|
174
|
+
--------------------------------------------------
|
|
175
|
+
[PASS] docs/getting-started.mdx (45.21ms)
|
|
176
|
+
[PASS] docs/installation.mdx (32.11ms)
|
|
177
|
+
[PASS] docs/configuration.mdx (28.54ms)
|
|
178
|
+
[PASS] docs/api-reference.mdx (35.67ms)
|
|
179
|
+
[FAIL] docs/advanced.mdx (14.79ms)
|
|
180
|
+
Error (line 42:15): Unexpected token
|
|
181
|
+
|
|
182
|
+
1 file(s) failed to compile.
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### createProgressReporter
|
|
186
|
+
|
|
187
|
+
Creates a simple progress reporter for console output.
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
function createProgressReporter(): (
|
|
191
|
+
current: number,
|
|
192
|
+
total: number,
|
|
193
|
+
result: MdxCompilationResult
|
|
194
|
+
) => void
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Example:**
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
import { testManifestMdx, createProgressReporter } from '@vendure-io/docs-provider/testing'
|
|
201
|
+
|
|
202
|
+
const report = await testManifestMdx(manifest, {
|
|
203
|
+
basePath: __dirname,
|
|
204
|
+
onProgress: createProgressReporter(),
|
|
205
|
+
})
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### getDefaultRemarkPlugins / getDefaultRehypePlugins
|
|
209
|
+
|
|
210
|
+
Get the default plugins used for MDX compilation. Useful for extending the plugin list.
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
function getDefaultRemarkPlugins(): PluggableList
|
|
214
|
+
function getDefaultRehypePlugins(): PluggableList
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Example (extending plugins):**
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
import {
|
|
221
|
+
testManifestMdx,
|
|
222
|
+
getDefaultRemarkPlugins,
|
|
223
|
+
getDefaultRehypePlugins,
|
|
224
|
+
} from '@vendure-io/docs-provider/testing'
|
|
225
|
+
import myCustomPlugin from './my-plugin'
|
|
226
|
+
|
|
227
|
+
const report = await testManifestMdx(manifest, {
|
|
228
|
+
basePath: __dirname,
|
|
229
|
+
remarkPlugins: [...getDefaultRemarkPlugins(), myCustomPlugin],
|
|
230
|
+
rehypePlugins: getDefaultRehypePlugins(),
|
|
231
|
+
})
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Types
|
|
235
|
+
|
|
236
|
+
### MdxCompilationResult
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
interface MdxCompilationResult {
|
|
240
|
+
/** Path to the MDX file that was compiled */
|
|
241
|
+
filePath: string
|
|
242
|
+
/** Whether compilation was successful */
|
|
243
|
+
success: boolean
|
|
244
|
+
/** Error message if compilation failed */
|
|
245
|
+
error?: string
|
|
246
|
+
/** Line number where the error occurred */
|
|
247
|
+
line?: number
|
|
248
|
+
/** Column number where the error occurred */
|
|
249
|
+
column?: number
|
|
250
|
+
/** Time taken to compile in milliseconds */
|
|
251
|
+
compilationTime: number
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### MdxTestReport
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
interface MdxTestReport {
|
|
259
|
+
/** Package ID from the manifest */
|
|
260
|
+
packageId: string
|
|
261
|
+
/** Total number of MDX files tested */
|
|
262
|
+
totalFiles: number
|
|
263
|
+
/** Number of files that compiled successfully */
|
|
264
|
+
passed: number
|
|
265
|
+
/** Number of files that failed to compile */
|
|
266
|
+
failed: number
|
|
267
|
+
/** Individual results for each file */
|
|
268
|
+
results: MdxCompilationResult[]
|
|
269
|
+
/** Total time taken in milliseconds */
|
|
270
|
+
totalTime: number
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Integration with Vitest
|
|
275
|
+
|
|
276
|
+
You can integrate MDX testing into your existing test suite:
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
// tests/mdx-compilation.test.ts
|
|
280
|
+
import { describe, it, expect } from 'vitest'
|
|
281
|
+
import { manifest } from '../src/manifest'
|
|
282
|
+
import { testManifestMdx } from '@vendure-io/docs-provider/testing'
|
|
283
|
+
|
|
284
|
+
describe('MDX Compilation', () => {
|
|
285
|
+
it('should compile all MDX files without errors', async () => {
|
|
286
|
+
const report = await testManifestMdx(manifest, {
|
|
287
|
+
basePath: __dirname + '/..',
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
expect(report.failed).toBe(0)
|
|
291
|
+
}, 30000) // Increase timeout for large doc sets
|
|
292
|
+
})
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Supported MDX Features
|
|
296
|
+
|
|
297
|
+
The testing module uses the same remark/rehype plugins as the Vendure documentation website:
|
|
298
|
+
|
|
299
|
+
### Admonitions
|
|
300
|
+
|
|
301
|
+
```mdx
|
|
302
|
+
:::info
|
|
303
|
+
This is an info callout.
|
|
304
|
+
:::
|
|
305
|
+
|
|
306
|
+
:::warning Custom Title
|
|
307
|
+
This is a warning with a custom title.
|
|
308
|
+
:::
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Supported types: `info`, `note`, `tip`, `warning`, `caution`, `danger`
|
|
312
|
+
|
|
313
|
+
### Code Fence Metadata
|
|
314
|
+
|
|
315
|
+
```mdx
|
|
316
|
+
```typescript title="src/example.ts"
|
|
317
|
+
export function example() {
|
|
318
|
+
return 'Hello'
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### GitHub Flavored Markdown
|
|
324
|
+
|
|
325
|
+
- Tables
|
|
326
|
+
- Task lists
|
|
327
|
+
- Strikethrough
|
|
328
|
+
- Autolinks
|
|
329
|
+
|
|
330
|
+
### JSX Components
|
|
331
|
+
|
|
332
|
+
```mdx
|
|
333
|
+
<Callout type="info" title="Note">
|
|
334
|
+
Custom JSX components work as expected.
|
|
335
|
+
</Callout>
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
## Common Errors
|
|
339
|
+
|
|
340
|
+
### Unclosed JSX Tags
|
|
341
|
+
|
|
342
|
+
```
|
|
343
|
+
Error (line 15): Expected closing tag for `<div>`
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Ensure all JSX tags are properly closed:
|
|
347
|
+
|
|
348
|
+
```mdx
|
|
349
|
+
<!-- Wrong -->
|
|
350
|
+
<div>
|
|
351
|
+
Content here
|
|
352
|
+
|
|
353
|
+
<!-- Correct -->
|
|
354
|
+
<div>
|
|
355
|
+
Content here
|
|
356
|
+
</div>
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Invalid JSX Syntax
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
Error (line 8:5): Unexpected token
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
Check for:
|
|
366
|
+
- Missing quotes around attribute values
|
|
367
|
+
- Unescaped special characters (`<`, `>`, `{`, `}`)
|
|
368
|
+
- JavaScript expressions not wrapped in curly braces
|
|
369
|
+
|
|
370
|
+
### Missing Frontmatter
|
|
371
|
+
|
|
372
|
+
While the MDX compiler doesn't require frontmatter, the docs website does. Ensure all files have at least a `title`:
|
|
373
|
+
|
|
374
|
+
```mdx
|
|
375
|
+
---
|
|
376
|
+
title: My Page Title
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
# Content
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
## Best Practices
|
|
383
|
+
|
|
384
|
+
1. **Run tests before commits**: Add MDX testing to your pre-commit hooks
|
|
385
|
+
2. **Use CI/CD**: Include MDX testing in your continuous integration pipeline
|
|
386
|
+
3. **Test incrementally**: Use `failFast: true` during development for faster feedback
|
|
387
|
+
4. **Verbose output for debugging**: Use `formatTestReport(report, true)` when troubleshooting
|
|
388
|
+
|
|
389
|
+
## Example: Complete Test Script
|
|
390
|
+
|
|
391
|
+
Here's a complete test script with all features:
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
// scripts/test-mdx.ts
|
|
395
|
+
import { dirname, join } from 'path'
|
|
396
|
+
import { fileURLToPath } from 'url'
|
|
397
|
+
import { manifest } from '../src/manifest'
|
|
398
|
+
import {
|
|
399
|
+
testManifestMdx,
|
|
400
|
+
formatTestReport,
|
|
401
|
+
createProgressReporter,
|
|
402
|
+
} from '@vendure-io/docs-provider/testing'
|
|
403
|
+
|
|
404
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
405
|
+
const projectRoot = join(__dirname, '..')
|
|
406
|
+
|
|
407
|
+
async function main() {
|
|
408
|
+
console.log('Testing MDX files...\n')
|
|
409
|
+
|
|
410
|
+
const report = await testManifestMdx(manifest, {
|
|
411
|
+
basePath: projectRoot,
|
|
412
|
+
onProgress: createProgressReporter(),
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
console.log('\n')
|
|
416
|
+
console.log(formatTestReport(report, process.argv.includes('--verbose')))
|
|
417
|
+
|
|
418
|
+
if (report.failed > 0) {
|
|
419
|
+
process.exit(1)
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
main().catch((error) => {
|
|
424
|
+
console.error('Test runner error:', error)
|
|
425
|
+
process.exit(1)
|
|
426
|
+
})
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
Run with:
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
# Standard output
|
|
433
|
+
bun run scripts/test-mdx.ts
|
|
434
|
+
|
|
435
|
+
# Verbose output showing all results
|
|
436
|
+
bun run scripts/test-mdx.ts --verbose
|
|
437
|
+
```
|
package/docs/publishing.md
CHANGED
|
@@ -319,6 +319,7 @@ Before publishing, verify:
|
|
|
319
319
|
- [ ] All file paths resolve correctly
|
|
320
320
|
- [ ] All MDX files have valid frontmatter
|
|
321
321
|
- [ ] All MDX files have at least a `title` in frontmatter
|
|
322
|
+
- [ ] All MDX files compile successfully (see [MDX Testing](./mdx-testing.md))
|
|
322
323
|
- [ ] `package.json` includes `src` and `docs` in `files`
|
|
323
324
|
- [ ] `package.json` has correct exports configuration
|
|
324
325
|
- [ ] Manifest validation passes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure-io/docs-provider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Contract types and utilities for Vendure documentation packages",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -36,6 +36,16 @@
|
|
|
36
36
|
"types": "./dist/loader.d.ts",
|
|
37
37
|
"default": "./dist/loader.js"
|
|
38
38
|
}
|
|
39
|
+
},
|
|
40
|
+
"./testing": {
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/testing/index.d.ts",
|
|
43
|
+
"default": "./dist/testing.js"
|
|
44
|
+
},
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/testing/index.d.ts",
|
|
47
|
+
"default": "./dist/testing.cjs"
|
|
48
|
+
}
|
|
39
49
|
}
|
|
40
50
|
},
|
|
41
51
|
"files": [
|
|
@@ -53,11 +63,20 @@
|
|
|
53
63
|
"publish:local": "bun run build && npm publish --registry http://localhost:4873"
|
|
54
64
|
},
|
|
55
65
|
"dependencies": {
|
|
66
|
+
"@mdx-js/mdx": "^3.0.0",
|
|
56
67
|
"gray-matter": "^4.0.3",
|
|
68
|
+
"rehype-slug": "^6.0.0",
|
|
69
|
+
"remark-directive": "^4.0.0",
|
|
70
|
+
"remark-gfm": "^4.0.1",
|
|
71
|
+
"unist-util-visit": "^5.0.0",
|
|
57
72
|
"zod": "^3.24.2"
|
|
58
73
|
},
|
|
59
74
|
"devDependencies": {
|
|
75
|
+
"@types/mdast": "^4.0.4",
|
|
60
76
|
"ajv": "^8.17.1",
|
|
77
|
+
"mdast-util-directive": "^3.1.0",
|
|
78
|
+
"mdast-util-mdx": "^3.0.0",
|
|
79
|
+
"unified": "^11.0.5",
|
|
61
80
|
"vite": "^6.0.0",
|
|
62
81
|
"vite-plugin-dts": "^4.5.4",
|
|
63
82
|
"vitest": "^3.0.0"
|