@doccov/cli 0.16.0 → 0.17.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/dist/cli.js CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/config/doccov-config.ts
4
- import { access } from "node:fs/promises";
4
+ import { access, readFile } from "node:fs/promises";
5
5
  import path from "node:path";
6
6
  import { pathToFileURL } from "node:url";
7
+ import { parse as parseYaml } from "yaml";
7
8
 
8
9
  // src/config/schema.ts
9
10
  import { z } from "zod";
@@ -95,7 +96,9 @@ var DOCCOV_CONFIG_FILENAMES = [
95
96
  "doccov.config.cts",
96
97
  "doccov.config.js",
97
98
  "doccov.config.mjs",
98
- "doccov.config.cjs"
99
+ "doccov.config.cjs",
100
+ "doccov.yml",
101
+ "doccov.yaml"
99
102
  ];
100
103
  var fileExists = async (filePath) => {
101
104
  try {
@@ -122,6 +125,11 @@ var findConfigFile = async (cwd) => {
122
125
  }
123
126
  };
124
127
  var importConfigModule = async (absolutePath) => {
128
+ const ext = path.extname(absolutePath);
129
+ if (ext === ".yml" || ext === ".yaml") {
130
+ const content = await readFile(absolutePath, "utf-8");
131
+ return parseYaml(content);
132
+ }
125
133
  const fileUrl = pathToFileURL(absolutePath);
126
134
  fileUrl.searchParams.set("t", Date.now().toString());
127
135
  const module = await import(fileUrl.href);
@@ -1878,11 +1886,11 @@ function registerInitCommand(program, dependencies = {}) {
1878
1886
  ...defaultDependencies3,
1879
1887
  ...dependencies
1880
1888
  };
1881
- program.command("init").description("Create a DocCov configuration file").option("--cwd <dir>", "Working directory", process.cwd()).option("--format <format>", "Config format: auto, mjs, js, cjs", "auto").action((options) => {
1889
+ program.command("init").description("Create a DocCov configuration file").option("--cwd <dir>", "Working directory", process.cwd()).option("--format <format>", "Config format: auto, mjs, js, cjs, yaml", "auto").action((options) => {
1882
1890
  const cwd = path6.resolve(options.cwd);
1883
1891
  const formatOption = String(options.format ?? "auto").toLowerCase();
1884
1892
  if (!isValidFormat(formatOption)) {
1885
- error(chalk6.red(`Invalid format "${formatOption}". Use auto, mjs, js, or cjs.`));
1893
+ error(chalk6.red(`Invalid format "${formatOption}". Use auto, mjs, js, cjs, or yaml.`));
1886
1894
  process.exitCode = 1;
1887
1895
  return;
1888
1896
  }
@@ -1897,7 +1905,7 @@ function registerInitCommand(program, dependencies = {}) {
1897
1905
  if (targetFormat === "js" && packageType !== "module") {
1898
1906
  log(chalk6.yellow('Package is not marked as "type": "module"; creating doccov.config.js may require enabling ESM.'));
1899
1907
  }
1900
- const fileName = `doccov.config.${targetFormat}`;
1908
+ const fileName = targetFormat === "yaml" ? "doccov.yml" : `doccov.config.${targetFormat}`;
1901
1909
  const outputPath = path6.join(cwd, fileName);
1902
1910
  if (fileExists2(outputPath)) {
1903
1911
  error(chalk6.red(`Cannot create ${fileName}; file already exists.`));
@@ -1910,7 +1918,7 @@ function registerInitCommand(program, dependencies = {}) {
1910
1918
  });
1911
1919
  }
1912
1920
  var isValidFormat = (value) => {
1913
- return value === "auto" || value === "mjs" || value === "js" || value === "cjs";
1921
+ return ["auto", "mjs", "js", "cjs", "yaml"].includes(value);
1914
1922
  };
1915
1923
  var findExistingConfig = (cwd, fileExists2) => {
1916
1924
  let current = path6.resolve(cwd);
@@ -1962,12 +1970,34 @@ var findNearestPackageJson = (cwd, fileExists2) => {
1962
1970
  return null;
1963
1971
  };
1964
1972
  var resolveFormat = (format, packageType) => {
1973
+ if (format === "yaml")
1974
+ return "yaml";
1965
1975
  if (format === "auto") {
1966
1976
  return packageType === "module" ? "js" : "mjs";
1967
1977
  }
1968
1978
  return format;
1969
1979
  };
1970
1980
  var buildTemplate = (format) => {
1981
+ if (format === "yaml") {
1982
+ return `# doccov.yml
1983
+ # include:
1984
+ # - "MyClass"
1985
+ # - "myFunction"
1986
+ # exclude:
1987
+ # - "internal*"
1988
+
1989
+ check:
1990
+ # minCoverage: 80
1991
+ # maxDrift: 20
1992
+ # examples: typecheck
1993
+
1994
+ quality:
1995
+ rules:
1996
+ # has-description: warn
1997
+ # has-params: off
1998
+ # has-returns: off
1999
+ `;
2000
+ }
1971
2001
  const configBody = `{
1972
2002
  // Filter which exports to analyze
1973
2003
  // include: ['MyClass', 'myFunction'],
@@ -2022,7 +2052,7 @@ import { DocCov as DocCov3, NodeFileSystem as NodeFileSystem3, resolveTarget as
2022
2052
  import { normalize, validateSpec } from "@openpkg-ts/spec";
2023
2053
  import chalk8 from "chalk";
2024
2054
  // package.json
2025
- var version = "0.15.1";
2055
+ var version = "0.16.0";
2026
2056
 
2027
2057
  // src/utils/filter-options.ts
2028
2058
  import { mergeFilters, parseListFlag } from "@doccov/sdk";
@@ -38,7 +38,7 @@ declare const docCovConfigSchema: z.ZodObject<{
38
38
  }>;
39
39
  type DocCovConfigInput = z.infer<typeof docCovConfigSchema>;
40
40
  type NormalizedDocCovConfig = DocCovConfig;
41
- declare const DOCCOV_CONFIG_FILENAMES: readonly ["doccov.config.ts", "doccov.config.mts", "doccov.config.cts", "doccov.config.js", "doccov.config.mjs", "doccov.config.cjs"];
41
+ declare const DOCCOV_CONFIG_FILENAMES: readonly ["doccov.config.ts", "doccov.config.mts", "doccov.config.cts", "doccov.config.js", "doccov.config.mjs", "doccov.config.cjs", "doccov.yml", "doccov.yaml"];
42
42
  interface LoadedDocCovConfig extends NormalizedDocCovConfig {
43
43
  filePath: string;
44
44
  }
@@ -1,7 +1,8 @@
1
1
  // src/config/doccov-config.ts
2
- import { access } from "node:fs/promises";
2
+ import { access, readFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { pathToFileURL } from "node:url";
5
+ import { parse as parseYaml } from "yaml";
5
6
 
6
7
  // src/config/schema.ts
7
8
  import { z } from "zod";
@@ -93,7 +94,9 @@ var DOCCOV_CONFIG_FILENAMES = [
93
94
  "doccov.config.cts",
94
95
  "doccov.config.js",
95
96
  "doccov.config.mjs",
96
- "doccov.config.cjs"
97
+ "doccov.config.cjs",
98
+ "doccov.yml",
99
+ "doccov.yaml"
97
100
  ];
98
101
  var fileExists = async (filePath) => {
99
102
  try {
@@ -120,6 +123,11 @@ var findConfigFile = async (cwd) => {
120
123
  }
121
124
  };
122
125
  var importConfigModule = async (absolutePath) => {
126
+ const ext = path.extname(absolutePath);
127
+ if (ext === ".yml" || ext === ".yaml") {
128
+ const content = await readFile(absolutePath, "utf-8");
129
+ return parseYaml(content);
130
+ }
123
131
  const fileUrl = pathToFileURL(absolutePath);
124
132
  fileUrl.searchParams.set("t", Date.now().toString());
125
133
  const module = await import(fileUrl.href);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doccov/cli",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "DocCov CLI - Documentation coverage and drift detection for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
@@ -56,6 +56,7 @@
56
56
  "commander": "^14.0.0",
57
57
  "glob": "^11.0.0",
58
58
  "simple-git": "^3.27.0",
59
+ "yaml": "^2.8.2",
59
60
  "zod": "^3.25.0"
60
61
  },
61
62
  "devDependencies": {