@clarify-labs/cli 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/output/cli.cjs +11 -84
- package/output/cli.cjs.map +1 -1
- package/output/cli.js +9 -82
- package/output/cli.js.map +1 -1
- package/output/core/dev-routes.d.ts +2 -2
- package/output/core/project-context.d.ts +16 -0
- package/output/core/project-info.d.ts +3 -3
- package/output/core/site.d.ts +2 -2
- package/output/core/ssg.d.ts +3 -3
- package/output/core/startup.d.ts +8 -0
- package/output/core/virtual-modules.d.ts +6 -4
- package/output/index.cjs +1 -1
- package/output/index.js +1 -1
- package/output/parsers/mdx.d.ts +7 -0
- package/output/{plugin-BUFe4vEb.cjs → plugin-Etn8ZfYN.cjs} +328 -113
- package/output/plugin-Etn8ZfYN.cjs.map +1 -0
- package/output/{plugin-poS3N83A.js → plugin-Z3fYTMcb.js} +313 -110
- package/output/plugin-Z3fYTMcb.js.map +1 -0
- package/output/plugins/openapi/virtual-modules.d.ts +1 -4
- package/output/types.d.ts +8 -2
- package/package.json +4 -4
- package/output/plugin-BUFe4vEb.cjs.map +0 -1
- package/output/plugin-poS3N83A.js.map +0 -1
package/output/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_plugin = require("./plugin-
|
|
2
|
+
const require_plugin = require("./plugin-Etn8ZfYN.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
let node_url = require("node:url");
|
|
@@ -143,11 +143,16 @@ function createHtmlFallbackPlugin() {
|
|
|
143
143
|
}
|
|
144
144
|
async function createViteConfig(options, env) {
|
|
145
145
|
const entryHtmlPath = ensureHtmlEntry(options.root);
|
|
146
|
-
const
|
|
147
|
-
...await require_plugin.loadClarifyConfig(options.root, env),
|
|
146
|
+
const context = await require_plugin.resolveProjectContext({
|
|
148
147
|
projectRoot: options.root,
|
|
149
148
|
rootDirectory: options.content,
|
|
150
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
|
|
151
156
|
};
|
|
152
157
|
return {
|
|
153
158
|
root: options.root,
|
|
@@ -334,13 +339,8 @@ function printTextResult(result, strict) {
|
|
|
334
339
|
console.log(`\n${result.errors.length} error(s), ${result.warnings.length} warning(s)${warningExit ? " (--strict treats warnings as failures)" : ""}`);
|
|
335
340
|
}
|
|
336
341
|
async function runCheck(options = {}) {
|
|
337
|
-
const root = (0, node_path.resolve)(options.root ?? process.cwd());
|
|
338
342
|
const site = await require_plugin.resolveClarifySite({
|
|
339
|
-
|
|
340
|
-
command: "build",
|
|
341
|
-
mode: "production"
|
|
342
|
-
}) : {},
|
|
343
|
-
projectRoot: root,
|
|
343
|
+
projectRoot: (0, node_path.resolve)(options.root ?? process.cwd()),
|
|
344
344
|
rootDirectory: options.content,
|
|
345
345
|
outputDirectory: options.output
|
|
346
346
|
}, { includeHtmlShellPlugin: false });
|
|
@@ -367,79 +367,6 @@ async function runDev(options) {
|
|
|
367
367
|
server.printUrls();
|
|
368
368
|
server.bindCLIShortcuts({ print: true });
|
|
369
369
|
}
|
|
370
|
-
var cliPackageVersion = {
|
|
371
|
-
name: "@clarify-labs/cli",
|
|
372
|
-
version: "0.9.2",
|
|
373
|
-
license: "AGPL-3.0-only",
|
|
374
|
-
type: "module",
|
|
375
|
-
repository: {
|
|
376
|
-
"type": "git",
|
|
377
|
-
"url": "https://github.com/taicode-labs/clarify",
|
|
378
|
-
"directory": "packages/cli"
|
|
379
|
-
},
|
|
380
|
-
main: "output/index.cjs",
|
|
381
|
-
module: "output/index.js",
|
|
382
|
-
types: "output/index.d.ts",
|
|
383
|
-
bin: { "clarify": "bin/clarify.js" },
|
|
384
|
-
exports: {
|
|
385
|
-
".": {
|
|
386
|
-
"types": "./output/index.d.ts",
|
|
387
|
-
"import": "./output/index.js",
|
|
388
|
-
"require": "./output/index.cjs",
|
|
389
|
-
"default": "./output/index.js"
|
|
390
|
-
},
|
|
391
|
-
"./package.json": "./package.json"
|
|
392
|
-
},
|
|
393
|
-
files: [
|
|
394
|
-
"LICENSE",
|
|
395
|
-
"bin",
|
|
396
|
-
"output"
|
|
397
|
-
],
|
|
398
|
-
scripts: {
|
|
399
|
-
"dev": "vite build --watch",
|
|
400
|
-
"build": "vite build",
|
|
401
|
-
"lint": "eslint source/",
|
|
402
|
-
"lint:fix": "eslint source/ --fix",
|
|
403
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
404
|
-
"test": "vitest run",
|
|
405
|
-
"test:watch": "vitest"
|
|
406
|
-
},
|
|
407
|
-
dependencies: {
|
|
408
|
-
"@apidevtools/swagger-parser": "^12.1.0",
|
|
409
|
-
"@clarify-labs/renderer": "workspace:*",
|
|
410
|
-
"@clarify-labs/templates": "workspace:*",
|
|
411
|
-
"@mdx-js/rollup": "^3.1.1",
|
|
412
|
-
"@tailwindcss/vite": "^4.1.11",
|
|
413
|
-
"@vitejs/plugin-react": "^6.0.2",
|
|
414
|
-
"cac": "^7.0.0",
|
|
415
|
-
"github-slugger": "^2.0.0",
|
|
416
|
-
"gray-matter": "^4.0.3",
|
|
417
|
-
"mdast-util-to-string": "^4.0.0",
|
|
418
|
-
"mermaid": "^11.4.0",
|
|
419
|
-
"openapi-types": "^12.1.3",
|
|
420
|
-
"pagefind": "^1.5.2",
|
|
421
|
-
"react": "^19.1.0",
|
|
422
|
-
"react-dom": "^19.1.0",
|
|
423
|
-
"react-router": "^7.0.0",
|
|
424
|
-
"react-router-dom": "^7.0.0",
|
|
425
|
-
"react-zoom-pan-pinch": "^4.0.3",
|
|
426
|
-
"remark": "^15.0.1",
|
|
427
|
-
"remark-gfm": "^4.0.1",
|
|
428
|
-
"shiki": "0.14.7",
|
|
429
|
-
"unist-util-visit": "^5.1.0",
|
|
430
|
-
"vite": "^8.0.15",
|
|
431
|
-
"yaml": "^2.9.0",
|
|
432
|
-
"zod": "^4.4.3"
|
|
433
|
-
},
|
|
434
|
-
devDependencies: {
|
|
435
|
-
"@mdx-js/mdx": "^3.1.1",
|
|
436
|
-
"@types/react": "^19.1.8",
|
|
437
|
-
"typescript": "^5.8.3",
|
|
438
|
-
"vite-plugin-dts": "^4.5.4",
|
|
439
|
-
"vitest": "^4.1.9"
|
|
440
|
-
}
|
|
441
|
-
}.version ?? "0.0.0";
|
|
442
|
-
var cliPackageVersionWithCaret = `^${cliPackageVersion}`;
|
|
443
370
|
//#endregion
|
|
444
371
|
//#region source/cli/spawn.ts
|
|
445
372
|
function spawnSync(command, args, options) {
|
|
@@ -507,7 +434,7 @@ function updatePackageJson(root, force) {
|
|
|
507
434
|
if (force || !scripts.build) scripts.build = "clarify build";
|
|
508
435
|
packageJson.scripts = scripts;
|
|
509
436
|
const devDependencies = typeof packageJson.devDependencies === "object" && packageJson.devDependencies !== null ? packageJson.devDependencies : {};
|
|
510
|
-
if (!devDependencies["@clarify-labs/cli"]) devDependencies["@clarify-labs/cli"] = cliPackageVersionWithCaret;
|
|
437
|
+
if (!devDependencies["@clarify-labs/cli"]) devDependencies["@clarify-labs/cli"] = require_plugin.cliPackageVersionWithCaret;
|
|
511
438
|
packageJson.devDependencies = devDependencies;
|
|
512
439
|
(0, node_fs.writeFileSync)(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, "utf-8");
|
|
513
440
|
return true;
|
|
@@ -575,7 +502,7 @@ function resolveOptions(options) {
|
|
|
575
502
|
}
|
|
576
503
|
function createCli() {
|
|
577
504
|
const cli = (0, cac.cac)("clarify");
|
|
578
|
-
cli.version(cliPackageVersion).help();
|
|
505
|
+
cli.version(require_plugin.cliPackageVersion).help();
|
|
579
506
|
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) => {
|
|
580
507
|
await runDev(resolveOptions(options));
|
|
581
508
|
});
|
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","../package.json","../source/cli/package.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 { createClarifyRuntimeAliases } from './runtime-deps.js'\nimport { createClarifyTempDir } from './temp-dir.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(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 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 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 { existsSync } from 'node:fs'\nimport { 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 { loadClarifyConfig } from '../../core/user-config.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 userConfig = existsSync(root) ? await loadClarifyConfig(root, { command: 'build', mode: 'production' }) : {}\n const site = await resolveClarifySite({\n ...userConfig,\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","{\n \"name\": \"@clarify-labs/cli\",\n \"version\": \"0.9.2\",\n \"license\": \"AGPL-3.0-only\",\n \"type\": \"module\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/taicode-labs/clarify\",\n \"directory\": \"packages/cli\"\n },\n \"main\": \"output/index.cjs\",\n \"module\": \"output/index.js\",\n \"types\": \"output/index.d.ts\",\n \"bin\": {\n \"clarify\": \"bin/clarify.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./output/index.d.ts\",\n \"import\": \"./output/index.js\",\n \"require\": \"./output/index.cjs\",\n \"default\": \"./output/index.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"LICENSE\",\n \"bin\",\n \"output\"\n ],\n \"scripts\": {\n \"dev\": \"vite build --watch\",\n \"build\": \"vite build\",\n \"lint\": \"eslint source/\",\n \"lint:fix\": \"eslint source/ --fix\",\n \"typecheck\": \"tsc -p tsconfig.json --noEmit\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\"\n },\n \"dependencies\": {\n \"@apidevtools/swagger-parser\": \"^12.1.0\",\n \"@clarify-labs/renderer\": \"workspace:*\",\n \"@clarify-labs/templates\": \"workspace:*\",\n \"@mdx-js/rollup\": \"^3.1.1\",\n \"@tailwindcss/vite\": \"^4.1.11\",\n \"@vitejs/plugin-react\": \"^6.0.2\",\n \"cac\": \"^7.0.0\",\n \"github-slugger\": \"^2.0.0\",\n \"gray-matter\": \"^4.0.3\",\n \"mdast-util-to-string\": \"^4.0.0\",\n \"mermaid\": \"^11.4.0\",\n \"openapi-types\": \"^12.1.3\",\n \"pagefind\": \"^1.5.2\",\n \"react\": \"^19.1.0\",\n \"react-dom\": \"^19.1.0\",\n \"react-router\": \"^7.0.0\",\n \"react-router-dom\": \"^7.0.0\",\n \"react-zoom-pan-pinch\": \"^4.0.3\",\n \"remark\": \"^15.0.1\",\n \"remark-gfm\": \"^4.0.1\",\n \"shiki\": \"0.14.7\",\n \"unist-util-visit\": \"^5.1.0\",\n \"vite\": \"^8.0.15\",\n \"yaml\": \"^2.9.0\",\n \"zod\": \"^4.4.3\"\n },\n \"devDependencies\": {\n \"@mdx-js/mdx\": \"^3.1.1\",\n \"@types/react\": \"^19.1.8\",\n \"typescript\": \"^5.8.3\",\n \"vite-plugin-dts\": \"^4.5.4\",\n \"vitest\": \"^4.1.9\"\n }\n}\n","import packageJson from '../../package.json' with { type: 'json' }\n\nexport const cliPackageJson = packageJson as { version?: string }\nexport const cliPackageVersion = cliPackageJson.version ?? '0.0.0'\nexport const cliPackageVersionWithCaret = `^${cliPackageVersion}`\n\nexport function readPackageVersion(): string {\n return cliPackageVersion\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,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,IAAI,UAAU,MAAM,OAAO;CAC3B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K,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/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,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,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,IAAI,UAAU,MAAM,OAAO;CAC3B,IAAI,iBAAiB,OAAO,OAAO,MAAM;CACzC,IAAI,OAAO,UAAU,UAAU;EAC7B,IAAI,aAAa,SAAS,OAAQ,MAAgC,YAAY,UAC5E,OAAQ,MAA8B;EAExC,IAAI;GACF,OAAO,KAAK,UAAU,KAAK;EAC7B,QAAQ;GACN,OAAO,OAAO,KAAK;EACrB;CACF;CACA,OAAO,OAAO,KAAK;AACrB;AAEA,SAAS,oBAAoB,OAAoC;CAC/D,IAAI,iBAAiB,OACnB,OAAO,MAAM;AAG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D,OAAO,OAAO,YAAwB;EACrC,MAAM,OAAO,eAAe,OAAO,CAAC;CACtC,CAAC;CAEH,kBAAkB,IAAI,QAAQ,SAAS,qCAAqC,CAAC,EAC1E,OAAO,OAAO,YAAwB;EACrC,MAAM,SAAS,eAAe,OAAO,CAAC;CACxC,CAAC;CAEH,kBAAkB,IAAI,QAAQ,SAAS,oCAAoC,CAAC,EACzE,OAAO,YAAY,4BAA4B,EAC/C,OAAO,qBAAqB,6BAA6B,EACzD,OAAO,OAAO,YAAiC;EAC9C,MAAM,SAAS,OAAO;CACxB,CAAC;CAEH,iBAAiB,IAAI,QAAQ,oBAAoB,mCAAmC,CAAC,EAClF,OAAO,WAAW,iCAAiC,EACnD,OAAO,qBAAqB,iDAAiD,EAC7E,OAAO,aAAa,iCAAiC,EACrD,QAAQ,WAA+B,YAAgC;EACtE,QAAQ,mBAAmB,WAAW,OAAO,GAAG,QAAQ,UAAU,MAAM,QAAQ,UAAU,QAAQ,YAAY,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"}
|
package/output/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { c as cliPackageVersionWithCaret, i as resolveProjectContext, n as createClarifyRuntimeAliases, o as createClarifyTempDir, r as resolveClarifySite, s as cliPackageVersion, t as clarifyPlugin } from "./plugin-Z3fYTMcb.js";
|
|
3
3
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { dirname, extname, isAbsolute, join, normalize, relative, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
@@ -143,11 +143,16 @@ function createHtmlFallbackPlugin() {
|
|
|
143
143
|
}
|
|
144
144
|
async function createViteConfig(options, env) {
|
|
145
145
|
const entryHtmlPath = ensureHtmlEntry(options.root);
|
|
146
|
-
const
|
|
147
|
-
...await loadClarifyConfig(options.root, env),
|
|
146
|
+
const context = await resolveProjectContext({
|
|
148
147
|
projectRoot: options.root,
|
|
149
148
|
rootDirectory: options.content,
|
|
150
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
|
|
151
156
|
};
|
|
152
157
|
return {
|
|
153
158
|
root: options.root,
|
|
@@ -334,13 +339,8 @@ function printTextResult(result, strict) {
|
|
|
334
339
|
console.log(`\n${result.errors.length} error(s), ${result.warnings.length} warning(s)${warningExit ? " (--strict treats warnings as failures)" : ""}`);
|
|
335
340
|
}
|
|
336
341
|
async function runCheck(options = {}) {
|
|
337
|
-
const root = resolve(options.root ?? process.cwd());
|
|
338
342
|
const site = await resolveClarifySite({
|
|
339
|
-
|
|
340
|
-
command: "build",
|
|
341
|
-
mode: "production"
|
|
342
|
-
}) : {},
|
|
343
|
-
projectRoot: root,
|
|
343
|
+
projectRoot: resolve(options.root ?? process.cwd()),
|
|
344
344
|
rootDirectory: options.content,
|
|
345
345
|
outputDirectory: options.output
|
|
346
346
|
}, { includeHtmlShellPlugin: false });
|
|
@@ -367,79 +367,6 @@ async function runDev(options) {
|
|
|
367
367
|
server.printUrls();
|
|
368
368
|
server.bindCLIShortcuts({ print: true });
|
|
369
369
|
}
|
|
370
|
-
var cliPackageVersion = {
|
|
371
|
-
name: "@clarify-labs/cli",
|
|
372
|
-
version: "0.9.2",
|
|
373
|
-
license: "AGPL-3.0-only",
|
|
374
|
-
type: "module",
|
|
375
|
-
repository: {
|
|
376
|
-
"type": "git",
|
|
377
|
-
"url": "https://github.com/taicode-labs/clarify",
|
|
378
|
-
"directory": "packages/cli"
|
|
379
|
-
},
|
|
380
|
-
main: "output/index.cjs",
|
|
381
|
-
module: "output/index.js",
|
|
382
|
-
types: "output/index.d.ts",
|
|
383
|
-
bin: { "clarify": "bin/clarify.js" },
|
|
384
|
-
exports: {
|
|
385
|
-
".": {
|
|
386
|
-
"types": "./output/index.d.ts",
|
|
387
|
-
"import": "./output/index.js",
|
|
388
|
-
"require": "./output/index.cjs",
|
|
389
|
-
"default": "./output/index.js"
|
|
390
|
-
},
|
|
391
|
-
"./package.json": "./package.json"
|
|
392
|
-
},
|
|
393
|
-
files: [
|
|
394
|
-
"LICENSE",
|
|
395
|
-
"bin",
|
|
396
|
-
"output"
|
|
397
|
-
],
|
|
398
|
-
scripts: {
|
|
399
|
-
"dev": "vite build --watch",
|
|
400
|
-
"build": "vite build",
|
|
401
|
-
"lint": "eslint source/",
|
|
402
|
-
"lint:fix": "eslint source/ --fix",
|
|
403
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
404
|
-
"test": "vitest run",
|
|
405
|
-
"test:watch": "vitest"
|
|
406
|
-
},
|
|
407
|
-
dependencies: {
|
|
408
|
-
"@apidevtools/swagger-parser": "^12.1.0",
|
|
409
|
-
"@clarify-labs/renderer": "workspace:*",
|
|
410
|
-
"@clarify-labs/templates": "workspace:*",
|
|
411
|
-
"@mdx-js/rollup": "^3.1.1",
|
|
412
|
-
"@tailwindcss/vite": "^4.1.11",
|
|
413
|
-
"@vitejs/plugin-react": "^6.0.2",
|
|
414
|
-
"cac": "^7.0.0",
|
|
415
|
-
"github-slugger": "^2.0.0",
|
|
416
|
-
"gray-matter": "^4.0.3",
|
|
417
|
-
"mdast-util-to-string": "^4.0.0",
|
|
418
|
-
"mermaid": "^11.4.0",
|
|
419
|
-
"openapi-types": "^12.1.3",
|
|
420
|
-
"pagefind": "^1.5.2",
|
|
421
|
-
"react": "^19.1.0",
|
|
422
|
-
"react-dom": "^19.1.0",
|
|
423
|
-
"react-router": "^7.0.0",
|
|
424
|
-
"react-router-dom": "^7.0.0",
|
|
425
|
-
"react-zoom-pan-pinch": "^4.0.3",
|
|
426
|
-
"remark": "^15.0.1",
|
|
427
|
-
"remark-gfm": "^4.0.1",
|
|
428
|
-
"shiki": "0.14.7",
|
|
429
|
-
"unist-util-visit": "^5.1.0",
|
|
430
|
-
"vite": "^8.0.15",
|
|
431
|
-
"yaml": "^2.9.0",
|
|
432
|
-
"zod": "^4.4.3"
|
|
433
|
-
},
|
|
434
|
-
devDependencies: {
|
|
435
|
-
"@mdx-js/mdx": "^3.1.1",
|
|
436
|
-
"@types/react": "^19.1.8",
|
|
437
|
-
"typescript": "^5.8.3",
|
|
438
|
-
"vite-plugin-dts": "^4.5.4",
|
|
439
|
-
"vitest": "^4.1.9"
|
|
440
|
-
}
|
|
441
|
-
}.version ?? "0.0.0";
|
|
442
|
-
var cliPackageVersionWithCaret = `^${cliPackageVersion}`;
|
|
443
370
|
//#endregion
|
|
444
371
|
//#region source/cli/spawn.ts
|
|
445
372
|
function spawnSync$1(command, args, options) {
|