@clarify-labs/cli 0.11.11 → 0.11.13

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_engine = require("./engine-BzxBO-E9.cjs");
2
+ const require_engine = require("./engine--f7G04zS.cjs");
3
3
  let node_path = require("node:path");
4
4
  let node_fs_promises = require("node:fs/promises");
5
5
  let node_child_process = require("node:child_process");
package/output/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as createClarifyTempDir, c as cliPackageVersion, i as findRouteConflicts, l as cliPackageVersionWithCaret, n as createClarifyEngine, o as deserializeSearchIndex, r as createClarifyRuntimeAliases, s as searchMcpIndex, u as createViteAdapter } from "./engine-DJ8vzo23.js";
2
+ import { a as createClarifyTempDir, c as cliPackageVersion, i as findRouteConflicts, l as cliPackageVersionWithCaret, n as createClarifyEngine, o as deserializeSearchIndex, r as createClarifyRuntimeAliases, s as searchMcpIndex, u as createViteAdapter } from "./engine-CTFNxQRw.js";
3
3
  import { dirname, extname, isAbsolute, join, normalize, relative, resolve } from "node:path";
4
4
  import { lstat, mkdir, readFile, stat, writeFile } from "node:fs/promises";
5
5
  import { spawnSync } from "node:child_process";
@@ -773,6 +773,8 @@ function buildNavigationFromConfig(routes, config) {
773
773
  title: resolveLocalizedText(item.group, "", "") ?? "",
774
774
  icon: item.icon,
775
775
  layout: item.layout,
776
+ visible: item.visible,
777
+ searchable: item.searchable,
776
778
  children
777
779
  };
778
780
  }
@@ -802,6 +804,8 @@ function buildNavigationFromConfig(routes, config) {
802
804
  path: children[0]?.path ?? "/",
803
805
  title: resolveLocalizedText(group.group, "", "") ?? "",
804
806
  icon: group.icon,
807
+ visible: group.visible,
808
+ searchable: group.searchable,
805
809
  children
806
810
  };
807
811
  });
@@ -827,6 +831,8 @@ function buildLocalizedNavigationForLocale(routes, config, locale, locales) {
827
831
  title: resolveLocalizedText(item.group, locale, locales.default) ?? "",
828
832
  icon: item.icon,
829
833
  layout: item.layout,
834
+ visible: item.visible,
835
+ searchable: item.searchable,
830
836
  children
831
837
  };
832
838
  }
@@ -847,6 +853,8 @@ function buildLocalizedNavigationForLocale(routes, config, locale, locales) {
847
853
  path: children[0]?.path ?? localizedRoutePath("/", locale, locales),
848
854
  title: resolveLocalizedText(group.group, locale, locales.default) ?? "",
849
855
  icon: group.icon,
856
+ visible: group.visible,
857
+ searchable: group.searchable,
850
858
  children
851
859
  };
852
860
  });
@@ -1473,6 +1481,7 @@ function routeToRuntimeManifestEntry(route, component, mode) {
1473
1481
  if (route.locale) entry.locale = route.locale;
1474
1482
  if (route.isFallback) entry.isFallback = true;
1475
1483
  if (route.isBareAlias) entry.isBareAlias = true;
1484
+ if (route.searchable === false) entry.searchable = false;
1476
1485
  if (route.alternates) entry.alternates = route.alternates;
1477
1486
  if (route.meta.description) entry.description = route.meta.description;
1478
1487
  if (route.meta.keywords?.length) entry.keywords = route.meta.keywords;
@@ -1804,7 +1813,7 @@ function createViteAdapter(engine) {
1804
1813
  }
1805
1814
  var cliPackageVersion = {
1806
1815
  name: "@clarify-labs/cli",
1807
- version: "0.11.11",
1816
+ version: "0.11.13",
1808
1817
  license: "AGPL-3.0-only",
1809
1818
  type: "module",
1810
1819
  repository: {
@@ -1927,6 +1936,49 @@ function readRouteArtifactContent(route) {
1927
1936
  const content = readRouteContent(route);
1928
1937
  return shouldUseUtf8Signature(route) ? withUtf8Signature(content) : content;
1929
1938
  }
1939
+ function mergeOpenAPIRecord(target, source, section, filePath) {
1940
+ if (!source) return;
1941
+ for (const [key, value] of Object.entries(source)) {
1942
+ const existing = target[key];
1943
+ if (existing !== void 0 && JSON.stringify(existing) !== JSON.stringify(value)) throw new Error(`[clarify] Cannot aggregate OpenAPI specs: conflicting ${section} entry "${key}" in ${filePath}.`);
1944
+ target[key] = value;
1945
+ }
1946
+ }
1947
+ function createRootOpenAPISpec(routes, projectConfig) {
1948
+ const paths = {};
1949
+ const webhooks = {};
1950
+ const components = {};
1951
+ const tags = /* @__PURE__ */ new Map();
1952
+ const defaultLocale = projectConfig.locales?.default;
1953
+ for (const route of routes) {
1954
+ if (route.kind !== "openapi" || route.diagnostic || !route.source.content || defaultLocale && route.locale && route.locale !== defaultLocale) continue;
1955
+ const filePath = route.source.filePath;
1956
+ const spec = JSON.parse(route.source.content);
1957
+ mergeOpenAPIRecord(paths, spec.paths, "paths", filePath);
1958
+ mergeOpenAPIRecord(webhooks, "webhooks" in spec ? spec.webhooks : void 0, "webhooks", filePath);
1959
+ for (const [section, entries] of Object.entries(spec.components ?? {})) {
1960
+ components[section] ??= {};
1961
+ mergeOpenAPIRecord(components[section], entries, `components.${section}`, filePath);
1962
+ }
1963
+ for (const tag of spec.tags ?? []) {
1964
+ const existing = tags.get(tag.name);
1965
+ if (existing !== void 0 && JSON.stringify(existing) !== JSON.stringify(tag)) throw new Error(`[clarify] Cannot aggregate OpenAPI specs: conflicting tag "${tag.name}" in ${filePath}.`);
1966
+ tags.set(tag.name, tag);
1967
+ }
1968
+ }
1969
+ return {
1970
+ openapi: "3.1.0",
1971
+ info: {
1972
+ title: projectConfig.title,
1973
+ description: projectConfig.description,
1974
+ version: "1.0.0"
1975
+ },
1976
+ paths,
1977
+ ...Object.keys(webhooks).length > 0 ? { webhooks } : {},
1978
+ ...Object.keys(components).length > 0 ? { components } : {},
1979
+ ...tags.size > 0 ? { tags: [...tags.values()] } : {}
1980
+ };
1981
+ }
1930
1982
  function isLlmsTxtRoute(route) {
1931
1983
  return !route.path.split("/").includes("404");
1932
1984
  }
@@ -2026,6 +2078,14 @@ function serveContentArtifacts(req, res, projectConfig, routes) {
2026
2078
  res.end(createLlmsTxtArtifact(routes, projectConfig), "utf8");
2027
2079
  return true;
2028
2080
  }
2081
+ if (contentPath === "/openapi.json" || contentPath === "/openapi.yml") {
2082
+ const spec = createRootOpenAPISpec(routes, projectConfig);
2083
+ const isJson = contentPath.endsWith(".json");
2084
+ res.statusCode = 200;
2085
+ res.setHeader("Content-Type", isJson ? "application/json; charset=utf-8" : "text/yaml; charset=utf-8");
2086
+ res.end(isJson ? JSON.stringify(spec, null, 2) : (0, yaml.stringify)(spec, { lineWidth: 0 }), "utf8");
2087
+ return true;
2088
+ }
2029
2089
  if (contentPath.endsWith(".openapi.yaml")) {
2030
2090
  const jsonPath = contentPath.replace(/\.yaml$/, ".json");
2031
2091
  const route = routes.find((route) => route.artifacts?.contentArtifactUrl === jsonPath);
@@ -2085,6 +2145,14 @@ function createContentArtifactsPlugin() {
2085
2145
  fileName: "llms.txt",
2086
2146
  source: createLlmsTxtArtifact(ctx.routes, ctx.projectConfig)
2087
2147
  });
2148
+ const rootOpenAPISpec = createRootOpenAPISpec(ctx.routes, ctx.projectConfig);
2149
+ assets.push({
2150
+ fileName: "openapi.json",
2151
+ source: JSON.stringify(rootOpenAPISpec, null, 2)
2152
+ }, {
2153
+ fileName: "openapi.yml",
2154
+ source: (0, yaml.stringify)(rootOpenAPISpec, { lineWidth: 0 })
2155
+ });
2088
2156
  return assets;
2089
2157
  }
2090
2158
  }
@@ -2312,7 +2380,7 @@ function routeSearchContent(route) {
2312
2380
  * Convert a `ContentRoute` into the document shape stored in the Orama index.
2313
2381
  */
2314
2382
  function routeToSearchDocument(route, defaultLocale) {
2315
- if (route.isBareAlias) return null;
2383
+ if (route.isBareAlias || route.searchable === false) return null;
2316
2384
  const content = routeSearchContent(route);
2317
2385
  if (!content.trim()) return null;
2318
2386
  return {
@@ -2375,7 +2443,7 @@ function collectIndexedLocales(routes, defaultLocale) {
2375
2443
  const seen = /* @__PURE__ */ new Set();
2376
2444
  const locales = [];
2377
2445
  for (const route of routes) {
2378
- if (route.isBareAlias) continue;
2446
+ if (route.isBareAlias || route.searchable === false) continue;
2379
2447
  const code = route.locale ?? defaultLocale ?? "en";
2380
2448
  if (!seen.has(code)) {
2381
2449
  seen.add(code);
@@ -3005,7 +3073,7 @@ async function generateDevSearchIndex(ctx, root, pagefind) {
3005
3073
  try {
3006
3074
  let pageCount = 0;
3007
3075
  for (const route of ctx.routes) {
3008
- if (route.isBareAlias) continue;
3076
+ if (route.isBareAlias || route.searchable === false) continue;
3009
3077
  const content = routeSearchContent(route);
3010
3078
  if (!content.trim()) continue;
3011
3079
  const result = await index.addCustomRecord({
@@ -3465,6 +3533,38 @@ function handleRouteConflicts(routes, development) {
3465
3533
  assertNoRouteConflicts(routes);
3466
3534
  return routes;
3467
3535
  }
3536
+ function unsearchablePaths(navigation) {
3537
+ const paths = /* @__PURE__ */ new Set();
3538
+ const visit = (nodes, inherited = true) => {
3539
+ for (const node of nodes) {
3540
+ const searchable = inherited && node.searchable !== false;
3541
+ if (!searchable) paths.add(node.path);
3542
+ visit(node.children ?? [], searchable);
3543
+ }
3544
+ };
3545
+ switch (navigation.kind) {
3546
+ case "flat":
3547
+ visit(navigation.nodes);
3548
+ break;
3549
+ case "tabbed":
3550
+ navigation.tabs.forEach((tab) => visit(tab.children));
3551
+ break;
3552
+ case "localized":
3553
+ Object.values(navigation.locales).forEach((nodes) => visit(nodes));
3554
+ break;
3555
+ case "localized-tabbed":
3556
+ Object.values(navigation.locales).forEach((locale) => locale.tabs.forEach((tab) => visit(tab.children)));
3557
+ break;
3558
+ }
3559
+ return paths;
3560
+ }
3561
+ function applySearchability(routes, navigation) {
3562
+ const excludedPaths = unsearchablePaths(navigation);
3563
+ return routes.map((route) => excludedPaths.has(route.path) ? {
3564
+ ...route,
3565
+ searchable: false
3566
+ } : route);
3567
+ }
3468
3568
  async function resolveRouteState(routes, plugins, ctx, development) {
3469
3569
  const tabs = ctx.projectConfig.navigation?.tabs;
3470
3570
  const configuredRoutes = applyConfiguredPageRoutePaths(routes, tabs, ctx.projectConfig.locales);
@@ -3472,10 +3572,11 @@ async function resolveRouteState(routes, plugins, ctx, development) {
3472
3572
  routes: configuredRoutes,
3473
3573
  navigation: buildNavigationTree(configuredRoutes, ctx)
3474
3574
  }, ctx);
3475
- const finalRoutes = handleRouteConflicts(resolved.routes, development);
3575
+ const conflictRoutes = handleRouteConflicts(resolved.routes, development);
3576
+ const finalNavigation = conflictRoutes === resolved.routes ? resolved.navigation : buildNavigationTree(conflictRoutes, ctx);
3476
3577
  return {
3477
- routes: finalRoutes,
3478
- navigation: finalRoutes === resolved.routes ? resolved.navigation : buildNavigationTree(finalRoutes, ctx)
3578
+ routes: applySearchability(conflictRoutes, finalNavigation),
3579
+ navigation: finalNavigation
3479
3580
  };
3480
3581
  }
3481
3582
  //#endregion
@@ -3587,7 +3688,7 @@ function injectSSRIntoTemplate(template, appHtml, contextOrConfig, route) {
3587
3688
  html = setNamedMeta(html, "description", route?.meta.description ?? projectConfig.description);
3588
3689
  html = setNamedMeta(html, "keywords", route?.meta.keywords?.join(", "));
3589
3690
  html = injectCanonicalUrl(html, contextOrConfig, route);
3590
- const dataPagefindIgnore = route?.isBareAlias ? " data-pagefind-ignore" : "";
3691
+ const dataPagefindIgnore = route?.isBareAlias || route?.searchable === false ? " data-pagefind-ignore" : "";
3591
3692
  html = html.replace(/<div id="root">([\s\S]*?)<\/div>/, `<div id="root"${dataPagefindIgnore}>${appHtml}</div>`);
3592
3693
  return html;
3593
3694
  }
@@ -4096,7 +4197,7 @@ var ClarifyEngine = class {
4096
4197
  assertNoContentDiagnostics(this.routes);
4097
4198
  const outputDir = this.runtime.outputDirectory ?? this.generateOptions.outputDirectory;
4098
4199
  if (!outputDir) throw new Error("[clarify] outputDirectory is required before SSG runs");
4099
- const ssrOutputDir = (0, node_path.join)(outputDir, ".ssr");
4200
+ const ssrOutputDir = createClarifyTempDir("ssr-output");
4100
4201
  let tempEntryPath;
4101
4202
  try {
4102
4203
  tempEntryPath = createTempEntryFile(SSR_ENTRY_CODE);
@@ -4112,6 +4213,7 @@ var ClarifyEngine = class {
4112
4213
  console.error("[clarify] SSG failed:", err);
4113
4214
  throw err;
4114
4215
  } finally {
4216
+ removeClarifyTempDir(ssrOutputDir);
4115
4217
  if (tempEntryPath) try {
4116
4218
  (0, node_fs.rmSync)(tempEntryPath, { force: true });
4117
4219
  } catch {}
@@ -4219,4 +4321,4 @@ Object.defineProperty(exports, "searchMcpIndex", {
4219
4321
  }
4220
4322
  });
4221
4323
 
4222
- //# sourceMappingURL=engine-BzxBO-E9.cjs.map
4324
+ //# sourceMappingURL=engine--f7G04zS.cjs.map