@clarify-labs/cli 0.9.4 → 0.10.1
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/spawn.d.ts +1 -1
- package/output/cli.cjs +72 -62
- package/output/cli.cjs.map +1 -1
- package/output/cli.js +68 -58
- package/output/cli.js.map +1 -1
- package/output/core/adapters.d.ts +11 -0
- package/output/core/{config-schema.d.ts → config/config-schema.d.ts} +1 -10
- package/output/core/{config.d.ts → config/config.d.ts} +1 -1
- package/output/core/{options.d.ts → config/options.d.ts} +1 -1
- package/output/core/{user-config.d.ts → config/user-config.d.ts} +1 -1
- package/output/core/engine/context.d.ts +51 -0
- package/output/core/engine/engine.d.ts +68 -0
- package/output/core/engine/phases.d.ts +10 -0
- package/output/core/engine/types.d.ts +26 -0
- package/output/core/{builtin.d.ts → plugin/builtin.d.ts} +1 -1
- package/output/core/plugin/hooks.d.ts +7 -0
- package/output/core/plugin/manager.d.ts +9 -0
- package/output/core/{project-context.d.ts → project/project-context.d.ts} +7 -7
- package/output/core/{project-info.d.ts → project/project-info.d.ts} +1 -1
- package/output/core/{env-types.d.ts → runtime/env-types.d.ts} +1 -1
- package/output/core/runtime/html-template.d.ts +13 -0
- package/output/core/{ssg.d.ts → runtime/ssg.d.ts} +3 -3
- package/output/core/{virtual-modules.d.ts → runtime/virtual-modules.d.ts} +13 -11
- package/output/core/{vite-config.d.ts → runtime/vite-config.d.ts} +2 -1
- package/output/{plugin-Etn8ZfYN.cjs → engine-5bdNX2Oo.cjs} +2755 -2158
- package/output/engine-5bdNX2Oo.cjs.map +1 -0
- package/output/{plugin-Z3fYTMcb.js → engine-Ca_2MCj9.js} +2750 -2152
- package/output/engine-Ca_2MCj9.js.map +1 -0
- package/output/index.cjs +5 -3
- package/output/index.d.ts +7 -5
- package/output/index.js +2 -2
- package/output/parsers/content/content.d.ts +20 -0
- package/output/parsers/markdown/mdx.d.ts +37 -0
- package/output/{core → parsers/router}/dev-routes.d.ts +1 -1
- package/output/parsers/{routes.d.ts → routes/routes.d.ts} +3 -2
- package/output/parsers/routes/routes.test-utils.d.ts +20 -0
- package/output/plugins/openapi/parser.d.ts +2 -1
- package/output/plugins/openapi/virtual-modules.d.ts +4 -3
- package/output/plugins/source-links/source-links.d.ts +2 -2
- package/output/plugins/variables/index.d.ts +2 -1
- package/output/types.d.ts +138 -45
- package/package.json +11 -11
- package/output/core/content.d.ts +0 -5
- package/output/core/hooks.d.ts +0 -6
- package/output/core/plugin.d.ts +0 -3
- package/output/core/site.d.ts +0 -17
- package/output/parsers/content.d.ts +0 -11
- package/output/parsers/mdx.d.ts +0 -20
- package/output/parsers/routes.test-utils.d.ts +0 -3
- package/output/parsers/variables.d.ts +0 -2
- package/output/plugin-Etn8ZfYN.cjs.map +0 -1
- package/output/plugin-Z3fYTMcb.js.map +0 -1
- /package/output/core/{temp-dir.d.ts → project/temp-dir.d.ts} +0 -0
- /package/output/core/{log.d.ts → runtime/log.d.ts} +0 -0
- /package/output/core/{runtime-deps.d.ts → runtime/runtime-deps.d.ts} +0 -0
- /package/output/core/{startup.d.ts → runtime/startup.d.ts} +0 -0
- /package/output/parsers/{frontmatter.d.ts → markdown/frontmatter.d.ts} +0 -0
- /package/output/{core → parsers/markdown}/utils.d.ts +0 -0
- /package/output/{core → parsers}/theme.d.ts +0 -0
- /package/output/{core → plugins/search-index}/search-language.d.ts +0 -0
package/output/cli/spawn.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ type SpawnOptions = {
|
|
|
2
2
|
cwd?: string;
|
|
3
3
|
stdio?: 'inherit' | 'ignore' | Array<string>;
|
|
4
4
|
};
|
|
5
|
-
export declare function spawnSync(command: string, args: string[], options: SpawnOptions): import('child_process').SpawnSyncReturns<string | NonSharedBuffer>;
|
|
5
|
+
export declare function spawnSync(command: string, args: string[], options: SpawnOptions): import('node:child_process').SpawnSyncReturns<string | NonSharedBuffer>;
|
|
6
6
|
export {};
|
package/output/cli.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const
|
|
3
|
-
let node_fs = require("node:fs");
|
|
2
|
+
const require_engine = require("./engine-5bdNX2Oo.cjs");
|
|
4
3
|
let node_path = require("node:path");
|
|
5
|
-
let
|
|
4
|
+
let node_fs_promises = require("node:fs/promises");
|
|
5
|
+
let node_fs = require("node:fs");
|
|
6
6
|
let vite = require("vite");
|
|
7
|
+
let node_url = require("node:url");
|
|
7
8
|
let node_module = require("node:module");
|
|
8
9
|
let cac = require("cac");
|
|
9
|
-
let node_fs_promises = require("node:fs/promises");
|
|
10
10
|
let _clarify_labs_templates = require("@clarify-labs/templates");
|
|
11
11
|
let node_child_process = require("node:child_process");
|
|
12
|
-
//#region source/core/log.ts
|
|
12
|
+
//#region source/core/runtime/log.ts
|
|
13
13
|
var LOG_FILE_NAME = ".clarify.log";
|
|
14
14
|
var DEFAULT_LOG_ENTRIES = 50;
|
|
15
15
|
var ENTRY_SEPARATOR = "\n\n---\n\n";
|
|
@@ -48,43 +48,40 @@ function formatLogEntry(root, error) {
|
|
|
48
48
|
stack ? `Stack:\n${stack}` : void 0
|
|
49
49
|
].filter(Boolean).join("\n");
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
function collectLogEntries(entries, entry, max) {
|
|
52
|
+
const next = [...entries, entry];
|
|
53
|
+
return next.length > max ? next.slice(-max) : next;
|
|
54
|
+
}
|
|
55
|
+
function readExistingEntries(content) {
|
|
56
|
+
return content.split(ENTRY_SEPARATOR).map((item) => item.trim()).filter(Boolean);
|
|
57
|
+
}
|
|
58
|
+
async function writeLogEntry(root, error, maxEntries, read, write) {
|
|
52
59
|
const logPath = (0, node_path.join)(root, LOG_FILE_NAME);
|
|
53
60
|
const entry = formatLogEntry(root, error);
|
|
54
61
|
const max = maxEntries ?? getMaxLogEntries();
|
|
55
62
|
let entries = [];
|
|
56
63
|
if ((0, node_fs.existsSync)(logPath)) try {
|
|
57
|
-
entries = (await (
|
|
64
|
+
entries = readExistingEntries(await read(logPath));
|
|
58
65
|
} catch {
|
|
59
66
|
entries = [];
|
|
60
67
|
}
|
|
61
|
-
entries
|
|
62
|
-
if (entries.length > max) entries = entries.slice(-max);
|
|
68
|
+
entries = collectLogEntries(entries, entry, max);
|
|
63
69
|
(0, node_fs.mkdirSync)((0, node_path.dirname)(logPath), { recursive: true });
|
|
64
|
-
await (
|
|
70
|
+
await write(logPath, entries.join(ENTRY_SEPARATOR) + "\n");
|
|
71
|
+
}
|
|
72
|
+
async function logBuildError(root, error, maxEntries) {
|
|
73
|
+
await writeLogEntry(root, error, maxEntries, (path) => (0, node_fs_promises.readFile)(path, "utf8"), (path, content) => (0, node_fs_promises.writeFile)(path, content, "utf8"));
|
|
65
74
|
}
|
|
66
75
|
function logBuildErrorSync(root, error, maxEntries) {
|
|
67
|
-
|
|
68
|
-
const entry = formatLogEntry(root, error);
|
|
69
|
-
const max = maxEntries ?? getMaxLogEntries();
|
|
70
|
-
let entries = [];
|
|
71
|
-
if ((0, node_fs.existsSync)(logPath)) try {
|
|
72
|
-
entries = (0, node_fs.readFileSync)(logPath, "utf8").split(ENTRY_SEPARATOR).map((item) => item.trim()).filter(Boolean);
|
|
73
|
-
} catch {
|
|
74
|
-
entries = [];
|
|
75
|
-
}
|
|
76
|
-
entries.push(entry);
|
|
77
|
-
if (entries.length > max) entries = entries.slice(-max);
|
|
78
|
-
(0, node_fs.mkdirSync)((0, node_path.dirname)(logPath), { recursive: true });
|
|
79
|
-
(0, node_fs.writeFileSync)(logPath, entries.join(ENTRY_SEPARATOR) + "\n", "utf8");
|
|
76
|
+
writeLogEntry(root, error, maxEntries, (path) => (0, node_fs.readFileSync)(path, "utf8"), (path, content) => (0, node_fs.writeFileSync)(path, content, "utf8"));
|
|
80
77
|
}
|
|
81
78
|
//#endregion
|
|
82
|
-
//#region source/core/vite-config.ts
|
|
79
|
+
//#region source/core/runtime/vite-config.ts
|
|
83
80
|
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>";
|
|
84
81
|
function ensureHtmlEntry(root) {
|
|
85
82
|
const projectHtmlPath = (0, node_path.resolve)(root, "index.html");
|
|
86
83
|
if ((0, node_fs.existsSync)(projectHtmlPath)) return projectHtmlPath;
|
|
87
|
-
const generatedHtmlPath = (0, node_path.resolve)(
|
|
84
|
+
const generatedHtmlPath = (0, node_path.resolve)(require_engine.createClarifyTempDir("html"), "index.html");
|
|
88
85
|
(0, node_fs.writeFileSync)(generatedHtmlPath, DEFAULT_HTML, "utf-8");
|
|
89
86
|
return generatedHtmlPath;
|
|
90
87
|
}
|
|
@@ -141,26 +138,15 @@ function createHtmlFallbackPlugin() {
|
|
|
141
138
|
}
|
|
142
139
|
};
|
|
143
140
|
}
|
|
144
|
-
async function createViteConfig(options, env) {
|
|
141
|
+
async function createViteConfig(options, env, engine) {
|
|
145
142
|
const entryHtmlPath = ensureHtmlEntry(options.root);
|
|
146
|
-
const context = await require_plugin.resolveProjectContext({
|
|
147
|
-
projectRoot: options.root,
|
|
148
|
-
rootDirectory: options.content,
|
|
149
|
-
outputDirectory: options.output
|
|
150
|
-
}, env);
|
|
151
|
-
const buildOptions = {
|
|
152
|
-
...context.config,
|
|
153
|
-
projectRoot: context.projectRoot,
|
|
154
|
-
rootDirectory: context.buildOptions.rootDirectory,
|
|
155
|
-
outputDirectory: context.buildOptions.outputDirectory
|
|
156
|
-
};
|
|
157
143
|
return {
|
|
158
144
|
root: options.root,
|
|
159
145
|
configFile: false,
|
|
160
146
|
appType: "custom",
|
|
161
|
-
resolve: { alias:
|
|
147
|
+
resolve: { alias: require_engine.createClarifyRuntimeAliases() },
|
|
162
148
|
customLogger: createClarifyLogger(options.root, env, "info"),
|
|
163
|
-
plugins: [
|
|
149
|
+
plugins: [require_engine.createViteAdapter(engine), createHtmlFallbackPlugin()],
|
|
164
150
|
server: {
|
|
165
151
|
host: options.host,
|
|
166
152
|
port: options.port,
|
|
@@ -187,6 +173,11 @@ async function createViteConfig(options, env) {
|
|
|
187
173
|
test: /node_modules[\\/](@headlessui|framer-motion)[\\/]/,
|
|
188
174
|
priority: 30
|
|
189
175
|
},
|
|
176
|
+
{
|
|
177
|
+
name: "mermaid-viewer-vendor",
|
|
178
|
+
test: /node_modules[\\/]react-zoom-pan-pinch[\\/]/,
|
|
179
|
+
priority: 25
|
|
180
|
+
},
|
|
190
181
|
{
|
|
191
182
|
name: "mermaid-vendor",
|
|
192
183
|
test: /node_modules[\\/](mermaid|@mermaid-js|cytoscape|cytoscape-[^\\/]+|dagre-d3-es|@dagrejs|dagre|graphlib|elkjs|katex|d3|d3-[^\\/]+|internmap|delaunator|robust-predicates|roughjs|points-on-curve|points-on-path|path-data-parser|@braintree[\\/]sanitize-url|dompurify|khroma|ts-dedent|stylis|cose-base|layout-base)[\\/]/,
|
|
@@ -205,11 +196,18 @@ async function createViteConfig(options, env) {
|
|
|
205
196
|
//#endregion
|
|
206
197
|
//#region source/cli/commands/build.ts
|
|
207
198
|
async function runBuild(options) {
|
|
199
|
+
const env = {
|
|
200
|
+
command: "build",
|
|
201
|
+
mode: "production"
|
|
202
|
+
};
|
|
203
|
+
const engine = require_engine.createClarifyEngine({
|
|
204
|
+
projectRoot: options.root,
|
|
205
|
+
rootDirectory: options.content,
|
|
206
|
+
outputDirectory: options.output
|
|
207
|
+
});
|
|
208
208
|
try {
|
|
209
|
-
await (
|
|
210
|
-
|
|
211
|
-
mode: "production"
|
|
212
|
-
}));
|
|
209
|
+
await engine.prepare(env);
|
|
210
|
+
await (0, vite.build)(await createViteConfig(options, env, engine));
|
|
213
211
|
} catch (error) {
|
|
214
212
|
await logBuildError(options.root, error);
|
|
215
213
|
throw error;
|
|
@@ -218,7 +216,7 @@ async function runBuild(options) {
|
|
|
218
216
|
//#endregion
|
|
219
217
|
//#region source/cli/commands/check.ts
|
|
220
218
|
var LOCAL_LINK_PATTERN = /(?<!!)(?:\[[^\]]*\]\(([^)\s]+)(?:\s+"[^"]*")?\)|<a\s+[^>]*href=["']([^"']+)["'])/gi;
|
|
221
|
-
var ROUTE_EXTENSIONS = new Set([".md", ".mdx"]);
|
|
219
|
+
var ROUTE_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".mdx"]);
|
|
222
220
|
var IGNORED_SCHEMES = /^[a-z][a-z0-9+.-]*:/i;
|
|
223
221
|
function addDiagnostic(result, diagnostic) {
|
|
224
222
|
if (diagnostic.level === "error") result.errors.push(diagnostic);
|
|
@@ -251,7 +249,7 @@ function isLocalHref(href) {
|
|
|
251
249
|
async function resolveLocalFileLink(href, route, contentRoot) {
|
|
252
250
|
const [withoutHashOrQuery] = href.split(/[?#]/);
|
|
253
251
|
if (!withoutHashOrQuery || withoutHashOrQuery.startsWith("/")) return false;
|
|
254
|
-
const target = (0, node_path.resolve)((0, node_path.dirname)(route.filePath), withoutHashOrQuery);
|
|
252
|
+
const target = (0, node_path.resolve)((0, node_path.dirname)(route.source.filePath), withoutHashOrQuery);
|
|
255
253
|
const relativeTarget = (0, node_path.relative)(contentRoot, target);
|
|
256
254
|
if (relativeTarget.startsWith("..") || (0, node_path.isAbsolute)(relativeTarget)) return false;
|
|
257
255
|
if (await pathExists(target)) return true;
|
|
@@ -286,8 +284,8 @@ function checkDuplicateRoutes(routes, result) {
|
|
|
286
284
|
for (const route of duplicated) addDiagnostic(result, {
|
|
287
285
|
level: "error",
|
|
288
286
|
code: "duplicate-route",
|
|
289
|
-
message: `Route "${route.path}" is defined by multiple files: ${duplicated.map((route) => (0, node_path.relative)(process.cwd(), route.filePath)).join(", ")}`,
|
|
290
|
-
filePath: route.filePath,
|
|
287
|
+
message: `Route "${route.path}" is defined by multiple files: ${duplicated.map((route) => (0, node_path.relative)(process.cwd(), route.source.filePath)).join(", ")}`,
|
|
288
|
+
filePath: route.source.filePath,
|
|
291
289
|
routePath: route.path
|
|
292
290
|
});
|
|
293
291
|
}
|
|
@@ -298,8 +296,8 @@ function checkFallbackRoutes(routes, result) {
|
|
|
298
296
|
addDiagnostic(result, {
|
|
299
297
|
level: "warning",
|
|
300
298
|
code: "i18n-fallback-route",
|
|
301
|
-
message: `Route "${route.path}" falls back to ${route.locale ?? "default"} content from ${(0, node_path.relative)(process.cwd(), route.filePath)}`,
|
|
302
|
-
filePath: route.filePath,
|
|
299
|
+
message: `Route "${route.path}" falls back to ${route.locale ?? "default"} content from ${(0, node_path.relative)(process.cwd(), route.source.filePath)}`,
|
|
300
|
+
filePath: route.source.filePath,
|
|
303
301
|
routePath: route.path
|
|
304
302
|
});
|
|
305
303
|
}
|
|
@@ -307,8 +305,8 @@ function checkFallbackRoutes(routes, result) {
|
|
|
307
305
|
async function checkLocalLinks(routes, contentRoot, result) {
|
|
308
306
|
const routePaths = new Set(routes.map((route) => route.path));
|
|
309
307
|
for (const route of routes) {
|
|
310
|
-
if (route.kind !== "mdx" || !route.content) continue;
|
|
311
|
-
for (const match of route.content.matchAll(LOCAL_LINK_PATTERN)) {
|
|
308
|
+
if (route.kind !== "mdx" || !route.source.content) continue;
|
|
309
|
+
for (const match of route.source.content.matchAll(LOCAL_LINK_PATTERN)) {
|
|
312
310
|
const href = match[1] ?? match[2];
|
|
313
311
|
if (!href || !isLocalHref(href)) continue;
|
|
314
312
|
if (routePathCandidates(href, route).some((candidate) => routePaths.has(candidate))) continue;
|
|
@@ -317,7 +315,7 @@ async function checkLocalLinks(routes, contentRoot, result) {
|
|
|
317
315
|
level: "error",
|
|
318
316
|
code: "broken-link",
|
|
319
317
|
message: `Broken local link "${href}" in route "${route.path}"`,
|
|
320
|
-
filePath: route.filePath,
|
|
318
|
+
filePath: route.source.filePath,
|
|
321
319
|
routePath: route.path
|
|
322
320
|
});
|
|
323
321
|
}
|
|
@@ -339,19 +337,24 @@ function printTextResult(result, strict) {
|
|
|
339
337
|
console.log(`\n${result.errors.length} error(s), ${result.warnings.length} warning(s)${warningExit ? " (--strict treats warnings as failures)" : ""}`);
|
|
340
338
|
}
|
|
341
339
|
async function runCheck(options = {}) {
|
|
342
|
-
const
|
|
340
|
+
const engine = require_engine.createClarifyEngine({
|
|
343
341
|
projectRoot: (0, node_path.resolve)(options.root ?? process.cwd()),
|
|
344
342
|
rootDirectory: options.content,
|
|
345
343
|
outputDirectory: options.output
|
|
346
|
-
}
|
|
344
|
+
});
|
|
345
|
+
await engine.prepare(void 0, void 0, {
|
|
346
|
+
htmlShell: false,
|
|
347
|
+
skipModules: true,
|
|
348
|
+
skipHints: true
|
|
349
|
+
});
|
|
347
350
|
const result = {
|
|
348
351
|
errors: [],
|
|
349
352
|
warnings: []
|
|
350
353
|
};
|
|
351
|
-
await checkContentDirectory(
|
|
352
|
-
checkDuplicateRoutes(
|
|
353
|
-
checkFallbackRoutes(
|
|
354
|
-
await checkLocalLinks(
|
|
354
|
+
await checkContentDirectory(engine.contentRoot, result);
|
|
355
|
+
checkDuplicateRoutes(engine.routes, result);
|
|
356
|
+
checkFallbackRoutes(engine.routes, result);
|
|
357
|
+
await checkLocalLinks(engine.routes, engine.contentRoot, result);
|
|
355
358
|
if (options.format === "json") console.log(JSON.stringify(result, null, 2));
|
|
356
359
|
else printTextResult(result, Boolean(options.strict));
|
|
357
360
|
if (result.errors.length > 0 || options.strict && result.warnings.length > 0) process.exitCode = 1;
|
|
@@ -359,10 +362,17 @@ async function runCheck(options = {}) {
|
|
|
359
362
|
//#endregion
|
|
360
363
|
//#region source/cli/commands/dev.ts
|
|
361
364
|
async function runDev(options) {
|
|
362
|
-
const
|
|
365
|
+
const env = {
|
|
363
366
|
command: "serve",
|
|
364
367
|
mode: "development"
|
|
365
|
-
}
|
|
368
|
+
};
|
|
369
|
+
const engine = require_engine.createClarifyEngine({
|
|
370
|
+
projectRoot: options.root,
|
|
371
|
+
rootDirectory: options.content,
|
|
372
|
+
outputDirectory: options.output
|
|
373
|
+
});
|
|
374
|
+
await engine.prepare(env);
|
|
375
|
+
const server = await (0, vite.createServer)(await createViteConfig(options, env, engine));
|
|
366
376
|
await server.listen();
|
|
367
377
|
server.printUrls();
|
|
368
378
|
server.bindCLIShortcuts({ print: true });
|
|
@@ -434,7 +444,7 @@ function updatePackageJson(root, force) {
|
|
|
434
444
|
if (force || !scripts.build) scripts.build = "clarify build";
|
|
435
445
|
packageJson.scripts = scripts;
|
|
436
446
|
const devDependencies = typeof packageJson.devDependencies === "object" && packageJson.devDependencies !== null ? packageJson.devDependencies : {};
|
|
437
|
-
if (!devDependencies["@clarify-labs/cli"]) devDependencies["@clarify-labs/cli"] =
|
|
447
|
+
if (!devDependencies["@clarify-labs/cli"]) devDependencies["@clarify-labs/cli"] = require_engine.cliPackageVersionWithCaret;
|
|
438
448
|
packageJson.devDependencies = devDependencies;
|
|
439
449
|
(0, node_fs.writeFileSync)(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, "utf-8");
|
|
440
450
|
return true;
|
|
@@ -502,7 +512,7 @@ function resolveOptions(options) {
|
|
|
502
512
|
}
|
|
503
513
|
function createCli() {
|
|
504
514
|
const cli = (0, cac.cac)("clarify");
|
|
505
|
-
cli.version(
|
|
515
|
+
cli.version(require_engine.cliPackageVersion).help();
|
|
506
516
|
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) => {
|
|
507
517
|
await runDev(resolveOptions(options));
|
|
508
518
|
});
|
package/output/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","names":[],"sources":["../source/core/log.ts","../source/core/vite-config.ts","../source/cli/commands/build.ts","../source/cli/commands/check.ts","../source/cli/commands/dev.ts","../source/cli/spawn.ts","../source/cli/commands/init.ts","../source/cli/options.ts","../source/cli/program.ts","../source/cli/index.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { readFile, writeFile } from 'node:fs/promises'\nimport { dirname, join } from 'node:path'\n\nconst LOG_FILE_NAME = '.clarify.log'\nconst DEFAULT_LOG_ENTRIES = 50\nconst ENTRY_SEPARATOR = '\\n\\n---\\n\\n'\n\nfunction getMaxLogEntries(): number {\n const envValue = process.env.CLARIFY_LOG_MAX_ENTRIES\n if (!envValue) return DEFAULT_LOG_ENTRIES\n const parsed = Number(envValue)\n return Number.isInteger(parsed) && parsed > 0 ? parsed : DEFAULT_LOG_ENTRIES\n}\n\nfunction normalizeErrorMessage(error: unknown): string {\n if (error === undefined) return 'undefined'\n if (error === null) return 'null'\n if (error instanceof Error) return error.message\n if (typeof error === 'object') {\n if ('message' in error && typeof (error as { message?: unknown }).message === 'string') {\n return (error as { message: string }).message\n }\n try {\n return JSON.stringify(error)\n } catch {\n return String(error)\n }\n }\n return String(error)\n}\n\nfunction normalizeErrorStack(error: unknown): string | undefined {\n if (error instanceof Error) {\n return error.stack\n }\n return undefined\n}\n\nfunction formatLogEntry(root: string, error: unknown): string {\n const timestamp = new Date().toISOString()\n const message = normalizeErrorMessage(error)\n const stack = normalizeErrorStack(error)\n\n return [`=== Clarify build error ===`, `Timestamp: ${timestamp}`, `Project root: ${root}`, `Error: ${message}`, stack ? `Stack:\\n${stack}` : undefined]\n .filter(Boolean)\n .join('\\n')\n}\n\nexport async function logBuildError(root: string, error: unknown, maxEntries?: number): Promise<void> {\n const logPath = join(root, LOG_FILE_NAME)\n const entry = formatLogEntry(root, error)\n const max = maxEntries ?? getMaxLogEntries()\n\n let entries: string[] = []\n if (existsSync(logPath)) {\n try {\n const content = await readFile(logPath, 'utf8')\n entries = content\n .split(ENTRY_SEPARATOR)\n .map((item) => item.trim())\n .filter(Boolean)\n } catch {\n entries = []\n }\n }\n\n entries.push(entry)\n if (entries.length > max) {\n entries = entries.slice(-max)\n }\n\n mkdirSync(dirname(logPath), { recursive: true })\n await writeFile(logPath, entries.join(ENTRY_SEPARATOR) + '\\n', 'utf8')\n}\n\nexport function logBuildErrorSync(root: string, error: unknown, maxEntries?: number): void {\n const logPath = join(root, LOG_FILE_NAME)\n const entry = formatLogEntry(root, error)\n const max = maxEntries ?? getMaxLogEntries()\n\n let entries: string[] = []\n if (existsSync(logPath)) {\n try {\n const content = readFileSync(logPath, 'utf8')\n entries = content\n .split(ENTRY_SEPARATOR)\n .map((item) => item.trim())\n .filter(Boolean)\n } catch {\n entries = []\n }\n }\n\n entries.push(entry)\n if (entries.length > max) {\n entries = entries.slice(-max)\n }\n\n mkdirSync(dirname(logPath), { recursive: true })\n writeFileSync(logPath, entries.join(ENTRY_SEPARATOR) + '\\n', 'utf8')\n}\n","import { existsSync, writeFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nimport { createLogger } from 'vite'\nimport type { ConfigEnv, InlineConfig, Plugin, LogLevel, Logger, LogOptions, LogErrorOptions, LogType } from 'vite'\n\nimport { logBuildErrorSync } from './log.js'\nimport type { ClarifyBuildOptions } from './options.js'\nimport { clarifyPlugin } from './plugin.js'\nimport { resolveProjectContext } from './project-context.js'\nimport { createClarifyRuntimeAliases } from './runtime-deps.js'\nimport { createClarifyTempDir } from './temp-dir.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(createClarifyTempDir('html'), 'index.html')\n writeFileSync(generatedHtmlPath, DEFAULT_HTML, 'utf-8')\n return generatedHtmlPath\n}\n\nfunction createClarifyLogger(root: string, env: ConfigEnv, level: LogLevel): Logger | undefined {\n if (env.command !== 'build') return undefined\n\n const baseLogger = createLogger(level, { allowClearScreen: true })\n\n return {\n info(msg: string, options?: LogOptions) {\n baseLogger.info(msg, options)\n },\n warn(msg: string, options?: LogOptions) {\n baseLogger.warn(msg, options)\n },\n warnOnce(msg: string, options?: LogOptions) {\n baseLogger.warnOnce(msg, options)\n },\n error(msg: string, options?: LogErrorOptions) {\n baseLogger.error(msg, options)\n if (options?.error) {\n logBuildErrorSync(root, options.error)\n } else {\n logBuildErrorSync(root, typeof msg === 'string' ? new Error(msg) : msg)\n }\n },\n clearScreen(type: LogType) {\n baseLogger.clearScreen(type)\n },\n hasErrorLogged(error: Error | unknown) {\n return baseLogger.hasErrorLogged(error as Error)\n },\n get hasWarned() {\n return baseLogger.hasWarned\n },\n }\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 context = await resolveProjectContext({\n projectRoot: options.root,\n rootDirectory: options.content,\n outputDirectory: options.output,\n }, env)\n const buildOptions: ClarifyBuildOptions = {\n ...context.config,\n projectRoot: context.projectRoot,\n rootDirectory: context.buildOptions.rootDirectory,\n outputDirectory: context.buildOptions.outputDirectory,\n }\n\n return {\n root: options.root,\n configFile: false,\n appType: 'custom',\n resolve: {\n alias: createClarifyRuntimeAliases(),\n },\n customLogger: createClarifyLogger(options.root, env, 'info'),\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 // Keep mermaid and its heavy diagram/render dependencies out of\n // the eager `vendor` chunk so they stay lazily loaded only on\n // pages that actually render a diagram.\n name: 'mermaid-vendor',\n test: /node_modules[\\\\/](mermaid|@mermaid-js|cytoscape|cytoscape-[^\\\\/]+|dagre-d3-es|@dagrejs|dagre|graphlib|elkjs|katex|d3|d3-[^\\\\/]+|internmap|delaunator|robust-predicates|roughjs|points-on-curve|points-on-path|path-data-parser|@braintree[\\\\/]sanitize-url|dompurify|khroma|ts-dedent|stylis|cose-base|layout-base)[\\\\/]/,\n priority: 20,\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 { logBuildError } from '../../core/log.js'\nimport { createViteConfig } from '../../core/vite-config.js'\nimport type { ResolvedCliOptions } from '../options.js'\n\nexport async function runBuild(options: ResolvedCliOptions): Promise<void> {\n try {\n await viteBuild(await createViteConfig(options, { command: 'build', mode: 'production' }))\n } catch (error) {\n await logBuildError(options.root, error)\n throw error\n }\n}\n","import { lstat, stat } from 'node:fs/promises'\nimport { dirname, extname, isAbsolute, join, normalize, relative, resolve } from 'node:path'\n\nimport { resolveClarifySite } from '../../core/site.js'\nimport type { ContentRoute } from '../../types.js'\nimport type { CliOptions } from '../options.js'\n\nexport type CheckCommandOptions = CliOptions & {\n strict?: boolean\n format?: 'text' | 'json' | string\n}\n\ntype CheckLevel = 'error' | 'warning'\n\ntype CheckDiagnostic = {\n level: CheckLevel\n code: string\n message: string\n filePath?: string\n routePath?: string\n}\n\ntype CheckResult = {\n errors: CheckDiagnostic[]\n warnings: CheckDiagnostic[]\n}\n\nconst LOCAL_LINK_PATTERN = /(?<!!)(?:\\[[^\\]]*\\]\\(([^)\\s]+)(?:\\s+\"[^\"]*\")?\\)|<a\\s+[^>]*href=[\"']([^\"']+)[\"'])/gi\nconst ROUTE_EXTENSIONS = new Set(['.md', '.mdx'])\nconst IGNORED_SCHEMES = /^[a-z][a-z0-9+.-]*:/i\n\nfunction addDiagnostic(result: CheckResult, diagnostic: CheckDiagnostic): void {\n if (diagnostic.level === 'error') result.errors.push(diagnostic)\n else result.warnings.push(diagnostic)\n}\n\nfunction normalizeRoutePath(path: string): string {\n const [withoutHash] = path.split('#')\n const clean = withoutHash.replace(/\\/index$/, '') || '/'\n return clean.startsWith('/') ? clean : `/${clean}`\n}\n\nfunction routePathCandidates(href: string, route: ContentRoute): string[] {\n const [withoutHashOrQuery] = href.split(/[?#]/)\n if (!withoutHashOrQuery || withoutHashOrQuery.startsWith('#')) return []\n if (withoutHashOrQuery.startsWith('/')) return [normalizeRoutePath(withoutHashOrQuery)]\n\n const routeDir = dirname(route.path)\n const joined = normalize(join(routeDir, withoutHashOrQuery)).replaceAll('\\\\', '/')\n const extension = extname(joined)\n const base = ROUTE_EXTENSIONS.has(extension) ? joined.slice(0, -extension.length) : joined\n return [normalizeRoutePath(base)]\n}\n\nasync function pathExists(filePath: string): Promise<boolean> {\n try {\n await stat(filePath)\n return true\n } catch {\n return false\n }\n}\n\nfunction isLocalHref(href: string): boolean {\n return Boolean(href) && !href.startsWith('#') && !href.startsWith('//') && !IGNORED_SCHEMES.test(href)\n}\n\nasync function resolveLocalFileLink(href: string, route: ContentRoute, contentRoot: string): Promise<boolean> {\n const [withoutHashOrQuery] = href.split(/[?#]/)\n if (!withoutHashOrQuery || withoutHashOrQuery.startsWith('/')) return false\n\n const target = resolve(dirname(route.filePath), withoutHashOrQuery)\n const relativeTarget = relative(contentRoot, target)\n if (relativeTarget.startsWith('..') || isAbsolute(relativeTarget)) return false\n if (await pathExists(target)) return true\n\n if (!extname(target)) {\n return pathExists(`${target}.md`) || pathExists(`${target}.mdx`) || pathExists(join(target, 'index.md')) || pathExists(join(target, 'index.mdx'))\n }\n return false\n}\n\nasync function checkContentDirectory(contentRoot: string, result: CheckResult): Promise<void> {\n try {\n const stats = await lstat(contentRoot)\n if (!stats.isDirectory()) {\n addDiagnostic(result, {\n level: 'error',\n code: 'content-not-directory',\n message: `Content path is not a directory: ${contentRoot}`,\n filePath: contentRoot,\n })\n }\n } catch {\n addDiagnostic(result, {\n level: 'error',\n code: 'content-missing',\n message: `Content directory does not exist: ${contentRoot}`,\n filePath: contentRoot,\n })\n }\n}\n\nfunction checkDuplicateRoutes(routes: ContentRoute[], result: CheckResult): void {\n const byPath = new Map<string, ContentRoute[]>()\n for (const route of routes) {\n const key = `${route.locale ?? ''}:${route.path}`\n byPath.set(key, [...(byPath.get(key) ?? []), route])\n }\n\n for (const duplicated of byPath.values()) {\n if (duplicated.length < 2) continue\n for (const route of duplicated) {\n addDiagnostic(result, {\n level: 'error',\n code: 'duplicate-route',\n message: `Route \"${route.path}\" is defined by multiple files: ${duplicated.map(route => relative(process.cwd(), route.filePath)).join(', ')}`,\n filePath: route.filePath,\n routePath: route.path,\n })\n }\n }\n}\n\nfunction checkFallbackRoutes(routes: ContentRoute[], result: CheckResult): void {\n for (const route of routes) {\n if (!route.isFallback) continue\n addDiagnostic(result, {\n level: 'warning',\n code: 'i18n-fallback-route',\n message: `Route \"${route.path}\" falls back to ${route.locale ?? 'default'} content from ${relative(process.cwd(), route.filePath)}`,\n filePath: route.filePath,\n routePath: route.path,\n })\n }\n}\n\nasync function checkLocalLinks(routes: ContentRoute[], contentRoot: string, result: CheckResult): Promise<void> {\n const routePaths = new Set(routes.map(route => route.path))\n\n for (const route of routes) {\n if (route.kind !== 'mdx' || !route.content) continue\n for (const match of route.content.matchAll(LOCAL_LINK_PATTERN)) {\n const href = match[1] ?? match[2]\n if (!href || !isLocalHref(href)) continue\n const candidates = routePathCandidates(href, route)\n if (candidates.some(candidate => routePaths.has(candidate))) continue\n if (await resolveLocalFileLink(href, route, contentRoot)) continue\n\n addDiagnostic(result, {\n level: 'error',\n code: 'broken-link',\n message: `Broken local link \"${href}\" in route \"${route.path}\"`,\n filePath: route.filePath,\n routePath: route.path,\n })\n }\n }\n}\n\nfunction printTextResult(result: CheckResult, strict: boolean): void {\n const diagnostics = [...result.errors, ...result.warnings]\n if (diagnostics.length === 0) {\n console.log('✓ Clarify check passed')\n return\n }\n\n for (const diagnostic of diagnostics) {\n const location = diagnostic.filePath ? ` ${relative(process.cwd(), diagnostic.filePath)}` : ''\n const route = diagnostic.routePath ? ` (${diagnostic.routePath})` : ''\n console.log(`${diagnostic.level.toUpperCase()} ${diagnostic.code}${location}${route}`)\n console.log(` ${diagnostic.message}`)\n }\n\n const warningExit = strict && result.warnings.length > 0\n console.log(`\\n${result.errors.length} error(s), ${result.warnings.length} warning(s)${warningExit ? ' (--strict treats warnings as failures)' : ''}`)\n}\n\nexport async function runCheck(options: CheckCommandOptions = {}): Promise<void> {\n const root = resolve(options.root ?? process.cwd())\n const site = await resolveClarifySite({\n projectRoot: root,\n rootDirectory: options.content,\n outputDirectory: options.output,\n }, { includeHtmlShellPlugin: false })\n\n const result: CheckResult = { errors: [], warnings: [] }\n await checkContentDirectory(site.contentRoot, result)\n checkDuplicateRoutes(site.routes, result)\n checkFallbackRoutes(site.routes, result)\n await checkLocalLinks(site.routes, site.contentRoot, result)\n\n if (options.format === 'json') {\n console.log(JSON.stringify(result, null, 2))\n } else {\n printTextResult(result, Boolean(options.strict))\n }\n\n if (result.errors.length > 0 || (options.strict && result.warnings.length > 0)) {\n process.exitCode = 1\n }\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 { spawnSync as nodeSpawnSync, SpawnSyncOptions } from 'node:child_process'\n\ntype SpawnOptions = { cwd?: string; stdio?: 'inherit' | 'ignore' | Array<string> }\n\nexport function spawnSync(command: string, args: string[], options: SpawnOptions) {\n return nodeSpawnSync(command, args, options as SpawnSyncOptions)\n}\n","import { existsSync, readFileSync, writeFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport { copyTemplateDirectory, getTemplateDirectory, resolveTemplate } from '@clarify-labs/templates'\n\nimport type { ResolvedCliOptions } from '../options.js'\nimport { cliPackageVersionWithCaret } from '../package.js'\nimport { spawnSync } from '../spawn.js'\n\nconst require = createRequire(import.meta.url)\n\nfunction findTemplatesPackagePath(): string {\n try {\n return require.resolve('@clarify-labs/templates/package.json')\n } catch {\n const currentDirectory = dirname(fileURLToPath(import.meta.url))\n const workspacePackagePath = resolve(currentDirectory, '../../../../templates/package.json')\n if (existsSync(workspacePackagePath)) return workspacePackagePath\n throw new Error('[clarify] Templates package not found.')\n }\n}\n\nconst templatesPackagePath = findTemplatesPackagePath()\nconst templatesDirectory = dirname(templatesPackagePath)\n\nfunction commandExists(program: string): boolean {\n const result = spawnSync(program, ['--version'], { stdio: 'ignore' })\n return result.status === 0 && result.error === undefined\n}\n\ntype InstallCommand = { command: string; args: string[] }\n\nfunction getInstallCommand(): InstallCommand {\n if (commandExists('pnpm')) return { command: 'pnpm', args: ['install'] }\n if (commandExists('npm')) return { command: 'npm', args: ['install'] }\n if (commandExists('yarn')) return { command: 'yarn', args: ['install'] }\n return { command: 'npm', args: ['install'] }\n}\n\nfunction installDependencies(root: string): void {\n const { command, args } = getInstallCommand()\n console.log(`[clarify] Installing dependencies with ${command}...`)\n const result = spawnSync(command, args, { cwd: root, stdio: 'inherit' })\n if (result.status !== 0) {\n throw new Error(`[clarify] Dependency install failed with ${command}`)\n }\n}\n\nfunction getSuggestedInstallCommand(): string {\n if (commandExists('pnpm')) return 'pnpm install'\n if (commandExists('npm')) return 'npm install'\n if (commandExists('yarn')) return 'yarn install'\n return 'npm install'\n}\n\nfunction getSuggestedRunCommand(): string {\n if (commandExists('pnpm')) return 'pnpm dev'\n if (commandExists('yarn')) return 'yarn dev'\n return 'npm run dev'\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'] = cliPackageVersionWithCaret\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, template?: string, install = false): void {\n const selectedTemplate = resolveTemplate(template)\n const templateDirectory = getTemplateDirectory(templatesDirectory, selectedTemplate)\n const { created } = copyTemplateDirectory(templateDirectory, options.root, {\n contentDir: options.content,\n force,\n })\n\n const packageJsonUpdated = updatePackageJson(options.root, force)\n if (packageJsonUpdated) created.push('package.json')\n\n console.log(`[clarify] Project scaffold created using the ${selectedTemplate} template.`)\n if (created.length > 0) {\n console.log(`[clarify] Created or updated ${created.length} ${created.length === 1 ? 'file' : 'files'}: ${created.join(', ')}`)\n }\n\n if (install) {\n installDependencies(options.root)\n const suggestedRun = getSuggestedRunCommand()\n console.log('[clarify] Dependencies installed successfully.')\n console.log(`[clarify] You can now run \\`${suggestedRun}\\` to start the local documentation server.`)\n return\n }\n\n const suggestedInstall = getSuggestedInstallCommand()\n const suggestedRun = getSuggestedRunCommand()\n console.log('[clarify] Next steps:')\n console.log(' 1. Change into your new project directory:')\n console.log(` cd ${options.root}`)\n console.log(' 2. Install dependencies:')\n console.log(` ${suggestedInstall}`)\n console.log(' 3. Start the local documentation server:')\n console.log(` ${suggestedRun}`)\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\nfunction resolvePort(port: CliOptions['port']): number | undefined {\n if (port === undefined) return undefined\n\n const parsedPort = typeof port === 'string' ? Number(port) : port\n if (!Number.isInteger(parsedPort) || parsedPort < 1 || parsedPort > 65535) {\n throw new Error('[clarify] --port must be an integer between 1 and 65535')\n }\n\n return parsedPort\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: resolvePort(options.port),\n open: options.open,\n }\n}\n","import { cac } from 'cac'\n\nimport { runBuild } from './commands/build.js'\nimport { runCheck, type CheckCommandOptions } from './commands/check.js'\nimport { runDev } from './commands/dev.js'\nimport { runInit } from './commands/init.js'\nimport { resolveCliOptions, type CliOptions, type ResolvedCliOptions } from './options.js'\nimport { cliPackageVersion } from './package.js'\n\ntype InitCommandOptions = CliOptions & {\n force?: boolean\n template?: string\n install?: boolean\n}\n\nfunction withBuildOptions(command: ReturnType<ReturnType<typeof cac>['command']>) {\n return command\n .option('--content <dir>', 'Content directory relative to root')\n}\n\nfunction resolveInitOptions(directory: string | undefined, options: InitCommandOptions): ResolvedCliOptions {\n return resolveOptions({\n ...options,\n root: directory,\n })\n}\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\nexport function createCli() {\n const cli = cac('clarify')\n\n cli\n .version(cliPackageVersion)\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('check', 'Validate the documentation project'))\n .option('--strict', 'Treat warnings as failures')\n .option('--format <format>', 'Output format: text or json')\n .action(async (options: CheckCommandOptions) => {\n await runCheck(options)\n })\n\n withBuildOptions(cli.command('init [directory]', 'Create a Clarify project scaffold'))\n .option('--force', 'Overwrite files created by init')\n .option('--template <name>', 'Template to use: minimal, standard, or complete')\n .option('--install', 'Install dependencies after init')\n .action((directory: string | undefined, options: InitCommandOptions) => {\n runInit(resolveInitOptions(directory, options), options.force === true, options.template, options.install === true)\n })\n\n return cli\n}\n\nexport async function main(argv = process.argv): Promise<void> {\n const cli = createCli()\n const args = argv.slice(2)\n cli.parse(argv, { run: false })\n\n if (args.length === 0) {\n cli.outputHelp()\n return\n }\n\n await cli.runMatchedCommand()\n}\n","#!/usr/bin/env node\nimport { main } from './program.js'\n\nmain().catch(error => {\n console.error(error instanceof Error ? error.stack ?? error.message : String(error))\n process.exitCode = 1\n})\n"],"mappings":";;;;;;;;;;;;AAIA,IAAM,gBAAgB;AACtB,IAAM,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,IAAI;CACpH,CAAC;CAEH,OAAO;AACT;AAEA,eAAsB,KAAK,OAAO,QAAQ,MAAqB;CAC7D,MAAM,MAAM,UAAU;CACtB,MAAM,OAAO,KAAK,MAAM,CAAC;CACzB,IAAI,MAAM,MAAM,EAAE,KAAK,MAAM,CAAC;CAE9B,IAAI,KAAK,WAAW,GAAG;EACrB,IAAI,WAAW;EACf;CACF;CAEA,MAAM,IAAI,kBAAkB;AAC9B;;;ACpFA,KAAK,EAAE,OAAM,UAAS;CACpB,QAAQ,MAAM,iBAAiB,QAAQ,MAAM,SAAS,MAAM,UAAU,OAAO,KAAK,CAAC;CACnF,QAAQ,WAAW;AACrB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.cjs","names":[],"sources":["../source/core/runtime/log.ts","../source/core/runtime/vite-config.ts","../source/cli/commands/build.ts","../source/cli/commands/check.ts","../source/cli/commands/dev.ts","../source/cli/spawn.ts","../source/cli/commands/init.ts","../source/cli/options.ts","../source/cli/program.ts","../source/cli/index.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { readFile, writeFile } from 'node:fs/promises'\nimport { dirname, join } from 'node:path'\n\nconst LOG_FILE_NAME = '.clarify.log'\nconst DEFAULT_LOG_ENTRIES = 50\nconst ENTRY_SEPARATOR = '\\n\\n---\\n\\n'\n\nfunction getMaxLogEntries(): number {\n const envValue = process.env.CLARIFY_LOG_MAX_ENTRIES\n if (!envValue) return DEFAULT_LOG_ENTRIES\n const parsed = Number(envValue)\n return Number.isInteger(parsed) && parsed > 0 ? parsed : DEFAULT_LOG_ENTRIES\n}\n\nfunction normalizeErrorMessage(error: unknown): string {\n if (error === undefined) return 'undefined'\n if (error === null) return 'null'\n if (error instanceof Error) return error.message\n if (typeof error === 'object') {\n if ('message' in error && typeof (error as { message?: unknown }).message === 'string') {\n return (error as { message: string }).message\n }\n try {\n return JSON.stringify(error)\n } catch {\n return String(error)\n }\n }\n return String(error)\n}\n\nfunction normalizeErrorStack(error: unknown): string | undefined {\n if (error instanceof Error) {\n return error.stack\n }\n return undefined\n}\n\nfunction formatLogEntry(root: string, error: unknown): string {\n const timestamp = new Date().toISOString()\n const message = normalizeErrorMessage(error)\n const stack = normalizeErrorStack(error)\n\n return [`=== Clarify build error ===`, `Timestamp: ${timestamp}`, `Project root: ${root}`, `Error: ${message}`, stack ? `Stack:\\n${stack}` : undefined]\n .filter(Boolean)\n .join('\\n')\n}\n\ntype LogEntryReader = (logPath: string) => Promise<string> | string\ntype LogEntryWriter = (logPath: string, content: string) => Promise<void> | void\n\nfunction collectLogEntries(entries: string[], entry: string, max: number): string[] {\n const next = [...entries, entry]\n return next.length > max ? next.slice(-max) : next\n}\n\nfunction readExistingEntries(content: string): string[] {\n return content\n .split(ENTRY_SEPARATOR)\n .map((item) => item.trim())\n .filter(Boolean)\n}\n\nasync function writeLogEntry(root: string, error: unknown, maxEntries: number | undefined, read: LogEntryReader, write: LogEntryWriter): Promise<void> {\n const logPath = join(root, LOG_FILE_NAME)\n const entry = formatLogEntry(root, error)\n const max = maxEntries ?? getMaxLogEntries()\n\n let entries: string[] = []\n if (existsSync(logPath)) {\n try {\n entries = readExistingEntries(await read(logPath))\n } catch {\n entries = []\n }\n }\n\n entries = collectLogEntries(entries, entry, max)\n\n mkdirSync(dirname(logPath), { recursive: true })\n await write(logPath, entries.join(ENTRY_SEPARATOR) + '\\n')\n}\n\nexport async function logBuildError(root: string, error: unknown, maxEntries?: number): Promise<void> {\n await writeLogEntry(root, error, maxEntries, (path) => readFile(path, 'utf8'), (path, content) => writeFile(path, content, 'utf8'))\n}\n\nexport function logBuildErrorSync(root: string, error: unknown, maxEntries?: number): void {\n void writeLogEntry(root, error, maxEntries, (path) => readFileSync(path, 'utf8'), (path, content) => writeFileSync(path, content, 'utf8'))\n}\n","import { existsSync, writeFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nimport { createLogger } from 'vite'\nimport type { ConfigEnv, InlineConfig, Plugin, LogLevel, Logger, LogOptions, LogErrorOptions, LogType } from 'vite'\n\nimport { createViteAdapter } from '../adapters.js'\nimport type { ClarifyEngine } from '../engine/engine.js'\nimport { createClarifyTempDir } from '../project/temp-dir.js'\n\nimport { logBuildErrorSync } from './log.js'\nimport { createClarifyRuntimeAliases } from './runtime-deps.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(createClarifyTempDir('html'), 'index.html')\n writeFileSync(generatedHtmlPath, DEFAULT_HTML, 'utf-8')\n return generatedHtmlPath\n}\n\nfunction createClarifyLogger(root: string, env: ConfigEnv, level: LogLevel): Logger | undefined {\n if (env.command !== 'build') return undefined\n\n const baseLogger = createLogger(level, { allowClearScreen: true })\n\n return {\n info(msg: string, options?: LogOptions) {\n baseLogger.info(msg, options)\n },\n warn(msg: string, options?: LogOptions) {\n baseLogger.warn(msg, options)\n },\n warnOnce(msg: string, options?: LogOptions) {\n baseLogger.warnOnce(msg, options)\n },\n error(msg: string, options?: LogErrorOptions) {\n baseLogger.error(msg, options)\n if (options?.error) {\n logBuildErrorSync(root, options.error)\n } else {\n logBuildErrorSync(root, typeof msg === 'string' ? new Error(msg) : msg)\n }\n },\n clearScreen(type: LogType) {\n baseLogger.clearScreen(type)\n },\n hasErrorLogged(error: Error | unknown) {\n return baseLogger.hasErrorLogged(error as Error)\n },\n get hasWarned() {\n return baseLogger.hasWarned\n },\n }\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, engine: ClarifyEngine): Promise<InlineConfig> {\n const entryHtmlPath = ensureHtmlEntry(options.root)\n\n return {\n root: options.root,\n configFile: false,\n appType: 'custom',\n resolve: {\n alias: createClarifyRuntimeAliases(),\n },\n customLogger: createClarifyLogger(options.root, env, 'info'),\n plugins: [\n createViteAdapter(engine),\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: 'mermaid-viewer-vendor',\n test: /node_modules[\\\\/]react-zoom-pan-pinch[\\\\/]/,\n priority: 25,\n },\n {\n // Keep mermaid and its heavy diagram/render dependencies out of\n // the eager `vendor` chunk so they stay lazily loaded only on\n // pages that actually render a diagram.\n name: 'mermaid-vendor',\n test: /node_modules[\\\\/](mermaid|@mermaid-js|cytoscape|cytoscape-[^\\\\/]+|dagre-d3-es|@dagrejs|dagre|graphlib|elkjs|katex|d3|d3-[^\\\\/]+|internmap|delaunator|robust-predicates|roughjs|points-on-curve|points-on-path|path-data-parser|@braintree[\\\\/]sanitize-url|dompurify|khroma|ts-dedent|stylis|cose-base|layout-base)[\\\\/]/,\n priority: 20,\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 { createClarifyEngine } from '../../core/engine/engine.js'\nimport { logBuildError } from '../../core/runtime/log.js'\nimport { createViteConfig } from '../../core/runtime/vite-config.js'\nimport type { ResolvedCliOptions } from '../options.js'\n\nexport async function runBuild(options: ResolvedCliOptions): Promise<void> {\n const env = { command: 'build' as const, mode: 'production' }\n const engine = createClarifyEngine({\n projectRoot: options.root,\n rootDirectory: options.content,\n outputDirectory: options.output,\n })\n try {\n await engine.prepare(env)\n await viteBuild(await createViteConfig(options, env, engine))\n } catch (error) {\n await logBuildError(options.root, error)\n throw error\n }\n}\n","import { lstat, stat } from 'node:fs/promises'\nimport { dirname, extname, isAbsolute, join, normalize, relative, resolve } from 'node:path'\n\nimport { createClarifyEngine } from '../../core/engine/engine.js'\nimport type { ContentRoute } from '../../types.js'\nimport type { CliOptions } from '../options.js'\n\nexport type CheckCommandOptions = CliOptions & {\n strict?: boolean\n format?: 'text' | 'json' | string\n}\n\ntype CheckLevel = 'error' | 'warning'\n\ntype CheckDiagnostic = {\n level: CheckLevel\n code: string\n message: string\n filePath?: string\n routePath?: string\n}\n\ntype CheckResult = {\n errors: CheckDiagnostic[]\n warnings: CheckDiagnostic[]\n}\n\nconst LOCAL_LINK_PATTERN = /(?<!!)(?:\\[[^\\]]*\\]\\(([^)\\s]+)(?:\\s+\"[^\"]*\")?\\)|<a\\s+[^>]*href=[\"']([^\"']+)[\"'])/gi\nconst ROUTE_EXTENSIONS = new Set(['.md', '.mdx'])\nconst IGNORED_SCHEMES = /^[a-z][a-z0-9+.-]*:/i\n\nfunction addDiagnostic(result: CheckResult, diagnostic: CheckDiagnostic): void {\n if (diagnostic.level === 'error') result.errors.push(diagnostic)\n else result.warnings.push(diagnostic)\n}\n\nfunction normalizeRoutePath(path: string): string {\n const [withoutHash] = path.split('#')\n const clean = withoutHash.replace(/\\/index$/, '') || '/'\n return clean.startsWith('/') ? clean : `/${clean}`\n}\n\nfunction routePathCandidates(href: string, route: ContentRoute): string[] {\n const [withoutHashOrQuery] = href.split(/[?#]/)\n if (!withoutHashOrQuery || withoutHashOrQuery.startsWith('#')) return []\n if (withoutHashOrQuery.startsWith('/')) return [normalizeRoutePath(withoutHashOrQuery)]\n\n const routeDir = dirname(route.path)\n const joined = normalize(join(routeDir, withoutHashOrQuery)).replaceAll('\\\\', '/')\n const extension = extname(joined)\n const base = ROUTE_EXTENSIONS.has(extension) ? joined.slice(0, -extension.length) : joined\n return [normalizeRoutePath(base)]\n}\n\nasync function pathExists(filePath: string): Promise<boolean> {\n try {\n await stat(filePath)\n return true\n } catch {\n return false\n }\n}\n\nfunction isLocalHref(href: string): boolean {\n return Boolean(href) && !href.startsWith('#') && !href.startsWith('//') && !IGNORED_SCHEMES.test(href)\n}\n\nasync function resolveLocalFileLink(href: string, route: ContentRoute, contentRoot: string): Promise<boolean> {\n const [withoutHashOrQuery] = href.split(/[?#]/)\n if (!withoutHashOrQuery || withoutHashOrQuery.startsWith('/')) return false\n\n const target = resolve(dirname(route.source.filePath), withoutHashOrQuery)\n const relativeTarget = relative(contentRoot, target)\n if (relativeTarget.startsWith('..') || isAbsolute(relativeTarget)) return false\n if (await pathExists(target)) return true\n\n if (!extname(target)) {\n return pathExists(`${target}.md`) || pathExists(`${target}.mdx`) || pathExists(join(target, 'index.md')) || pathExists(join(target, 'index.mdx'))\n }\n return false\n}\n\nasync function checkContentDirectory(contentRoot: string, result: CheckResult): Promise<void> {\n try {\n const stats = await lstat(contentRoot)\n if (!stats.isDirectory()) {\n addDiagnostic(result, {\n level: 'error',\n code: 'content-not-directory',\n message: `Content path is not a directory: ${contentRoot}`,\n filePath: contentRoot,\n })\n }\n } catch {\n addDiagnostic(result, {\n level: 'error',\n code: 'content-missing',\n message: `Content directory does not exist: ${contentRoot}`,\n filePath: contentRoot,\n })\n }\n}\n\nfunction checkDuplicateRoutes(routes: ContentRoute[], result: CheckResult): void {\n const byPath = new Map<string, ContentRoute[]>()\n for (const route of routes) {\n const key = `${route.locale ?? ''}:${route.path}`\n byPath.set(key, [...(byPath.get(key) ?? []), route])\n }\n\n for (const duplicated of byPath.values()) {\n if (duplicated.length < 2) continue\n for (const route of duplicated) {\n addDiagnostic(result, {\n level: 'error',\n code: 'duplicate-route',\n message: `Route \"${route.path}\" is defined by multiple files: ${duplicated.map(route => relative(process.cwd(), route.source.filePath)).join(', ')}`,\n filePath: route.source.filePath,\n routePath: route.path,\n })\n }\n }\n}\n\nfunction checkFallbackRoutes(routes: ContentRoute[], result: CheckResult): void {\n for (const route of routes) {\n if (!route.isFallback) continue\n addDiagnostic(result, {\n level: 'warning',\n code: 'i18n-fallback-route',\n message: `Route \"${route.path}\" falls back to ${route.locale ?? 'default'} content from ${relative(process.cwd(), route.source.filePath)}`,\n filePath: route.source.filePath,\n routePath: route.path,\n })\n }\n}\n\nasync function checkLocalLinks(routes: ContentRoute[], contentRoot: string, result: CheckResult): Promise<void> {\n const routePaths = new Set(routes.map(route => route.path))\n\n for (const route of routes) {\n if (route.kind !== 'mdx' || !route.source.content) continue\n for (const match of route.source.content.matchAll(LOCAL_LINK_PATTERN)) {\n const href = match[1] ?? match[2]\n if (!href || !isLocalHref(href)) continue\n const candidates = routePathCandidates(href, route)\n if (candidates.some(candidate => routePaths.has(candidate))) continue\n if (await resolveLocalFileLink(href, route, contentRoot)) continue\n\n addDiagnostic(result, {\n level: 'error',\n code: 'broken-link',\n message: `Broken local link \"${href}\" in route \"${route.path}\"`,\n filePath: route.source.filePath,\n routePath: route.path,\n })\n }\n }\n}\n\nfunction printTextResult(result: CheckResult, strict: boolean): void {\n const diagnostics = [...result.errors, ...result.warnings]\n if (diagnostics.length === 0) {\n console.log('✓ Clarify check passed')\n return\n }\n\n for (const diagnostic of diagnostics) {\n const location = diagnostic.filePath ? ` ${relative(process.cwd(), diagnostic.filePath)}` : ''\n const route = diagnostic.routePath ? ` (${diagnostic.routePath})` : ''\n console.log(`${diagnostic.level.toUpperCase()} ${diagnostic.code}${location}${route}`)\n console.log(` ${diagnostic.message}`)\n }\n\n const warningExit = strict && result.warnings.length > 0\n console.log(`\\n${result.errors.length} error(s), ${result.warnings.length} warning(s)${warningExit ? ' (--strict treats warnings as failures)' : ''}`)\n}\n\nexport async function runCheck(options: CheckCommandOptions = {}): Promise<void> {\n const root = resolve(options.root ?? process.cwd())\n const engine = createClarifyEngine({\n projectRoot: root,\n rootDirectory: options.content,\n outputDirectory: options.output,\n })\n await engine.prepare(undefined, undefined, { htmlShell: false, skipModules: true, skipHints: true })\n\n const result: CheckResult = { errors: [], warnings: [] }\n await checkContentDirectory(engine.contentRoot, result)\n checkDuplicateRoutes(engine.routes, result)\n checkFallbackRoutes(engine.routes, result)\n await checkLocalLinks(engine.routes, engine.contentRoot, result)\n\n if (options.format === 'json') {\n console.log(JSON.stringify(result, null, 2))\n } else {\n printTextResult(result, Boolean(options.strict))\n }\n\n if (result.errors.length > 0 || (options.strict && result.warnings.length > 0)) {\n process.exitCode = 1\n }\n}\n","import { createServer } from 'vite'\n\nimport { createClarifyEngine } from '../../core/engine/engine.js'\nimport { createViteConfig } from '../../core/runtime/vite-config.js'\nimport type { ResolvedCliOptions } from '../options.js'\n\nexport async function runDev(options: ResolvedCliOptions): Promise<void> {\n const env = { command: 'serve' as const, mode: 'development' }\n const engine = createClarifyEngine({\n projectRoot: options.root,\n rootDirectory: options.content,\n outputDirectory: options.output,\n })\n await engine.prepare(env)\n const server = await createServer(await createViteConfig(options, env, engine))\n await server.listen()\n server.printUrls()\n server.bindCLIShortcuts({ print: true })\n}\n","import { spawnSync as nodeSpawnSync, SpawnSyncOptions } from 'node:child_process'\n\ntype SpawnOptions = { cwd?: string; stdio?: 'inherit' | 'ignore' | Array<string> }\n\nexport function spawnSync(command: string, args: string[], options: SpawnOptions) {\n return nodeSpawnSync(command, args, options as SpawnSyncOptions)\n}\n","import { existsSync, readFileSync, writeFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport { copyTemplateDirectory, getTemplateDirectory, resolveTemplate } from '@clarify-labs/templates'\n\nimport type { ResolvedCliOptions } from '../options.js'\nimport { cliPackageVersionWithCaret } from '../package.js'\nimport { spawnSync } from '../spawn.js'\n\nconst require = createRequire(import.meta.url)\n\nfunction findTemplatesPackagePath(): string {\n try {\n return require.resolve('@clarify-labs/templates/package.json')\n } catch {\n const currentDirectory = dirname(fileURLToPath(import.meta.url))\n const workspacePackagePath = resolve(currentDirectory, '../../../../templates/package.json')\n if (existsSync(workspacePackagePath)) return workspacePackagePath\n throw new Error('[clarify] Templates package not found.')\n }\n}\n\nconst templatesPackagePath = findTemplatesPackagePath()\nconst templatesDirectory = dirname(templatesPackagePath)\n\nfunction commandExists(program: string): boolean {\n const result = spawnSync(program, ['--version'], { stdio: 'ignore' })\n return result.status === 0 && result.error === undefined\n}\n\ntype InstallCommand = { command: string; args: string[] }\n\nfunction getInstallCommand(): InstallCommand {\n if (commandExists('pnpm')) return { command: 'pnpm', args: ['install'] }\n if (commandExists('npm')) return { command: 'npm', args: ['install'] }\n if (commandExists('yarn')) return { command: 'yarn', args: ['install'] }\n return { command: 'npm', args: ['install'] }\n}\n\nfunction installDependencies(root: string): void {\n const { command, args } = getInstallCommand()\n console.log(`[clarify] Installing dependencies with ${command}...`)\n const result = spawnSync(command, args, { cwd: root, stdio: 'inherit' })\n if (result.status !== 0) {\n throw new Error(`[clarify] Dependency install failed with ${command}`)\n }\n}\n\nfunction getSuggestedInstallCommand(): string {\n if (commandExists('pnpm')) return 'pnpm install'\n if (commandExists('npm')) return 'npm install'\n if (commandExists('yarn')) return 'yarn install'\n return 'npm install'\n}\n\nfunction getSuggestedRunCommand(): string {\n if (commandExists('pnpm')) return 'pnpm dev'\n if (commandExists('yarn')) return 'yarn dev'\n return 'npm run dev'\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'] = cliPackageVersionWithCaret\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, template?: string, install = false): void {\n const selectedTemplate = resolveTemplate(template)\n const templateDirectory = getTemplateDirectory(templatesDirectory, selectedTemplate)\n const { created } = copyTemplateDirectory(templateDirectory, options.root, {\n contentDir: options.content,\n force,\n })\n\n const packageJsonUpdated = updatePackageJson(options.root, force)\n if (packageJsonUpdated) created.push('package.json')\n\n console.log(`[clarify] Project scaffold created using the ${selectedTemplate} template.`)\n if (created.length > 0) {\n console.log(`[clarify] Created or updated ${created.length} ${created.length === 1 ? 'file' : 'files'}: ${created.join(', ')}`)\n }\n\n if (install) {\n installDependencies(options.root)\n const suggestedRun = getSuggestedRunCommand()\n console.log('[clarify] Dependencies installed successfully.')\n console.log(`[clarify] You can now run \\`${suggestedRun}\\` to start the local documentation server.`)\n return\n }\n\n const suggestedInstall = getSuggestedInstallCommand()\n const suggestedRun = getSuggestedRunCommand()\n console.log('[clarify] Next steps:')\n console.log(' 1. Change into your new project directory:')\n console.log(` cd ${options.root}`)\n console.log(' 2. Install dependencies:')\n console.log(` ${suggestedInstall}`)\n console.log(' 3. Start the local documentation server:')\n console.log(` ${suggestedRun}`)\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\nfunction resolvePort(port: CliOptions['port']): number | undefined {\n if (port === undefined) return undefined\n\n const parsedPort = typeof port === 'string' ? Number(port) : port\n if (!Number.isInteger(parsedPort) || parsedPort < 1 || parsedPort > 65535) {\n throw new Error('[clarify] --port must be an integer between 1 and 65535')\n }\n\n return parsedPort\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: resolvePort(options.port),\n open: options.open,\n }\n}\n","import { cac } from 'cac'\n\nimport { runBuild } from './commands/build.js'\nimport { runCheck, type CheckCommandOptions } from './commands/check.js'\nimport { runDev } from './commands/dev.js'\nimport { runInit } from './commands/init.js'\nimport { resolveCliOptions, type CliOptions, type ResolvedCliOptions } from './options.js'\nimport { cliPackageVersion } from './package.js'\n\ntype InitCommandOptions = CliOptions & {\n force?: boolean\n template?: string\n install?: boolean\n}\n\nfunction withBuildOptions(command: ReturnType<ReturnType<typeof cac>['command']>) {\n return command\n .option('--content <dir>', 'Content directory relative to root')\n}\n\nfunction resolveInitOptions(directory: string | undefined, options: InitCommandOptions): ResolvedCliOptions {\n return resolveOptions({\n ...options,\n root: directory,\n })\n}\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\nexport function createCli() {\n const cli = cac('clarify')\n\n cli\n .version(cliPackageVersion)\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('check', 'Validate the documentation project'))\n .option('--strict', 'Treat warnings as failures')\n .option('--format <format>', 'Output format: text or json')\n .action(async (options: CheckCommandOptions) => {\n await runCheck(options)\n })\n\n withBuildOptions(cli.command('init [directory]', 'Create a Clarify project scaffold'))\n .option('--force', 'Overwrite files created by init')\n .option('--template <name>', 'Template to use: minimal, standard, or complete')\n .option('--install', 'Install dependencies after init')\n .action((directory: string | undefined, options: InitCommandOptions) => {\n runInit(resolveInitOptions(directory, options), options.force === true, options.template, options.install === true)\n })\n\n return cli\n}\n\nexport async function main(argv = process.argv): Promise<void> {\n const cli = createCli()\n const args = argv.slice(2)\n cli.parse(argv, { run: false })\n\n if (args.length === 0) {\n cli.outputHelp()\n return\n }\n\n await cli.runMatchedCommand()\n}\n","#!/usr/bin/env node\nimport { main } from './program.js'\n\nmain().catch(error => {\n console.error(error instanceof Error ? error.stack ?? error.message : String(error))\n process.exitCode = 1\n})\n"],"mappings":";;;;;;;;;;;;AAIA,IAAM,gBAAgB;AACtB,IAAM,sBAAsB;AAC5B,IAAM,kBAAkB;AAExB,SAAS,mBAA2B;CAClC,MAAM,WAAW,QAAQ,IAAI;CAC7B,IAAI,CAAC,UAAU,OAAO;CACtB,MAAM,SAAS,OAAO,QAAQ;CAC9B,OAAO,OAAO,UAAU,MAAM,KAAK,SAAS,IAAI,SAAS;AAC3D;AAEA,SAAS,sBAAsB,OAAwB;CACrD,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