@clarify-labs/cli 0.11.7 → 0.11.9

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-BbQJ97Ed.cjs");
2
+ const require_engine = require("./engine-Bupsozys.cjs");
3
3
  let node_path = require("node:path");
4
4
  let node_fs_promises = require("node:fs/promises");
5
5
  let node_fs = require("node:fs");
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-Cc7Ve6o-.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-CdH3JL_y.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 { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
@@ -119,6 +119,12 @@ export declare const clarifyProjectConfigSchema: z.ZodObject<{
119
119
  maxWidth: z.ZodOptional<z.ZodString>;
120
120
  }, z.core.$strict>>;
121
121
  }, z.core.$strict>>;
122
+ layout: z.ZodOptional<z.ZodObject<{
123
+ tabs: z.ZodOptional<z.ZodEnum<{
124
+ subnav: "subnav";
125
+ navbar: "navbar";
126
+ }>>;
127
+ }, z.core.$strict>>;
122
128
  navigation: z.ZodOptional<z.ZodObject<{
123
129
  links: z.ZodOptional<z.ZodArray<z.ZodObject<{
124
130
  label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
@@ -4,7 +4,7 @@ export { injectSSRIntoTemplate } from './html-template.js';
4
4
  export declare function readIndexHtml(outputDirectory: string): string | undefined;
5
5
  export declare function isNotFoundRoute(route: ContentRoute): boolean;
6
6
  export declare function routeOutputFiles(outputDirectory: string, route: ContentRoute): string[];
7
- export declare const SSR_ENTRY_CODE = "import { renderToHTML } from '@clarify-labs/renderer/server';\nimport { routes, navigation } from 'virtual:clarify/routes/server';\nimport { config } from 'virtual:clarify/config';\nimport { openApiSpecs } from 'virtual:clarify/openapi/server';\nimport { runtimeSlots } from 'virtual:clarify/slots';\n\nexport async function render(url) {\n // Pre-resolve every slot component factory so renderToString can use\n // them synchronously (renderToString has no Suspense support).\n const entries = Object.values(runtimeSlots).flat()\n await Promise.all(entries.map(async (entry) => {\n const mod = await entry.loadComponent()\n entry._resolved = mod.default\n }))\n return renderToHTML({ config, routes, navigation, openApiSpecs, runtimeSlots, url, themeEditor: config.theme.editor });\n}";
7
+ export declare const SSR_ENTRY_CODE = "import { renderToHTML } from '@clarify-labs/renderer/server';\nimport { routes, navigation } from 'virtual:clarify/routes/server';\nimport { config, runtime } from 'virtual:clarify/config';\nimport { openApiSpecs } from 'virtual:clarify/openapi/server';\nimport { runtimeSlots } from 'virtual:clarify/slots';\n\nexport async function render(url) {\n // Pre-resolve every slot component factory so renderToString can use\n // them synchronously (renderToString has no Suspense support).\n const entries = Object.values(runtimeSlots).flat()\n await Promise.all(entries.map(async (entry) => {\n const mod = await entry.loadComponent()\n entry._resolved = mod.default\n }))\n return renderToHTML({ config, routes, navigation, openApiSpecs, runtimeSlots, url, themeEditor: runtime.themeEditor });\n}";
8
8
  export declare function createTempEntryFile(content: string): string;
9
9
  export declare function buildSSRBundle(root: string, ssrEntry: string, ssrOutDir: string, plugins: Plugin[]): Promise<void>;
10
10
  export declare function renderSSGRoutes(routes: ContentRoute[], contextOrConfig: ClarifyProjectContext | ResolvedProjectConfig, outputDirectory: string, ssrBundlePath: string): Promise<void>;
@@ -13,9 +13,6 @@ type BuildVirtualModulesArgs = {
13
13
  navigation: NavigationTree;
14
14
  themeEditor?: boolean;
15
15
  };
16
- type CreateClientEntryModuleOptions = {
17
- themeEditor?: boolean;
18
- };
19
16
  export declare function resolveVirtualId(id: string): string;
20
17
  export declare function stripVirtualPrefix(id: string): string;
21
18
  export declare function virtualContentModuleId(route: MarkdownContentRoute): string;
@@ -28,9 +25,9 @@ export declare function virtualContentModuleId(route: MarkdownContentRoute): str
28
25
  * if the ID is not a Clarify virtual module.
29
26
  */
30
27
  export declare function resolveVirtualModuleId(id: string, modules: VirtualModules, routes: readonly ContentRoute[]): string | null;
31
- export declare function generateConfigModule(projectConfig: ResolvedProjectConfig, version?: string): string;
28
+ export declare function generateConfigModule(projectConfig: ResolvedProjectConfig, version?: string, themeEditor?: boolean): string;
32
29
  export declare function generateRoutesModule(routes: ContentRoute[], navigation: NavigationTree, mode?: 'client' | 'server'): string;
33
- export declare function createClientEntryModule(options?: CreateClientEntryModuleOptions): string;
30
+ export declare function createClientEntryModule(): string;
34
31
  /**
35
32
  * Collect every plugin's `slots` declarations into a single runtime registry
36
33
  * module. Component modules are exported as lazy import factories so the
@@ -1014,6 +1014,22 @@ var clarifyVariableValueSchema = zod.z.lazy(() => zod.z.union([
1014
1014
  zod.z.record(zod.z.string(), clarifyVariableValueSchema)
1015
1015
  ]));
1016
1016
  var clarifyVariablesConfigSchema = zod.z.record(zod.z.string(), clarifyVariableValueSchema);
1017
+ var clarifySiteUrlSchema = zod.z.string().superRefine((value, ctx) => {
1018
+ let url;
1019
+ try {
1020
+ url = new URL(value);
1021
+ } catch {
1022
+ ctx.addIssue({
1023
+ code: zod.z.ZodIssueCode.custom,
1024
+ message: "must be an absolute HTTP(S) origin"
1025
+ });
1026
+ return;
1027
+ }
1028
+ if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.pathname !== "/" || url.search || url.hash) ctx.addIssue({
1029
+ code: zod.z.ZodIssueCode.custom,
1030
+ message: "must be an HTTP(S) origin without a path, query, or hash; configure deployment subpaths with routePrefix"
1031
+ });
1032
+ });
1017
1033
  var clarifyRepositoryConfigSchema = zod.z.object({
1018
1034
  url: zod.z.string().optional(),
1019
1035
  branch: zod.z.string().optional(),
@@ -1081,6 +1097,7 @@ var clarifyThemeConfigSchema = zod.z.object({
1081
1097
  tokens: clarifyThemeTokensConfigSchema.optional(),
1082
1098
  layout: clarifyThemeLayoutConfigSchema.optional()
1083
1099
  }).strict();
1100
+ var clarifyLayoutConfigSchema = zod.z.object({ tabs: zod.z.enum(["subnav", "navbar"]).optional() }).strict();
1084
1101
  function featureSchema(shape, defaults, enabledByDefault = true) {
1085
1102
  const resolvedDefaults = {
1086
1103
  enabled: enabledByDefault,
@@ -1104,13 +1121,14 @@ var clarifyFeaturesConfigSchema = zod.z.object({
1104
1121
  var clarifyProjectConfigSchema = zod.z.object({
1105
1122
  title: zod.z.string().optional(),
1106
1123
  description: zod.z.string().optional(),
1107
- siteUrl: zod.z.string().optional(),
1124
+ siteUrl: clarifySiteUrlSchema.optional(),
1108
1125
  routePrefix: zod.z.string().default("/"),
1109
1126
  assetPrefix: zod.z.string().optional(),
1110
1127
  logo: clarifyLogoConfigSchema.optional(),
1111
1128
  homeUrl: zod.z.string().optional(),
1112
1129
  favicon: clarifyFaviconConfigSchema.optional(),
1113
1130
  theme: clarifyThemeConfigSchema.optional(),
1131
+ layout: clarifyLayoutConfigSchema.optional(),
1114
1132
  navigation: zod.z.object({
1115
1133
  links: zod.z.array(clarifyNavbarLinkSchema).optional(),
1116
1134
  tabs: clarifyTabsConfigSchema.optional()
@@ -1182,6 +1200,7 @@ function resolveProjectConfig(config = {}) {
1182
1200
  homeUrl: config.homeUrl,
1183
1201
  favicon: config.favicon,
1184
1202
  theme: resolveThemeConfig(config.theme),
1203
+ layout: { tabs: config.layout?.tabs ?? "subnav" },
1185
1204
  navigation: config.navigation,
1186
1205
  banner: config.banner,
1187
1206
  footer: config.footer,
@@ -1326,7 +1345,7 @@ function resolveVirtualModuleId(id, modules, routes) {
1326
1345
  if (route) return resolveVirtualId(route.module.pageVirtualModuleId);
1327
1346
  return null;
1328
1347
  }
1329
- function generateConfigModule(projectConfig, version) {
1348
+ function generateConfigModule(projectConfig, version, themeEditor = false) {
1330
1349
  const runtimeConfig = {
1331
1350
  title: projectConfig.title,
1332
1351
  description: projectConfig.description,
@@ -1337,6 +1356,7 @@ function generateConfigModule(projectConfig, version) {
1337
1356
  homeUrl: projectConfig.homeUrl,
1338
1357
  favicon: projectConfig.favicon,
1339
1358
  theme: projectConfig.theme,
1359
+ layout: projectConfig.layout,
1340
1360
  navigation: projectConfig.navigation,
1341
1361
  banner: projectConfig.banner,
1342
1362
  footer: projectConfig.footer,
@@ -1345,7 +1365,7 @@ function generateConfigModule(projectConfig, version) {
1345
1365
  features: projectConfig.features
1346
1366
  };
1347
1367
  if (version) runtimeConfig.version = version;
1348
- return `export const config = ${JSON.stringify(runtimeConfig)};`;
1368
+ return `export const config = ${JSON.stringify(runtimeConfig)};\nexport const runtime = ${JSON.stringify({ themeEditor })};`;
1349
1369
  }
1350
1370
  function moduleSpecifier(value) {
1351
1371
  return JSON.stringify(value);
@@ -1384,15 +1404,15 @@ function generateRoutesModule(routes, navigation, mode = "client") {
1384
1404
  return ` ${JSON.stringify(manifestEntry, null, 0).replace(`"${placeholder}"`, component).replace(/"([A-Za-z_$][\w$]*)":/g, "$1: ")}`;
1385
1405
  }).join(",\n")}\n];\n\nexport const navigation = ${JSON.stringify(navigation, null, 2)};\n`;
1386
1406
  }
1387
- function createClientEntryModule(options = {}) {
1407
+ function createClientEntryModule() {
1388
1408
  return `
1389
1409
  import '@clarify-labs/renderer/style.css';
1390
1410
  import { render } from '@clarify-labs/renderer/client';
1391
1411
  import { routes, navigation } from '${VIRTUAL_ROUTES}';
1392
- import { config } from '${VIRTUAL_CONFIG}';
1412
+ import { config, runtime } from '${VIRTUAL_CONFIG}';
1393
1413
  import { openApiSpecs } from '${VIRTUAL_OPENAPI}';
1394
1414
  import { runtimeSlots } from '${VIRTUAL_SLOTS}';
1395
- const renderOptions = { config, routes, navigation, openApiSpecs, runtimeSlots, themeEditor: ${JSON.stringify(options.themeEditor ?? false)} };
1415
+ const renderOptions = { config, routes, navigation, openApiSpecs, runtimeSlots, themeEditor: runtime.themeEditor };
1396
1416
  render(renderOptions);
1397
1417
  if (import.meta.hot) {
1398
1418
  import.meta.hot.accept('${VIRTUAL_ROUTES}', (mod) => {
@@ -1444,9 +1464,9 @@ export default createContentDiagnosticComponent(contentDiagnostic);
1444
1464
  }
1445
1465
  function buildVirtualModules(args) {
1446
1466
  const modules = /* @__PURE__ */ new Map();
1447
- const clientEntryModule = createClientEntryModule({ themeEditor: args.themeEditor });
1467
+ const clientEntryModule = createClientEntryModule();
1448
1468
  const allPlugins = [...args.plugins ?? []];
1449
- modules.set(VIRTUAL_CONFIG, generateConfigModule(args.projectConfig, args.version));
1469
+ modules.set(VIRTUAL_CONFIG, generateConfigModule(args.projectConfig, args.version, args.themeEditor));
1450
1470
  modules.set(VIRTUAL_ROUTES, generateRoutesModule(args.routes, args.navigation, "client"));
1451
1471
  modules.set(VIRTUAL_SERVER_ROUTES, generateRoutesModule(args.routes, args.navigation, "server"));
1452
1472
  modules.set(VIRTUAL_SLOTS, createRuntimeSlotsModule(allPlugins, args.generateOptions.projectRoot));
@@ -1691,7 +1711,7 @@ function createViteAdapter(engine) {
1691
1711
  }
1692
1712
  var cliPackageVersion = {
1693
1713
  name: "@clarify-labs/cli",
1694
- version: "0.11.7",
1714
+ version: "0.11.9",
1695
1715
  license: "AGPL-3.0-only",
1696
1716
  type: "module",
1697
1717
  repository: {
@@ -1899,7 +1919,8 @@ function normalizeRoutePrefix$1(routePrefix) {
1899
1919
  function resolveContentArtifactPath(url, projectConfig) {
1900
1920
  const requestPath = url?.split("?")[0] ?? "";
1901
1921
  const basePath = normalizeRoutePrefix$1(projectConfig.routePrefix);
1902
- return basePath && requestPath.startsWith(basePath) ? requestPath.slice(basePath.length) || "/" : requestPath;
1922
+ const hasBasePath = requestPath === basePath || requestPath.startsWith(`${basePath}/`);
1923
+ return basePath && hasBasePath ? requestPath.slice(basePath.length) || "/" : requestPath;
1903
1924
  }
1904
1925
  function resolveContentArtifactType(route) {
1905
1926
  return route.kind === "openapi" ? "application/json; charset=utf-8" : "text/markdown; charset=utf-8";
@@ -2799,15 +2820,16 @@ function createOpenAPIPlugin() {
2799
2820
  return {
2800
2821
  name: "clarify:openapi",
2801
2822
  hooks: {
2802
- "routes:discover": (input, ctx) => ({
2823
+ "routes:discover": (input, ctx) => ctx.projectConfig.features.openapi.enabled ? {
2803
2824
  ...input,
2804
2825
  routes: [...input.routes, ...discoverOpenAPIRoutes(input.contentRoot, ctx.projectConfig.locales)]
2805
- }),
2826
+ } : input,
2806
2827
  "routes:discovered": async (routes, ctx) => {
2828
+ if (!ctx.projectConfig.features.openapi.enabled) return state.enrichRoutes(routes.filter((route) => route.kind !== "openapi"), ctx);
2807
2829
  const expandedRoutes = expandConfiguredOpenAPIRoutes(routes, ctx.projectConfig);
2808
2830
  return state.enrichRoutes(expandedRoutes, ctx);
2809
2831
  },
2810
- "modules:before": (modules, ctx) => state.contributeModules(modules, ctx.routes)
2832
+ "modules:before": (modules, ctx) => state.contributeModules(modules, ctx.projectConfig.features.openapi.enabled ? ctx.routes : ctx.routes.filter((route) => route.kind !== "openapi"))
2811
2833
  }
2812
2834
  };
2813
2835
  }
@@ -3569,7 +3591,7 @@ function routeOutputFiles(outputDirectory, route) {
3569
3591
  }
3570
3592
  var SSR_ENTRY_CODE = `import { renderToHTML } from '@clarify-labs/renderer/server';
3571
3593
  import { routes, navigation } from 'virtual:clarify/routes/server';
3572
- import { config } from 'virtual:clarify/config';
3594
+ import { config, runtime } from 'virtual:clarify/config';
3573
3595
  import { openApiSpecs } from 'virtual:clarify/openapi/server';
3574
3596
  import { runtimeSlots } from 'virtual:clarify/slots';
3575
3597
 
@@ -3581,7 +3603,7 @@ export async function render(url) {
3581
3603
  const mod = await entry.loadComponent()
3582
3604
  entry._resolved = mod.default
3583
3605
  }))
3584
- return renderToHTML({ config, routes, navigation, openApiSpecs, runtimeSlots, url, themeEditor: config.theme.editor });
3606
+ return renderToHTML({ config, routes, navigation, openApiSpecs, runtimeSlots, url, themeEditor: runtime.themeEditor });
3585
3607
  }`;
3586
3608
  function createTempEntryFile(content) {
3587
3609
  const entryPath = (0, node_path.join)(createClarifyTempDir("ssr"), "entry-server.ts");
@@ -4095,4 +4117,4 @@ Object.defineProperty(exports, "searchMcpIndex", {
4095
4117
  }
4096
4118
  });
4097
4119
 
4098
- //# sourceMappingURL=engine-BbQJ97Ed.cjs.map
4120
+ //# sourceMappingURL=engine-Bupsozys.cjs.map