@clarify-labs/cli 0.1.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/LICENSE +661 -0
- package/bin/clarify.js +2 -0
- package/output/cli/commands/build.d.ts +2 -0
- package/output/cli/commands/dev.d.ts +2 -0
- package/output/cli/commands/init.d.ts +2 -0
- package/output/cli/index.d.ts +2 -0
- package/output/cli/options.d.ts +17 -0
- package/output/cli/package.d.ts +1 -0
- package/output/cli.cjs +187 -0
- package/output/cli.cjs.map +1 -0
- package/output/cli.js +187 -0
- package/output/cli.js.map +1 -0
- package/output/core/config-schema.d.ts +140 -0
- package/output/core/config.d.ts +3 -0
- package/output/core/hooks.d.ts +5 -0
- package/output/core/options.d.ts +24 -0
- package/output/core/plugin.d.ts +4 -0
- package/output/core/runtime-deps.d.ts +7 -0
- package/output/core/ssg.d.ts +8 -0
- package/output/core/user-config.d.ts +7 -0
- package/output/core/utils.d.ts +1 -0
- package/output/core/virtual-modules.d.ts +18 -0
- package/output/core/vite-config.d.ts +10 -0
- package/output/index.cjs +4 -0
- package/output/index.d.ts +5 -0
- package/output/index.js +2 -0
- package/output/parsers/frontmatter.d.ts +5 -0
- package/output/parsers/mdx.d.ts +14 -0
- package/output/parsers/routes.d.ts +13 -0
- package/output/plugin-BUWojlPv.js +1277 -0
- package/output/plugin-BUWojlPv.js.map +1 -0
- package/output/plugin-CEyCiD5r.cjs +1330 -0
- package/output/plugin-CEyCiD5r.cjs.map +1 -0
- package/output/plugins/content-artifacts/index.d.ts +2 -0
- package/output/plugins/content-artifacts/raw-content.d.ts +8 -0
- package/output/plugins/content-artifacts/server.d.ts +5 -0
- package/output/plugins/html-shell/index.d.ts +2 -0
- package/output/plugins/openapi/index.d.ts +2 -0
- package/output/plugins/openapi/parser.d.ts +5 -0
- package/output/plugins/openapi/virtual-modules.d.ts +4 -0
- package/output/types.d.ts +191 -0
- package/package.json +63 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type CliOptions = {
|
|
2
|
+
root?: string;
|
|
3
|
+
content?: string;
|
|
4
|
+
output?: string;
|
|
5
|
+
host?: string | boolean;
|
|
6
|
+
port?: string | number;
|
|
7
|
+
open?: boolean | string;
|
|
8
|
+
};
|
|
9
|
+
export type ResolvedCliOptions = {
|
|
10
|
+
root: string;
|
|
11
|
+
content: string;
|
|
12
|
+
output: string;
|
|
13
|
+
host?: string | boolean;
|
|
14
|
+
port?: number;
|
|
15
|
+
open?: boolean | string;
|
|
16
|
+
};
|
|
17
|
+
export declare function resolveCliOptions(options: CliOptions): ResolvedCliOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readPackageVersion(): string;
|
package/output/cli.cjs
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const require_plugin = require("./plugin-CEyCiD5r.cjs");
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
let node_path = require("node:path");
|
|
5
|
+
let node_url = require("node:url");
|
|
6
|
+
let vite = require("vite");
|
|
7
|
+
let cac = require("cac");
|
|
8
|
+
//#region source/core/vite-config.ts
|
|
9
|
+
var 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>";
|
|
10
|
+
function ensureHtmlEntry(root) {
|
|
11
|
+
const projectHtmlPath = (0, node_path.resolve)(root, "index.html");
|
|
12
|
+
if ((0, node_fs.existsSync)(projectHtmlPath)) return projectHtmlPath;
|
|
13
|
+
const generatedHtmlPath = (0, node_path.resolve)(root, ".clarify/index.html");
|
|
14
|
+
(0, node_fs.mkdirSync)((0, node_path.dirname)(generatedHtmlPath), { recursive: true });
|
|
15
|
+
(0, node_fs.writeFileSync)(generatedHtmlPath, DEFAULT_HTML, "utf-8");
|
|
16
|
+
return generatedHtmlPath;
|
|
17
|
+
}
|
|
18
|
+
function createHtmlFallbackPlugin() {
|
|
19
|
+
return {
|
|
20
|
+
name: "clarify:cli-html-fallback",
|
|
21
|
+
configureServer(server) {
|
|
22
|
+
server.middlewares.use(async (req, res, next) => {
|
|
23
|
+
const requestPath = req.url?.split("?")[0] ?? "/";
|
|
24
|
+
const acceptsHtml = req.headers.accept?.includes("text/html") ?? false;
|
|
25
|
+
const hasFileExtension = /\.[^/]+$/.test(requestPath);
|
|
26
|
+
if (!acceptsHtml || hasFileExtension) {
|
|
27
|
+
next();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const html = await server.transformIndexHtml(requestPath, DEFAULT_HTML);
|
|
32
|
+
res.statusCode = 200;
|
|
33
|
+
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
34
|
+
res.end(html);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
next(error);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async function createViteConfig(options, env) {
|
|
43
|
+
const entryHtmlPath = ensureHtmlEntry(options.root);
|
|
44
|
+
const buildOptions = {
|
|
45
|
+
...await require_plugin.loadClarifyConfig(options.root, env),
|
|
46
|
+
projectRoot: options.root,
|
|
47
|
+
rootDirectory: options.content,
|
|
48
|
+
outputDirectory: options.output
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
root: options.root,
|
|
52
|
+
configFile: false,
|
|
53
|
+
appType: "custom",
|
|
54
|
+
resolve: { alias: require_plugin.createClarifyRuntimeAliases() },
|
|
55
|
+
plugins: [require_plugin.clarifyPlugin(buildOptions), createHtmlFallbackPlugin()],
|
|
56
|
+
server: {
|
|
57
|
+
host: options.host,
|
|
58
|
+
port: options.port,
|
|
59
|
+
open: options.open
|
|
60
|
+
},
|
|
61
|
+
build: {
|
|
62
|
+
outDir: options.output,
|
|
63
|
+
rollupOptions: { input: { index: entryHtmlPath } }
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region source/cli/commands/build.ts
|
|
69
|
+
async function runBuild(options) {
|
|
70
|
+
await (0, vite.build)(await createViteConfig(options, {
|
|
71
|
+
command: "build",
|
|
72
|
+
mode: "production"
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region source/cli/commands/dev.ts
|
|
77
|
+
async function runDev(options) {
|
|
78
|
+
const server = await (0, vite.createServer)(await createViteConfig(options, {
|
|
79
|
+
command: "serve",
|
|
80
|
+
mode: "development"
|
|
81
|
+
}));
|
|
82
|
+
await server.listen();
|
|
83
|
+
server.printUrls();
|
|
84
|
+
server.bindCLIShortcuts({ print: true });
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region source/cli/commands/init.ts
|
|
88
|
+
function writeTextFile(filePath, content, force) {
|
|
89
|
+
if ((0, node_fs.existsSync)(filePath) && !force) return false;
|
|
90
|
+
(0, node_fs.mkdirSync)((0, node_path.dirname)(filePath), { recursive: true });
|
|
91
|
+
(0, node_fs.writeFileSync)(filePath, content, "utf-8");
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
function updatePackageJson(root, force) {
|
|
95
|
+
const packageJsonPath = (0, node_path.resolve)(root, "package.json");
|
|
96
|
+
const packageJson = (0, node_fs.existsSync)(packageJsonPath) ? JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf-8")) : { type: "module" };
|
|
97
|
+
const scripts = typeof packageJson.scripts === "object" && packageJson.scripts !== null ? packageJson.scripts : {};
|
|
98
|
+
if (force || !scripts.dev) scripts.dev = "clarify dev";
|
|
99
|
+
if (force || !scripts.build) scripts.build = "clarify build";
|
|
100
|
+
packageJson.scripts = scripts;
|
|
101
|
+
const devDependencies = typeof packageJson.devDependencies === "object" && packageJson.devDependencies !== null ? packageJson.devDependencies : {};
|
|
102
|
+
if (!devDependencies["@clarify-labs/cli"]) devDependencies["@clarify-labs/cli"] = "^0.1.0";
|
|
103
|
+
packageJson.devDependencies = devDependencies;
|
|
104
|
+
(0, node_fs.writeFileSync)(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, "utf-8");
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
function runInit(options, force) {
|
|
108
|
+
const created = [];
|
|
109
|
+
const skipped = [];
|
|
110
|
+
(writeTextFile((0, node_path.resolve)(options.root, "clarify.ts"), `import { defineConfig } from '@clarify-labs/cli'
|
|
111
|
+
|
|
112
|
+
export default defineConfig({
|
|
113
|
+
title: 'Clarify Docs',
|
|
114
|
+
description: 'Documentation powered by Clarify',
|
|
115
|
+
theme: { primary: '#0ea5e9' },
|
|
116
|
+
})
|
|
117
|
+
`, force) ? created : skipped).push("clarify.ts");
|
|
118
|
+
(writeTextFile((0, node_path.resolve)(options.root, options.content, "index.mdx"), `---
|
|
119
|
+
title: Welcome
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
# Welcome to Clarify
|
|
123
|
+
|
|
124
|
+
Start writing your documentation in \`${options.content}\`.
|
|
125
|
+
`, force) ? created : skipped).push(`${options.content}/index.mdx`);
|
|
126
|
+
if (updatePackageJson(options.root, force)) created.push("package.json");
|
|
127
|
+
console.log("[clarify] Init complete.");
|
|
128
|
+
if (created.length > 0) console.log(`[clarify] Created or updated: ${created.join(", ")}`);
|
|
129
|
+
if (skipped.length > 0) console.log(`[clarify] Skipped existing files: ${skipped.join(", ")}. Use --force to overwrite.`);
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region source/cli/options.ts
|
|
133
|
+
function resolveCliOptions(options) {
|
|
134
|
+
return {
|
|
135
|
+
root: (0, node_path.resolve)(options.root ?? process.cwd()),
|
|
136
|
+
content: options.content ?? "source",
|
|
137
|
+
output: options.output ?? "output",
|
|
138
|
+
host: options.host,
|
|
139
|
+
port: typeof options.port === "string" ? Number.parseInt(options.port, 10) : options.port,
|
|
140
|
+
open: options.open
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region source/cli/package.ts
|
|
145
|
+
function readPackageVersion() {
|
|
146
|
+
try {
|
|
147
|
+
const packageJsonPath = (0, node_path.resolve)((0, node_path.dirname)((0, node_url.fileURLToPath)({}.url)), "../package.json");
|
|
148
|
+
return JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf-8")).version ?? "0.0.0";
|
|
149
|
+
} catch {
|
|
150
|
+
return "0.0.0";
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region source/cli/index.ts
|
|
155
|
+
function withSharedOptions(command) {
|
|
156
|
+
return command.option("--root <dir>", "Project root directory").option("--content <dir>", "Content directory relative to root").option("--output <dir>", "Build output directory relative to root");
|
|
157
|
+
}
|
|
158
|
+
function resolveOptions(options) {
|
|
159
|
+
return resolveCliOptions(options);
|
|
160
|
+
}
|
|
161
|
+
async function main() {
|
|
162
|
+
const cli = (0, cac.cac)("clarify");
|
|
163
|
+
cli.version(readPackageVersion()).help();
|
|
164
|
+
withSharedOptions(cli.command("dev", "Start the local documentation server")).option("--host [host]", "Dev server host").option("--port <port>", "Dev server port").option("--open [path]", "Open the dev server in a browser").action(async (options) => {
|
|
165
|
+
await runDev(resolveOptions(options));
|
|
166
|
+
});
|
|
167
|
+
withSharedOptions(cli.command("build", "Build the static documentation site")).action(async (options) => {
|
|
168
|
+
await runBuild(resolveOptions(options));
|
|
169
|
+
});
|
|
170
|
+
withSharedOptions(cli.command("init", "Create a minimal Clarify project scaffold")).option("--force", "Overwrite files created by init").action((options) => {
|
|
171
|
+
runInit(resolveOptions(options), options.force === true);
|
|
172
|
+
});
|
|
173
|
+
const args = process.argv.slice(2);
|
|
174
|
+
cli.parse(process.argv, { run: false });
|
|
175
|
+
if (args.length === 0) {
|
|
176
|
+
cli.outputHelp();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
await cli.runMatchedCommand();
|
|
180
|
+
}
|
|
181
|
+
main().catch((error) => {
|
|
182
|
+
console.error(error instanceof Error ? error.message : error);
|
|
183
|
+
process.exitCode = 1;
|
|
184
|
+
});
|
|
185
|
+
//#endregion
|
|
186
|
+
|
|
187
|
+
//# sourceMappingURL=cli.cjs.map
|
|
@@ -0,0 +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,gBAAg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D,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"}
|
package/output/cli.js
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { i as createClarifyRuntimeAliases, r as loadClarifyConfig, t as clarifyPlugin } from "./plugin-BUWojlPv.js";
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { build, createServer } from "vite";
|
|
7
|
+
import { cac } from "cac";
|
|
8
|
+
//#region source/core/vite-config.ts
|
|
9
|
+
var 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>";
|
|
10
|
+
function ensureHtmlEntry(root) {
|
|
11
|
+
const projectHtmlPath = resolve(root, "index.html");
|
|
12
|
+
if (existsSync(projectHtmlPath)) return projectHtmlPath;
|
|
13
|
+
const generatedHtmlPath = resolve(root, ".clarify/index.html");
|
|
14
|
+
mkdirSync(dirname(generatedHtmlPath), { recursive: true });
|
|
15
|
+
writeFileSync(generatedHtmlPath, DEFAULT_HTML, "utf-8");
|
|
16
|
+
return generatedHtmlPath;
|
|
17
|
+
}
|
|
18
|
+
function createHtmlFallbackPlugin() {
|
|
19
|
+
return {
|
|
20
|
+
name: "clarify:cli-html-fallback",
|
|
21
|
+
configureServer(server) {
|
|
22
|
+
server.middlewares.use(async (req, res, next) => {
|
|
23
|
+
const requestPath = req.url?.split("?")[0] ?? "/";
|
|
24
|
+
const acceptsHtml = req.headers.accept?.includes("text/html") ?? false;
|
|
25
|
+
const hasFileExtension = /\.[^/]+$/.test(requestPath);
|
|
26
|
+
if (!acceptsHtml || hasFileExtension) {
|
|
27
|
+
next();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const html = await server.transformIndexHtml(requestPath, DEFAULT_HTML);
|
|
32
|
+
res.statusCode = 200;
|
|
33
|
+
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
34
|
+
res.end(html);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
next(error);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async function createViteConfig(options, env) {
|
|
43
|
+
const entryHtmlPath = ensureHtmlEntry(options.root);
|
|
44
|
+
const buildOptions = {
|
|
45
|
+
...await loadClarifyConfig(options.root, env),
|
|
46
|
+
projectRoot: options.root,
|
|
47
|
+
rootDirectory: options.content,
|
|
48
|
+
outputDirectory: options.output
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
root: options.root,
|
|
52
|
+
configFile: false,
|
|
53
|
+
appType: "custom",
|
|
54
|
+
resolve: { alias: createClarifyRuntimeAliases() },
|
|
55
|
+
plugins: [clarifyPlugin(buildOptions), createHtmlFallbackPlugin()],
|
|
56
|
+
server: {
|
|
57
|
+
host: options.host,
|
|
58
|
+
port: options.port,
|
|
59
|
+
open: options.open
|
|
60
|
+
},
|
|
61
|
+
build: {
|
|
62
|
+
outDir: options.output,
|
|
63
|
+
rollupOptions: { input: { index: entryHtmlPath } }
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region source/cli/commands/build.ts
|
|
69
|
+
async function runBuild(options) {
|
|
70
|
+
await build(await createViteConfig(options, {
|
|
71
|
+
command: "build",
|
|
72
|
+
mode: "production"
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region source/cli/commands/dev.ts
|
|
77
|
+
async function runDev(options) {
|
|
78
|
+
const server = await createServer(await createViteConfig(options, {
|
|
79
|
+
command: "serve",
|
|
80
|
+
mode: "development"
|
|
81
|
+
}));
|
|
82
|
+
await server.listen();
|
|
83
|
+
server.printUrls();
|
|
84
|
+
server.bindCLIShortcuts({ print: true });
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region source/cli/commands/init.ts
|
|
88
|
+
function writeTextFile(filePath, content, force) {
|
|
89
|
+
if (existsSync(filePath) && !force) return false;
|
|
90
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
91
|
+
writeFileSync(filePath, content, "utf-8");
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
function updatePackageJson(root, force) {
|
|
95
|
+
const packageJsonPath = resolve(root, "package.json");
|
|
96
|
+
const packageJson = existsSync(packageJsonPath) ? JSON.parse(readFileSync(packageJsonPath, "utf-8")) : { type: "module" };
|
|
97
|
+
const scripts = typeof packageJson.scripts === "object" && packageJson.scripts !== null ? packageJson.scripts : {};
|
|
98
|
+
if (force || !scripts.dev) scripts.dev = "clarify dev";
|
|
99
|
+
if (force || !scripts.build) scripts.build = "clarify build";
|
|
100
|
+
packageJson.scripts = scripts;
|
|
101
|
+
const devDependencies = typeof packageJson.devDependencies === "object" && packageJson.devDependencies !== null ? packageJson.devDependencies : {};
|
|
102
|
+
if (!devDependencies["@clarify-labs/cli"]) devDependencies["@clarify-labs/cli"] = "^0.1.0";
|
|
103
|
+
packageJson.devDependencies = devDependencies;
|
|
104
|
+
writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, "utf-8");
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
function runInit(options, force) {
|
|
108
|
+
const created = [];
|
|
109
|
+
const skipped = [];
|
|
110
|
+
(writeTextFile(resolve(options.root, "clarify.ts"), `import { defineConfig } from '@clarify-labs/cli'
|
|
111
|
+
|
|
112
|
+
export default defineConfig({
|
|
113
|
+
title: 'Clarify Docs',
|
|
114
|
+
description: 'Documentation powered by Clarify',
|
|
115
|
+
theme: { primary: '#0ea5e9' },
|
|
116
|
+
})
|
|
117
|
+
`, force) ? created : skipped).push("clarify.ts");
|
|
118
|
+
(writeTextFile(resolve(options.root, options.content, "index.mdx"), `---
|
|
119
|
+
title: Welcome
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
# Welcome to Clarify
|
|
123
|
+
|
|
124
|
+
Start writing your documentation in \`${options.content}\`.
|
|
125
|
+
`, force) ? created : skipped).push(`${options.content}/index.mdx`);
|
|
126
|
+
if (updatePackageJson(options.root, force)) created.push("package.json");
|
|
127
|
+
console.log("[clarify] Init complete.");
|
|
128
|
+
if (created.length > 0) console.log(`[clarify] Created or updated: ${created.join(", ")}`);
|
|
129
|
+
if (skipped.length > 0) console.log(`[clarify] Skipped existing files: ${skipped.join(", ")}. Use --force to overwrite.`);
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region source/cli/options.ts
|
|
133
|
+
function resolveCliOptions(options) {
|
|
134
|
+
return {
|
|
135
|
+
root: resolve(options.root ?? process.cwd()),
|
|
136
|
+
content: options.content ?? "source",
|
|
137
|
+
output: options.output ?? "output",
|
|
138
|
+
host: options.host,
|
|
139
|
+
port: typeof options.port === "string" ? Number.parseInt(options.port, 10) : options.port,
|
|
140
|
+
open: options.open
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region source/cli/package.ts
|
|
145
|
+
function readPackageVersion() {
|
|
146
|
+
try {
|
|
147
|
+
const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), "../package.json");
|
|
148
|
+
return JSON.parse(readFileSync(packageJsonPath, "utf-8")).version ?? "0.0.0";
|
|
149
|
+
} catch {
|
|
150
|
+
return "0.0.0";
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region source/cli/index.ts
|
|
155
|
+
function withSharedOptions(command) {
|
|
156
|
+
return command.option("--root <dir>", "Project root directory").option("--content <dir>", "Content directory relative to root").option("--output <dir>", "Build output directory relative to root");
|
|
157
|
+
}
|
|
158
|
+
function resolveOptions(options) {
|
|
159
|
+
return resolveCliOptions(options);
|
|
160
|
+
}
|
|
161
|
+
async function main() {
|
|
162
|
+
const cli = cac("clarify");
|
|
163
|
+
cli.version(readPackageVersion()).help();
|
|
164
|
+
withSharedOptions(cli.command("dev", "Start the local documentation server")).option("--host [host]", "Dev server host").option("--port <port>", "Dev server port").option("--open [path]", "Open the dev server in a browser").action(async (options) => {
|
|
165
|
+
await runDev(resolveOptions(options));
|
|
166
|
+
});
|
|
167
|
+
withSharedOptions(cli.command("build", "Build the static documentation site")).action(async (options) => {
|
|
168
|
+
await runBuild(resolveOptions(options));
|
|
169
|
+
});
|
|
170
|
+
withSharedOptions(cli.command("init", "Create a minimal Clarify project scaffold")).option("--force", "Overwrite files created by init").action((options) => {
|
|
171
|
+
runInit(resolveOptions(options), options.force === true);
|
|
172
|
+
});
|
|
173
|
+
const args = process.argv.slice(2);
|
|
174
|
+
cli.parse(process.argv, { run: false });
|
|
175
|
+
if (args.length === 0) {
|
|
176
|
+
cli.outputHelp();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
await cli.runMatchedCommand();
|
|
180
|
+
}
|
|
181
|
+
main().catch((error) => {
|
|
182
|
+
console.error(error instanceof Error ? error.message : error);
|
|
183
|
+
process.exitCode = 1;
|
|
184
|
+
});
|
|
185
|
+
//#endregion
|
|
186
|
+
|
|
187
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +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 inst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+
}, z.core.$strip>]>;
|
|
6
|
+
export declare const clarifyFaviconConfigSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
7
|
+
light: z.ZodOptional<z.ZodString>;
|
|
8
|
+
dark: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>]>;
|
|
10
|
+
export declare const clarifyLocalizedTextSchema: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
11
|
+
export declare const clarifyLocaleConfigSchema: z.ZodObject<{
|
|
12
|
+
code: z.ZodString;
|
|
13
|
+
label: z.ZodString;
|
|
14
|
+
dir: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ltr">, z.ZodLiteral<"rtl">]>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const clarifyI18nConfigSchema: z.ZodObject<{
|
|
17
|
+
defaultLocale: z.ZodOptional<z.ZodString>;
|
|
18
|
+
missing: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"fallback">, z.ZodLiteral<"404">, z.ZodLiteral<"hide">]>>;
|
|
19
|
+
locales: z.ZodArray<z.ZodObject<{
|
|
20
|
+
code: z.ZodString;
|
|
21
|
+
label: z.ZodString;
|
|
22
|
+
dir: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ltr">, z.ZodLiteral<"rtl">]>>;
|
|
23
|
+
}, z.core.$strip>>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export declare const clarifyNavbarLinkSchema: z.ZodObject<{
|
|
26
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
27
|
+
href: z.ZodString;
|
|
28
|
+
external: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export declare const clarifyBannerConfigSchema: z.ZodObject<{
|
|
31
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
32
|
+
dismissible: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export declare const clarifyFooterConfigSchema: z.ZodObject<{
|
|
35
|
+
links: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
36
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
37
|
+
href: z.ZodString;
|
|
38
|
+
external: z.ZodOptional<z.ZodBoolean>;
|
|
39
|
+
}, z.core.$strip>>>;
|
|
40
|
+
socials: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
41
|
+
copyright: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export declare const clarifyPagesItemSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
44
|
+
page: z.ZodString;
|
|
45
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
46
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
47
|
+
redirect: z.ZodOptional<z.ZodString>;
|
|
48
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
49
|
+
openapi: z.ZodString;
|
|
50
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
51
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
52
|
+
}, z.core.$strip>]>;
|
|
53
|
+
export declare const clarifyPagesGroupSchema: z.ZodObject<{
|
|
54
|
+
group: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
55
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
56
|
+
pages: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
57
|
+
page: z.ZodString;
|
|
58
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
59
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
60
|
+
redirect: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
62
|
+
openapi: z.ZodString;
|
|
63
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
64
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
65
|
+
}, z.core.$strip>]>>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export declare const clarifyPagesConfigSchema: z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
68
|
+
group: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
69
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
70
|
+
pages: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
71
|
+
page: z.ZodString;
|
|
72
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
73
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
74
|
+
redirect: z.ZodOptional<z.ZodString>;
|
|
75
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
76
|
+
openapi: z.ZodString;
|
|
77
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
78
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
79
|
+
}, z.core.$strip>]>>;
|
|
80
|
+
}, z.core.$strip>>, z.ZodLiteral<"FileTree">]>;
|
|
81
|
+
export declare const clarifyProjectConfigSchema: z.ZodObject<{
|
|
82
|
+
title: z.ZodOptional<z.ZodString>;
|
|
83
|
+
description: z.ZodOptional<z.ZodString>;
|
|
84
|
+
logo: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
85
|
+
light: z.ZodOptional<z.ZodString>;
|
|
86
|
+
dark: z.ZodOptional<z.ZodString>;
|
|
87
|
+
}, z.core.$strip>]>>;
|
|
88
|
+
favicon: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
89
|
+
light: z.ZodOptional<z.ZodString>;
|
|
90
|
+
dark: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, z.core.$strip>]>>;
|
|
92
|
+
theme: z.ZodOptional<z.ZodObject<{
|
|
93
|
+
primary: z.ZodOptional<z.ZodString>;
|
|
94
|
+
}, z.core.$strip>>;
|
|
95
|
+
routePrefix: z.ZodOptional<z.ZodString>;
|
|
96
|
+
navbar: z.ZodOptional<z.ZodObject<{
|
|
97
|
+
links: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
98
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
99
|
+
href: z.ZodString;
|
|
100
|
+
external: z.ZodOptional<z.ZodBoolean>;
|
|
101
|
+
}, z.core.$strip>>>;
|
|
102
|
+
}, z.core.$strip>>;
|
|
103
|
+
banner: z.ZodOptional<z.ZodObject<{
|
|
104
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
105
|
+
dismissible: z.ZodOptional<z.ZodBoolean>;
|
|
106
|
+
}, z.core.$strip>>;
|
|
107
|
+
footer: z.ZodOptional<z.ZodObject<{
|
|
108
|
+
links: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
109
|
+
label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
110
|
+
href: z.ZodString;
|
|
111
|
+
external: z.ZodOptional<z.ZodBoolean>;
|
|
112
|
+
}, z.core.$strip>>>;
|
|
113
|
+
socials: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
114
|
+
copyright: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
115
|
+
}, z.core.$strip>>;
|
|
116
|
+
i18n: z.ZodOptional<z.ZodObject<{
|
|
117
|
+
defaultLocale: z.ZodOptional<z.ZodString>;
|
|
118
|
+
missing: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"fallback">, z.ZodLiteral<"404">, z.ZodLiteral<"hide">]>>;
|
|
119
|
+
locales: z.ZodArray<z.ZodObject<{
|
|
120
|
+
code: z.ZodString;
|
|
121
|
+
label: z.ZodString;
|
|
122
|
+
dir: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ltr">, z.ZodLiteral<"rtl">]>>;
|
|
123
|
+
}, z.core.$strip>>;
|
|
124
|
+
}, z.core.$strip>>;
|
|
125
|
+
pages: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
126
|
+
group: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
127
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
128
|
+
pages: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
129
|
+
page: z.ZodString;
|
|
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;
|
|
135
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
136
|
+
title: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
137
|
+
}, z.core.$strip>]>>;
|
|
138
|
+
}, z.core.$strip>>, z.ZodLiteral<"FileTree">]>>;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
export type ClarifyProjectConfigInput = z.input<typeof clarifyProjectConfigSchema>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ViteDevServer } from 'vite';
|
|
2
|
+
import { ClarifyHookContext, ClarifyHooks, ClarifyPlugin } from '../types.js';
|
|
3
|
+
export declare function runHooks<K extends Exclude<keyof ClarifyHooks, 'build:done' | 'dev:configureServer'>>(plugins: ClarifyPlugin[], hookName: K, input: Parameters<NonNullable<ClarifyHooks[K]>>[0], ctx: ClarifyHookContext): Promise<Parameters<NonNullable<ClarifyHooks[K]>>[0]>;
|
|
4
|
+
export declare function runDevConfigureServerHooks(plugins: ClarifyPlugin[], server: ViteDevServer, ctx: ClarifyHookContext): Promise<void>;
|
|
5
|
+
export declare function runBuildDoneHooks(plugins: ClarifyPlugin[], ctx: ClarifyHookContext): Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ClarifyPlugin, ClarifyProjectConfig } from '../types.js';
|
|
2
|
+
export type ClarifyBuildOptions = ClarifyProjectConfig & {
|
|
3
|
+
/** Project root directory. Defaults to the current working directory. */
|
|
4
|
+
projectRoot?: string;
|
|
5
|
+
/** Root directory for MDX content. Default: 'source' */
|
|
6
|
+
rootDirectory?: string;
|
|
7
|
+
/** Output directory for the built docs site. When omitted, Vite's build.outDir is used. */
|
|
8
|
+
outputDirectory?: string;
|
|
9
|
+
/** Static generation behavior. */
|
|
10
|
+
ssg?: {
|
|
11
|
+
/** Fail the build when SSG fails. Default: true. */
|
|
12
|
+
failOnError?: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** Clarify plugin extensions for translation, search, and other build-time features. */
|
|
15
|
+
plugins?: ClarifyPlugin[];
|
|
16
|
+
};
|
|
17
|
+
export type ResolvedBuildOptions = {
|
|
18
|
+
rootDirectory: string;
|
|
19
|
+
outputDirectory?: string;
|
|
20
|
+
ssg: {
|
|
21
|
+
failOnError: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare function resolveBuildOptions(options?: ClarifyBuildOptions): ResolvedBuildOptions;
|