@doccov/cli 0.23.0 → 0.24.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/dist/cli.js +55 -19
- package/package.json +4 -3
package/dist/cli.js
CHANGED
|
@@ -292,8 +292,10 @@ import chalk3 from "chalk";
|
|
|
292
292
|
// src/commands/check/utils.ts
|
|
293
293
|
import * as fs from "node:fs";
|
|
294
294
|
import * as path2 from "node:path";
|
|
295
|
-
import {
|
|
296
|
-
|
|
295
|
+
import {
|
|
296
|
+
DRIFT_CATEGORIES,
|
|
297
|
+
parseMarkdownFiles
|
|
298
|
+
} from "@doccov/sdk";
|
|
297
299
|
import { glob } from "glob";
|
|
298
300
|
function collectDriftsFromExports(exports) {
|
|
299
301
|
const results = [];
|
|
@@ -810,7 +812,7 @@ ${status} Coverage ${coverageScore >= 80 ? "passing" : coverageScore >= 50 ? "ne
|
|
|
810
812
|
return output;
|
|
811
813
|
}
|
|
812
814
|
// src/reports/markdown.ts
|
|
813
|
-
import { DRIFT_CATEGORY_LABELS } from "@
|
|
815
|
+
import { DRIFT_CATEGORY_LABELS } from "@doccov/sdk";
|
|
814
816
|
function bar2(pct, width = 10) {
|
|
815
817
|
const filled = Math.round(pct / 100 * width);
|
|
816
818
|
return "█".repeat(filled) + "░".repeat(width - filled);
|
|
@@ -1220,10 +1222,10 @@ function renderDetailsTable(lines, diff) {
|
|
|
1220
1222
|
}
|
|
1221
1223
|
}
|
|
1222
1224
|
// src/reports/stats.ts
|
|
1223
|
-
import { isFixableDrift } from "@doccov/sdk";
|
|
1224
1225
|
import {
|
|
1225
|
-
DRIFT_CATEGORIES as DRIFT_CATEGORIES2
|
|
1226
|
-
|
|
1226
|
+
DRIFT_CATEGORIES as DRIFT_CATEGORIES2,
|
|
1227
|
+
isFixableDrift
|
|
1228
|
+
} from "@doccov/sdk";
|
|
1227
1229
|
function computeStats(spec) {
|
|
1228
1230
|
const exports = spec.exports ?? [];
|
|
1229
1231
|
const signals = {
|
|
@@ -2351,16 +2353,18 @@ var detectRepoInfo = (cwd, fileExists2, readFileSync4) => {
|
|
|
2351
2353
|
import * as fs6 from "node:fs";
|
|
2352
2354
|
import * as path8 from "node:path";
|
|
2353
2355
|
import {
|
|
2356
|
+
buildDocCovSpec,
|
|
2354
2357
|
DocCov as DocCov3,
|
|
2355
2358
|
detectPackageManager,
|
|
2356
2359
|
NodeFileSystem as NodeFileSystem3,
|
|
2357
2360
|
renderApiSurface,
|
|
2358
2361
|
resolveTarget as resolveTarget3
|
|
2359
2362
|
} from "@doccov/sdk";
|
|
2363
|
+
import { validateDocCovSpec } from "@doccov/spec";
|
|
2360
2364
|
import { normalize, validateSpec } from "@openpkg-ts/spec";
|
|
2361
2365
|
import chalk10 from "chalk";
|
|
2362
2366
|
// package.json
|
|
2363
|
-
var version = "0.
|
|
2367
|
+
var version = "0.24.0";
|
|
2364
2368
|
|
|
2365
2369
|
// src/commands/spec.ts
|
|
2366
2370
|
var defaultDependencies4 = {
|
|
@@ -2384,15 +2388,19 @@ function registerSpecCommand(program, dependencies = {}) {
|
|
|
2384
2388
|
...defaultDependencies4,
|
|
2385
2389
|
...dependencies
|
|
2386
2390
|
};
|
|
2387
|
-
program.command("spec [entry]").description("Generate OpenPkg
|
|
2391
|
+
program.command("spec [entry]").description("Generate OpenPkg + DocCov specifications").option("--cwd <dir>", "Working directory", process.cwd()).option("-p, --package <name>", "Target package name (for monorepos)").option("-o, --output <dir>", "Output directory", ".doccov").option("-f, --format <format>", "Output format: json (default) or api-surface", "json").option("--openpkg-only", "Only generate openpkg.json (skip coverage analysis)").option("--include <patterns>", "Include exports matching pattern (comma-separated)").option("--exclude <patterns>", "Exclude exports matching pattern (comma-separated)").option("--visibility <tags>", "Filter by release stage: public,beta,alpha,internal (comma-separated)").option("--skip-resolve", "Skip external type resolution from node_modules").option("--max-type-depth <n>", "Maximum depth for type conversion", "20").option("--runtime", "Enable Standard Schema runtime extraction (richer output for Zod, Valibot, etc.)").option("--no-cache", "Bypass spec cache and force regeneration").option("--show-diagnostics", "Show TypeScript compiler diagnostics").option("--verbose", "Show detailed generation metadata").action(async (entry, options) => {
|
|
2388
2392
|
try {
|
|
2389
|
-
const
|
|
2393
|
+
const stepsList = [
|
|
2390
2394
|
{ label: "Resolved target", activeLabel: "Resolving target" },
|
|
2391
2395
|
{ label: "Loaded config", activeLabel: "Loading config" },
|
|
2392
2396
|
{ label: "Generated spec", activeLabel: "Generating spec" },
|
|
2393
|
-
{ label: "Validated schema", activeLabel: "Validating schema" }
|
|
2394
|
-
|
|
2395
|
-
|
|
2397
|
+
{ label: "Validated schema", activeLabel: "Validating schema" }
|
|
2398
|
+
];
|
|
2399
|
+
if (!options.openpkgOnly) {
|
|
2400
|
+
stepsList.push({ label: "Built coverage analysis", activeLabel: "Building coverage" });
|
|
2401
|
+
}
|
|
2402
|
+
stepsList.push({ label: "Wrote output", activeLabel: "Writing output" });
|
|
2403
|
+
const steps = new StepProgress(stepsList);
|
|
2396
2404
|
steps.start();
|
|
2397
2405
|
const fileSystem = new NodeFileSystem3(options.cwd);
|
|
2398
2406
|
const resolved = await resolveTarget3(fileSystem, {
|
|
@@ -2457,18 +2465,46 @@ function registerSpecCommand(program, dependencies = {}) {
|
|
|
2457
2465
|
process.exit(1);
|
|
2458
2466
|
}
|
|
2459
2467
|
steps.next();
|
|
2468
|
+
let doccovSpec = null;
|
|
2469
|
+
if (!options.openpkgOnly) {
|
|
2470
|
+
doccovSpec = buildDocCovSpec({
|
|
2471
|
+
openpkgPath: "openpkg.json",
|
|
2472
|
+
openpkg: normalized,
|
|
2473
|
+
packagePath: targetDir
|
|
2474
|
+
});
|
|
2475
|
+
const doccovValidation = validateDocCovSpec(doccovSpec);
|
|
2476
|
+
if (!doccovValidation.ok) {
|
|
2477
|
+
error(chalk10.red("DocCov spec failed schema validation"));
|
|
2478
|
+
for (const err of doccovValidation.errors) {
|
|
2479
|
+
error(chalk10.red(`doccov: ${err.instancePath || "/"} ${err.message}`));
|
|
2480
|
+
}
|
|
2481
|
+
process.exit(1);
|
|
2482
|
+
}
|
|
2483
|
+
steps.next();
|
|
2484
|
+
}
|
|
2460
2485
|
const format = options.format ?? "json";
|
|
2461
|
-
const
|
|
2486
|
+
const outputDir = path8.resolve(options.cwd, options.output);
|
|
2487
|
+
fs6.mkdirSync(outputDir, { recursive: true });
|
|
2462
2488
|
if (format === "api-surface") {
|
|
2463
2489
|
const apiSurface = renderApiSurface(normalized);
|
|
2464
|
-
|
|
2465
|
-
|
|
2490
|
+
const apiSurfacePath = path8.join(outputDir, "api-surface.txt");
|
|
2491
|
+
writeFileSync4(apiSurfacePath, apiSurface);
|
|
2492
|
+
steps.complete(`Generated ${options.output}/ (API surface)`);
|
|
2466
2493
|
} else {
|
|
2467
|
-
|
|
2468
|
-
|
|
2494
|
+
const openpkgPath = path8.join(outputDir, "openpkg.json");
|
|
2495
|
+
writeFileSync4(openpkgPath, JSON.stringify(normalized, null, 2));
|
|
2496
|
+
if (doccovSpec) {
|
|
2497
|
+
const doccovPath = path8.join(outputDir, "doccov.json");
|
|
2498
|
+
writeFileSync4(doccovPath, JSON.stringify(doccovSpec, null, 2));
|
|
2499
|
+
steps.complete(`Generated ${options.output}/`);
|
|
2500
|
+
log(chalk10.gray(` openpkg.json: ${getArrayLength(normalized.exports)} exports`));
|
|
2501
|
+
log(chalk10.gray(` doccov.json: ${doccovSpec.summary.score}% coverage, ${doccovSpec.summary.drift.total} drift issues`));
|
|
2502
|
+
} else {
|
|
2503
|
+
steps.complete(`Generated ${options.output}/openpkg.json`);
|
|
2504
|
+
log(chalk10.gray(` ${getArrayLength(normalized.exports)} exports`));
|
|
2505
|
+
log(chalk10.gray(` ${getArrayLength(normalized.types)} types`));
|
|
2506
|
+
}
|
|
2469
2507
|
}
|
|
2470
|
-
log(chalk10.gray(` ${getArrayLength(normalized.exports)} exports`));
|
|
2471
|
-
log(chalk10.gray(` ${getArrayLength(normalized.types)} types`));
|
|
2472
2508
|
const schemaExtraction = normalized.generation?.analysis?.schemaExtraction;
|
|
2473
2509
|
if (options.runtime && (!schemaExtraction?.runtimeCount || schemaExtraction.runtimeCount === 0)) {
|
|
2474
2510
|
const pm = await detectPackageManager(fileSystem);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doccov/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.1",
|
|
4
4
|
"description": "DocCov CLI - Documentation coverage and drift detection for TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -48,9 +48,10 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@ai-sdk/anthropic": "^1.0.0",
|
|
50
50
|
"@ai-sdk/openai": "^1.0.0",
|
|
51
|
-
"@doccov/sdk": "^0.
|
|
51
|
+
"@doccov/sdk": "^0.24.1",
|
|
52
|
+
"@doccov/spec": "^0.24.1",
|
|
52
53
|
"@inquirer/prompts": "^7.8.0",
|
|
53
|
-
"@openpkg-ts/spec": "^0.11.
|
|
54
|
+
"@openpkg-ts/spec": "^0.11.1",
|
|
54
55
|
"ai": "^4.0.0",
|
|
55
56
|
"chalk": "^5.4.1",
|
|
56
57
|
"commander": "^14.0.0",
|