@clarify-labs/cli 0.1.0 → 0.4.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/output/cli.cjs +29 -4
- package/output/cli.cjs.map +1 -1
- package/output/cli.js +29 -4
- package/output/cli.js.map +1 -1
- package/output/core/config-schema.d.ts +145 -13
- package/output/core/ssg.d.ts +1 -1
- package/output/core/theme.d.ts +52 -0
- package/output/core/virtual-modules.d.ts +3 -2
- package/output/index.cjs +1 -1
- package/output/index.js +1 -1
- package/output/parsers/frontmatter.d.ts +12 -0
- package/output/parsers/routes.d.ts +4 -2
- package/output/parsers/routes.test-utils.d.ts +3 -0
- package/output/{plugin-BUWojlPv.js → plugin-B-_5mQmO.js} +345 -96
- package/output/plugin-B-_5mQmO.js.map +1 -0
- package/output/{plugin-CEyCiD5r.cjs → plugin-BSPUvgb3.cjs} +345 -96
- package/output/plugin-BSPUvgb3.cjs.map +1 -0
- package/output/plugins/content-artifacts/artifacts.d.ts +10 -0
- package/output/plugins/content-artifacts/server.d.ts +1 -1
- package/output/plugins/openapi/parser.d.ts +9 -2
- package/output/plugins/openapi/virtual-modules.d.ts +2 -1
- package/output/types.d.ts +91 -16
- package/package.json +7 -2
- package/output/plugin-BUWojlPv.js.map +0 -1
- package/output/plugin-CEyCiD5r.cjs.map +0 -1
- package/output/plugins/content-artifacts/raw-content.d.ts +0 -8
package/output/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_plugin = require("./plugin-
|
|
2
|
+
const require_plugin = require("./plugin-BSPUvgb3.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
let node_url = require("node:url");
|
|
@@ -60,7 +60,32 @@ async function createViteConfig(options, env) {
|
|
|
60
60
|
},
|
|
61
61
|
build: {
|
|
62
62
|
outDir: options.output,
|
|
63
|
-
|
|
63
|
+
rolldownOptions: {
|
|
64
|
+
input: { index: entryHtmlPath },
|
|
65
|
+
checks: { pluginTimings: false },
|
|
66
|
+
output: { codeSplitting: { groups: [
|
|
67
|
+
{
|
|
68
|
+
name: "react-vendor",
|
|
69
|
+
test: /node_modules[\\/](react|react-dom|react-router|react-router-dom)[\\/]/,
|
|
70
|
+
priority: 40
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "icons-vendor",
|
|
74
|
+
test: /node_modules[\\/]lucide-react[\\/]/,
|
|
75
|
+
priority: 35
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "ui-vendor",
|
|
79
|
+
test: /node_modules[\\/](@headlessui|framer-motion)[\\/]/,
|
|
80
|
+
priority: 30
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "vendor",
|
|
84
|
+
test: /node_modules[\\/]/,
|
|
85
|
+
priority: 10
|
|
86
|
+
}
|
|
87
|
+
] } }
|
|
88
|
+
}
|
|
64
89
|
}
|
|
65
90
|
};
|
|
66
91
|
}
|
|
@@ -99,7 +124,7 @@ function updatePackageJson(root, force) {
|
|
|
99
124
|
if (force || !scripts.build) scripts.build = "clarify build";
|
|
100
125
|
packageJson.scripts = scripts;
|
|
101
126
|
const devDependencies = typeof packageJson.devDependencies === "object" && packageJson.devDependencies !== null ? packageJson.devDependencies : {};
|
|
102
|
-
if (!devDependencies["@clarify-labs/cli"]) devDependencies["@clarify-labs/cli"] = "^0.
|
|
127
|
+
if (!devDependencies["@clarify-labs/cli"]) devDependencies["@clarify-labs/cli"] = "^0.2.0";
|
|
103
128
|
packageJson.devDependencies = devDependencies;
|
|
104
129
|
(0, node_fs.writeFileSync)(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, "utf-8");
|
|
105
130
|
return true;
|
|
@@ -112,7 +137,7 @@ function runInit(options, force) {
|
|
|
112
137
|
export default defineConfig({
|
|
113
138
|
title: 'Clarify Docs',
|
|
114
139
|
description: 'Documentation powered by Clarify',
|
|
115
|
-
theme: {
|
|
140
|
+
theme: { preset: 'default' },
|
|
116
141
|
})
|
|
117
142
|
`, force) ? created : skipped).push("clarify.ts");
|
|
118
143
|
(writeTextFile((0, node_path.resolve)(options.root, options.content, "index.mdx"), `---
|
package/output/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","names":[],"sources":["../source/core/vite-config.ts","../source/cli/commands/build.ts","../source/cli/commands/dev.ts","../source/cli/commands/init.ts","../source/cli/options.ts","../source/cli/package.ts","../source/cli/index.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\n\nimport type { ConfigEnv, InlineConfig, Plugin } from 'vite'\n\nimport type { ClarifyBuildOptions } from './options.js'\nimport { clarifyPlugin } from './plugin.js'\nimport { createClarifyRuntimeAliases } from './runtime-deps.js'\nimport { loadClarifyConfig } from './user-config.js'\n\nexport type ClarifyViteConfigOptions = {\n root: string\n content: string\n output: string\n host?: string | boolean\n port?: number\n open?: boolean | string\n}\n\nconst DEFAULT_HTML = '<!doctype html><html lang=\"en\"><head><meta charset=\"UTF-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /><title>Clarify</title></head><body><div id=\"root\"></div></body></html>'\n\nfunction ensureHtmlEntry(root: string): string {\n const projectHtmlPath = resolve(root, 'index.html')\n if (existsSync(projectHtmlPath)) return projectHtmlPath\n\n const generatedHtmlPath = resolve(root, '.clarify/index.html')\n mkdirSync(dirname(generatedHtmlPath), { recursive: true })\n writeFileSync(generatedHtmlPath, DEFAULT_HTML, 'utf-8')\n return generatedHtmlPath\n}\n\nfunction createHtmlFallbackPlugin(): Plugin {\n return {\n name: 'clarify:cli-html-fallback',\n configureServer(server) {\n server.middlewares.use(async (req, res, next) => {\n const requestPath = req.url?.split('?')[0] ?? '/'\n const acceptsHtml = req.headers.accept?.includes('text/html') ?? false\n const hasFileExtension = /\\.[^/]+$/.test(requestPath)\n if (!acceptsHtml || hasFileExtension) {\n next()\n return\n }\n\n try {\n const html = await server.transformIndexHtml(requestPath, DEFAULT_HTML)\n res.statusCode = 200\n res.setHeader('Content-Type', 'text/html; charset=utf-8')\n res.end(html)\n } catch (error) {\n next(error)\n }\n })\n },\n }\n}\n\nexport async function createViteConfig(options: ClarifyViteConfigOptions, env: ConfigEnv): Promise<InlineConfig> {\n const entryHtmlPath = ensureHtmlEntry(options.root)\n const userConfig = await loadClarifyConfig(options.root, env)\n const buildOptions: ClarifyBuildOptions = {\n ...userConfig,\n projectRoot: options.root,\n rootDirectory: options.content,\n outputDirectory: options.output,\n }\n\n return {\n root: options.root,\n configFile: false,\n appType: 'custom',\n resolve: {\n alias: createClarifyRuntimeAliases(),\n },\n plugins: [\n clarifyPlugin(buildOptions),\n createHtmlFallbackPlugin(),\n ],\n server: {\n host: options.host,\n port: options.port,\n open: options.open,\n },\n build: {\n outDir: options.output,\n rollupOptions: {\n input: {\n index: entryHtmlPath,\n },\n },\n },\n }\n}\n","import { build as viteBuild } from 'vite'\n\nimport { createViteConfig } from '../../core/vite-config.js'\nimport type { ResolvedCliOptions } from '../options.js'\n\nexport async function runBuild(options: ResolvedCliOptions): Promise<void> {\n await viteBuild(await createViteConfig(options, { command: 'build', mode: 'production' }))\n}\n","import { createServer } from 'vite'\n\nimport { createViteConfig } from '../../core/vite-config.js'\nimport type { ResolvedCliOptions } from '../options.js'\n\nexport async function runDev(options: ResolvedCliOptions): Promise<void> {\n const server = await createServer(await createViteConfig(options, { command: 'serve', mode: 'development' }))\n await server.listen()\n server.printUrls()\n server.bindCLIShortcuts({ print: true })\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\n\nimport type { ResolvedCliOptions } from '../options.js'\n\nfunction writeTextFile(filePath: string, content: string, force: boolean): boolean {\n if (existsSync(filePath) && !force) return false\n mkdirSync(dirname(filePath), { recursive: true })\n writeFileSync(filePath, content, 'utf-8')\n return true\n}\n\nfunction updatePackageJson(root: string, force: boolean): boolean {\n const packageJsonPath = resolve(root, 'package.json')\n const packageJson = existsSync(packageJsonPath)\n ? JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as Record<string, unknown>\n : { type: 'module' }\n\n const scripts = typeof packageJson.scripts === 'object' && packageJson.scripts !== null\n ? packageJson.scripts as Record<string, string>\n : {}\n\n if (force || !scripts.dev) scripts.dev = 'clarify dev'\n if (force || !scripts.build) scripts.build = 'clarify build'\n packageJson.scripts = scripts\n\n const devDependencies = typeof packageJson.devDependencies === 'object' && packageJson.devDependencies !== null\n ? packageJson.devDependencies as Record<string, string>\n : {}\n if (!devDependencies['@clarify-labs/cli']) devDependencies['@clarify-labs/cli'] = '^0.1.0'\n packageJson.devDependencies = devDependencies\n\n writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\\n`, 'utf-8')\n return true\n}\n\nexport function runInit(options: ResolvedCliOptions, force: boolean): void {\n const created: string[] = []\n const skipped: string[] = []\n\n const clarifyConfigCreated = writeTextFile(resolve(options.root, 'clarify.ts'), `import { defineConfig } from '@clarify-labs/cli'\n\nexport default defineConfig({\n title: 'Clarify Docs',\n description: 'Documentation powered by Clarify',\n theme: { primary: '#0ea5e9' },\n})\n`, force)\n ;(clarifyConfigCreated ? created : skipped).push('clarify.ts')\n\n const contentCreated = writeTextFile(resolve(options.root, options.content, 'index.mdx'), `---\ntitle: Welcome\n---\n\n# Welcome to Clarify\n\nStart writing your documentation in \\`${options.content}\\`.\n`, force)\n ;(contentCreated ? created : skipped).push(`${options.content}/index.mdx`)\n\n const packageJsonUpdated = updatePackageJson(options.root, force)\n if (packageJsonUpdated) created.push('package.json')\n\n console.log('[clarify] Init complete.')\n if (created.length > 0) console.log(`[clarify] Created or updated: ${created.join(', ')}`)\n if (skipped.length > 0) console.log(`[clarify] Skipped existing files: ${skipped.join(', ')}. Use --force to overwrite.`)\n}\n","import { resolve } from 'node:path'\n\nexport type CliOptions = {\n root?: string\n content?: string\n output?: string\n host?: string | boolean\n port?: string | number\n open?: boolean | string\n}\n\nexport type ResolvedCliOptions = {\n root: string\n content: string\n output: string\n host?: string | boolean\n port?: number\n open?: boolean | string\n}\n\nexport function resolveCliOptions(options: CliOptions): ResolvedCliOptions {\n return {\n root: resolve(options.root ?? process.cwd()),\n content: options.content ?? 'source',\n output: options.output ?? 'output',\n host: options.host,\n port: typeof options.port === 'string' ? Number.parseInt(options.port, 10) : options.port,\n open: options.open,\n }\n}\n","import { readFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nexport function readPackageVersion(): string {\n try {\n const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../package.json')\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as { version?: string }\n return packageJson.version ?? '0.0.0'\n } catch {\n return '0.0.0'\n }\n}\n","#!/usr/bin/env node\nimport { cac } from 'cac'\n\nimport { runBuild } from './commands/build.js'\nimport { runDev } from './commands/dev.js'\nimport { runInit } from './commands/init.js'\nimport { resolveCliOptions, type CliOptions, type ResolvedCliOptions } from './options.js'\nimport { readPackageVersion } from './package.js'\n\nfunction withSharedOptions(command: ReturnType<ReturnType<typeof cac>['command']>) {\n return command\n .option('--root <dir>', 'Project root directory')\n .option('--content <dir>', 'Content directory relative to root')\n .option('--output <dir>', 'Build output directory relative to root')\n}\n\nfunction resolveOptions(options: CliOptions): ResolvedCliOptions {\n return resolveCliOptions(options)\n}\n\nasync function main(): Promise<void> {\n const cli = cac('clarify')\n\n cli\n .version(readPackageVersion())\n .help()\n\n withSharedOptions(cli.command('dev', 'Start the local documentation server'))\n .option('--host [host]', 'Dev server host')\n .option('--port <port>', 'Dev server port')\n .option('--open [path]', 'Open the dev server in a browser')\n .action(async (options: CliOptions) => {\n await runDev(resolveOptions(options))\n })\n\n withSharedOptions(cli.command('build', 'Build the static documentation site'))\n .action(async (options: CliOptions) => {\n await runBuild(resolveOptions(options))\n })\n\n withSharedOptions(cli.command('init', 'Create a minimal Clarify project scaffold'))\n .option('--force', 'Overwrite files created by init')\n .action((options: CliOptions & { force?: boolean }) => {\n runInit(resolveOptions(options), options.force === true)\n })\n\n const args = process.argv.slice(2)\n cli.parse(process.argv, { run: false })\n\n if (args.length === 0) {\n cli.outputHelp()\n return\n }\n\n await cli.runMatchedCommand()\n}\n\nmain().catch(error => {\n console.error(error instanceof Error ? error.message : error)\n process.exitCode = 1\n})\n"],"mappings":";;;;;;;;AAmBA,IAAM,eAAe;AAErB,SAAS,gBAAgB,MAAsB;CAC7C,MAAM,mBAAA,GAAA,UAAA,SAA0B,MAAM,YAAY;CAClD,KAAA,GAAA,QAAA,YAAe,eAAe,GAAG,OAAO;CAExC,MAAM,qBAAA,GAAA,UAAA,SAA4B,MAAM,qBAAqB;CAC7D,CAAA,GAAA,QAAA,YAAA,GAAA,UAAA,SAAkB,iBAAiB,GAAG,EAAE,WAAW,KAAK,CAAC;CACzD,CAAA,GAAA,QAAA,eAAc,mBAAmB,cAAc,OAAO;CACtD,OAAO;AACT;AAEA,SAAS,2BAAmC;CAC1C,OAAO;EACL,MAAM;EACN,gBAAgB,QAAQ;GACtB,OAAO,YAAY,IAAI,OAAO,KAAK,KAAK,SAAS;IAC/C,MAAM,cAAc,IAAI,KAAK,MAAM,GAAG,EAAE,MAAM;IAC9C,MAAM,cAAc,IAAI,QAAQ,QAAQ,SAAS,WAAW,KAAK;IACjE,MAAM,mBAAmB,WAAW,KAAK,WAAW;IACpD,IAAI,CAAC,eAAe,kBAAkB;KACpC,KAAK;KACL;IACF;IAEA,IAAI;KACF,MAAM,OAAO,MAAM,OAAO,mBAAmB,aAAa,YAAY;KACtE,IAAI,aAAa;KACjB,IAAI,UAAU,gBAAgB,0BAA0B;KACxD,IAAI,IAAI,IAAI;IACd,SAAS,OAAO;KACd,KAAK,KAAK;IACZ;GACF,CAAC;EACH;CACF;AACF;AAEA,eAAsB,iBAAiB,SAAmC,KAAuC;CAC/G,MAAM,gBAAgB,gB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EACrD,QAAQ,eAAe,OAAO,GAAG,QAAQ,UAAU,IAAI;CACzD,CAAC;CAEH,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;CACjC,IAAI,MAAM,QAAQ,MAAM,EAAE,KAAK,MAAM,CAAC;CAEtC,IAAI,KAAK,WAAW,GAAG;EACrB,IAAI,WAAW;EACf;CACF;CAEA,MAAM,IAAI,kBAAkB;AAC9B;AAEA,KAAK,EAAE,OAAM,UAAS;CACpB,QAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,KAAK;CAC5D,QAAQ,WAAW;AACrB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.cjs","names":[],"sources":["../source/core/vite-config.ts","../source/cli/commands/build.ts","../source/cli/commands/dev.ts","../source/cli/commands/init.ts","../source/cli/options.ts","../source/cli/package.ts","../source/cli/index.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\n\nimport type { ConfigEnv, InlineConfig, Plugin } from 'vite'\n\nimport type { ClarifyBuildOptions } from './options.js'\nimport { clarifyPlugin } from './plugin.js'\nimport { createClarifyRuntimeAliases } from './runtime-deps.js'\nimport { loadClarifyConfig } from './user-config.js'\n\nexport type ClarifyViteConfigOptions = {\n root: string\n content: string\n output: string\n host?: string | boolean\n port?: number\n open?: boolean | string\n}\n\nconst DEFAULT_HTML = '<!doctype html><html lang=\"en\"><head><meta charset=\"UTF-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /><title>Clarify</title></head><body><div id=\"root\"></div></body></html>'\n\nfunction ensureHtmlEntry(root: string): string {\n const projectHtmlPath = resolve(root, 'index.html')\n if (existsSync(projectHtmlPath)) return projectHtmlPath\n\n const generatedHtmlPath = resolve(root, '.clarify/index.html')\n mkdirSync(dirname(generatedHtmlPath), { recursive: true })\n writeFileSync(generatedHtmlPath, DEFAULT_HTML, 'utf-8')\n return generatedHtmlPath\n}\n\nfunction createHtmlFallbackPlugin(): Plugin {\n return {\n name: 'clarify:cli-html-fallback',\n configureServer(server) {\n server.middlewares.use(async (req, res, next) => {\n const requestPath = req.url?.split('?')[0] ?? '/'\n const acceptsHtml = req.headers.accept?.includes('text/html') ?? false\n const hasFileExtension = /\\.[^/]+$/.test(requestPath)\n if (!acceptsHtml || hasFileExtension) {\n next()\n return\n }\n\n try {\n const html = await server.transformIndexHtml(requestPath, DEFAULT_HTML)\n res.statusCode = 200\n res.setHeader('Content-Type', 'text/html; charset=utf-8')\n res.end(html)\n } catch (error) {\n next(error)\n }\n })\n },\n }\n}\n\nexport async function createViteConfig(options: ClarifyViteConfigOptions, env: ConfigEnv): Promise<InlineConfig> {\n const entryHtmlPath = ensureHtmlEntry(options.root)\n const userConfig = await loadClarifyConfig(options.root, env)\n const buildOptions: ClarifyBuildOptions = {\n ...userConfig,\n projectRoot: options.root,\n rootDirectory: options.content,\n outputDirectory: options.output,\n }\n\n return {\n root: options.root,\n configFile: false,\n appType: 'custom',\n resolve: {\n alias: createClarifyRuntimeAliases(),\n },\n plugins: [\n clarifyPlugin(buildOptions),\n createHtmlFallbackPlugin(),\n ],\n server: {\n host: options.host,\n port: options.port,\n open: options.open,\n },\n build: {\n outDir: options.output,\n rolldownOptions: {\n input: {\n index: entryHtmlPath,\n },\n checks: {\n pluginTimings: false,\n },\n output: {\n codeSplitting: {\n groups: [\n {\n name: 'react-vendor',\n test: /node_modules[\\\\/](react|react-dom|react-router|react-router-dom)[\\\\/]/,\n priority: 40,\n },\n {\n name: 'icons-vendor',\n test: /node_modules[\\\\/]lucide-react[\\\\/]/,\n priority: 35,\n },\n {\n name: 'ui-vendor',\n test: /node_modules[\\\\/](@headlessui|framer-motion)[\\\\/]/,\n priority: 30,\n },\n {\n name: 'vendor',\n test: /node_modules[\\\\/]/,\n priority: 10\n },\n ],\n },\n },\n },\n },\n }\n}\n","import { build as viteBuild } from 'vite'\n\nimport { createViteConfig } from '../../core/vite-config.js'\nimport type { ResolvedCliOptions } from '../options.js'\n\nexport async function runBuild(options: ResolvedCliOptions): Promise<void> {\n await viteBuild(await createViteConfig(options, { command: 'build', mode: 'production' }))\n}\n","import { createServer } from 'vite'\n\nimport { createViteConfig } from '../../core/vite-config.js'\nimport type { ResolvedCliOptions } from '../options.js'\n\nexport async function runDev(options: ResolvedCliOptions): Promise<void> {\n const server = await createServer(await createViteConfig(options, { command: 'serve', mode: 'development' }))\n await server.listen()\n server.printUrls()\n server.bindCLIShortcuts({ print: true })\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\n\nimport type { ResolvedCliOptions } from '../options.js'\n\nfunction writeTextFile(filePath: string, content: string, force: boolean): boolean {\n if (existsSync(filePath) && !force) return false\n mkdirSync(dirname(filePath), { recursive: true })\n writeFileSync(filePath, content, 'utf-8')\n return true\n}\n\nfunction updatePackageJson(root: string, force: boolean): boolean {\n const packageJsonPath = resolve(root, 'package.json')\n const packageJson = existsSync(packageJsonPath)\n ? JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as Record<string, unknown>\n : { type: 'module' }\n\n const scripts = typeof packageJson.scripts === 'object' && packageJson.scripts !== null\n ? packageJson.scripts as Record<string, string>\n : {}\n\n if (force || !scripts.dev) scripts.dev = 'clarify dev'\n if (force || !scripts.build) scripts.build = 'clarify build'\n packageJson.scripts = scripts\n\n const devDependencies = typeof packageJson.devDependencies === 'object' && packageJson.devDependencies !== null\n ? packageJson.devDependencies as Record<string, string>\n : {}\n if (!devDependencies['@clarify-labs/cli']) devDependencies['@clarify-labs/cli'] = '^0.2.0'\n packageJson.devDependencies = devDependencies\n\n writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\\n`, 'utf-8')\n return true\n}\n\nexport function runInit(options: ResolvedCliOptions, force: boolean): void {\n const created: string[] = []\n const skipped: string[] = []\n\n const clarifyConfigCreated = writeTextFile(resolve(options.root, 'clarify.ts'), `import { defineConfig } from '@clarify-labs/cli'\n\nexport default defineConfig({\n title: 'Clarify Docs',\n description: 'Documentation powered by Clarify',\n theme: { preset: 'default' },\n})\n`, force)\n ;(clarifyConfigCreated ? created : skipped).push('clarify.ts')\n\n const contentCreated = writeTextFile(resolve(options.root, options.content, 'index.mdx'), `---\ntitle: Welcome\n---\n\n# Welcome to Clarify\n\nStart writing your documentation in \\`${options.content}\\`.\n`, force)\n ;(contentCreated ? created : skipped).push(`${options.content}/index.mdx`)\n\n const packageJsonUpdated = updatePackageJson(options.root, force)\n if (packageJsonUpdated) created.push('package.json')\n\n console.log('[clarify] Init complete.')\n if (created.length > 0) console.log(`[clarify] Created or updated: ${created.join(', ')}`)\n if (skipped.length > 0) console.log(`[clarify] Skipped existing files: ${skipped.join(', ')}. Use --force to overwrite.`)\n}\n","import { resolve } from 'node:path'\n\nexport type CliOptions = {\n root?: string\n content?: string\n output?: string\n host?: string | boolean\n port?: string | number\n open?: boolean | string\n}\n\nexport type ResolvedCliOptions = {\n root: string\n content: string\n output: string\n host?: string | boolean\n port?: number\n open?: boolean | string\n}\n\nexport function resolveCliOptions(options: CliOptions): ResolvedCliOptions {\n return {\n root: resolve(options.root ?? process.cwd()),\n content: options.content ?? 'source',\n output: options.output ?? 'output',\n host: options.host,\n port: typeof options.port === 'string' ? Number.parseInt(options.port, 10) : options.port,\n open: options.open,\n }\n}\n","import { readFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nexport function readPackageVersion(): string {\n try {\n const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../package.json')\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as { version?: string }\n return packageJson.version ?? '0.0.0'\n } catch {\n return '0.0.0'\n }\n}\n","#!/usr/bin/env node\nimport { cac } from 'cac'\n\nimport { runBuild } from './commands/build.js'\nimport { runDev } from './commands/dev.js'\nimport { runInit } from './commands/init.js'\nimport { resolveCliOptions, type CliOptions, type ResolvedCliOptions } from './options.js'\nimport { readPackageVersion } from './package.js'\n\nfunction withSharedOptions(command: ReturnType<ReturnType<typeof cac>['command']>) {\n return command\n .option('--root <dir>', 'Project root directory')\n .option('--content <dir>', 'Content directory relative to root')\n .option('--output <dir>', 'Build output directory relative to root')\n}\n\nfunction resolveOptions(options: CliOptions): ResolvedCliOptions {\n return resolveCliOptions(options)\n}\n\nasync function main(): Promise<void> {\n const cli = cac('clarify')\n\n cli\n .version(readPackageVersion())\n .help()\n\n withSharedOptions(cli.command('dev', 'Start the local documentation server'))\n .option('--host [host]', 'Dev server host')\n .option('--port <port>', 'Dev server port')\n .option('--open [path]', 'Open the dev server in a browser')\n .action(async (options: CliOptions) => {\n await runDev(resolveOptions(options))\n })\n\n withSharedOptions(cli.command('build', 'Build the static documentation site'))\n .action(async (options: CliOptions) => {\n await runBuild(resolveOptions(options))\n })\n\n withSharedOptions(cli.command('init', 'Create a minimal Clarify project scaffold'))\n .option('--force', 'Overwrite files created by init')\n .action((options: CliOptions & { force?: boolean }) => {\n runInit(resolveOptions(options), options.force === true)\n })\n\n const args = process.argv.slice(2)\n cli.parse(process.argv, { run: false })\n\n if (args.length === 0) {\n cli.outputHelp()\n return\n }\n\n await cli.runMatchedCommand()\n}\n\nmain().catch(error => {\n console.error(error instanceof Error ? error.message : error)\n process.exitCode = 1\n})\n"],"mappings":";;;;;;;;AAmBA,IAAM,eAAe;AAErB,SAAS,gBAAgB,MAAsB;CAC7C,MAAM,mBAAA,GAAA,UAAA,SAA0B,MAAM,YAAY;CAClD,KAAA,GAAA,QAAA,YAAe,eAAe,GAAG,OAAO;CAExC,MAAM,qBAAA,GAAA,UAAA,SAA4B,MAAM,qBAAqB;CAC7D,CAAA,GAAA,QAAA,YAAA,GAAA,UAAA,SAAkB,iBAAiB,GAAG,EAAE,WAAW,KAAK,CAAC;CACzD,CAAA,GAAA,QAAA,eAAc,mBAAmB,cAAc,OAAO;CACtD,OAAO;AACT;AAEA,SAAS,2BAAmC;CAC1C,OAAO;EACL,MAAM;EACN,gBAAgB,QAAQ;GAC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ifyRuntimeAliases, r as loadClarifyConfig, t as clarifyPlugin } from "./plugin-
|
|
2
|
+
import { i as createClarifyRuntimeAliases, r as loadClarifyConfig, t as clarifyPlugin } from "./plugin-B-_5mQmO.js";
|
|
3
3
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { dirname, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
@@ -60,7 +60,32 @@ async function createViteConfig(options, env) {
|
|
|
60
60
|
},
|
|
61
61
|
build: {
|
|
62
62
|
outDir: options.output,
|
|
63
|
-
|
|
63
|
+
rolldownOptions: {
|
|
64
|
+
input: { index: entryHtmlPath },
|
|
65
|
+
checks: { pluginTimings: false },
|
|
66
|
+
output: { codeSplitting: { groups: [
|
|
67
|
+
{
|
|
68
|
+
name: "react-vendor",
|
|
69
|
+
test: /node_modules[\\/](react|react-dom|react-router|react-router-dom)[\\/]/,
|
|
70
|
+
priority: 40
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "icons-vendor",
|
|
74
|
+
test: /node_modules[\\/]lucide-react[\\/]/,
|
|
75
|
+
priority: 35
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "ui-vendor",
|
|
79
|
+
test: /node_modules[\\/](@headlessui|framer-motion)[\\/]/,
|
|
80
|
+
priority: 30
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "vendor",
|
|
84
|
+
test: /node_modules[\\/]/,
|
|
85
|
+
priority: 10
|
|
86
|
+
}
|
|
87
|
+
] } }
|
|
88
|
+
}
|
|
64
89
|
}
|
|
65
90
|
};
|
|
66
91
|
}
|
|
@@ -99,7 +124,7 @@ function updatePackageJson(root, force) {
|
|
|
99
124
|
if (force || !scripts.build) scripts.build = "clarify build";
|
|
100
125
|
packageJson.scripts = scripts;
|
|
101
126
|
const devDependencies = typeof packageJson.devDependencies === "object" && packageJson.devDependencies !== null ? packageJson.devDependencies : {};
|
|
102
|
-
if (!devDependencies["@clarify-labs/cli"]) devDependencies["@clarify-labs/cli"] = "^0.
|
|
127
|
+
if (!devDependencies["@clarify-labs/cli"]) devDependencies["@clarify-labs/cli"] = "^0.2.0";
|
|
103
128
|
packageJson.devDependencies = devDependencies;
|
|
104
129
|
writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, "utf-8");
|
|
105
130
|
return true;
|
|
@@ -112,7 +137,7 @@ function runInit(options, force) {
|
|
|
112
137
|
export default defineConfig({
|
|
113
138
|
title: 'Clarify Docs',
|
|
114
139
|
description: 'Documentation powered by Clarify',
|
|
115
|
-
theme: {
|
|
140
|
+
theme: { preset: 'default' },
|
|
116
141
|
})
|
|
117
142
|
`, force) ? created : skipped).push("clarify.ts");
|
|
118
143
|
(writeTextFile(resolve(options.root, options.content, "index.mdx"), `---
|
package/output/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../source/core/vite-config.ts","../source/cli/commands/build.ts","../source/cli/commands/dev.ts","../source/cli/commands/init.ts","../source/cli/options.ts","../source/cli/package.ts","../source/cli/index.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\n\nimport type { ConfigEnv, InlineConfig, Plugin } from 'vite'\n\nimport type { ClarifyBuildOptions } from './options.js'\nimport { clarifyPlugin } from './plugin.js'\nimport { createClarifyRuntimeAliases } from './runtime-deps.js'\nimport { loadClarifyConfig } from './user-config.js'\n\nexport type ClarifyViteConfigOptions = {\n root: string\n content: string\n output: string\n host?: string | boolean\n port?: number\n open?: boolean | string\n}\n\nconst DEFAULT_HTML = '<!doctype html><html lang=\"en\"><head><meta charset=\"UTF-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /><title>Clarify</title></head><body><div id=\"root\"></div></body></html>'\n\nfunction ensureHtmlEntry(root: string): string {\n const projectHtmlPath = resolve(root, 'index.html')\n if (existsSync(projectHtmlPath)) return projectHtmlPath\n\n const generatedHtmlPath = resolve(root, '.clarify/index.html')\n mkdirSync(dirname(generatedHtmlPath), { recursive: true })\n writeFileSync(generatedHtmlPath, DEFAULT_HTML, 'utf-8')\n return generatedHtmlPath\n}\n\nfunction createHtmlFallbackPlugin(): Plugin {\n return {\n name: 'clarify:cli-html-fallback',\n configureServer(server) {\n server.middlewares.use(async (req, res, next) => {\n const requestPath = req.url?.split('?')[0] ?? '/'\n const acceptsHtml = req.headers.accept?.includes('text/html') ?? false\n const hasFileExtension = /\\.[^/]+$/.test(requestPath)\n if (!acceptsHtml || hasFileExtension) {\n next()\n return\n }\n\n try {\n const html = await server.transformIndexHtml(requestPath, DEFAULT_HTML)\n res.statusCode = 200\n res.setHeader('Content-Type', 'text/html; charset=utf-8')\n res.end(html)\n } catch (error) {\n next(error)\n }\n })\n },\n }\n}\n\nexport async function createViteConfig(options: ClarifyViteConfigOptions, env: ConfigEnv): Promise<InlineConfig> {\n const entryHtmlPath = ensureHtmlEntry(options.root)\n const userConfig = await loadClarifyConfig(options.root, env)\n const buildOptions: ClarifyBuildOptions = {\n ...userConfig,\n projectRoot: options.root,\n rootDirectory: options.content,\n outputDirectory: options.output,\n }\n\n return {\n root: options.root,\n configFile: false,\n appType: 'custom',\n resolve: {\n alias: createClarifyRuntimeAliases(),\n },\n plugins: [\n clarifyPlugin(buildOptions),\n createHtmlFallbackPlugin(),\n ],\n server: {\n host: options.host,\n port: options.port,\n open: options.open,\n },\n build: {\n outDir: options.output,\n rollupOptions: {\n input: {\n index: entryHtmlPath,\n },\n },\n },\n }\n}\n","import { build as viteBuild } from 'vite'\n\nimport { createViteConfig } from '../../core/vite-config.js'\nimport type { ResolvedCliOptions } from '../options.js'\n\nexport async function runBuild(options: ResolvedCliOptions): Promise<void> {\n await viteBuild(await createViteConfig(options, { command: 'build', mode: 'production' }))\n}\n","import { createServer } from 'vite'\n\nimport { createViteConfig } from '../../core/vite-config.js'\nimport type { ResolvedCliOptions } from '../options.js'\n\nexport async function runDev(options: ResolvedCliOptions): Promise<void> {\n const server = await createServer(await createViteConfig(options, { command: 'serve', mode: 'development' }))\n await server.listen()\n server.printUrls()\n server.bindCLIShortcuts({ print: true })\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\n\nimport type { ResolvedCliOptions } from '../options.js'\n\nfunction writeTextFile(filePath: string, content: string, force: boolean): boolean {\n if (existsSync(filePath) && !force) return false\n mkdirSync(dirname(filePath), { recursive: true })\n writeFileSync(filePath, content, 'utf-8')\n return true\n}\n\nfunction updatePackageJson(root: string, force: boolean): boolean {\n const packageJsonPath = resolve(root, 'package.json')\n const packageJson = existsSync(packageJsonPath)\n ? JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as Record<string, unknown>\n : { type: 'module' }\n\n const scripts = typeof packageJson.scripts === 'object' && packageJson.scripts !== null\n ? packageJson.scripts as Record<string, string>\n : {}\n\n if (force || !scripts.dev) scripts.dev = 'clarify dev'\n if (force || !scripts.build) scripts.build = 'clarify build'\n packageJson.scripts = scripts\n\n const devDependencies = typeof packageJson.devDependencies === 'object' && packageJson.devDependencies !== null\n ? packageJson.devDependencies as Record<string, string>\n : {}\n if (!devDependencies['@clarify-labs/cli']) devDependencies['@clarify-labs/cli'] = '^0.1.0'\n packageJson.devDependencies = devDependencies\n\n writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\\n`, 'utf-8')\n return true\n}\n\nexport function runInit(options: ResolvedCliOptions, force: boolean): void {\n const created: string[] = []\n const skipped: string[] = []\n\n const clarifyConfigCreated = writeTextFile(resolve(options.root, 'clarify.ts'), `import { defineConfig } from '@clarify-labs/cli'\n\nexport default defineConfig({\n title: 'Clarify Docs',\n description: 'Documentation powered by Clarify',\n theme: { primary: '#0ea5e9' },\n})\n`, force)\n ;(clarifyConfigCreated ? created : skipped).push('clarify.ts')\n\n const contentCreated = writeTextFile(resolve(options.root, options.content, 'index.mdx'), `---\ntitle: Welcome\n---\n\n# Welcome to Clarify\n\nStart writing your documentation in \\`${options.content}\\`.\n`, force)\n ;(contentCreated ? created : skipped).push(`${options.content}/index.mdx`)\n\n const packageJsonUpdated = updatePackageJson(options.root, force)\n if (packageJsonUpdated) created.push('package.json')\n\n console.log('[clarify] Init complete.')\n if (created.length > 0) console.log(`[clarify] Created or updated: ${created.join(', ')}`)\n if (skipped.length > 0) console.log(`[clarify] Skipped existing files: ${skipped.join(', ')}. Use --force to overwrite.`)\n}\n","import { resolve } from 'node:path'\n\nexport type CliOptions = {\n root?: string\n content?: string\n output?: string\n host?: string | boolean\n port?: string | number\n open?: boolean | string\n}\n\nexport type ResolvedCliOptions = {\n root: string\n content: string\n output: string\n host?: string | boolean\n port?: number\n open?: boolean | string\n}\n\nexport function resolveCliOptions(options: CliOptions): ResolvedCliOptions {\n return {\n root: resolve(options.root ?? process.cwd()),\n content: options.content ?? 'source',\n output: options.output ?? 'output',\n host: options.host,\n port: typeof options.port === 'string' ? Number.parseInt(options.port, 10) : options.port,\n open: options.open,\n }\n}\n","import { readFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nexport function readPackageVersion(): string {\n try {\n const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../package.json')\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as { version?: string }\n return packageJson.version ?? '0.0.0'\n } catch {\n return '0.0.0'\n }\n}\n","#!/usr/bin/env node\nimport { cac } from 'cac'\n\nimport { runBuild } from './commands/build.js'\nimport { runDev } from './commands/dev.js'\nimport { runInit } from './commands/init.js'\nimport { resolveCliOptions, type CliOptions, type ResolvedCliOptions } from './options.js'\nimport { readPackageVersion } from './package.js'\n\nfunction withSharedOptions(command: ReturnType<ReturnType<typeof cac>['command']>) {\n return command\n .option('--root <dir>', 'Project root directory')\n .option('--content <dir>', 'Content directory relative to root')\n .option('--output <dir>', 'Build output directory relative to root')\n}\n\nfunction resolveOptions(options: CliOptions): ResolvedCliOptions {\n return resolveCliOptions(options)\n}\n\nasync function main(): Promise<void> {\n const cli = cac('clarify')\n\n cli\n .version(readPackageVersion())\n .help()\n\n withSharedOptions(cli.command('dev', 'Start the local documentation server'))\n .option('--host [host]', 'Dev server host')\n .option('--port <port>', 'Dev server port')\n .option('--open [path]', 'Open the dev server in a browser')\n .action(async (options: CliOptions) => {\n await runDev(resolveOptions(options))\n })\n\n withSharedOptions(cli.command('build', 'Build the static documentation site'))\n .action(async (options: CliOptions) => {\n await runBuild(resolveOptions(options))\n })\n\n withSharedOptions(cli.command('init', 'Create a minimal Clarify project scaffold'))\n .option('--force', 'Overwrite files created by init')\n .action((options: CliOptions & { force?: boolean }) => {\n runInit(resolveOptions(options), options.force === true)\n })\n\n const args = process.argv.slice(2)\n cli.parse(process.argv, { run: false })\n\n if (args.length === 0) {\n cli.outputHelp()\n return\n }\n\n await cli.runMatchedCommand()\n}\n\nmain().catch(error => {\n console.error(error instanceof Error ? error.message : error)\n process.exitCode = 1\n})\n"],"mappings":";;;;;;;;AAmBA,IAAM,eAAe;AAErB,SAAS,gBAAgB,MAAsB;CAC7C,MAAM,kBAAkB,QAAQ,MAAM,YAAY;CAClD,IAAI,WAAW,eAAe,GAAG,OAAO;CAExC,MAAM,oBAAoB,QAAQ,MAAM,qBAAqB;CAC7D,UAAU,QAAQ,iBAAiB,GAAG,EAAE,WAAW,KAAK,CAAC;CACzD,cAAc,mBAAmB,cAAc,OAAO;CACtD,OAAO;AACT;AAEA,SAAS,2BAAmC;CAC1C,OAAO;EACL,MAAM;EACN,gBAAgB,QAAQ;GACtB,OAAO,YAAY,IAAI,OAAO,KAAK,KAAK,SAAS;IAC/C,MAAM,cAAc,IAAI,KAAK,MAAM,GAAG,EAAE,MAAM;IAC9C,MAAM,cAAc,IAAI,QAAQ,QAAQ,SAAS,WAAW,KAAK;IACjE,MAAM,mBAAmB,WAAW,KAAK,WAAW;IACpD,IAAI,CAAC,eAAe,kBAAkB;KACpC,K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iC,EACnD,QAAQ,YAA8C;EACrD,QAAQ,eAAe,OAAO,GAAG,QAAQ,UAAU,IAAI;CACzD,CAAC;CAEH,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;CACjC,IAAI,MAAM,QAAQ,MAAM,EAAE,KAAK,MAAM,CAAC;CAEtC,IAAI,KAAK,WAAW,GAAG;EACrB,IAAI,WAAW;EACf;CACF;CAEA,MAAM,IAAI,kBAAkB;AAC9B;AAEA,KAAK,EAAE,OAAM,UAAS;CACpB,QAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,KAAK;CAC5D,QAAQ,WAAW;AACrB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../source/core/vite-config.ts","../source/cli/commands/build.ts","../source/cli/commands/dev.ts","../source/cli/commands/init.ts","../source/cli/options.ts","../source/cli/package.ts","../source/cli/index.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\n\nimport type { ConfigEnv, InlineConfig, Plugin } from 'vite'\n\nimport type { ClarifyBuildOptions } from './options.js'\nimport { clarifyPlugin } from './plugin.js'\nimport { createClarifyRuntimeAliases } from './runtime-deps.js'\nimport { loadClarifyConfig } from './user-config.js'\n\nexport type ClarifyViteConfigOptions = {\n root: string\n content: string\n output: string\n host?: string | boolean\n port?: number\n open?: boolean | string\n}\n\nconst DEFAULT_HTML = '<!doctype html><html lang=\"en\"><head><meta charset=\"UTF-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /><title>Clarify</title></head><body><div id=\"root\"></div></body></html>'\n\nfunction ensureHtmlEntry(root: string): string {\n const projectHtmlPath = resolve(root, 'index.html')\n if (existsSync(projectHtmlPath)) return projectHtmlPath\n\n const generatedHtmlPath = resolve(root, '.clarify/index.html')\n mkdirSync(dirname(generatedHtmlPath), { recursive: true })\n writeFileSync(generatedHtmlPath, DEFAULT_HTML, 'utf-8')\n return generatedHtmlPath\n}\n\nfunction createHtmlFallbackPlugin(): Plugin {\n return {\n name: 'clarify:cli-html-fallback',\n configureServer(server) {\n server.middlewares.use(async (req, res, next) => {\n const requestPath = req.url?.split('?')[0] ?? '/'\n const acceptsHtml = req.headers.accept?.includes('text/html') ?? false\n const hasFileExtension = /\\.[^/]+$/.test(requestPath)\n if (!acceptsHtml || hasFileExtension) {\n next()\n return\n }\n\n try {\n const html = await server.transformIndexHtml(requestPath, DEFAULT_HTML)\n res.statusCode = 200\n res.setHeader('Content-Type', 'text/html; charset=utf-8')\n res.end(html)\n } catch (error) {\n next(error)\n }\n })\n },\n }\n}\n\nexport async function createViteConfig(options: ClarifyViteConfigOptions, env: ConfigEnv): Promise<InlineConfig> {\n const entryHtmlPath = ensureHtmlEntry(options.root)\n const userConfig = await loadClarifyConfig(options.root, env)\n const buildOptions: ClarifyBuildOptions = {\n ...userConfig,\n projectRoot: options.root,\n rootDirectory: options.content,\n outputDirectory: options.output,\n }\n\n return {\n root: options.root,\n configFile: false,\n appType: 'custom',\n resolve: {\n alias: createClarifyRuntimeAliases(),\n },\n plugins: [\n clarifyPlugin(buildOptions),\n createHtmlFallbackPlugin(),\n ],\n server: {\n host: options.host,\n port: options.port,\n open: options.open,\n },\n build: {\n outDir: options.output,\n rolldownOptions: {\n input: {\n index: entryHtmlPath,\n },\n checks: {\n pluginTimings: false,\n },\n output: {\n codeSplitting: {\n groups: [\n {\n name: 'react-vendor',\n test: /node_modules[\\\\/](react|react-dom|react-router|react-router-dom)[\\\\/]/,\n priority: 40,\n },\n {\n name: 'icons-vendor',\n test: /node_modules[\\\\/]lucide-react[\\\\/]/,\n priority: 35,\n },\n {\n name: 'ui-vendor',\n test: /node_modules[\\\\/](@headlessui|framer-motion)[\\\\/]/,\n priority: 30,\n },\n {\n name: 'vendor',\n test: /node_modules[\\\\/]/,\n priority: 10\n },\n ],\n },\n },\n },\n },\n }\n}\n","import { build as viteBuild } from 'vite'\n\nimport { createViteConfig } from '../../core/vite-config.js'\nimport type { ResolvedCliOptions } from '../options.js'\n\nexport async function runBuild(options: ResolvedCliOptions): Promise<void> {\n await viteBuild(await createViteConfig(options, { command: 'build', mode: 'production' }))\n}\n","import { createServer } from 'vite'\n\nimport { createViteConfig } from '../../core/vite-config.js'\nimport type { ResolvedCliOptions } from '../options.js'\n\nexport async function runDev(options: ResolvedCliOptions): Promise<void> {\n const server = await createServer(await createViteConfig(options, { command: 'serve', mode: 'development' }))\n await server.listen()\n server.printUrls()\n server.bindCLIShortcuts({ print: true })\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\n\nimport type { ResolvedCliOptions } from '../options.js'\n\nfunction writeTextFile(filePath: string, content: string, force: boolean): boolean {\n if (existsSync(filePath) && !force) return false\n mkdirSync(dirname(filePath), { recursive: true })\n writeFileSync(filePath, content, 'utf-8')\n return true\n}\n\nfunction updatePackageJson(root: string, force: boolean): boolean {\n const packageJsonPath = resolve(root, 'package.json')\n const packageJson = existsSync(packageJsonPath)\n ? JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as Record<string, unknown>\n : { type: 'module' }\n\n const scripts = typeof packageJson.scripts === 'object' && packageJson.scripts !== null\n ? packageJson.scripts as Record<string, string>\n : {}\n\n if (force || !scripts.dev) scripts.dev = 'clarify dev'\n if (force || !scripts.build) scripts.build = 'clarify build'\n packageJson.scripts = scripts\n\n const devDependencies = typeof packageJson.devDependencies === 'object' && packageJson.devDependencies !== null\n ? packageJson.devDependencies as Record<string, string>\n : {}\n if (!devDependencies['@clarify-labs/cli']) devDependencies['@clarify-labs/cli'] = '^0.2.0'\n packageJson.devDependencies = devDependencies\n\n writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\\n`, 'utf-8')\n return true\n}\n\nexport function runInit(options: ResolvedCliOptions, force: boolean): void {\n const created: string[] = []\n const skipped: string[] = []\n\n const clarifyConfigCreated = writeTextFile(resolve(options.root, 'clarify.ts'), `import { defineConfig } from '@clarify-labs/cli'\n\nexport default defineConfig({\n title: 'Clarify Docs',\n description: 'Documentation powered by Clarify',\n theme: { preset: 'default' },\n})\n`, force)\n ;(clarifyConfigCreated ? created : skipped).push('clarify.ts')\n\n const contentCreated = writeTextFile(resolve(options.root, options.content, 'index.mdx'), `---\ntitle: Welcome\n---\n\n# Welcome to Clarify\n\nStart writing your documentation in \\`${options.content}\\`.\n`, force)\n ;(contentCreated ? created : skipped).push(`${options.content}/index.mdx`)\n\n const packageJsonUpdated = updatePackageJson(options.root, force)\n if (packageJsonUpdated) created.push('package.json')\n\n console.log('[clarify] Init complete.')\n if (created.length > 0) console.log(`[clarify] Created or updated: ${created.join(', ')}`)\n if (skipped.length > 0) console.log(`[clarify] Skipped existing files: ${skipped.join(', ')}. Use --force to overwrite.`)\n}\n","import { resolve } from 'node:path'\n\nexport type CliOptions = {\n root?: string\n content?: string\n output?: string\n host?: string | boolean\n port?: string | number\n open?: boolean | string\n}\n\nexport type ResolvedCliOptions = {\n root: string\n content: string\n output: string\n host?: string | boolean\n port?: number\n open?: boolean | string\n}\n\nexport function resolveCliOptions(options: CliOptions): ResolvedCliOptions {\n return {\n root: resolve(options.root ?? process.cwd()),\n content: options.content ?? 'source',\n output: options.output ?? 'output',\n host: options.host,\n port: typeof options.port === 'string' ? Number.parseInt(options.port, 10) : options.port,\n open: options.open,\n }\n}\n","import { readFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nexport function readPackageVersion(): string {\n try {\n const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../package.json')\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as { version?: string }\n return packageJson.version ?? '0.0.0'\n } catch {\n return '0.0.0'\n }\n}\n","#!/usr/bin/env node\nimport { cac } from 'cac'\n\nimport { runBuild } from './commands/build.js'\nimport { runDev } from './commands/dev.js'\nimport { runInit } from './commands/init.js'\nimport { resolveCliOptions, type CliOptions, type ResolvedCliOptions } from './options.js'\nimport { readPackageVersion } from './package.js'\n\nfunction withSharedOptions(command: ReturnType<ReturnType<typeof cac>['command']>) {\n return command\n .option('--root <dir>', 'Project root directory')\n .option('--content <dir>', 'Content directory relative to root')\n .option('--output <dir>', 'Build output directory relative to root')\n}\n\nfunction resolveOptions(options: CliOptions): ResolvedCliOptions {\n return resolveCliOptions(options)\n}\n\nasync function main(): Promise<void> {\n const cli = cac('clarify')\n\n cli\n .version(readPackageVersion())\n .help()\n\n withSharedOptions(cli.command('dev', 'Start the local documentation server'))\n .option('--host [host]', 'Dev server host')\n .option('--port <port>', 'Dev server port')\n .option('--open [path]', 'Open the dev server in a browser')\n .action(async (options: CliOptions) => {\n await runDev(resolveOptions(options))\n })\n\n withSharedOptions(cli.command('build', 'Build the static documentation site'))\n .action(async (options: CliOptions) => {\n await runBuild(resolveOptions(options))\n })\n\n withSharedOptions(cli.command('init', 'Create a minimal Clarify project scaffold'))\n .option('--force', 'Overwrite files created by init')\n .action((options: CliOptions & { force?: boolean }) => {\n runInit(resolveOptions(options), options.force === true)\n })\n\n const args = process.argv.slice(2)\n cli.parse(process.argv, { run: false })\n\n if (args.length === 0) {\n cli.outputHelp()\n return\n }\n\n await cli.runMatchedCommand()\n}\n\nmain().catch(error => {\n console.error(error instanceof Error ? error.message : error)\n process.exitCode = 1\n})\n"],"mappings":";;;;;;;;AAmBA,IAAM,eAAe;AAErB,SAAS,gBAAgB,MAAsB;CAC7C,MAAM,kBAAkB,QAAQ,MAAM,YAAY;CAClD,IAAI,WAAW,eAAe,GAAG,OAAO;CAExC,MAAM,oBAAoB,QAAQ,MAAM,qBAAqB;CAC7D,UAAU,QAAQ,iBAAiB,GAAG,EAAE,WAAW,KAAK,CAAC;CACzD,cAAc,mBAAmB,cAAc,OAAO;CACtD,OAAO;AACT;AAEA,SAAS,2BAAmC;CAC1C,OAAO;EACL,MAAM;EACN,gBAAgB,QAAQ;GACtB,OAAO,YAAY,IAAI,OAAO,KAAK,KAAK,SAAS;IAC/C,MAAM,c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BAAmB,CAAC,EAC5B,KAAK;CAER,kBAAkB,IAAI,QAAQ,OAAO,sCAAsC,CAAC,EACzE,OAAO,iBAAiB,iBAAiB,EACzC,OAAO,iBAAiB,iBAAiB,EACzC,OAAO,iBAAiB,kCAAkC,EAC1D,OAAO,OAAO,YAAwB;EACrC,MAAM,OAAO,eAAe,OAAO,CAAC;CACtC,CAAC;CAEH,kBAAkB,IAAI,QAAQ,SAAS,qCAAqC,CAAC,EAC1E,OAAO,OAAO,YAAwB;EACrC,MAAM,SAAS,eAAe,OAAO,CAAC;CACxC,CAAC;CAEH,kBAAkB,IAAI,QAAQ,QAAQ,2CAA2C,CAAC,EAC/E,OAAO,WAAW,iCAAiC,EACnD,QAAQ,YAA8C;EACrD,QAAQ,eAAe,OAAO,GAAG,QAAQ,UAAU,IAAI;CACzD,CAAC;CAEH,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;CACjC,IAAI,MAAM,QAAQ,MAAM,EAAE,KAAK,MAAM,CAAC;CAEtC,IAAI,KAAK,WAAW,GAAG;EACrB,IAAI,WAAW;EACf;CACF;CAEA,MAAM,IAAI,kBAAkB;AAC9B;AAEA,KAAK,EAAE,OAAM,UAAS;CACpB,QAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,KAAK;CAC5D,QAAQ,WAAW;AACrB,CAAC"}
|
|
@@ -78,6 +78,110 @@ export declare const clarifyPagesConfigSchema: z.ZodUnion<readonly [z.ZodArray<z
|
|
|
78
78
|
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
79
79
|
}, z.core.$strip>]>>;
|
|
80
80
|
}, z.core.$strip>>, z.ZodLiteral<"FileTree">]>;
|
|
81
|
+
export declare const clarifyTabItemSchema: z.ZodObject<{
|
|
82
|
+
tab: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
83
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
84
|
+
pages: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
85
|
+
group: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
86
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
87
|
+
pages: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
88
|
+
page: z.ZodString;
|
|
89
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
90
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
91
|
+
redirect: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
93
|
+
openapi: z.ZodString;
|
|
94
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
95
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
96
|
+
}, z.core.$strip>]>>;
|
|
97
|
+
}, z.core.$strip>>, z.ZodLiteral<"FileTree">]>>;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
export declare const clarifyTabsConfigSchema: z.ZodArray<z.ZodObject<{
|
|
100
|
+
tab: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
101
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
102
|
+
pages: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
103
|
+
group: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
104
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
105
|
+
pages: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
106
|
+
page: z.ZodString;
|
|
107
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
108
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
109
|
+
redirect: z.ZodOptional<z.ZodString>;
|
|
110
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
111
|
+
openapi: z.ZodString;
|
|
112
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
113
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
114
|
+
}, z.core.$strip>]>>;
|
|
115
|
+
}, z.core.$strip>>, z.ZodLiteral<"FileTree">]>>;
|
|
116
|
+
}, z.core.$strip>>;
|
|
117
|
+
export declare const clarifyThemePresetSchema: z.ZodEnum<{
|
|
118
|
+
default: "default";
|
|
119
|
+
base: "base";
|
|
120
|
+
}>;
|
|
121
|
+
export declare const clarifyThemeColorTokensConfigSchema: z.ZodObject<{
|
|
122
|
+
primary: z.ZodOptional<z.ZodString>;
|
|
123
|
+
accent: z.ZodOptional<z.ZodString>;
|
|
124
|
+
background: z.ZodOptional<z.ZodString>;
|
|
125
|
+
foreground: z.ZodOptional<z.ZodString>;
|
|
126
|
+
surface: z.ZodOptional<z.ZodString>;
|
|
127
|
+
muted: z.ZodOptional<z.ZodString>;
|
|
128
|
+
border: z.ZodOptional<z.ZodString>;
|
|
129
|
+
codeBackground: z.ZodOptional<z.ZodString>;
|
|
130
|
+
}, z.core.$strip>;
|
|
131
|
+
export declare const clarifyThemeRadiusTokensConfigSchema: z.ZodObject<{
|
|
132
|
+
sm: z.ZodOptional<z.ZodString>;
|
|
133
|
+
md: z.ZodOptional<z.ZodString>;
|
|
134
|
+
lg: z.ZodOptional<z.ZodString>;
|
|
135
|
+
xl: z.ZodOptional<z.ZodString>;
|
|
136
|
+
}, z.core.$strip>;
|
|
137
|
+
export declare const clarifyThemeTokensConfigSchema: z.ZodObject<{
|
|
138
|
+
colors: z.ZodOptional<z.ZodObject<{
|
|
139
|
+
primary: z.ZodOptional<z.ZodString>;
|
|
140
|
+
accent: z.ZodOptional<z.ZodString>;
|
|
141
|
+
background: z.ZodOptional<z.ZodString>;
|
|
142
|
+
foreground: z.ZodOptional<z.ZodString>;
|
|
143
|
+
surface: z.ZodOptional<z.ZodString>;
|
|
144
|
+
muted: z.ZodOptional<z.ZodString>;
|
|
145
|
+
border: z.ZodOptional<z.ZodString>;
|
|
146
|
+
codeBackground: z.ZodOptional<z.ZodString>;
|
|
147
|
+
}, z.core.$strip>>;
|
|
148
|
+
radius: z.ZodOptional<z.ZodObject<{
|
|
149
|
+
sm: z.ZodOptional<z.ZodString>;
|
|
150
|
+
md: z.ZodOptional<z.ZodString>;
|
|
151
|
+
lg: z.ZodOptional<z.ZodString>;
|
|
152
|
+
xl: z.ZodOptional<z.ZodString>;
|
|
153
|
+
}, z.core.$strip>>;
|
|
154
|
+
}, z.core.$strip>;
|
|
155
|
+
export declare const clarifyThemeLayoutConfigSchema: z.ZodObject<{
|
|
156
|
+
maxWidth: z.ZodOptional<z.ZodString>;
|
|
157
|
+
}, z.core.$strip>;
|
|
158
|
+
export declare const clarifyThemeConfigSchema: z.ZodObject<{
|
|
159
|
+
preset: z.ZodOptional<z.ZodEnum<{
|
|
160
|
+
default: "default";
|
|
161
|
+
base: "base";
|
|
162
|
+
}>>;
|
|
163
|
+
tokens: z.ZodOptional<z.ZodObject<{
|
|
164
|
+
colors: z.ZodOptional<z.ZodObject<{
|
|
165
|
+
primary: z.ZodOptional<z.ZodString>;
|
|
166
|
+
accent: z.ZodOptional<z.ZodString>;
|
|
167
|
+
background: z.ZodOptional<z.ZodString>;
|
|
168
|
+
foreground: z.ZodOptional<z.ZodString>;
|
|
169
|
+
surface: z.ZodOptional<z.ZodString>;
|
|
170
|
+
muted: z.ZodOptional<z.ZodString>;
|
|
171
|
+
border: z.ZodOptional<z.ZodString>;
|
|
172
|
+
codeBackground: z.ZodOptional<z.ZodString>;
|
|
173
|
+
}, z.core.$strip>>;
|
|
174
|
+
radius: z.ZodOptional<z.ZodObject<{
|
|
175
|
+
sm: z.ZodOptional<z.ZodString>;
|
|
176
|
+
md: z.ZodOptional<z.ZodString>;
|
|
177
|
+
lg: z.ZodOptional<z.ZodString>;
|
|
178
|
+
xl: z.ZodOptional<z.ZodString>;
|
|
179
|
+
}, z.core.$strip>>;
|
|
180
|
+
}, z.core.$strip>>;
|
|
181
|
+
layout: z.ZodOptional<z.ZodObject<{
|
|
182
|
+
maxWidth: z.ZodOptional<z.ZodString>;
|
|
183
|
+
}, z.core.$strip>>;
|
|
184
|
+
}, z.core.$strip>;
|
|
81
185
|
export declare const clarifyProjectConfigSchema: z.ZodObject<{
|
|
82
186
|
title: z.ZodOptional<z.ZodString>;
|
|
83
187
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -90,7 +194,31 @@ export declare const clarifyProjectConfigSchema: z.ZodObject<{
|
|
|
90
194
|
dark: z.ZodOptional<z.ZodString>;
|
|
91
195
|
}, z.core.$strip>]>>;
|
|
92
196
|
theme: z.ZodOptional<z.ZodObject<{
|
|
93
|
-
|
|
197
|
+
preset: z.ZodOptional<z.ZodEnum<{
|
|
198
|
+
default: "default";
|
|
199
|
+
base: "base";
|
|
200
|
+
}>>;
|
|
201
|
+
tokens: z.ZodOptional<z.ZodObject<{
|
|
202
|
+
colors: z.ZodOptional<z.ZodObject<{
|
|
203
|
+
primary: z.ZodOptional<z.ZodString>;
|
|
204
|
+
accent: z.ZodOptional<z.ZodString>;
|
|
205
|
+
background: z.ZodOptional<z.ZodString>;
|
|
206
|
+
foreground: z.ZodOptional<z.ZodString>;
|
|
207
|
+
surface: z.ZodOptional<z.ZodString>;
|
|
208
|
+
muted: z.ZodOptional<z.ZodString>;
|
|
209
|
+
border: z.ZodOptional<z.ZodString>;
|
|
210
|
+
codeBackground: z.ZodOptional<z.ZodString>;
|
|
211
|
+
}, z.core.$strip>>;
|
|
212
|
+
radius: z.ZodOptional<z.ZodObject<{
|
|
213
|
+
sm: z.ZodOptional<z.ZodString>;
|
|
214
|
+
md: z.ZodOptional<z.ZodString>;
|
|
215
|
+
lg: z.ZodOptional<z.ZodString>;
|
|
216
|
+
xl: z.ZodOptional<z.ZodString>;
|
|
217
|
+
}, z.core.$strip>>;
|
|
218
|
+
}, z.core.$strip>>;
|
|
219
|
+
layout: z.ZodOptional<z.ZodObject<{
|
|
220
|
+
maxWidth: z.ZodOptional<z.ZodString>;
|
|
221
|
+
}, z.core.$strip>>;
|
|
94
222
|
}, z.core.$strip>>;
|
|
95
223
|
routePrefix: z.ZodOptional<z.ZodString>;
|
|
96
224
|
navbar: z.ZodOptional<z.ZodObject<{
|
|
@@ -122,19 +250,23 @@ export declare const clarifyProjectConfigSchema: z.ZodObject<{
|
|
|
122
250
|
dir: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ltr">, z.ZodLiteral<"rtl">]>>;
|
|
123
251
|
}, z.core.$strip>>;
|
|
124
252
|
}, z.core.$strip>>;
|
|
125
|
-
|
|
126
|
-
|
|
253
|
+
tabs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
254
|
+
tab: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
127
255
|
icon: z.ZodOptional<z.ZodString>;
|
|
128
|
-
pages: z.
|
|
129
|
-
|
|
130
|
-
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
131
|
-
icon: z.ZodOptional<z.ZodString>;
|
|
132
|
-
redirect: z.ZodOptional<z.ZodString>;
|
|
133
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
134
|
-
openapi: z.ZodString;
|
|
256
|
+
pages: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
257
|
+
group: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
135
258
|
icon: z.ZodOptional<z.ZodString>;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
259
|
+
pages: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
260
|
+
page: z.ZodString;
|
|
261
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
262
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
263
|
+
redirect: z.ZodOptional<z.ZodString>;
|
|
264
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
265
|
+
openapi: z.ZodString;
|
|
266
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
267
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
268
|
+
}, z.core.$strip>]>>;
|
|
269
|
+
}, z.core.$strip>>, z.ZodLiteral<"FileTree">]>>;
|
|
270
|
+
}, z.core.$strip>>>;
|
|
139
271
|
}, z.core.$strip>;
|
|
140
272
|
export type ClarifyProjectConfigInput = z.input<typeof clarifyProjectConfigSchema>;
|
package/output/core/ssg.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Plugin } from 'vite';
|
|
|
2
2
|
import { ResolvedProjectConfig, ContentRoute } from '../types.js';
|
|
3
3
|
export declare function readIndexHtml(outputDirectory: string): string | undefined;
|
|
4
4
|
export declare function injectSSRIntoTemplate(template: string, appHtml: string, projectConfig: ResolvedProjectConfig, route?: ContentRoute): string;
|
|
5
|
-
export declare const SSR_ENTRY_CODE = "import { renderToHTML } from '@clarify-labs/renderer/server';\nimport { routes, navigation } from 'virtual:clarify-routes';\nimport { config } from 'virtual:clarify-config';\nimport { openApis } from 'virtual:clarify-openapi-registry';\n\nexport function render(url) {\n return renderToHTML({ config, routes, navigation, openApis, url });\n}";
|
|
5
|
+
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 { openApis } from 'virtual:clarify-openapi-registry';\n\nexport function render(url) {\n return renderToHTML({ config, routes, navigation, openApis, url });\n}";
|
|
6
6
|
export declare function createTempEntryFile(content: string): string;
|
|
7
7
|
export declare function buildSSRBundle(root: string, ssrEntry: string, ssrOutDir: string, plugins: Plugin[]): Promise<void>;
|
|
8
8
|
export declare function renderSSGRoutes(routes: ContentRoute[], projectConfig: ResolvedProjectConfig, outputDirectory: string, ssrBundlePath: string, failOnError?: boolean): Promise<void>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ClarifyThemeConfig, ResolvedClarifyThemeConfig } from '../types.js';
|
|
2
|
+
export declare const clarifyThemePresets: {
|
|
3
|
+
readonly default: {
|
|
4
|
+
readonly preset: "default";
|
|
5
|
+
readonly tokens: {
|
|
6
|
+
readonly colors: {
|
|
7
|
+
readonly primary: "#00D492";
|
|
8
|
+
readonly accent: "#00F6C9";
|
|
9
|
+
readonly background: "#ffffff";
|
|
10
|
+
readonly foreground: "#111827";
|
|
11
|
+
readonly surface: "#ffffff";
|
|
12
|
+
readonly muted: "#64748b";
|
|
13
|
+
readonly border: "rgb(15 23 42 / 0.12)";
|
|
14
|
+
readonly codeBackground: "#f7fefb";
|
|
15
|
+
};
|
|
16
|
+
readonly radius: {
|
|
17
|
+
readonly sm: "6px";
|
|
18
|
+
readonly md: "10px";
|
|
19
|
+
readonly lg: "14px";
|
|
20
|
+
readonly xl: "18px";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly layout: {
|
|
24
|
+
readonly maxWidth: "82rem";
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
readonly base: {
|
|
28
|
+
readonly preset: "base";
|
|
29
|
+
readonly tokens: {
|
|
30
|
+
readonly colors: {
|
|
31
|
+
readonly primary: "#18181b";
|
|
32
|
+
readonly accent: "#52525b";
|
|
33
|
+
readonly background: "#ffffff";
|
|
34
|
+
readonly foreground: "#18181b";
|
|
35
|
+
readonly surface: "#ffffff";
|
|
36
|
+
readonly muted: "#71717a";
|
|
37
|
+
readonly border: "rgb(24 24 27 / 0.12)";
|
|
38
|
+
readonly codeBackground: "#f4f4f5";
|
|
39
|
+
};
|
|
40
|
+
readonly radius: {
|
|
41
|
+
readonly sm: "6px";
|
|
42
|
+
readonly md: "8px";
|
|
43
|
+
readonly lg: "12px";
|
|
44
|
+
readonly xl: "16px";
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
readonly layout: {
|
|
48
|
+
readonly maxWidth: "80rem";
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare function resolveThemeConfig(theme?: ClarifyThemeConfig): ResolvedClarifyThemeConfig;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContentRoute, NavigationTree, ResolvedBuildOptions, ResolvedProjectConfig } from '../types.js';
|
|
2
2
|
export declare const VIRTUAL_CONFIG = "virtual:clarify-config";
|
|
3
3
|
export declare const VIRTUAL_ROUTES = "virtual:clarify-routes";
|
|
4
|
+
export declare const VIRTUAL_SERVER_ROUTES = "virtual:clarify-routes/server";
|
|
4
5
|
export declare const VIRTUAL_OPENAPI_REGISTRY = "virtual:clarify-openapi-registry";
|
|
5
6
|
export declare const VIRTUAL_CLIENT_ENTRY = "virtual:clarify-entry-client";
|
|
6
7
|
export declare const RESOLVED_CLIENT_ENTRY: string;
|
|
@@ -8,7 +9,7 @@ export type VirtualModules = Map<string, string>;
|
|
|
8
9
|
export declare function resolveVirtualId(id: string): string;
|
|
9
10
|
export declare function stripVirtualPrefix(id: string): string;
|
|
10
11
|
export declare function generateConfigModule(projectConfig: ResolvedProjectConfig, buildOptions: ResolvedBuildOptions): string;
|
|
11
|
-
export declare function generateRoutesModule(routes: ContentRoute[],
|
|
12
|
+
export declare function generateRoutesModule(routes: ContentRoute[], resolvedNavigation?: NavigationTree, projectConfig?: ResolvedProjectConfig, mode?: 'client' | 'server'): string;
|
|
12
13
|
export declare function createClientEntryModule(): string;
|
|
13
14
|
export declare function buildVirtualModules(args: {
|
|
14
15
|
projectConfig: ResolvedProjectConfig;
|
package/output/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_plugin = require("./plugin-
|
|
2
|
+
const require_plugin = require("./plugin-BSPUvgb3.cjs");
|
|
3
3
|
exports.clarifyPlugin = require_plugin.clarifyPlugin;
|
|
4
4
|
exports.defineConfig = require_plugin.defineConfig;
|
package/output/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as defineConfig, t as clarifyPlugin } from "./plugin-
|
|
1
|
+
import { n as defineConfig, t as clarifyPlugin } from "./plugin-B-_5mQmO.js";
|
|
2
2
|
export { clarifyPlugin, defineConfig };
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
export type ParsedFrontmatter = {
|
|
2
|
+
frontmatter: Record<string, unknown>;
|
|
3
|
+
content: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* 在内容入口统一解析 MDX frontmatter,并返回可供后续流程复用的标准化正文。
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseFrontmatter(content: string): ParsedFrontmatter;
|
|
1
9
|
/**
|
|
2
10
|
* 从 MDX 文件内容中提取 frontmatter。
|
|
3
11
|
* 使用 gray-matter 支持 YAML frontmatter 的标准语法和类型解析。
|
|
4
12
|
*/
|
|
5
13
|
export declare function extractFrontmatter(content: string): Record<string, unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* 移除 MDX 文件开头的 YAML frontmatter,保留页面正文。
|
|
16
|
+
*/
|
|
17
|
+
export declare function stripFrontmatter(content: string): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContentRoute, ContentSection, ClarifyNavigationNode, ClarifyPagesGroup, ClarifyLocalizedText, LocalizedNavigation, ResolvedClarifyI18nConfig } from '../types.js';
|
|
1
|
+
import { ContentRoute, ContentSection, ClarifyNavigationNode, ClarifyPagesConfig, ClarifyPagesGroup, ClarifyLocalizedText, ClarifyTabsConfig, LocalizedNavigation, LocalizedTabbedNavigation, ResolvedClarifyI18nConfig, TabbedNavigation } from '../types.js';
|
|
2
2
|
/** 从 MDX/Markdown 内容中提取 H2/H3 章节 */
|
|
3
3
|
export declare function extractMdxSections(content: string): ContentSection[];
|
|
4
4
|
export declare function basePathFromRef(ref: string): string;
|
|
@@ -9,5 +9,7 @@ export declare function resolveLocalizedText(text: ClarifyLocalizedText | undefi
|
|
|
9
9
|
export declare function findContentRoutes(dir: string, base?: string): ContentRoute[];
|
|
10
10
|
export declare function findLocalizedContentRoutes(contentRoot: string, i18n?: ResolvedClarifyI18nConfig): ContentRoute[];
|
|
11
11
|
export declare function buildNavigation(routes: ContentRoute[]): ClarifyNavigationNode[];
|
|
12
|
+
export declare function buildNavigationFromTabsConfig(routes: ContentRoute[], tabs: ClarifyTabsConfig): TabbedNavigation;
|
|
12
13
|
export declare function buildNavigationFromConfig(routes: ContentRoute[], config: ClarifyPagesGroup[]): ClarifyNavigationNode[];
|
|
13
|
-
export declare function buildLocalizedNavigation(routes: ContentRoute[], config:
|
|
14
|
+
export declare function buildLocalizedNavigation(routes: ContentRoute[], config: ClarifyPagesConfig | undefined, i18n?: ResolvedClarifyI18nConfig): LocalizedNavigation | undefined;
|
|
15
|
+
export declare function buildLocalizedNavigationFromTabsConfig(routes: ContentRoute[], tabs: ClarifyTabsConfig, i18n?: ResolvedClarifyI18nConfig): LocalizedTabbedNavigation | undefined;
|