@clarify-labs/cli 0.10.2 → 0.10.3
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/output/cli.cjs +18 -32
- package/output/cli.cjs.map +1 -1
- package/output/cli.js +18 -32
- package/output/cli.js.map +1 -1
- package/output/core/adapters.d.ts +5 -0
- package/output/core/config/config-schema.d.ts +6 -110
- package/output/core/engine/engine.d.ts +1 -0
- package/output/core/runtime/virtual-modules.d.ts +1 -1
- package/output/{engine-qafLfnXQ.cjs → engine-BDdPszs2.cjs} +169 -99
- package/output/engine-BDdPszs2.cjs.map +1 -0
- package/output/{engine-CSSL_gGd.js → engine-CyFtr8Pz.js} +169 -99
- package/output/engine-CyFtr8Pz.js.map +1 -0
- package/output/index.cjs +1 -1
- package/output/index.js +1 -1
- package/output/parsers/content/diagnostic.d.ts +12 -0
- package/output/parsers/markdown/mdx.d.ts +8 -0
- package/output/plugins/openapi/parser.d.ts +1 -1
- package/output/plugins/openapi/virtual-modules.d.ts +1 -2
- package/output/types.d.ts +4 -9
- package/package.json +3 -3
- package/output/engine-CSSL_gGd.js.map +0 -1
- package/output/engine-qafLfnXQ.cjs.map +0 -1
|
@@ -22,6 +22,24 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
22
22
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
23
23
|
import { tmpdir } from "node:os";
|
|
24
24
|
import { createRequire } from "node:module";
|
|
25
|
+
//#region source/parsers/content/diagnostic.ts
|
|
26
|
+
function displayPath(filePath, projectRoot) {
|
|
27
|
+
if (!filePath) return void 0;
|
|
28
|
+
if (!projectRoot) return filePath.replace(/^[A-Za-z]:\//, "").replace(/^\/+/, "");
|
|
29
|
+
const normalized = relative(projectRoot, filePath);
|
|
30
|
+
return normalized && !normalized.startsWith("..") && !isAbsolute(normalized) ? normalized : filePath.replace(/^[A-Za-z]:\//, "").replace(/^\/+/, "");
|
|
31
|
+
}
|
|
32
|
+
function createContentDiagnostic(options) {
|
|
33
|
+
const { error } = options;
|
|
34
|
+
return {
|
|
35
|
+
kind: options.kind,
|
|
36
|
+
title: options.title,
|
|
37
|
+
message: options.message,
|
|
38
|
+
filePath: displayPath(options.filePath, options.projectRoot),
|
|
39
|
+
details: error instanceof Error ? options.includeStack ? error.stack ?? error.message : error.message : String(error)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
25
43
|
//#region source/parsers/markdown/mdx.ts
|
|
26
44
|
function getLanguage(className) {
|
|
27
45
|
return (Array.isArray(className) ? className : typeof className === "string" ? className.split(/\s+/) : []).find((item) => typeof item === "string" && item.startsWith("language-"))?.replace(/^language-/, "") || "txt";
|
|
@@ -57,9 +75,18 @@ var rehypePlugins = [
|
|
|
57
75
|
parseMetaString: parseCodeMeta
|
|
58
76
|
}]
|
|
59
77
|
];
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
78
|
+
function createContentCompileDiagnostic(options) {
|
|
79
|
+
const { format, phase, error, filePath, projectRoot } = options;
|
|
80
|
+
const label = format === "mdx" ? "MDX" : "Markdown";
|
|
81
|
+
return createContentDiagnostic({
|
|
82
|
+
kind: format,
|
|
83
|
+
title: `${label} ${phase} error`,
|
|
84
|
+
message: phase === "syntax" ? "This page could not be compiled. Fix the MDX syntax or component usage above, then reload the route." : `This page could not be compiled. Fix the ${label} syntax or plugin error below, then reload the route.`,
|
|
85
|
+
error,
|
|
86
|
+
filePath,
|
|
87
|
+
projectRoot,
|
|
88
|
+
includeStack: phase === "compilation"
|
|
89
|
+
});
|
|
63
90
|
}
|
|
64
91
|
/**
|
|
65
92
|
* Validate MDX content for diagnostics WITHOUT running the build-time rehype
|
|
@@ -90,13 +117,13 @@ async function compileMdxContent(content, filePath, projectRoot) {
|
|
|
90
117
|
} catch (error) {
|
|
91
118
|
return {
|
|
92
119
|
ok: false,
|
|
93
|
-
diagnostic: {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
filePath
|
|
98
|
-
|
|
99
|
-
}
|
|
120
|
+
diagnostic: createContentCompileDiagnostic({
|
|
121
|
+
format: "mdx",
|
|
122
|
+
phase: "syntax",
|
|
123
|
+
error,
|
|
124
|
+
filePath,
|
|
125
|
+
projectRoot
|
|
126
|
+
})
|
|
100
127
|
};
|
|
101
128
|
}
|
|
102
129
|
}
|
|
@@ -452,6 +479,7 @@ function routeIntentFromPagesItem(item) {
|
|
|
452
479
|
kind: "page",
|
|
453
480
|
ref: item
|
|
454
481
|
};
|
|
482
|
+
if ("group" in item) throw new Error("Navigation groups do not resolve to route intents");
|
|
455
483
|
if ("openapi" in item) return {
|
|
456
484
|
kind: "openapi",
|
|
457
485
|
ref: item.openapi,
|
|
@@ -479,15 +507,19 @@ function firstNavigationPath(nodes) {
|
|
|
479
507
|
}
|
|
480
508
|
function collectExplicitPagePathIntents(tabs) {
|
|
481
509
|
const intents = [];
|
|
482
|
-
|
|
483
|
-
if (
|
|
484
|
-
|
|
510
|
+
const collectItems = (items) => {
|
|
511
|
+
for (const item of items) if (typeof item !== "string" && "group" in item) collectItems(item.pages);
|
|
512
|
+
else if (typeof item !== "string" && "page" in item && item.path) {
|
|
485
513
|
const intent = routeIntentFromPagesItem(item);
|
|
486
514
|
if (intent.kind === "page" && intent.path) intents.push({
|
|
487
515
|
...intent,
|
|
488
516
|
path: intent.path
|
|
489
517
|
});
|
|
490
518
|
}
|
|
519
|
+
};
|
|
520
|
+
for (const tab of tabs ?? []) {
|
|
521
|
+
if (!tab.pages || tab.pages === "FileTree") continue;
|
|
522
|
+
for (const group of tab.pages) collectItems(group.pages);
|
|
491
523
|
}
|
|
492
524
|
return intents;
|
|
493
525
|
}
|
|
@@ -538,28 +570,38 @@ function buildNavigationFromTabsConfig(routes, tabs) {
|
|
|
538
570
|
}
|
|
539
571
|
function buildNavigationFromConfig(routes, config) {
|
|
540
572
|
const routeMap = new Map(routes.map((r) => [r.path, r]));
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
const path = routePathFromRef(intent.ref, intent.path);
|
|
573
|
+
const buildItem = (item) => {
|
|
574
|
+
if (typeof item !== "string" && "group" in item) {
|
|
575
|
+
const children = item.pages.map(buildItem);
|
|
576
|
+
return {
|
|
577
|
+
path: firstNavigationPath(children),
|
|
578
|
+
title: resolveLocalizedText(item.group, "", "") ?? "",
|
|
579
|
+
icon: item.icon,
|
|
580
|
+
children
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
const intent = routeIntentFromPagesItem(item);
|
|
584
|
+
if (intent.kind === "openapi") {
|
|
585
|
+
const path = openAPIPagePathFromRef(intent.ref, intent.tagFilter, intent.path);
|
|
555
586
|
const route = routeMap.get(path);
|
|
556
587
|
return {
|
|
557
|
-
path
|
|
588
|
+
path,
|
|
558
589
|
title: resolveLocalizedText(intent.title, "", "") ?? route?.meta.title ?? kebabToTitle(path.split("/").pop() ?? intent.ref),
|
|
559
590
|
icon: intent.icon,
|
|
560
591
|
sections: route?.meta.sections ? navigationSections(route.meta.sections) : void 0
|
|
561
592
|
};
|
|
562
|
-
}
|
|
593
|
+
}
|
|
594
|
+
const path = routePathFromRef(intent.ref, intent.path);
|
|
595
|
+
const route = routeMap.get(path);
|
|
596
|
+
return {
|
|
597
|
+
path: intent.redirect ? normalizePath(intent.redirect) : path,
|
|
598
|
+
title: resolveLocalizedText(intent.title, "", "") ?? route?.meta.title ?? kebabToTitle(path.split("/").pop() ?? intent.ref),
|
|
599
|
+
icon: intent.icon,
|
|
600
|
+
sections: route?.meta.sections ? navigationSections(route.meta.sections) : void 0
|
|
601
|
+
};
|
|
602
|
+
};
|
|
603
|
+
return config.map((group) => {
|
|
604
|
+
const children = group.pages.map(buildItem);
|
|
563
605
|
return {
|
|
564
606
|
path: children[0]?.path ?? "/",
|
|
565
607
|
title: resolveLocalizedText(group.group, "", "") ?? "",
|
|
@@ -581,19 +623,29 @@ function buildLocalizedNavigationForLocale(routes, config, locale, i18n) {
|
|
|
581
623
|
path: route.basePath ?? route.path
|
|
582
624
|
}))), locale, i18n);
|
|
583
625
|
const routeMap = new Map(routes.map((route) => [route.basePath ?? route.path, route]));
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
const
|
|
587
|
-
const basePath = intent.kind === "openapi" ? openAPIPagePathFromRef(intent.ref, intent.tagFilter, intent.path) : routePathFromRef(intent.ref, intent.path);
|
|
588
|
-
const route = routeMap.get(basePath);
|
|
589
|
-
const path = route?.path ?? localizedRoutePath(basePath, locale, i18n);
|
|
626
|
+
const buildItem = (item) => {
|
|
627
|
+
if (typeof item !== "string" && "group" in item) {
|
|
628
|
+
const children = item.pages.map(buildItem);
|
|
590
629
|
return {
|
|
591
|
-
path: (
|
|
592
|
-
title: resolveLocalizedText(
|
|
593
|
-
icon:
|
|
594
|
-
|
|
630
|
+
path: firstNavigationPath(children),
|
|
631
|
+
title: resolveLocalizedText(item.group, locale, i18n.defaultLocale) ?? "",
|
|
632
|
+
icon: item.icon,
|
|
633
|
+
children
|
|
595
634
|
};
|
|
596
|
-
}
|
|
635
|
+
}
|
|
636
|
+
const intent = routeIntentFromPagesItem(item);
|
|
637
|
+
const basePath = intent.kind === "openapi" ? openAPIPagePathFromRef(intent.ref, intent.tagFilter, intent.path) : routePathFromRef(intent.ref, intent.path);
|
|
638
|
+
const route = routeMap.get(basePath);
|
|
639
|
+
const path = route?.path ?? localizedRoutePath(basePath, locale, i18n);
|
|
640
|
+
return {
|
|
641
|
+
path: (intent.kind === "page" && intent.redirect ? localizedRoutePath(routePathFromRef(intent.redirect), locale, i18n) : void 0) ?? path,
|
|
642
|
+
title: resolveLocalizedText(intent.title, locale, i18n.defaultLocale) ?? route?.meta.title ?? kebabToTitle(basePath.split("/").pop() ?? intent.ref),
|
|
643
|
+
icon: intent.icon,
|
|
644
|
+
sections: route?.meta.sections ? navigationSections(route.meta.sections) : void 0
|
|
645
|
+
};
|
|
646
|
+
};
|
|
647
|
+
return config.map((group) => {
|
|
648
|
+
const children = group.pages.map(buildItem);
|
|
597
649
|
return {
|
|
598
650
|
path: children[0]?.path ?? localizedRoutePath("/", locale, i18n),
|
|
599
651
|
title: resolveLocalizedText(group.group, locale, i18n.defaultLocale) ?? "",
|
|
@@ -838,8 +890,9 @@ var clarifySourceConfigSchema = z.object({
|
|
|
838
890
|
branch: z.string().optional(),
|
|
839
891
|
directory: z.string().optional()
|
|
840
892
|
});
|
|
841
|
-
var clarifyPagesItemSchema = z.union([
|
|
893
|
+
var clarifyPagesItemSchema = z.lazy(() => z.union([
|
|
842
894
|
z.string(),
|
|
895
|
+
clarifyPagesGroupSchema,
|
|
843
896
|
z.object({
|
|
844
897
|
page: z.string(),
|
|
845
898
|
path: z.string().optional(),
|
|
@@ -854,12 +907,12 @@ var clarifyPagesItemSchema = z.union([
|
|
|
854
907
|
title: clarifyLocalizedTextSchema.optional(),
|
|
855
908
|
filter: z.object({ tags: z.array(z.string()).optional() }).optional()
|
|
856
909
|
})
|
|
857
|
-
]);
|
|
858
|
-
var clarifyPagesGroupSchema = z.object({
|
|
910
|
+
]));
|
|
911
|
+
var clarifyPagesGroupSchema = z.lazy(() => z.object({
|
|
859
912
|
group: clarifyLocalizedTextSchema,
|
|
860
913
|
icon: z.string().optional(),
|
|
861
914
|
pages: z.array(clarifyPagesItemSchema)
|
|
862
|
-
});
|
|
915
|
+
}));
|
|
863
916
|
var clarifyPagesConfigSchema = z.union([z.array(clarifyPagesGroupSchema), z.literal("FileTree")]);
|
|
864
917
|
var clarifyTabItemSchema = z.object({
|
|
865
918
|
tab: clarifyLocalizedTextSchema,
|
|
@@ -1207,16 +1260,10 @@ function createRuntimeSlotsModule(plugins = [], root = process.cwd()) {
|
|
|
1207
1260
|
}
|
|
1208
1261
|
return `export const runtimeSlots = {\n${[...grouped.entries()].map(([name, list]) => ` ${JSON.stringify(name)}: [\n ${list.join(",\n ")}\n ]`).join(",\n")}\n};\n`;
|
|
1209
1262
|
}
|
|
1210
|
-
function
|
|
1263
|
+
function generateContentDiagnosticModule(diagnostic) {
|
|
1211
1264
|
return `import { createContentDiagnosticComponent } from '@clarify-labs/renderer';
|
|
1212
1265
|
|
|
1213
|
-
export const contentDiagnostic = ${JSON.stringify(
|
|
1214
|
-
kind: diagnostic.kind ?? "mdx",
|
|
1215
|
-
title: diagnostic.title,
|
|
1216
|
-
message: diagnostic.message,
|
|
1217
|
-
filePath: diagnostic.filePath,
|
|
1218
|
-
details: diagnostic.details
|
|
1219
|
-
})};
|
|
1266
|
+
export const contentDiagnostic = ${JSON.stringify(diagnostic)};
|
|
1220
1267
|
|
|
1221
1268
|
export default createContentDiagnosticComponent(contentDiagnostic);
|
|
1222
1269
|
`;
|
|
@@ -1234,7 +1281,7 @@ function buildVirtualModules(args) {
|
|
|
1234
1281
|
modules.set(VIRTUAL_CLIENT_ENTRY, clientEntryModule);
|
|
1235
1282
|
modules.set(RESOLVED_CLIENT_ENTRY, clientEntryModule);
|
|
1236
1283
|
for (const route of args.routes) {
|
|
1237
|
-
const moduleContent = route.diagnostic ?
|
|
1284
|
+
const moduleContent = route.diagnostic ? generateContentDiagnosticModule(route.diagnostic) : `export { default } from ${moduleSpecifier(route.source.filePath)};`;
|
|
1238
1285
|
modules.set(route.module.virtualModuleId, moduleContent);
|
|
1239
1286
|
}
|
|
1240
1287
|
return modules;
|
|
@@ -1285,26 +1332,42 @@ function createNormalizedContentPlugin(engine) {
|
|
|
1285
1332
|
}
|
|
1286
1333
|
};
|
|
1287
1334
|
}
|
|
1288
|
-
function
|
|
1289
|
-
return
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1335
|
+
function createContentCompileTransform(transform, format, projectRoot, errorPolicy = () => "diagnostic") {
|
|
1336
|
+
return async function contentCompileTransform(code, id) {
|
|
1337
|
+
try {
|
|
1338
|
+
return await transform.call(this, code, id);
|
|
1339
|
+
} catch (error) {
|
|
1340
|
+
if (errorPolicy() === "throw") throw error;
|
|
1341
|
+
return {
|
|
1342
|
+
code: generateContentDiagnosticModule(createContentCompileDiagnostic({
|
|
1343
|
+
format,
|
|
1344
|
+
phase: "compilation",
|
|
1345
|
+
error,
|
|
1346
|
+
filePath: id.replace(/\?.*$/, ""),
|
|
1347
|
+
projectRoot
|
|
1348
|
+
})),
|
|
1349
|
+
map: null
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1297
1353
|
}
|
|
1298
|
-
function
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1354
|
+
function createContentCompilerPlugin(format, projectRoot, errorPolicy) {
|
|
1355
|
+
const markdown = format === "markdown";
|
|
1356
|
+
const plugin = mdxPlugin({
|
|
1357
|
+
include: [markdown ? "**/*.md" : "**/*.mdx"],
|
|
1358
|
+
format: markdown ? "md" : "mdx",
|
|
1302
1359
|
jsxImportSource: "react",
|
|
1303
1360
|
providerImportSource: "@clarify-labs/renderer",
|
|
1304
1361
|
remarkPlugins,
|
|
1305
|
-
remarkRehypeOptions: { allowDangerousHtml: true },
|
|
1306
|
-
rehypePlugins: [rehypeRaw, ...rehypePlugins]
|
|
1362
|
+
...markdown ? { remarkRehypeOptions: { allowDangerousHtml: true } } : {},
|
|
1363
|
+
rehypePlugins: markdown ? [rehypeRaw, ...rehypePlugins] : rehypePlugins
|
|
1307
1364
|
});
|
|
1365
|
+
const transform = typeof plugin.transform === "function" ? plugin.transform : plugin.transform?.handler;
|
|
1366
|
+
if (!transform) return plugin;
|
|
1367
|
+
return {
|
|
1368
|
+
...plugin,
|
|
1369
|
+
transform: createContentCompileTransform(transform, format, projectRoot, errorPolicy)
|
|
1370
|
+
};
|
|
1308
1371
|
}
|
|
1309
1372
|
function createClarifyViteCorePlugin(engine, normalizedContentPlugin, markdown, mdx) {
|
|
1310
1373
|
let viteConfig;
|
|
@@ -1426,13 +1489,22 @@ function createClarifyViteCorePlugin(engine, normalizedContentPlugin, markdown,
|
|
|
1426
1489
|
* site itself - it only bridges Vite lifecycle hooks to the engine.
|
|
1427
1490
|
*/
|
|
1428
1491
|
function createViteAdapter(engine) {
|
|
1492
|
+
let contentCompileErrorPolicy = "diagnostic";
|
|
1493
|
+
const errorPolicy = () => contentCompileErrorPolicy;
|
|
1429
1494
|
const normalizedContentPlugin = createNormalizedContentPlugin(engine);
|
|
1430
|
-
const markdown =
|
|
1431
|
-
const mdx =
|
|
1495
|
+
const markdown = createContentCompilerPlugin("markdown", engine.root, errorPolicy);
|
|
1496
|
+
const mdx = createContentCompilerPlugin("mdx", engine.root, errorPolicy);
|
|
1497
|
+
const compilePolicyPlugin = {
|
|
1498
|
+
name: "clarify:content-compile-policy",
|
|
1499
|
+
configResolved(config) {
|
|
1500
|
+
contentCompileErrorPolicy = config.command === "build" && engine.generateOptions.ssg.failOnError ? "throw" : "diagnostic";
|
|
1501
|
+
}
|
|
1502
|
+
};
|
|
1432
1503
|
const tailwind = tailwindcss();
|
|
1433
1504
|
return [
|
|
1434
1505
|
...react(),
|
|
1435
1506
|
...Array.isArray(tailwind) ? tailwind : [tailwind],
|
|
1507
|
+
compilePolicyPlugin,
|
|
1436
1508
|
normalizedContentPlugin,
|
|
1437
1509
|
createClarifyViteCorePlugin(engine, normalizedContentPlugin, markdown, mdx),
|
|
1438
1510
|
markdown,
|
|
@@ -1441,7 +1513,7 @@ function createViteAdapter(engine) {
|
|
|
1441
1513
|
}
|
|
1442
1514
|
var cliPackageVersion = {
|
|
1443
1515
|
name: "@clarify-labs/cli",
|
|
1444
|
-
version: "0.10.
|
|
1516
|
+
version: "0.10.3",
|
|
1445
1517
|
license: "AGPL-3.0-only",
|
|
1446
1518
|
type: "module",
|
|
1447
1519
|
repository: {
|
|
@@ -1794,9 +1866,6 @@ var OPENAPI_HTTP_METHODS = [
|
|
|
1794
1866
|
"trace"
|
|
1795
1867
|
];
|
|
1796
1868
|
var CLARIFY_OPENAPI_SECTION_ID_EXTENSION = "x-clarify-section-id";
|
|
1797
|
-
function errorMessage(error) {
|
|
1798
|
-
return error instanceof Error ? error.message : String(error);
|
|
1799
|
-
}
|
|
1800
1869
|
function isSameOpenAPIFile(url, filePath) {
|
|
1801
1870
|
try {
|
|
1802
1871
|
return resolve(fileURLToPath(url)) === resolve(filePath);
|
|
@@ -1911,7 +1980,7 @@ function extractOpenAPISections(spec, filterTags) {
|
|
|
1911
1980
|
}
|
|
1912
1981
|
return sections;
|
|
1913
1982
|
}
|
|
1914
|
-
async function readOpenAPISpec(filePath, contentProcessor) {
|
|
1983
|
+
async function readOpenAPISpec(filePath, contentProcessor, projectRoot) {
|
|
1915
1984
|
try {
|
|
1916
1985
|
if (!contentProcessor) return {
|
|
1917
1986
|
ok: true,
|
|
@@ -1934,13 +2003,14 @@ async function readOpenAPISpec(filePath, contentProcessor) {
|
|
|
1934
2003
|
} catch (error) {
|
|
1935
2004
|
return {
|
|
1936
2005
|
ok: false,
|
|
1937
|
-
diagnostic: {
|
|
2006
|
+
diagnostic: createContentDiagnostic({
|
|
1938
2007
|
kind: "openapi",
|
|
1939
2008
|
title: "OpenAPI spec parse failed",
|
|
1940
|
-
message:
|
|
2009
|
+
message: "Clarify could not parse this OpenAPI specification.",
|
|
2010
|
+
error,
|
|
1941
2011
|
filePath,
|
|
1942
|
-
|
|
1943
|
-
}
|
|
2012
|
+
projectRoot
|
|
2013
|
+
})
|
|
1944
2014
|
};
|
|
1945
2015
|
}
|
|
1946
2016
|
}
|
|
@@ -1971,31 +2041,24 @@ export const routeData = {};
|
|
|
1971
2041
|
export default createOpenApiRouteComponent({ ...routeData, spec });
|
|
1972
2042
|
`;
|
|
1973
2043
|
}
|
|
1974
|
-
function generateOpenAPIErrorModule(diagnostic) {
|
|
1975
|
-
return `import { createContentDiagnosticComponent } from '@clarify-labs/renderer';
|
|
1976
|
-
|
|
1977
|
-
export const contentDiagnostic = ${JSON.stringify({
|
|
1978
|
-
kind: diagnostic.kind ?? "openapi",
|
|
1979
|
-
title: diagnostic.title,
|
|
1980
|
-
message: diagnostic.message,
|
|
1981
|
-
filePath: diagnostic.filePath,
|
|
1982
|
-
details: diagnostic.details
|
|
1983
|
-
})};
|
|
1984
|
-
|
|
1985
|
-
export default createContentDiagnosticComponent(contentDiagnostic);
|
|
1986
|
-
`;
|
|
1987
|
-
}
|
|
1988
2044
|
//#endregion
|
|
1989
2045
|
//#region source/plugins/openapi/index.ts
|
|
1990
2046
|
function collectOpenAPIPageIntents(config) {
|
|
1991
2047
|
const intents = [];
|
|
1992
|
-
function
|
|
1993
|
-
|
|
1994
|
-
|
|
2048
|
+
function visitItems(items) {
|
|
2049
|
+
for (const item of items) {
|
|
2050
|
+
if (typeof item !== "string" && "group" in item) {
|
|
2051
|
+
visitItems(item.pages);
|
|
2052
|
+
continue;
|
|
2053
|
+
}
|
|
1995
2054
|
const intent = routeIntentFromPagesItem(item);
|
|
1996
2055
|
if (intent.kind === "openapi" && (intent.path || intent.tagFilter?.length)) intents.push(intent);
|
|
1997
2056
|
}
|
|
1998
2057
|
}
|
|
2058
|
+
function visitPages(pages) {
|
|
2059
|
+
if (!pages || pages === "FileTree") return;
|
|
2060
|
+
for (const group of pages) visitItems(group.pages);
|
|
2061
|
+
}
|
|
1999
2062
|
for (const tab of config.tabs ?? []) visitPages(tab.pages);
|
|
2000
2063
|
return intents;
|
|
2001
2064
|
}
|
|
@@ -2141,7 +2204,7 @@ function createOpenAPIPlugin() {
|
|
|
2141
2204
|
const result = specFromCache ? {
|
|
2142
2205
|
ok: true,
|
|
2143
2206
|
spec: specFromCache
|
|
2144
|
-
} : await readOpenAPISpec(route.source.filePath, processor);
|
|
2207
|
+
} : await readOpenAPISpec(route.source.filePath, processor, ctx.generateOptions.projectRoot);
|
|
2145
2208
|
if (!result.ok) {
|
|
2146
2209
|
route.diagnostic = result.diagnostic;
|
|
2147
2210
|
route.meta.title = route.meta.title || "OpenAPI parse error";
|
|
@@ -2188,7 +2251,7 @@ function createOpenAPIPlugin() {
|
|
|
2188
2251
|
for (const [routeSpecModuleId, spec] of specModules) modules.set(specVirtualModuleId(routeSpecModuleId), generateOpenAPISpecModule(spec));
|
|
2189
2252
|
for (const route of ctx.routes) {
|
|
2190
2253
|
if (route.kind !== "openapi") continue;
|
|
2191
|
-
if (route.diagnostic) modules.set(route.module.virtualModuleId,
|
|
2254
|
+
if (route.diagnostic) modules.set(route.module.virtualModuleId, generateContentDiagnosticModule(route.diagnostic));
|
|
2192
2255
|
else if (route.openapi?.sourceSpecId) {
|
|
2193
2256
|
const routeSpecModuleId = route.openapi.routeSpecModuleId ?? route.openapi.sourceSpecId;
|
|
2194
2257
|
if (!specModules.has(routeSpecModuleId)) continue;
|
|
@@ -3020,6 +3083,12 @@ function loadVirtualModule(id, modules) {
|
|
|
3020
3083
|
const bareId = stripVirtualPrefix(id);
|
|
3021
3084
|
return modules.get(bareId) ?? modules.get(id) ?? null;
|
|
3022
3085
|
}
|
|
3086
|
+
function assertNoContentDiagnostics(routes) {
|
|
3087
|
+
const failures = routes.filter((route) => route.diagnostic);
|
|
3088
|
+
if (failures.length === 0) return;
|
|
3089
|
+
const summary = failures.map((route) => `- ${route.path}: ${route.diagnostic?.title ?? "Content error"}${route.diagnostic?.filePath ? ` (${route.diagnostic.filePath})` : ""}`).join("\n");
|
|
3090
|
+
throw new Error(`[clarify] Content diagnostics prevented the build:\n${summary}`);
|
|
3091
|
+
}
|
|
3023
3092
|
var ClarifyEngine = class {
|
|
3024
3093
|
options;
|
|
3025
3094
|
root;
|
|
@@ -3244,6 +3313,7 @@ var ClarifyEngine = class {
|
|
|
3244
3313
|
await runPhase(this.plugins, "ssg", this.ctx, async () => {
|
|
3245
3314
|
if (process.env.SKIP_CLARIFY_SSG) return;
|
|
3246
3315
|
if (!await runInterceptHooks(this.plugins, "ssg:shouldRun", this.ctx)) return;
|
|
3316
|
+
if (this.generateOptions.ssg.failOnError) assertNoContentDiagnostics(this.routes);
|
|
3247
3317
|
const outputDir = this.runtime.outputDirectory ?? this.generateOptions.outputDirectory;
|
|
3248
3318
|
if (!outputDir) throw new Error("[clarify] outputDirectory is required before SSG runs");
|
|
3249
3319
|
const ssrOutputDir = join(outputDir, ".ssr");
|
|
@@ -3304,4 +3374,4 @@ function createClarifyEngine(options = {}) {
|
|
|
3304
3374
|
//#endregion
|
|
3305
3375
|
export { cliPackageVersion as a, defineConfig as c, createClarifyTempDir as i, createClarifyEngine as n, cliPackageVersionWithCaret as o, createClarifyRuntimeAliases as r, createViteAdapter as s, ClarifyEngine as t };
|
|
3306
3376
|
|
|
3307
|
-
//# sourceMappingURL=engine-
|
|
3377
|
+
//# sourceMappingURL=engine-CyFtr8Pz.js.map
|