@vendure-io/docs-provider 0.8.2 → 0.10.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/testing/index.d.ts +5 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/run-all-tests.d.ts +56 -0
- package/dist/testing/run-all-tests.d.ts.map +1 -0
- package/dist/testing/types.d.ts +210 -0
- package/dist/testing/types.d.ts.map +1 -1
- package/dist/testing/validate-admonitions.d.ts +59 -0
- package/dist/testing/validate-admonitions.d.ts.map +1 -0
- package/dist/testing/validate-code-languages.d.ts +86 -0
- package/dist/testing/validate-code-languages.d.ts.map +1 -0
- package/dist/testing/validate-frontmatter.d.ts +40 -0
- package/dist/testing/validate-frontmatter.d.ts.map +1 -0
- package/dist/testing.cjs +14 -4
- package/dist/testing.js +818 -128
- package/docs/mdx-testing.md +553 -140
- package/package.json +1 -1
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { MdxCompilationResult, MdxTestReport } from './types';
|
|
2
|
-
export type { CompileMdxOptions, MdxCompilationResult, MdxTestReport, TestManifestOptions, } from './types';
|
|
2
|
+
export type { AdmonitionError, AdmonitionValidationReport, CodeLanguageError, CodeLanguageValidationReport, CompileMdxOptions, FrontmatterError, FrontmatterValidationReport, MdxCompilationResult, MdxTestReport, TestManifestOptions, TestRunnerOptions, TestRunnerReport, ValidateAdmonitionsOptions, ValidateCodeLanguagesOptions, ValidateFrontmatterOptions, } from './types';
|
|
3
3
|
export { compileMdx, getDefaultRehypePlugins, getDefaultRemarkPlugins } from './mdx-compiler';
|
|
4
|
+
export { formatTestRunnerReport, runAllTests } from './run-all-tests';
|
|
4
5
|
export { testManifestMdx } from './test-manifest';
|
|
6
|
+
export { ADMONITION_TYPES, formatAdmonitionReport, INVALID_ADMONITION_PATTERN, validateAdmonitions, } from './validate-admonitions';
|
|
7
|
+
export { formatCodeLanguageReport, getCanonicalLanguage, isValidCodeLanguage, LANGUAGE_ALIASES, SHIKI_BUNDLED_LANGUAGES, validateCodeLanguages, } from './validate-code-languages';
|
|
8
|
+
export { formatFrontmatterReport, validateFrontmatter } from './validate-frontmatter';
|
|
5
9
|
/**
|
|
6
10
|
* Format a test report for console output.
|
|
7
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAGlE,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAGlE,YAAY,EACV,eAAe,EACf,0BAA0B,EAC1B,iBAAiB,EACjB,4BAA4B,EAC5B,iBAAiB,EACjB,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAC7F,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAErF;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,UAAQ,GAAG,MAAM,CAgE/E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,IAAI,CACxC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,oBAAoB,KACzB,IAAI,CAcR"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { DocsPackageManifest } from '../types';
|
|
2
|
+
import { TestRunnerOptions, TestRunnerReport } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Run all documentation validation tests on a manifest.
|
|
5
|
+
*
|
|
6
|
+
* This function runs all validators in sequence (fast validators first):
|
|
7
|
+
* 1. Frontmatter validation (fast, catches missing/invalid metadata)
|
|
8
|
+
* 2. Admonition validation (fast, regex-based)
|
|
9
|
+
* 3. Code language validation (fast, regex-based)
|
|
10
|
+
* 4. MDX compilation (slowest, full AST parsing)
|
|
11
|
+
*
|
|
12
|
+
* By default, all validators are enabled. Pass `false` to skip specific validators.
|
|
13
|
+
*
|
|
14
|
+
* @param manifest - The documentation package manifest to test
|
|
15
|
+
* @param options - Optional configuration for the test runner
|
|
16
|
+
* @returns A unified report containing results from all validators
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Minimal usage - runs ALL validators by default
|
|
21
|
+
* import { manifest } from '../src/manifest'
|
|
22
|
+
* import { runAllTests } from '@vendure-io/docs-provider/testing'
|
|
23
|
+
*
|
|
24
|
+
* runAllTests(manifest)
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* // With options
|
|
30
|
+
* import { manifest } from '../src/manifest'
|
|
31
|
+
* import { runAllTests } from '@vendure-io/docs-provider/testing'
|
|
32
|
+
*
|
|
33
|
+
* runAllTests(manifest, {
|
|
34
|
+
* verbose: true, // Show all files, not just failures
|
|
35
|
+
* failFast: true, // Stop on first error
|
|
36
|
+
* frontmatter: false, // Skip frontmatter validation
|
|
37
|
+
* mdx: { /* pass options to MDX validator *\/ },
|
|
38
|
+
* })
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function runAllTests(manifest: DocsPackageManifest, options?: TestRunnerOptions): Promise<TestRunnerReport>;
|
|
42
|
+
/**
|
|
43
|
+
* Format a unified test runner report for console output.
|
|
44
|
+
*
|
|
45
|
+
* @param report - The test runner report to format
|
|
46
|
+
* @param verbose - If true, show details for all files. If false, only show failures.
|
|
47
|
+
* @returns A formatted string suitable for console output
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const report = await runAllTests(manifest, { exit: false, silent: true })
|
|
52
|
+
* console.log(formatTestRunnerReport(report, true))
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function formatTestRunnerReport(report: TestRunnerReport, verbose?: boolean): string;
|
|
56
|
+
//# sourceMappingURL=run-all-tests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-all-tests.d.ts","sourceRoot":"","sources":["../../src/testing/run-all-tests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAGnD,OAAO,KAAK,EAEV,iBAAiB,EACjB,gBAAgB,EAIjB,MAAM,SAAS,CAAA;AAKhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,gBAAgB,CAAC,CAqF3B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,UAAQ,GAAG,MAAM,CAiKxF"}
|
package/dist/testing/types.d.ts
CHANGED
|
@@ -73,4 +73,214 @@ export interface CompileMdxOptions {
|
|
|
73
73
|
*/
|
|
74
74
|
rehypePlugins?: PluggableList;
|
|
75
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Error found during admonition syntax validation
|
|
78
|
+
*/
|
|
79
|
+
export interface AdmonitionError {
|
|
80
|
+
/** Relative path to the file from the manifest basePath */
|
|
81
|
+
file: string;
|
|
82
|
+
/** Absolute path to the file */
|
|
83
|
+
absolutePath: string;
|
|
84
|
+
/** Line number where the error was found (1-indexed) */
|
|
85
|
+
line: number;
|
|
86
|
+
/** Column number where the error was found (1-indexed) */
|
|
87
|
+
column: number;
|
|
88
|
+
/** The full content of the line containing the error */
|
|
89
|
+
content: string;
|
|
90
|
+
/** The type of admonition (warning, info, tip, etc.) */
|
|
91
|
+
admonitionType: string;
|
|
92
|
+
/** The label that was incorrectly space-separated */
|
|
93
|
+
label: string;
|
|
94
|
+
/** Suggested fix using bracket syntax */
|
|
95
|
+
suggestion: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Report from validating admonition syntax in a manifest
|
|
99
|
+
*/
|
|
100
|
+
export interface AdmonitionValidationReport {
|
|
101
|
+
/** Package ID from the manifest */
|
|
102
|
+
packageId: string;
|
|
103
|
+
/** Number of files that were scanned */
|
|
104
|
+
filesScanned: number;
|
|
105
|
+
/** List of validation errors found */
|
|
106
|
+
errors: AdmonitionError[];
|
|
107
|
+
/** Total time taken for validation in milliseconds */
|
|
108
|
+
totalTime: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Options for validating admonition syntax
|
|
112
|
+
*/
|
|
113
|
+
export interface ValidateAdmonitionsOptions {
|
|
114
|
+
/**
|
|
115
|
+
* Stop on first error.
|
|
116
|
+
* @default false
|
|
117
|
+
*/
|
|
118
|
+
failFast?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Callback invoked for each error found.
|
|
121
|
+
* Useful for real-time reporting.
|
|
122
|
+
*/
|
|
123
|
+
onError?: (error: AdmonitionError) => void;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Error found during code language validation
|
|
127
|
+
*/
|
|
128
|
+
export interface CodeLanguageError {
|
|
129
|
+
/** Relative path to the file from the manifest basePath */
|
|
130
|
+
file: string;
|
|
131
|
+
/** Absolute path to the file */
|
|
132
|
+
absolutePath: string;
|
|
133
|
+
/** Line number where the code block starts (1-indexed) */
|
|
134
|
+
line: number;
|
|
135
|
+
/** The invalid language identifier found */
|
|
136
|
+
language: string;
|
|
137
|
+
/** The full code fence line */
|
|
138
|
+
content: string;
|
|
139
|
+
/** Suggested fix if there's a known alias */
|
|
140
|
+
suggestion?: string;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Report from validating code block languages in a manifest
|
|
144
|
+
*/
|
|
145
|
+
export interface CodeLanguageValidationReport {
|
|
146
|
+
/** Package ID from the manifest */
|
|
147
|
+
packageId: string;
|
|
148
|
+
/** Number of files that were scanned */
|
|
149
|
+
filesScanned: number;
|
|
150
|
+
/** Total number of code blocks found */
|
|
151
|
+
codeBlocksFound: number;
|
|
152
|
+
/** List of validation errors found */
|
|
153
|
+
errors: CodeLanguageError[];
|
|
154
|
+
/** Total time taken for validation in milliseconds */
|
|
155
|
+
totalTime: number;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Options for validating code block languages
|
|
159
|
+
*/
|
|
160
|
+
export interface ValidateCodeLanguagesOptions {
|
|
161
|
+
/**
|
|
162
|
+
* Stop on first error.
|
|
163
|
+
* @default false
|
|
164
|
+
*/
|
|
165
|
+
failFast?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Callback invoked for each error found.
|
|
168
|
+
* Useful for real-time reporting.
|
|
169
|
+
*/
|
|
170
|
+
onError?: (error: CodeLanguageError) => void;
|
|
171
|
+
/**
|
|
172
|
+
* Additional language aliases to consider valid.
|
|
173
|
+
* Maps alias to the actual Shiki language name.
|
|
174
|
+
*/
|
|
175
|
+
additionalAliases?: Record<string, string>;
|
|
176
|
+
/**
|
|
177
|
+
* Additional languages to consider valid (custom grammars).
|
|
178
|
+
*/
|
|
179
|
+
additionalLanguages?: string[];
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Error found during frontmatter validation
|
|
183
|
+
*/
|
|
184
|
+
export interface FrontmatterError {
|
|
185
|
+
/** Relative path to the file from the manifest basePath */
|
|
186
|
+
file: string;
|
|
187
|
+
/** Absolute path to the file */
|
|
188
|
+
absolutePath: string;
|
|
189
|
+
/** Zod validation issues or parsing error message */
|
|
190
|
+
issues: string[];
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Report from validating frontmatter in a manifest
|
|
194
|
+
*/
|
|
195
|
+
export interface FrontmatterValidationReport {
|
|
196
|
+
/** Package ID from the manifest */
|
|
197
|
+
packageId: string;
|
|
198
|
+
/** Number of files that were scanned */
|
|
199
|
+
filesScanned: number;
|
|
200
|
+
/** List of validation errors found */
|
|
201
|
+
errors: FrontmatterError[];
|
|
202
|
+
/** Total time taken for validation in milliseconds */
|
|
203
|
+
totalTime: number;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Options for validating frontmatter
|
|
207
|
+
*/
|
|
208
|
+
export interface ValidateFrontmatterOptions {
|
|
209
|
+
/**
|
|
210
|
+
* Stop on first error.
|
|
211
|
+
* @default false
|
|
212
|
+
*/
|
|
213
|
+
failFast?: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Callback invoked for each error found.
|
|
216
|
+
* Useful for real-time reporting.
|
|
217
|
+
*/
|
|
218
|
+
onError?: (error: FrontmatterError) => void;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Options for the unified test runner
|
|
222
|
+
*/
|
|
223
|
+
export interface TestRunnerOptions {
|
|
224
|
+
/**
|
|
225
|
+
* Show detailed output for all files (not just failures).
|
|
226
|
+
* @default false
|
|
227
|
+
*/
|
|
228
|
+
verbose?: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* Stop on first error in any validator.
|
|
231
|
+
* @default false
|
|
232
|
+
*/
|
|
233
|
+
failFast?: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Auto-exit process with appropriate code after completion.
|
|
236
|
+
* @default true
|
|
237
|
+
*/
|
|
238
|
+
exit?: boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Suppress all console output.
|
|
241
|
+
* @default false
|
|
242
|
+
*/
|
|
243
|
+
silent?: boolean;
|
|
244
|
+
/**
|
|
245
|
+
* MDX compilation options, or false to skip MDX compilation.
|
|
246
|
+
* @default true (run with default options)
|
|
247
|
+
*/
|
|
248
|
+
mdx?: boolean | TestManifestOptions;
|
|
249
|
+
/**
|
|
250
|
+
* Admonition validation options, or false to skip validation.
|
|
251
|
+
* @default true (run with default options)
|
|
252
|
+
*/
|
|
253
|
+
admonitions?: boolean | ValidateAdmonitionsOptions;
|
|
254
|
+
/**
|
|
255
|
+
* Code language validation options, or false to skip validation.
|
|
256
|
+
* @default true (run with default options)
|
|
257
|
+
*/
|
|
258
|
+
codeLanguages?: boolean | ValidateCodeLanguagesOptions;
|
|
259
|
+
/**
|
|
260
|
+
* Frontmatter validation options, or false to skip validation.
|
|
261
|
+
* @default true (run with default options)
|
|
262
|
+
*/
|
|
263
|
+
frontmatter?: boolean | ValidateFrontmatterOptions;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Report from the unified test runner
|
|
267
|
+
*/
|
|
268
|
+
export interface TestRunnerReport {
|
|
269
|
+
/** Package ID from the manifest */
|
|
270
|
+
packageId: string;
|
|
271
|
+
/** Frontmatter validation report (if run) */
|
|
272
|
+
frontmatter?: FrontmatterValidationReport;
|
|
273
|
+
/** Admonition validation report (if run) */
|
|
274
|
+
admonitions?: AdmonitionValidationReport;
|
|
275
|
+
/** Code language validation report (if run) */
|
|
276
|
+
codeLanguages?: CodeLanguageValidationReport;
|
|
277
|
+
/** MDX compilation test report (if run) */
|
|
278
|
+
mdx?: MdxTestReport;
|
|
279
|
+
/** Total number of errors across all validators */
|
|
280
|
+
totalErrors: number;
|
|
281
|
+
/** Total time taken for all validations in milliseconds */
|
|
282
|
+
totalTime: number;
|
|
283
|
+
/** Whether all validations passed */
|
|
284
|
+
success: boolean;
|
|
285
|
+
}
|
|
76
286
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/testing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAA;IAChB,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAA;IAChB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qDAAqD;IACrD,eAAe,EAAE,MAAM,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAA;IACd,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAA;IACd,uCAAuC;IACvC,OAAO,EAAE,oBAAoB,EAAE,CAAA;IAC/B,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE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itionValidationReport, ValidateAdmonitionsOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Supported admonition types in remark-directive
|
|
5
|
+
*/
|
|
6
|
+
export declare const ADMONITION_TYPES: readonly ["warning", "info", "tip", "note", "caution", "danger"];
|
|
7
|
+
/**
|
|
8
|
+
* Pattern that matches invalid admonition syntax with space-separated labels.
|
|
9
|
+
*
|
|
10
|
+
* Valid: :::warning[Deprecated]
|
|
11
|
+
* Invalid: :::warning Deprecated
|
|
12
|
+
*
|
|
13
|
+
* This pattern captures:
|
|
14
|
+
* - Group 1: The admonition type (warning, info, tip, etc.)
|
|
15
|
+
* - Group 2: The label text (everything after the space until end of line)
|
|
16
|
+
*/
|
|
17
|
+
export declare const INVALID_ADMONITION_PATTERN: RegExp;
|
|
18
|
+
/**
|
|
19
|
+
* Validate admonition syntax in all MDX files of a manifest.
|
|
20
|
+
*
|
|
21
|
+
* The remark-directive v4 plugin requires square bracket syntax for labels:
|
|
22
|
+
* - Valid: `:::warning[Deprecated]`
|
|
23
|
+
* - Invalid: `:::warning Deprecated`
|
|
24
|
+
*
|
|
25
|
+
* This function scans all MDX files in the manifest and reports any
|
|
26
|
+
* admonitions using the invalid space-separated label syntax.
|
|
27
|
+
*
|
|
28
|
+
* @param manifest - The documentation package manifest to validate
|
|
29
|
+
* @param options - Optional configuration for validation
|
|
30
|
+
* @returns A report containing all validation errors
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { manifest } from '../src/manifest'
|
|
35
|
+
* import { validateAdmonitions, formatAdmonitionReport } from '@vendure-io/docs-provider/testing'
|
|
36
|
+
*
|
|
37
|
+
* const report = validateAdmonitions(manifest)
|
|
38
|
+
*
|
|
39
|
+
* if (report.errors.length > 0) {
|
|
40
|
+
* console.error(formatAdmonitionReport(report))
|
|
41
|
+
* process.exit(1)
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function validateAdmonitions(manifest: DocsPackageManifest, options?: ValidateAdmonitionsOptions): AdmonitionValidationReport;
|
|
46
|
+
/**
|
|
47
|
+
* Format an admonition validation report for console output.
|
|
48
|
+
*
|
|
49
|
+
* @param report - The validation report to format
|
|
50
|
+
* @returns A formatted string suitable for console output
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const report = validateAdmonitions(manifest)
|
|
55
|
+
* console.log(formatAdmonitionReport(report))
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function formatAdmonitionReport(report: AdmonitionValidationReport): string;
|
|
59
|
+
//# sourceMappingURL=validate-admonitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-admonitions.d.ts","sourceRoot":"","sources":["../../src/testing/validate-admonitions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAEnD,OAAO,KAAK,EAEV,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,SAAS,CAAA;AAEhB;;GAEG;AACH,eAAO,MAAM,gBAAgB,kEAAmE,CAAA;AAEhG;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,QAEtC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,CAAC,EAAE,0BAA0B,GACnC,0BAA0B,CAuD5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,0BAA0B,GAAG,MAAM,CAsCjF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { DocsPackageManifest } from '../types';
|
|
2
|
+
import { CodeLanguageValidationReport, ValidateCodeLanguagesOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Shiki bundled languages (as of shiki v3.22.0)
|
|
5
|
+
* This list includes both primary language identifiers and their aliases.
|
|
6
|
+
*
|
|
7
|
+
* @see https://shiki.style/languages
|
|
8
|
+
*/
|
|
9
|
+
export declare const SHIKI_BUNDLED_LANGUAGES: Set<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Common language aliases that are NOT in Shiki's bundle but are commonly used.
|
|
12
|
+
* These map to their correct Shiki language name.
|
|
13
|
+
*/
|
|
14
|
+
export declare const LANGUAGE_ALIASES: Record<string, string>;
|
|
15
|
+
/**
|
|
16
|
+
* Validate code block languages in all MDX files of a manifest.
|
|
17
|
+
*
|
|
18
|
+
* This function scans all MDX files in the manifest and reports any
|
|
19
|
+
* code blocks using unsupported language identifiers that Shiki
|
|
20
|
+
* cannot highlight.
|
|
21
|
+
*
|
|
22
|
+
* @param manifest - The documentation package manifest to validate
|
|
23
|
+
* @param options - Optional configuration for validation
|
|
24
|
+
* @returns A report containing all validation errors
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { manifest } from '../src/manifest'
|
|
29
|
+
* import { validateCodeLanguages, formatCodeLanguageReport } from '@vendure-io/docs-provider/testing'
|
|
30
|
+
*
|
|
31
|
+
* const report = validateCodeLanguages(manifest)
|
|
32
|
+
*
|
|
33
|
+
* if (report.errors.length > 0) {
|
|
34
|
+
* console.error(formatCodeLanguageReport(report))
|
|
35
|
+
* process.exit(1)
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function validateCodeLanguages(manifest: DocsPackageManifest, options?: ValidateCodeLanguagesOptions): CodeLanguageValidationReport;
|
|
40
|
+
/**
|
|
41
|
+
* Check if a single language identifier is valid.
|
|
42
|
+
*
|
|
43
|
+
* @param language - The language identifier to check
|
|
44
|
+
* @param options - Optional additional aliases and languages
|
|
45
|
+
* @returns True if the language is supported, false otherwise
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { isValidCodeLanguage } from '@vendure-io/docs-provider/testing'
|
|
50
|
+
*
|
|
51
|
+
* console.log(isValidCodeLanguage('typescript')) // true
|
|
52
|
+
* console.log(isValidCodeLanguage('env')) // false (use 'dotenv')
|
|
53
|
+
* console.log(isValidCodeLanguage('foobar')) // false
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function isValidCodeLanguage(language: string, options?: Pick<ValidateCodeLanguagesOptions, 'additionalAliases' | 'additionalLanguages'>): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Get the canonical Shiki language name for an alias.
|
|
59
|
+
*
|
|
60
|
+
* @param language - The language identifier (may be an alias)
|
|
61
|
+
* @returns The canonical language name, or undefined if not found
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* import { getCanonicalLanguage } from '@vendure-io/docs-provider/testing'
|
|
66
|
+
*
|
|
67
|
+
* console.log(getCanonicalLanguage('ts')) // 'typescript' (Shiki handles this)
|
|
68
|
+
* console.log(getCanonicalLanguage('env')) // 'dotenv'
|
|
69
|
+
* console.log(getCanonicalLanguage('foo')) // undefined
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function getCanonicalLanguage(language: string): string | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Format a code language validation report for console output.
|
|
75
|
+
*
|
|
76
|
+
* @param report - The validation report to format
|
|
77
|
+
* @returns A formatted string suitable for console output
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const report = validateCodeLanguages(manifest)
|
|
82
|
+
* console.log(formatCodeLanguageReport(report))
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare function formatCodeLanguageReport(report: CodeLanguageValidationReport): string;
|
|
86
|
+
//# sourceMappingURL=validate-code-languages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-code-languages.d.ts","sourceRoot":"","sources":["../../src/testing/validate-code-languages.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAEnD,OAAO,KAAK,EAEV,4BAA4B,EAC5B,4BAA4B,EAC7B,MAAM,SAAS,CAAA;AAEhB;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,aA0UlC,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAUnD,CAAA;AAaD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,CAAC,EAAE,4BAA4B,GACrC,4BAA4B,CAiF9B;AAgDD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,IAAI,CAAC,4BAA4B,EAAE,mBAAmB,GAAG,qBAAqB,CAAC,GACxF,OAAO,CAwBT;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAczE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,4BAA4B,GAAG,MAAM,CAmDrF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DocsPackageManifest } from '../types';
|
|
2
|
+
import { FrontmatterValidationReport, ValidateFrontmatterOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Validate frontmatter in all MDX files of a manifest.
|
|
5
|
+
*
|
|
6
|
+
* This function scans all MDX files in the manifest and validates their
|
|
7
|
+
* frontmatter against the DocPageMeta schema using Zod.
|
|
8
|
+
*
|
|
9
|
+
* @param manifest - The documentation package manifest to validate
|
|
10
|
+
* @param options - Optional configuration for validation
|
|
11
|
+
* @returns A report containing all validation errors
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { manifest } from '../src/manifest'
|
|
16
|
+
* import { validateFrontmatter, formatFrontmatterReport } from '@vendure-io/docs-provider/testing'
|
|
17
|
+
*
|
|
18
|
+
* const report = validateFrontmatter(manifest)
|
|
19
|
+
*
|
|
20
|
+
* if (report.errors.length > 0) {
|
|
21
|
+
* console.error(formatFrontmatterReport(report))
|
|
22
|
+
* process.exit(1)
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateFrontmatter(manifest: DocsPackageManifest, options?: ValidateFrontmatterOptions): FrontmatterValidationReport;
|
|
27
|
+
/**
|
|
28
|
+
* Format a frontmatter validation report for console output.
|
|
29
|
+
*
|
|
30
|
+
* @param report - The validation report to format
|
|
31
|
+
* @returns A formatted string suitable for console output
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const report = validateFrontmatter(manifest)
|
|
36
|
+
* console.log(formatFrontmatterReport(report))
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function formatFrontmatterReport(report: FrontmatterValidationReport): string;
|
|
40
|
+
//# sourceMappingURL=validate-frontmatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-frontmatter.d.ts","sourceRoot":"","sources":["../../src/testing/validate-frontmatter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAEnD,OAAO,KAAK,EAEV,2BAA2B,EAC3B,0BAA0B,EAC3B,MAAM,SAAS,CAAA;AAEhB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,CAAC,EAAE,0BAA0B,GACnC,2BAA2B,CA6C7B;AAoCD;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,2BAA2B,GAAG,MAAM,CA0CnF"}
|
package/dist/testing.cjs
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
${
|
|
3
|
-
`)
|
|
4
|
-
`)}}
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("@mdx-js/mdx"),C=require("rehype-slug"),M=require("remark-directive"),O=require("remark-gfm"),$=require("unist-util-visit"),_=require("fs/promises"),y=require("./manifest-BkO3d77g.cjs"),k=require("node:fs"),T=require("node:path"),w=require("./frontmatter-QFErVd9b.cjs"),L={info:"info",note:"note",tip:"tip",warning:"warning",caution:"caution",danger:"danger"},U={info:"Info",note:"Note",tip:"Tip",warning:"Warning",caution:"Caution",danger:"Danger"},V=()=>s=>{$.visit(s,"containerDirective",e=>{var u;const t=e.name.toLowerCase();if(!(t in L))return;const n=L[t];let r;if(e.children.length>0){const l=e.children[0];if(l.type==="paragraph"&&"data"in l&&((u=l.data)==null?void 0:u.directiveLabel)===!0){const c=[];for(const d of l.children)d.type==="text"&&c.push(d.value);c.length>0&&(r=c.join("")),e.children=e.children.slice(1)}}const a=r||U[t],i=e.data||(e.data={});i.hName="Callout",i.hProperties={type:n,title:a}})};function z(){return s=>{$.visit(s,"code",e=>{if(!e.meta)return;const t=e.meta.match(/(?:title|filename)=["']([^"']+)["']/);if(!t)return;const n=t[1];e.value.trim().startsWith("// filename:")||(e.value=`// filename: ${n}
|
|
2
|
+
${e.value}`)})}}const G=()=>s=>{const e=[];$.visit(s,"html",(t,n,r)=>{n!==void 0&&r&&typeof t.value=="string"&&t.value.trim().startsWith("<!--")&&t.value.trim().endsWith("-->")&&e.push(n)});for(const t of e.reverse())s.children.splice(t,1)},B=["@theme/Tabs","@theme/TabItem"],W=()=>s=>{const e=[];$.visit(s,"mdxjsEsm",t=>{const n=t.value;B.some(a=>n.includes(`from '${a}'`)||n.includes(`from "${a}"`))&&e.push(t)});for(const t of e){const n=s.children.indexOf(t);n!==-1&&s.children.splice(n,1)}};function F(){return[O,M,V,z,W,G]}function E(){return[C]}async function A(s,e,t){var i,u,l,c;const n=performance.now(),r=(t==null?void 0:t.remarkPlugins)??F(),a=(t==null?void 0:t.rehypePlugins)??E();try{return await q.compile(s,{remarkPlugins:r,rehypePlugins:a,outputFormat:"function-body",development:!1}),{filePath:e,success:!0,compilationTime:performance.now()-n}}catch(d){const o=performance.now()-n;let h="Unknown compilation error",f,g;if(d instanceof Error){h=d.message;const m=d;if(m.line!==void 0?f=m.line:((u=(i=m.position)==null?void 0:i.start)==null?void 0:u.line)!==void 0&&(f=m.position.start.line),m.column!==void 0?g=m.column:((c=(l=m.position)==null?void 0:l.start)==null?void 0:c.column)!==void 0&&(g=m.position.start.column),f===void 0){const p=h.match(/\((\d+):(\d+)\)/);p&&(f=parseInt(p[1],10),g=parseInt(p[2],10))}}return{filePath:e,success:!1,error:h,line:f,column:g,compilationTime:o}}}async function j(s,e){const t=performance.now(),n=y.getLeafNodes(s),r=[];let a=0,i=0;for(let u=0;u<n.length;u++){const l=n[u];if(!l.file)continue;const c=l.file;try{const d=await _.readFile(c,"utf-8"),o=await A(d,l.file,{remarkPlugins:e==null?void 0:e.remarkPlugins,rehypePlugins:e==null?void 0:e.rehypePlugins});if(r.push(o),o.success?a++:i++,e!=null&&e.onProgress&&e.onProgress(u+1,n.length,o),e!=null&&e.failFast&&!o.success)break}catch(d){const o=d instanceof Error?d.message:"Unknown error reading file",h={filePath:l.file,success:!1,error:`Failed to read file: ${o}`,compilationTime:0};if(r.push(h),i++,e!=null&&e.onProgress&&e.onProgress(u+1,n.length,h),e!=null&&e.failFast)break}}return{packageId:s.id,totalFiles:r.length,passed:a,failed:i,results:r,totalTime:performance.now()-t}}const P=["warning","info","tip","note","caution","danger"],I=new RegExp(`^:::(${P.join("|")}) ([A-Z].*)$`);function S(s,e){const t=performance.now(),n=[],r=y.getLeafNodes(s);let a=0;for(const i of r){if(!i.file)continue;a++;const l=k.readFileSync(i.file,"utf-8").split(`
|
|
3
|
+
`);for(let c=0;c<l.length;c++){const d=l[c],o=d.match(I);if(o){const[,h,f]=o,g={file:s.basePath?T.relative(s.basePath,i.file):i.file,absolutePath:i.file,line:c+1,column:1,content:d.trim(),admonitionType:h,label:f,suggestion:`:::${h}[${f}]`};if(n.push(g),e!=null&&e.onError&&e.onError(g),e!=null&&e.failFast&&n.length>0)return{packageId:s.id,filesScanned:a,errors:n,totalTime:performance.now()-t}}}}return{packageId:s.id,filesScanned:a,errors:n,totalTime:performance.now()-t}}function X(s){const e=[];if(e.push(""),e.push(`Admonition Syntax Report: ${s.packageId}`),e.push("=".repeat(50)),e.push(""),e.push(`Files scanned: ${s.filesScanned}`),e.push(`Errors found: ${s.errors.length}`),e.push(`Total time: ${s.totalTime.toFixed(2)}ms`),e.push(""),s.errors.length===0)return e.push("All admonitions use correct bracket syntax!"),e.push(""),e.join(`
|
|
4
|
+
`);e.push("Errors:"),e.push("-".repeat(50)),e.push("");for(const t of s.errors)e.push(` ${t.file}:${t.line}`),e.push(` ${t.content}`),e.push(` Fix: ${t.suggestion}`),e.push("");return e.push("Admonitions with custom titles must use bracket syntax:"),e.push(" Before: :::warning Deprecated"),e.push(" After: :::warning[Deprecated]"),e.push(""),e.push("See: https://github.com/remarkjs/remark-directive"),e.push(""),e.join(`
|
|
5
|
+
`)}const x=new Set(["abap","actionscript-3","ada","angular-html","angular-ts","apache","apex","apl","applescript","ara","asciidoc","asm","astro","awk","ballerina","bat","beancount","berry","bibtex","bicep","blade","bsl","c","c3","cadence","cairo","clarity","clojure","cmake","cobol","codeowners","codeql","coffee","common-lisp","coq","cpp","crystal","csharp","css","csv","cue","cypher","d","dart","dax","desktop","diff","docker","dotenv","dream-maker","edge","elixir","elm","emacs-lisp","erb","erlang","fennel","fish","fluent","fortran-fixed-form","fortran-free-form","fsharp","gdresource","gdscript","gdshader","genie","gherkin","git-commit","git-rebase","gleam","glimmer-js","glimmer-ts","glsl","gn","gnuplot","go","graphql","groovy","hack","haml","handlebars","haskell","haxe","hcl","hjson","hlsl","html","html-derivative","http","hurl","hxml","hy","imba","ini","java","javascript","jinja","jison","json","json5","jsonc","jsonl","jsonnet","jssm","jsx","julia","kdl","kotlin","kusto","latex","lean","less","liquid","llvm","log","logo","lua","luau","make","markdown","marko","matlab","mdc","mdx","mermaid","mipsasm","mojo","moonbit","move","narrat","nextflow","nginx","nim","nix","nushell","objective-c","objective-cpp","ocaml","odin","openscad","pascal","perl","php","pkl","plsql","po","polar","postcss","powerquery","powershell","prisma","prolog","proto","pug","puppet","purescript","python","qml","qmldir","qss","r","racket","raku","razor","reg","regexp","rel","riscv","ron","rosmsg","rst","ruby","rust","sas","sass","scala","scheme","scss","sdbl","shaderlab","shellscript","shellsession","smalltalk","solidity","soy","sparql","splunk","sql","ssh-config","stata","stylus","surrealql","svelte","swift","system-verilog","systemd","talonscript","tasl","tcl","templ","terraform","tex","toml","ts-tags","tsv","tsx","turtle","twig","typescript","typespec","typst","v","vala","vb","verilog","vhdl","viml","vue","vue-html","vue-vine","vyper","wasm","wenyan","wgsl","wikitext","wit","wolfram","xml","xsl","yaml","zenscript","zig","adoc","batch","be","1c","cdc","clj","ql","coffeescript","lisp","c++","c#","cs","cql","dockerfile","elisp","erl","ftl","f","for","f77","f90","f95","f03","f08","f18","f#","fs","tscn","tres","gd","gjs","gts","gql","hbs","hs","properties","js","cjs","mjs","fsl","jl","kt","kts","kql","lean4","makefile","md","mmd","mips","mbt","mbti","nar","nf","nu","objc","scad","pot","potx","ps","ps1","protobuf","jade","py","perl6","regex","rb","rs","1c-query","shader","bash","sh","shell","zsh","console","closure-templates","spl","styl","surql","talon","tf","tfvars","lit","ts","cts","mts","tsp","typ","cmd","vim","vimscript","vy","文言","mediawiki","wiki","wl","yml"]),v={env:"dotenv",text:"ini",plaintext:"ini",txt:"ini",plain:"ini",terminal:"shellscript",term:"shellscript",cURL:"bash",curl:"bash"},K=/^```(\w[\w+#-]*)?/;function R(s,e){const t=performance.now(),n=[],r=y.getLeafNodes(s),a=new Set(x);if(e!=null&&e.additionalLanguages)for(const c of e.additionalLanguages)a.add(c.toLowerCase());const i={...v,...e==null?void 0:e.additionalAliases};let u=0,l=0;for(const c of r){if(!c.file)continue;u++;const o=k.readFileSync(c.file,"utf-8").split(`
|
|
6
|
+
`);for(let h=0;h<o.length;h++){const f=o[h],g=f.match(K);if(g){l++;const m=g[1];if(!m)continue;const p=m.toLowerCase();if(!(a.has(p)||p in i)){const b={file:s.basePath?T.relative(s.basePath,c.file):c.file,absolutePath:c.file,line:h+1,language:m,content:f.trim(),suggestion:H(p,a,i)};if(n.push(b),e!=null&&e.onError&&e.onError(b),e!=null&&e.failFast&&n.length>0)return{packageId:s.id,filesScanned:u,codeBlocksFound:l,errors:n,totalTime:performance.now()-t}}}}}return{packageId:s.id,filesScanned:u,codeBlocksFound:l,errors:n,totalTime:performance.now()-t}}function H(s,e,t){if(s in t)return`Use '${t[s]}' instead of '${s}'`;const n={typescript:"ts",javascript:"js","node.js":"javascript",nodejs:"javascript","c-sharp":"csharp","c-plus-plus":"cpp",py3:"python",python3:"python",bash4:"bash",zshell:"zsh",cfg:"ini",conf:"ini",config:"ini",env:"dotenv",".env":"dotenv"};if(s in n)return`Use '${n[s]}' instead of '${s}'`;for(const r of e)if(r.includes(s)||s.includes(r))return`Did you mean '${r}'?`}function Y(s,e){var n;const t=s.toLowerCase();return!!(x.has(t)||t in v||(n=e==null?void 0:e.additionalLanguages)!=null&&n.includes(t)||e!=null&&e.additionalAliases&&t in e.additionalAliases)}function Z(s){const e=s.toLowerCase();if(e in v)return v[e];if(x.has(e))return e}function J(s){const e=[];if(e.push(""),e.push(`Code Language Validation Report: ${s.packageId}`),e.push("=".repeat(50)),e.push(""),e.push(`Files scanned: ${s.filesScanned}`),e.push(`Code blocks found: ${s.codeBlocksFound}`),e.push(`Invalid languages: ${s.errors.length}`),e.push(`Total time: ${s.totalTime.toFixed(2)}ms`),e.push(""),s.errors.length===0)return e.push("All code blocks use valid language identifiers!"),e.push(""),e.join(`
|
|
7
|
+
`);e.push("Errors:"),e.push("-".repeat(50)),e.push("");const t=new Map;for(const n of s.errors){const r=t.get(n.language)??[];r.push(n),t.set(n.language,r)}for(const[n,r]of t){const a=r[0].suggestion;e.push(` Language: '${n}'${a?` - ${a}`:" (unsupported)"}`),e.push(` Found in ${r.length} location(s):`);for(const i of r)e.push(` - ${i.file}:${i.line}`);e.push("")}return e.push("Common fixes:"),e.push(" - 'env' → 'dotenv' (for .env files)"),e.push(" - 'text' → remove language or use 'ini' for config-like content"),e.push(" - 'terminal' → 'bash' or 'shell'"),e.push(""),e.push("See supported languages: https://shiki.style/languages"),e.push(""),e.join(`
|
|
8
|
+
`)}function D(s,e){const t=performance.now(),n=[],r=y.getLeafNodes(s);let a=0;for(const i of r){if(!i.file)continue;a++;const u=k.readFileSync(i.file,"utf-8");try{w.parseFrontmatter(u,i.file)}catch(l){const c={file:s.basePath?T.relative(s.basePath,i.file):i.file,absolutePath:i.file,issues:Q(l)};if(n.push(c),e!=null&&e.onError&&e.onError(c),e!=null&&e.failFast&&n.length>0)return{packageId:s.id,filesScanned:a,errors:n,totalTime:performance.now()-t}}}return{packageId:s.id,filesScanned:a,errors:n,totalTime:performance.now()-t}}function Q(s){if(s instanceof w.FrontmatterParseError){const e=s.message,t=e.split(`
|
|
9
|
+
`),n=[];for(const r of t){const a=r.trim();a.startsWith("- ")&&n.push(a.slice(2))}return n.length===0?[e]:n}return s instanceof Error?[s.message]:["Unknown error"]}function ee(s){const e=[];if(e.push(""),e.push(`Frontmatter Validation Report: ${s.packageId}`),e.push("=".repeat(50)),e.push(""),e.push(`Files scanned: ${s.filesScanned}`),e.push(`Errors found: ${s.errors.length}`),e.push(`Total time: ${s.totalTime.toFixed(2)}ms`),e.push(""),s.errors.length===0)return e.push("All files have valid frontmatter!"),e.push(""),e.join(`
|
|
10
|
+
`);e.push("Errors:"),e.push("-".repeat(50)),e.push("");for(const t of s.errors){e.push(` ${t.file}`);for(const n of t.issues)e.push(` - ${n}`);e.push("")}return e.push("Frontmatter requirements:"),e.push(" - title: Required, non-empty string"),e.push(" - description: Optional string"),e.push(" - keywords: Optional array of strings"),e.push(" - sidebarLabel: Optional string"),e.push(" - hidden: Optional boolean"),e.push(" - order: Optional integer"),e.push(" - lastModified: Optional ISO 8601 datetime"),e.push(""),e.join(`
|
|
11
|
+
`)}async function se(s,e){const t=performance.now(),{verbose:n=!1,failFast:r=!1,exit:a=!0,silent:i=!1,mdx:u=!0,admonitions:l=!0,codeLanguages:c=!0,frontmatter:d=!0}=e??{},o={packageId:s.id,totalErrors:0,totalTime:0,success:!0},h=()=>r&&o.totalErrors>0;if(d!==!1&&!h()){const f=typeof d=="object"?d:{};r&&(f.failFast=!0),o.frontmatter=D(s,f),o.totalErrors+=o.frontmatter.errors.length}if(l!==!1&&!h()){const f=typeof l=="object"?l:{};r&&(f.failFast=!0),o.admonitions=S(s,f),o.totalErrors+=o.admonitions.errors.length}if(c!==!1&&!h()){const f=typeof c=="object"?c:{};r&&(f.failFast=!0),o.codeLanguages=R(s,f),o.totalErrors+=o.codeLanguages.errors.length}if(u!==!1&&!h()){const f=typeof u=="object"?u:{};r&&(f.failFast=!0),o.mdx=await j(s,f),o.totalErrors+=o.mdx.failed}return o.totalTime=performance.now()-t,o.success=o.totalErrors===0,i||console.log(N(o,n)),a&&process.exit(o.success?0:1),o}function N(s,e=!1){const t=[];t.push(""),t.push(`Documentation Test Report: ${s.packageId}`),t.push("=".repeat(60)),t.push(""),t.push("Summary"),t.push("-".repeat(60));const n=[];s.frontmatter&&n.push({name:"Frontmatter",errors:s.frontmatter.errors.length,time:s.frontmatter.totalTime,details:`${s.frontmatter.filesScanned} files`}),s.admonitions&&n.push({name:"Admonitions",errors:s.admonitions.errors.length,time:s.admonitions.totalTime,details:`${s.admonitions.filesScanned} files`}),s.codeLanguages&&n.push({name:"Code Languages",errors:s.codeLanguages.errors.length,time:s.codeLanguages.totalTime,details:`${s.codeLanguages.codeBlocksFound} blocks`}),s.mdx&&n.push({name:"MDX Compilation",errors:s.mdx.failed,time:s.mdx.totalTime,details:`${s.mdx.passed}/${s.mdx.totalFiles} passed`});for(const r of n){const a=r.errors===0?"✓":"✗",i=r.errors===0?"OK":`${r.errors} error${r.errors>1?"s":""}`;t.push(` ${a} ${r.name.padEnd(16)} ${i.padEnd(12)} (${r.details})`)}if(t.push(""),t.push(`Total errors: ${s.totalErrors}`),t.push(`Total time: ${s.totalTime.toFixed(2)}ms`),t.push(""),s.totalErrors>0||e){if(t.push("Details"),t.push("-".repeat(60)),s.frontmatter&&(s.frontmatter.errors.length>0||e))if(t.push(""),t.push("Frontmatter Validation:"),s.frontmatter.errors.length===0)t.push(" All files have valid frontmatter.");else for(const r of s.frontmatter.errors){t.push(` [FAIL] ${r.file}`);for(const a of r.issues)t.push(` ${a}`)}if(s.admonitions&&(s.admonitions.errors.length>0||e))if(t.push(""),t.push("Admonition Validation:"),s.admonitions.errors.length===0)t.push(" All admonitions use correct syntax.");else for(const r of s.admonitions.errors)t.push(` [FAIL] ${r.file}:${r.line}`),t.push(` ${r.content}`),t.push(` Fix: ${r.suggestion}`);if(s.codeLanguages&&(s.codeLanguages.errors.length>0||e))if(t.push(""),t.push("Code Language Validation:"),s.codeLanguages.errors.length===0)t.push(" All code blocks use valid languages.");else{const r=new Map;for(const a of s.codeLanguages.errors){const i=r.get(a.language)??[];i.push(a),r.set(a.language,i)}for(const[a,i]of r){const u=i[0].suggestion;t.push(` Language '${a}'${u?` - ${u}`:" (unsupported)"}`);for(const l of i)t.push(` - ${l.file}:${l.line}`)}}if(s.mdx&&(s.mdx.failed>0||e)){if(t.push(""),t.push("MDX Compilation:"),s.mdx.failed===0)t.push(" All MDX files compiled successfully.");else for(const r of s.mdx.results)if(r.success)e&&t.push(` [PASS] ${r.filePath}`);else if(t.push(` [FAIL] ${r.filePath}`),r.error){const a=r.line?` (line ${r.line}${r.column?`:${r.column}`:""})`:"";t.push(` Error${a}: ${r.error}`)}}}return t.push(""),s.success?t.push("✔ All documentation tests passed!"):t.push(`✖ ${s.totalErrors} error${s.totalErrors>1?"s":""} found.`),t.push(""),t.join(`
|
|
12
|
+
`)}function te(s,e=!1){const t=[];t.push(""),t.push(`MDX Compilation Report: ${s.packageId}`),t.push("=".repeat(50)),t.push("");const n=s.totalFiles>0?(s.passed/s.totalFiles*100).toFixed(1):"0";if(t.push(`Total files: ${s.totalFiles}`),t.push(`Passed: ${s.passed} (${n}%)`),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 a=r.success?"[PASS]":"[FAIL]",i=`(${r.compilationTime.toFixed(2)}ms)`;if(t.push(`${a} ${r.filePath} ${i}`),!r.success&&r.error){const u=r.line?` (line ${r.line}${r.column?`:${r.column}`:""})`:"";t.push(` Error${u}: ${r.error}`)}}}else if(s.failed>0){t.push("Failures:"),t.push("-".repeat(50));for(const r of s.results.filter(a=>!a.success))if(t.push(`[FAIL] ${r.filePath}`),r.error){const a=r.line?` (line ${r.line}${r.column?`:${r.column}`:""})`:"";t.push(` Error${a}: ${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(`
|
|
13
|
+
`)}function re(){return(s,e,t)=>{const n=t.success?"✓":"✗",r=(s/e*100).toFixed(0);process.stdout.write(`\r[${s}/${e}] (${r}%) ${n} ${t.filePath}`),process.stdout.write("\x1B[K"),s===e&&process.stdout.write(`
|
|
14
|
+
`)}}exports.ADMONITION_TYPES=P;exports.INVALID_ADMONITION_PATTERN=I;exports.LANGUAGE_ALIASES=v;exports.SHIKI_BUNDLED_LANGUAGES=x;exports.compileMdx=A;exports.createProgressReporter=re;exports.formatAdmonitionReport=X;exports.formatCodeLanguageReport=J;exports.formatFrontmatterReport=ee;exports.formatTestReport=te;exports.formatTestRunnerReport=N;exports.getCanonicalLanguage=Z;exports.getDefaultRehypePlugins=E;exports.getDefaultRemarkPlugins=F;exports.isValidCodeLanguage=Y;exports.runAllTests=se;exports.testManifestMdx=j;exports.validateAdmonitions=S;exports.validateCodeLanguages=R;exports.validateFrontmatter=D;
|