@doccov/cli 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/cli.js +16 -14
- package/dist/config/index.d.ts +2 -10
- package/dist/config/index.js +3 -13
- package/package.json +3 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Ryan Waits
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/cli.js
CHANGED
|
@@ -18,7 +18,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
20
20
|
|
|
21
|
-
// src/config/
|
|
21
|
+
// src/config/doccov-config.ts
|
|
22
22
|
import { access } from "node:fs/promises";
|
|
23
23
|
import path from "node:path";
|
|
24
24
|
import { pathToFileURL } from "node:url";
|
|
@@ -52,20 +52,14 @@ var normalizeConfig = (input) => {
|
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
// src/config/
|
|
55
|
+
// src/config/doccov-config.ts
|
|
56
56
|
var DOCCOV_CONFIG_FILENAMES = [
|
|
57
57
|
"doccov.config.ts",
|
|
58
58
|
"doccov.config.mts",
|
|
59
59
|
"doccov.config.cts",
|
|
60
60
|
"doccov.config.js",
|
|
61
61
|
"doccov.config.mjs",
|
|
62
|
-
"doccov.config.cjs"
|
|
63
|
-
"openpkg.config.ts",
|
|
64
|
-
"openpkg.config.mts",
|
|
65
|
-
"openpkg.config.cts",
|
|
66
|
-
"openpkg.config.js",
|
|
67
|
-
"openpkg.config.mjs",
|
|
68
|
-
"openpkg.config.cjs"
|
|
62
|
+
"doccov.config.cjs"
|
|
69
63
|
];
|
|
70
64
|
var fileExists = async (filePath) => {
|
|
71
65
|
try {
|
|
@@ -126,8 +120,6 @@ ${formatIssues(issues)}`);
|
|
|
126
120
|
...normalized
|
|
127
121
|
};
|
|
128
122
|
};
|
|
129
|
-
var loadOpenPkgConfigInternal = loadDocCovConfig;
|
|
130
|
-
var loadOpenPkgConfig = loadDocCovConfig;
|
|
131
123
|
|
|
132
124
|
// src/config/index.ts
|
|
133
125
|
var defineConfig = (config) => config;
|
|
@@ -294,7 +286,7 @@ function registerCheckCommand(program, dependencies = {}) {
|
|
|
294
286
|
...defaultDependencies,
|
|
295
287
|
...dependencies
|
|
296
288
|
};
|
|
297
|
-
program.command("check [entry]").description("Fail if documentation coverage falls below a threshold").option("--cwd <dir>", "Working directory", process.cwd()).option("--package <name>", "Target package name (for monorepos)").option("--min-coverage <percentage>", "Minimum docs coverage percentage (0-100)", (value) => Number(value)).option("--require-examples", "Require at least one @example for every export").option("--no-external-types", "Skip external type resolution from node_modules").action(async (entry, options) => {
|
|
289
|
+
program.command("check [entry]").description("Fail if documentation coverage falls below a threshold").option("--cwd <dir>", "Working directory", process.cwd()).option("--package <name>", "Target package name (for monorepos)").option("--min-coverage <percentage>", "Minimum docs coverage percentage (0-100)", (value) => Number(value)).option("--require-examples", "Require at least one @example for every export").option("--ignore-drift", "Do not fail on documentation drift").option("--no-external-types", "Skip external type resolution from node_modules").action(async (entry, options) => {
|
|
298
290
|
try {
|
|
299
291
|
let targetDir = options.cwd;
|
|
300
292
|
let entryFile = entry;
|
|
@@ -339,7 +331,7 @@ function registerCheckCommand(program, dependencies = {}) {
|
|
|
339
331
|
const driftExports = collectDrift(spec.exports ?? []);
|
|
340
332
|
const coverageFailed = coverageScore < minCoverage;
|
|
341
333
|
const hasMissingExamples = missingExamples.length > 0;
|
|
342
|
-
const hasDrift = driftExports.length > 0;
|
|
334
|
+
const hasDrift = !options.ignoreDrift && driftExports.length > 0;
|
|
343
335
|
if (!coverageFailed && !hasMissingExamples && !hasDrift) {
|
|
344
336
|
log(chalk.green(`✓ Docs coverage ${coverageScore}% (min ${minCoverage}%)`));
|
|
345
337
|
if (failingExports.length > 0) {
|
|
@@ -348,6 +340,16 @@ function registerCheckCommand(program, dependencies = {}) {
|
|
|
348
340
|
log(chalk.gray(` • ${name}: missing ${missing?.join(", ")}`));
|
|
349
341
|
}
|
|
350
342
|
}
|
|
343
|
+
if (options.ignoreDrift && driftExports.length > 0) {
|
|
344
|
+
log("");
|
|
345
|
+
log(chalk.yellow(`⚠️ ${driftExports.length} drift issue(s) detected (ignored):`));
|
|
346
|
+
for (const drift of driftExports.slice(0, 10)) {
|
|
347
|
+
log(chalk.yellow(` • ${drift.name}: ${drift.issue}`));
|
|
348
|
+
if (drift.suggestion) {
|
|
349
|
+
log(chalk.gray(` Suggestion: ${drift.suggestion}`));
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
351
353
|
return;
|
|
352
354
|
}
|
|
353
355
|
error("");
|
|
@@ -471,7 +473,7 @@ function loadSpec(filePath, readFileSync3) {
|
|
|
471
473
|
throw new Error(`Failed to parse ${filePath}: ${parseError instanceof Error ? parseError.message : parseError}`);
|
|
472
474
|
}
|
|
473
475
|
}
|
|
474
|
-
function printTextDiff(diff, log,
|
|
476
|
+
function printTextDiff(diff, log, _error) {
|
|
475
477
|
log("");
|
|
476
478
|
log(chalk2.bold("DocCov Diff Report"));
|
|
477
479
|
log("─".repeat(40));
|
package/dist/config/index.d.ts
CHANGED
|
@@ -11,18 +11,10 @@ interface NormalizedDocCovConfig {
|
|
|
11
11
|
exclude?: string[];
|
|
12
12
|
plugins?: unknown[];
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
type NormalizedOpenPkgConfig = NormalizedDocCovConfig;
|
|
16
|
-
declare const DOCCOV_CONFIG_FILENAMES: readonly ["doccov.config.ts", "doccov.config.mts", "doccov.config.cts", "doccov.config.js", "doccov.config.mjs", "doccov.config.cjs", "openpkg.config.ts", "openpkg.config.mts", "openpkg.config.cts", "openpkg.config.js", "openpkg.config.mjs", "openpkg.config.cjs"];
|
|
14
|
+
declare const DOCCOV_CONFIG_FILENAMES: readonly ["doccov.config.ts", "doccov.config.mts", "doccov.config.cts", "doccov.config.js", "doccov.config.mjs", "doccov.config.cjs"];
|
|
17
15
|
interface LoadedDocCovConfig extends NormalizedDocCovConfig {
|
|
18
16
|
filePath: string;
|
|
19
17
|
}
|
|
20
|
-
/** @deprecated Use LoadedDocCovConfig instead */
|
|
21
|
-
type LoadedOpenPkgConfig = LoadedDocCovConfig;
|
|
22
18
|
declare const loadDocCovConfig: (cwd: string) => Promise<LoadedDocCovConfig | null>;
|
|
23
|
-
/** @deprecated Use loadDocCovConfig instead */
|
|
24
|
-
declare const loadOpenPkgConfigInternal: typeof loadDocCovConfig;
|
|
25
|
-
/** @deprecated Use loadDocCovConfig instead */
|
|
26
|
-
declare const loadOpenPkgConfig: typeof loadDocCovConfig;
|
|
27
19
|
declare const defineConfig: (config: DocCovConfigInput) => DocCovConfigInput;
|
|
28
|
-
export {
|
|
20
|
+
export { loadDocCovConfig, defineConfig, NormalizedDocCovConfig, LoadedDocCovConfig, DocCovConfigInput, DOCCOV_CONFIG_FILENAMES };
|
package/dist/config/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
19
|
|
|
20
|
-
// src/config/
|
|
20
|
+
// src/config/doccov-config.ts
|
|
21
21
|
import { access } from "node:fs/promises";
|
|
22
22
|
import path from "node:path";
|
|
23
23
|
import { pathToFileURL } from "node:url";
|
|
@@ -51,20 +51,14 @@ var normalizeConfig = (input) => {
|
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
// src/config/
|
|
54
|
+
// src/config/doccov-config.ts
|
|
55
55
|
var DOCCOV_CONFIG_FILENAMES = [
|
|
56
56
|
"doccov.config.ts",
|
|
57
57
|
"doccov.config.mts",
|
|
58
58
|
"doccov.config.cts",
|
|
59
59
|
"doccov.config.js",
|
|
60
60
|
"doccov.config.mjs",
|
|
61
|
-
"doccov.config.cjs"
|
|
62
|
-
"openpkg.config.ts",
|
|
63
|
-
"openpkg.config.mts",
|
|
64
|
-
"openpkg.config.cts",
|
|
65
|
-
"openpkg.config.js",
|
|
66
|
-
"openpkg.config.mjs",
|
|
67
|
-
"openpkg.config.cjs"
|
|
61
|
+
"doccov.config.cjs"
|
|
68
62
|
];
|
|
69
63
|
var fileExists = async (filePath) => {
|
|
70
64
|
try {
|
|
@@ -125,14 +119,10 @@ ${formatIssues(issues)}`);
|
|
|
125
119
|
...normalized
|
|
126
120
|
};
|
|
127
121
|
};
|
|
128
|
-
var loadOpenPkgConfigInternal = loadDocCovConfig;
|
|
129
|
-
var loadOpenPkgConfig = loadDocCovConfig;
|
|
130
122
|
|
|
131
123
|
// src/config/index.ts
|
|
132
124
|
var defineConfig = (config) => config;
|
|
133
125
|
export {
|
|
134
|
-
loadOpenPkgConfigInternal,
|
|
135
|
-
loadOpenPkgConfig,
|
|
136
126
|
loadDocCovConfig,
|
|
137
127
|
defineConfig,
|
|
138
128
|
DOCCOV_CONFIG_FILENAMES
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doccov/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "DocCov CLI - Documentation coverage and drift detection for TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"@ai-sdk/anthropic": "^1.0.0",
|
|
50
50
|
"@ai-sdk/openai": "^1.0.0",
|
|
51
51
|
"@inquirer/prompts": "^7.8.0",
|
|
52
|
-
"@doccov/sdk": "^0.2.
|
|
53
|
-
"@openpkg-ts/spec": "^0.2.
|
|
52
|
+
"@doccov/sdk": "^0.2.2",
|
|
53
|
+
"@openpkg-ts/spec": "^0.2.2",
|
|
54
54
|
"ai": "^4.0.0",
|
|
55
55
|
"chalk": "^5.4.1",
|
|
56
56
|
"commander": "^14.0.0",
|