@doccov/cli 0.2.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/README.md +67 -0
- package/dist/cli.d.ts +0 -0
- package/dist/cli.js +1551 -0
- package/dist/config/index.d.ts +28 -0
- package/dist/config/index.js +139 -0
- package/package.json +70 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const stringList: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
3
|
+
declare const docCovConfigSchema: z.ZodObject<{
|
|
4
|
+
include: z.ZodOptional<typeof stringList>
|
|
5
|
+
exclude: z.ZodOptional<typeof stringList>
|
|
6
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>
|
|
7
|
+
}>;
|
|
8
|
+
type DocCovConfigInput = z.infer<typeof docCovConfigSchema>;
|
|
9
|
+
interface NormalizedDocCovConfig {
|
|
10
|
+
include?: string[];
|
|
11
|
+
exclude?: string[];
|
|
12
|
+
plugins?: unknown[];
|
|
13
|
+
}
|
|
14
|
+
/** @deprecated Use NormalizedDocCovConfig instead */
|
|
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"];
|
|
17
|
+
interface LoadedDocCovConfig extends NormalizedDocCovConfig {
|
|
18
|
+
filePath: string;
|
|
19
|
+
}
|
|
20
|
+
/** @deprecated Use LoadedDocCovConfig instead */
|
|
21
|
+
type LoadedOpenPkgConfig = LoadedDocCovConfig;
|
|
22
|
+
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
|
+
declare const defineConfig: (config: DocCovConfigInput) => DocCovConfigInput;
|
|
28
|
+
export { loadOpenPkgConfigInternal, loadOpenPkgConfig, loadDocCovConfig, defineConfig, NormalizedOpenPkgConfig, NormalizedDocCovConfig, LoadedOpenPkgConfig, LoadedDocCovConfig, DocCovConfigInput, DOCCOV_CONFIG_FILENAMES };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
+
|
|
20
|
+
// src/config/openpkg-config.ts
|
|
21
|
+
import { access } from "node:fs/promises";
|
|
22
|
+
import path from "node:path";
|
|
23
|
+
import { pathToFileURL } from "node:url";
|
|
24
|
+
|
|
25
|
+
// src/config/schema.ts
|
|
26
|
+
import { z } from "zod";
|
|
27
|
+
var stringList = z.union([
|
|
28
|
+
z.string(),
|
|
29
|
+
z.array(z.string())
|
|
30
|
+
]);
|
|
31
|
+
var docCovConfigSchema = z.object({
|
|
32
|
+
include: stringList.optional(),
|
|
33
|
+
exclude: stringList.optional(),
|
|
34
|
+
plugins: z.array(z.unknown()).optional()
|
|
35
|
+
});
|
|
36
|
+
var normalizeList = (value) => {
|
|
37
|
+
if (!value) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const list = Array.isArray(value) ? value : [value];
|
|
41
|
+
const normalized = list.map((item) => item.trim()).filter(Boolean);
|
|
42
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
43
|
+
};
|
|
44
|
+
var normalizeConfig = (input) => {
|
|
45
|
+
const include = normalizeList(input.include);
|
|
46
|
+
const exclude = normalizeList(input.exclude);
|
|
47
|
+
return {
|
|
48
|
+
include,
|
|
49
|
+
exclude,
|
|
50
|
+
plugins: input.plugins
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/config/openpkg-config.ts
|
|
55
|
+
var DOCCOV_CONFIG_FILENAMES = [
|
|
56
|
+
"doccov.config.ts",
|
|
57
|
+
"doccov.config.mts",
|
|
58
|
+
"doccov.config.cts",
|
|
59
|
+
"doccov.config.js",
|
|
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"
|
|
68
|
+
];
|
|
69
|
+
var fileExists = async (filePath) => {
|
|
70
|
+
try {
|
|
71
|
+
await access(filePath);
|
|
72
|
+
return true;
|
|
73
|
+
} catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
var findConfigFile = async (cwd) => {
|
|
78
|
+
let current = path.resolve(cwd);
|
|
79
|
+
const { root } = path.parse(current);
|
|
80
|
+
while (true) {
|
|
81
|
+
for (const candidate of DOCCOV_CONFIG_FILENAMES) {
|
|
82
|
+
const candidatePath = path.join(current, candidate);
|
|
83
|
+
if (await fileExists(candidatePath)) {
|
|
84
|
+
return candidatePath;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (current === root) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
current = path.dirname(current);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
var importConfigModule = async (absolutePath) => {
|
|
94
|
+
const fileUrl = pathToFileURL(absolutePath);
|
|
95
|
+
fileUrl.searchParams.set("t", Date.now().toString());
|
|
96
|
+
const module = await import(fileUrl.href);
|
|
97
|
+
return module?.default ?? module?.config ?? module;
|
|
98
|
+
};
|
|
99
|
+
var formatIssues = (issues) => issues.map((issue) => `- ${issue}`).join(`
|
|
100
|
+
`);
|
|
101
|
+
var loadDocCovConfig = async (cwd) => {
|
|
102
|
+
const configPath = await findConfigFile(cwd);
|
|
103
|
+
if (!configPath) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
let rawConfig;
|
|
107
|
+
try {
|
|
108
|
+
rawConfig = await importConfigModule(configPath);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
111
|
+
throw new Error(`Failed to load DocCov config at ${configPath}: ${message}`);
|
|
112
|
+
}
|
|
113
|
+
const parsed = docCovConfigSchema.safeParse(rawConfig);
|
|
114
|
+
if (!parsed.success) {
|
|
115
|
+
const issues = parsed.error.issues.map((issue) => {
|
|
116
|
+
const pathLabel = issue.path.length > 0 ? issue.path.join(".") : "(root)";
|
|
117
|
+
return `${pathLabel}: ${issue.message}`;
|
|
118
|
+
});
|
|
119
|
+
throw new Error(`Invalid DocCov configuration at ${configPath}.
|
|
120
|
+
${formatIssues(issues)}`);
|
|
121
|
+
}
|
|
122
|
+
const normalized = normalizeConfig(parsed.data);
|
|
123
|
+
return {
|
|
124
|
+
filePath: configPath,
|
|
125
|
+
...normalized
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
var loadOpenPkgConfigInternal = loadDocCovConfig;
|
|
129
|
+
var loadOpenPkgConfig = loadDocCovConfig;
|
|
130
|
+
|
|
131
|
+
// src/config/index.ts
|
|
132
|
+
var defineConfig = (config) => config;
|
|
133
|
+
export {
|
|
134
|
+
loadOpenPkgConfigInternal,
|
|
135
|
+
loadOpenPkgConfig,
|
|
136
|
+
loadDocCovConfig,
|
|
137
|
+
defineConfig,
|
|
138
|
+
DOCCOV_CONFIG_FILENAMES
|
|
139
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@doccov/cli",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "DocCov CLI - Documentation coverage and drift detection for TypeScript",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"typescript",
|
|
7
|
+
"cli",
|
|
8
|
+
"documentation",
|
|
9
|
+
"doccov",
|
|
10
|
+
"docs-coverage",
|
|
11
|
+
"drift-detection"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/doccov/doccov#readme",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/doccov/doccov.git",
|
|
17
|
+
"directory": "packages/cli"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "Ryan Waits",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"bin": {
|
|
25
|
+
"doccov": "./dist/cli.js"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"./config": {
|
|
33
|
+
"import": "./dist/config/index.js",
|
|
34
|
+
"types": "./dist/config/index.d.ts"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "bunup",
|
|
39
|
+
"dev": "bunup --watch",
|
|
40
|
+
"cli": "bun run src/cli.ts",
|
|
41
|
+
"lint": "biome check src/",
|
|
42
|
+
"lint:fix": "biome check --write src/",
|
|
43
|
+
"format": "biome format --write src/"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"dist"
|
|
47
|
+
],
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@ai-sdk/anthropic": "^1.0.0",
|
|
50
|
+
"@ai-sdk/openai": "^1.0.0",
|
|
51
|
+
"@inquirer/prompts": "^7.8.0",
|
|
52
|
+
"@doccov/sdk": "^0.2.1",
|
|
53
|
+
"@openpkg-ts/spec": "^0.2.1",
|
|
54
|
+
"ai": "^4.0.0",
|
|
55
|
+
"chalk": "^5.4.1",
|
|
56
|
+
"commander": "^14.0.0",
|
|
57
|
+
"glob": "^11.0.0",
|
|
58
|
+
"ora": "^8.2.0",
|
|
59
|
+
"simple-git": "^3.27.0",
|
|
60
|
+
"zod": "^3.23.8"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@types/bun": "latest",
|
|
64
|
+
"@types/node": "^20.0.0",
|
|
65
|
+
"bunup": "latest"
|
|
66
|
+
},
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public"
|
|
69
|
+
}
|
|
70
|
+
}
|