@vendure-io/docs-provider 0.6.0 → 0.7.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.
@@ -7,6 +7,9 @@ import { MdxTestReport, TestManifestOptions } from './types';
7
7
  * manifest's navigation tree and attempts to compile each MDX file using
8
8
  * the same plugins as @apps/docs.
9
9
  *
10
+ * Note: Manifests must contain absolute file paths. The function reads
11
+ * files directly from the paths specified in the navigation nodes.
12
+ *
10
13
  * @param manifest - The documentation package manifest to test
11
14
  * @param options - Optional configuration for testing
12
15
  * @returns A report containing results for each file
@@ -17,7 +20,6 @@ import { MdxTestReport, TestManifestOptions } from './types';
17
20
  * import { testManifestMdx, formatTestReport } from '@vendure-io/docs-provider/testing'
18
21
  *
19
22
  * const report = await testManifestMdx(manifest, {
20
- * basePath: __dirname,
21
23
  * onProgress: (current, total, result) => {
22
24
  * console.log(`[${current}/${total}] ${result.success ? '✓' : '✗'} ${result.filePath}`)
23
25
  * },
@@ -1 +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"}
1
+ {"version":3,"file":"test-manifest.d.ts","sourceRoot":"","sources":["../../src/testing/test-manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAGnD,OAAO,KAAK,EAAwB,aAAa,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,aAAa,CAAC,CA4ExB"}
@@ -37,11 +37,6 @@ export interface MdxTestReport {
37
37
  * Options for testing a manifest's MDX files
38
38
  */
39
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
40
  /**
46
41
  * Stop on first failure.
47
42
  * @default false
@@ -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,MAAM,CAAA;IACjB;;;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"}
package/dist/testing.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use 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;
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-D-EWZlSh.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;
package/dist/testing.js CHANGED
@@ -1,11 +1,10 @@
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";
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";
5
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";
6
+ import { readFile as w } from "fs/promises";
7
+ import { h as y } from "./manifest-ZCrzbFSf.js";
9
8
  const P = {
10
9
  info: "info",
11
10
  note: "note",
@@ -13,190 +12,190 @@ const P = {
13
12
  warning: "warning",
14
13
  caution: "caution",
15
14
  danger: "danger"
16
- }, E = {
15
+ }, x = {
17
16
  info: "Info",
18
17
  note: "Note",
19
18
  tip: "Tip",
20
19
  warning: "Warning",
21
20
  caution: "Caution",
22
21
  danger: "Danger"
23
- }, M = () => (r) => {
24
- g(r, "containerDirective", (e) => {
25
- var l;
26
- const t = e.name.toLowerCase();
27
- if (!(t in P))
22
+ }, I = () => (r) => {
23
+ g(r, "containerDirective", (t) => {
24
+ var a;
25
+ const e = t.name.toLowerCase();
26
+ if (!(e in P))
28
27
  return;
29
- const i = P[t];
28
+ const i = P[e];
30
29
  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);
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) {
33
+ 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);
38
37
  }
39
38
  }
40
- const a = s || E[t], o = e.data || (e.data = {});
41
- o.hName = "Callout", o.hProperties = {
39
+ const n = s || x[e], c = t.data || (t.data = {});
40
+ c.hName = "Callout", c.hProperties = {
42
41
  type: i,
43
- title: a
42
+ title: n
44
43
  };
45
44
  });
46
45
  };
47
- function D() {
46
+ function E() {
48
47
  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}`);
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}`);
56
55
  });
57
56
  };
58
57
  }
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);
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);
63
62
  });
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);
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(
70
+ (n) => i.includes(`from '${n}'`) || i.includes(`from "${n}"`)
71
+ ) && t.push(e);
73
72
  });
74
- for (const t of e) {
75
- const i = r.children.indexOf(t);
73
+ for (const e of t) {
74
+ const i = r.children.indexOf(e);
76
75
  i !== -1 && r.children.splice(i, 1);
77
76
  }
78
77
  };
79
- function C() {
78
+ function S() {
80
79
  return [
80
+ k,
81
81
  F,
82
- w,
83
- M,
84
- D,
85
- S,
86
- R
82
+ I,
83
+ E,
84
+ R,
85
+ M
87
86
  ];
88
87
  }
89
- function L() {
90
- return [T];
88
+ function C() {
89
+ return [v];
91
90
  }
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();
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();
95
94
  try {
96
- return await v(r, {
95
+ return await T(r, {
97
96
  remarkPlugins: s,
98
- rehypePlugins: a,
97
+ rehypePlugins: n,
99
98
  // Don't output to JS, just compile to check for errors
100
99
  outputFormat: "function-body",
101
100
  // Suppress development warnings about missing 'development' option
102
101
  development: !1
103
102
  }), {
104
- filePath: e,
103
+ filePath: t,
105
104
  success: !0,
106
105
  compilationTime: performance.now() - i
107
106
  };
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));
107
+ } catch (o) {
108
+ 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));
117
116
  }
118
117
  }
119
118
  return {
120
- filePath: e,
119
+ filePath: t,
121
120
  success: !1,
122
- error: u,
123
- line: m,
121
+ error: h,
122
+ line: d,
124
123
  column: p,
125
- compilationTime: d
124
+ compilationTime: f
126
125
  };
127
126
  }
128
127
  }
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)
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];
133
+ if (!l.file)
135
134
  continue;
136
- const f = x(i, c.file);
135
+ const u = l.file;
137
136
  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
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
141
140
  });
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)
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
142
  break;
144
- } catch (d) {
145
- const u = d instanceof Error ? d.message : "Unknown error reading file", m = {
146
- filePath: c.file,
143
+ } catch (o) {
144
+ const f = o instanceof Error ? o.message : "Unknown error reading file", h = {
145
+ filePath: l.file,
147
146
  success: !1,
148
- error: `Failed to read file: ${u}`,
147
+ error: `Failed to read file: ${f}`,
149
148
  compilationTime: 0
150
149
  };
151
- if (a.push(m), l++, e != null && e.onProgress && e.onProgress(n + 1, s.length, m), e != null && e.failFast)
150
+ if (s.push(h), c++, t != null && t.onProgress && t.onProgress(a + 1, i.length, h), t != null && t.failFast)
152
151
  break;
153
152
  }
154
153
  }
155
154
  return {
156
155
  packageId: r.id,
157
- totalFiles: a.length,
158
- passed: o,
159
- failed: l,
160
- results: a,
161
- totalTime: performance.now() - t
156
+ totalFiles: s.length,
157
+ passed: n,
158
+ failed: c,
159
+ results: s,
160
+ totalTime: performance.now() - e
162
161
  };
163
162
  }
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("");
163
+ function X(r, t = !1) {
164
+ const e = [];
165
+ e.push(""), e.push(`MDX Compilation Report: ${r.packageId}`), e.push("=".repeat(50)), e.push("");
167
166
  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));
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));
170
169
  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}`);
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}`);
175
174
  }
176
175
  }
177
176
  } 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}`);
177
+ e.push("Failures:"), e.push("-".repeat(50));
178
+ for (const s of r.results.filter((n) => !n.success))
179
+ if (e.push(`[FAIL] ${s.filePath}`), s.error) {
180
+ const n = s.line ? ` (line ${s.line}${s.column ? `:${s.column}` : ""})` : "";
181
+ e.push(` Error${n}: ${s.error}`);
183
182
  }
184
183
  }
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(`
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(`
186
185
  `);
187
186
  }
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(`
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(`
192
191
  `);
193
192
  };
194
193
  }
195
194
  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
195
+ L as compileMdx,
196
+ B as createProgressReporter,
197
+ X as formatTestReport,
198
+ C as getDefaultRehypePlugins,
199
+ S as getDefaultRemarkPlugins,
200
+ O as testManifestMdx
202
201
  };
@@ -36,9 +36,7 @@ import { manifest } from './src/manifest'
36
36
  import { testManifestMdx, formatTestReport } from '@vendure-io/docs-provider/testing'
37
37
 
38
38
  async function main() {
39
- const report = await testManifestMdx(manifest, {
40
- basePath: __dirname,
41
- })
39
+ const report = await testManifestMdx(manifest)
42
40
 
43
41
  console.log(formatTestReport(report))
44
42
  process.exit(report.failed > 0 ? 1 : 0)
@@ -85,14 +83,13 @@ async function testManifestMdx(
85
83
 
86
84
  **Parameters:**
87
85
 
88
- - `manifest` - The documentation package manifest to test
86
+ - `manifest` - The documentation package manifest to test (must contain absolute file paths)
89
87
  - `options` - Optional configuration (see below)
90
88
 
91
89
  **Options:**
92
90
 
93
91
  | Option | Type | Default | Description |
94
92
  |--------|------|---------|-------------|
95
- | `basePath` | `string` | `manifest.basePath` or `cwd()` | Base path for resolving file paths |
96
93
  | `failFast` | `boolean` | `false` | Stop on first failure |
97
94
  | `remarkPlugins` | `PluggableList` | Default plugins | Custom remark plugins |
98
95
  | `rehypePlugins` | `PluggableList` | Default plugins | Custom rehype plugins |
@@ -102,7 +99,6 @@ async function testManifestMdx(
102
99
 
103
100
  ```typescript
104
101
  const report = await testManifestMdx(manifest, {
105
- basePath: __dirname,
106
102
  onProgress: (current, total, result) => {
107
103
  const status = result.success ? '✓' : '✗'
108
104
  console.log(`[${current}/${total}] ${status} ${result.filePath}`)
@@ -200,7 +196,6 @@ function createProgressReporter(): (
200
196
  import { testManifestMdx, createProgressReporter } from '@vendure-io/docs-provider/testing'
201
197
 
202
198
  const report = await testManifestMdx(manifest, {
203
- basePath: __dirname,
204
199
  onProgress: createProgressReporter(),
205
200
  })
206
201
  ```
@@ -225,7 +220,6 @@ import {
225
220
  import myCustomPlugin from './my-plugin'
226
221
 
227
222
  const report = await testManifestMdx(manifest, {
228
- basePath: __dirname,
229
223
  remarkPlugins: [...getDefaultRemarkPlugins(), myCustomPlugin],
230
224
  rehypePlugins: getDefaultRehypePlugins(),
231
225
  })
@@ -283,9 +277,7 @@ import { testManifestMdx } from '@vendure-io/docs-provider/testing'
283
277
 
284
278
  describe('MDX Compilation', () => {
285
279
  it('should compile all MDX files without errors', async () => {
286
- const report = await testManifestMdx(manifest, {
287
- basePath: __dirname + '/..',
288
- })
280
+ const report = await testManifestMdx(manifest)
289
281
 
290
282
  expect(report.failed).toBe(0)
291
283
  }, 30000) // Increase timeout for large doc sets
@@ -392,8 +384,6 @@ Here's a complete test script with all features:
392
384
 
393
385
  ```typescript
394
386
  // scripts/test-mdx.ts
395
- import { dirname, join } from 'path'
396
- import { fileURLToPath } from 'url'
397
387
  import { manifest } from '../src/manifest'
398
388
  import {
399
389
  testManifestMdx,
@@ -401,14 +391,10 @@ import {
401
391
  createProgressReporter,
402
392
  } from '@vendure-io/docs-provider/testing'
403
393
 
404
- const __dirname = dirname(fileURLToPath(import.meta.url))
405
- const projectRoot = join(__dirname, '..')
406
-
407
394
  async function main() {
408
395
  console.log('Testing MDX files...\n')
409
396
 
410
397
  const report = await testManifestMdx(manifest, {
411
- basePath: projectRoot,
412
398
  onProgress: createProgressReporter(),
413
399
  })
414
400
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendure-io/docs-provider",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Contract types and utilities for Vendure documentation packages",
5
5
  "private": false,
6
6
  "publishConfig": {