@doccov/sdk 0.29.4 → 0.30.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/analysis/index.d.ts +10 -4
- package/dist/analysis/index.js +1 -1
- package/dist/index.d.ts +48 -10
- package/dist/index.js +17 -13
- package/dist/shared/{chunk-0048g7g0.js → chunk-fdjehkbt.js} +65 -54
- package/package.json +3 -3
package/dist/analysis/index.d.ts
CHANGED
|
@@ -258,7 +258,7 @@ declare function hasNonAssertionComments(code: string): boolean;
|
|
|
258
258
|
*/
|
|
259
259
|
declare function detectExampleAssertionFailures(entry: SpecExport2, runtimeResults: Map<number, ExampleRunResult>): SpecDocDrift[];
|
|
260
260
|
import { OpenPkg as OpenPkg2 } from "@openpkg-ts/spec";
|
|
261
|
-
/** Directory for storing history snapshots */
|
|
261
|
+
/** Directory for storing history snapshots (relative to .doccov) */
|
|
262
262
|
declare const HISTORY_DIR = ".doccov/history";
|
|
263
263
|
/**
|
|
264
264
|
* A historical coverage snapshot.
|
|
@@ -351,14 +351,18 @@ declare function computeSnapshot(spec: OpenPkg2, options?: {
|
|
|
351
351
|
/**
|
|
352
352
|
* Save a coverage snapshot to history.
|
|
353
353
|
*
|
|
354
|
+
* Uses project root for .doccov location (walks up from cwd to find root).
|
|
355
|
+
*
|
|
354
356
|
* @param snapshot - The snapshot to save
|
|
355
|
-
* @param cwd - Working directory
|
|
357
|
+
* @param cwd - Working directory (will resolve to project root)
|
|
356
358
|
*/
|
|
357
359
|
declare function saveSnapshot(snapshot: CoverageSnapshot, cwd: string): void;
|
|
358
360
|
/**
|
|
359
361
|
* Load all historical snapshots.
|
|
360
362
|
*
|
|
361
|
-
*
|
|
363
|
+
* Uses project root for .doccov location (walks up from cwd to find root).
|
|
364
|
+
*
|
|
365
|
+
* @param cwd - Working directory (will resolve to project root)
|
|
362
366
|
* @returns Array of snapshots sorted by timestamp (most recent first)
|
|
363
367
|
*/
|
|
364
368
|
declare function loadSnapshots(cwd: string): CoverageSnapshot[];
|
|
@@ -391,7 +395,9 @@ declare function formatDelta(delta: number): string;
|
|
|
391
395
|
/**
|
|
392
396
|
* Prune old snapshots to keep history manageable.
|
|
393
397
|
*
|
|
394
|
-
*
|
|
398
|
+
* Uses project root for .doccov location (walks up from cwd to find root).
|
|
399
|
+
*
|
|
400
|
+
* @param cwd - Working directory (will resolve to project root)
|
|
395
401
|
* @param keepCount - Number of snapshots to keep (default: 100)
|
|
396
402
|
* @returns Number of snapshots deleted
|
|
397
403
|
*/
|
package/dist/analysis/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -767,13 +767,17 @@ interface CacheContext {
|
|
|
767
767
|
/**
|
|
768
768
|
* Load cached spec from disk.
|
|
769
769
|
*
|
|
770
|
-
*
|
|
770
|
+
* Uses project root for cache location (walks up from cwd to find root).
|
|
771
|
+
*
|
|
772
|
+
* @param cwd - Working directory (will resolve to project root)
|
|
771
773
|
* @returns Cached spec, or null if not found or invalid JSON
|
|
772
774
|
*/
|
|
773
775
|
declare function loadSpecCache(cwd: string): SpecCache | null;
|
|
774
776
|
/**
|
|
775
777
|
* Save spec to cache.
|
|
776
778
|
*
|
|
779
|
+
* Uses project root for cache location (walks up from cwd to find root).
|
|
780
|
+
*
|
|
777
781
|
* @param spec - OpenPkg spec to cache
|
|
778
782
|
* @param context - Cache context with file paths and config
|
|
779
783
|
*/
|
|
@@ -797,14 +801,18 @@ declare function validateSpecCache(cache: SpecCache, context: CacheContext): Cac
|
|
|
797
801
|
/**
|
|
798
802
|
* Clear the spec cache.
|
|
799
803
|
*
|
|
800
|
-
*
|
|
804
|
+
* Uses project root for cache location (walks up from cwd to find root).
|
|
805
|
+
*
|
|
806
|
+
* @param cwd - Working directory (will resolve to project root)
|
|
801
807
|
* @returns True if cache was deleted, false if it didn't exist
|
|
802
808
|
*/
|
|
803
809
|
declare function clearSpecCache(cwd: string): boolean;
|
|
804
810
|
/**
|
|
805
811
|
* Get cache file path for a given working directory.
|
|
806
812
|
*
|
|
807
|
-
*
|
|
813
|
+
* Uses project root for cache location (walks up from cwd to find root).
|
|
814
|
+
*
|
|
815
|
+
* @param cwd - Working directory (will resolve to project root)
|
|
808
816
|
* @returns Absolute path to cache file
|
|
809
817
|
*/
|
|
810
818
|
declare function getSpecCachePath(cwd: string): string;
|
|
@@ -2026,7 +2034,7 @@ interface DetectedSchemaEntry {
|
|
|
2026
2034
|
vendor: string;
|
|
2027
2035
|
}
|
|
2028
2036
|
import { OpenPkg as OpenPkg6 } from "@openpkg-ts/spec";
|
|
2029
|
-
/** Directory for storing history snapshots */
|
|
2037
|
+
/** Directory for storing history snapshots (relative to .doccov) */
|
|
2030
2038
|
declare const HISTORY_DIR = ".doccov/history";
|
|
2031
2039
|
/**
|
|
2032
2040
|
* A historical coverage snapshot.
|
|
@@ -2119,14 +2127,18 @@ declare function computeSnapshot(spec: OpenPkg6, options?: {
|
|
|
2119
2127
|
/**
|
|
2120
2128
|
* Save a coverage snapshot to history.
|
|
2121
2129
|
*
|
|
2130
|
+
* Uses project root for .doccov location (walks up from cwd to find root).
|
|
2131
|
+
*
|
|
2122
2132
|
* @param snapshot - The snapshot to save
|
|
2123
|
-
* @param cwd - Working directory
|
|
2133
|
+
* @param cwd - Working directory (will resolve to project root)
|
|
2124
2134
|
*/
|
|
2125
2135
|
declare function saveSnapshot(snapshot: CoverageSnapshot, cwd: string): void;
|
|
2126
2136
|
/**
|
|
2127
2137
|
* Load all historical snapshots.
|
|
2128
2138
|
*
|
|
2129
|
-
*
|
|
2139
|
+
* Uses project root for .doccov location (walks up from cwd to find root).
|
|
2140
|
+
*
|
|
2141
|
+
* @param cwd - Working directory (will resolve to project root)
|
|
2130
2142
|
* @returns Array of snapshots sorted by timestamp (most recent first)
|
|
2131
2143
|
*/
|
|
2132
2144
|
declare function loadSnapshots(cwd: string): CoverageSnapshot[];
|
|
@@ -2159,7 +2171,9 @@ declare function formatDelta(delta: number): string;
|
|
|
2159
2171
|
/**
|
|
2160
2172
|
* Prune old snapshots to keep history manageable.
|
|
2161
2173
|
*
|
|
2162
|
-
*
|
|
2174
|
+
* Uses project root for .doccov location (walks up from cwd to find root).
|
|
2175
|
+
*
|
|
2176
|
+
* @param cwd - Working directory (will resolve to project root)
|
|
2163
2177
|
* @param keepCount - Number of snapshots to keep (default: 100)
|
|
2164
2178
|
* @returns Number of snapshots deleted
|
|
2165
2179
|
*/
|
|
@@ -2618,7 +2632,7 @@ interface SpecSummary {
|
|
|
2618
2632
|
* ```
|
|
2619
2633
|
*/
|
|
2620
2634
|
declare function extractSpecSummary(openpkg: OpenPkg8, doccov: DocCovSpec4): SpecSummary;
|
|
2621
|
-
import { OpenPkg as
|
|
2635
|
+
import { OpenPkg as OpenPkg_vkaurybbgl } from "@openpkg-ts/spec";
|
|
2622
2636
|
/**
|
|
2623
2637
|
* Build Plan types for AI-powered repository scanning.
|
|
2624
2638
|
*/
|
|
@@ -2715,7 +2729,7 @@ interface BuildPlanExecutionResult {
|
|
|
2715
2729
|
/** Whether all required steps succeeded */
|
|
2716
2730
|
success: boolean;
|
|
2717
2731
|
/** Generated OpenPkg spec (if successful) */
|
|
2718
|
-
spec?:
|
|
2732
|
+
spec?: OpenPkg_vkaurybbgl;
|
|
2719
2733
|
/** Results for each step */
|
|
2720
2734
|
stepResults: BuildPlanStepResult[];
|
|
2721
2735
|
/** Total execution time in milliseconds */
|
|
@@ -2723,4 +2737,28 @@ interface BuildPlanExecutionResult {
|
|
|
2723
2737
|
/** Overall error message if failed */
|
|
2724
2738
|
error?: string;
|
|
2725
2739
|
}
|
|
2726
|
-
|
|
2740
|
+
/**
|
|
2741
|
+
* Find the project root by walking up from the given directory.
|
|
2742
|
+
*
|
|
2743
|
+
* Looks for:
|
|
2744
|
+
* 1. .git directory
|
|
2745
|
+
* 2. pnpm-workspace.yaml
|
|
2746
|
+
* 3. package.json with "workspaces" field
|
|
2747
|
+
* 4. Other monorepo markers (lerna.json, nx.json, rush.json)
|
|
2748
|
+
*
|
|
2749
|
+
* Falls back to the original directory if no root is found.
|
|
2750
|
+
*
|
|
2751
|
+
* @param startDir - Directory to start searching from
|
|
2752
|
+
* @returns Absolute path to the project root
|
|
2753
|
+
*/
|
|
2754
|
+
declare function findProjectRoot(startDir: string): string;
|
|
2755
|
+
/**
|
|
2756
|
+
* Get the .doccov cache directory for a project.
|
|
2757
|
+
*
|
|
2758
|
+
* Always uses the project root, not the package directory.
|
|
2759
|
+
*
|
|
2760
|
+
* @param cwd - Current working directory or package directory
|
|
2761
|
+
* @returns Absolute path to the .doccov directory
|
|
2762
|
+
*/
|
|
2763
|
+
declare function getDoccovDir(cwd: string): string;
|
|
2764
|
+
export { validateSpecCache, validateExamples, typecheckExamples, typecheckExample, shouldValidate, serializeJSDoc, saveSpecCache, saveSnapshot, saveReport, safeParseJson, runExamplesWithPackage, runExamples, runExample, resolveTarget, resolveCompiledPath, renderSparkline, renderApiSurface, readPackageJson, pruneHistory, previewForgottenExportFixes, parseGitHubUrl2 as parseScanGitHubUrl, parseMarkdownFiles, parseMarkdownFile, parseListFlag, parseJSDocToPatch, parseGitHubUrl, parseExamplesFlag, parseAssertions, normalizeConfig, mergeFixes, mergeFilters, loadSpecCache, loadSnapshots, loadCachedReport, listWorkspacePackages, isStandardJSONSchema, isSchemaType, isFixableDrift, isExportFullyDocumented, isExecutableLang, installDependencies, hashString, hashFiles, hashFile, hasNonAssertionComments, hasDocsImpact, hasDocsForExport, groupFixesByFile, groupDriftsByCategory, getUndocumentedExports, getTrend, getSupportedLibraries, getSpecCachePath, getRunCommand, getReportPath, getRegisteredAdapters, getPrimaryBuildScript, getInstallCommand, getExtendedTrend, getExportScore, getExportMissing, getExportDrift, getExportAnalysis, getDriftSummary, getDocumentedExports, getDocsImpactSummary, getDoccovDir, getDiffReportPath, generateReportFromDocCov, generateReport, generateForgottenExportFixes, generateFixesForExport, generateFix, formatPackageList, formatDriftSummaryLine, formatDelta, findRemovedReferences, findProjectRoot, findPackageByName, findJSDocLocation, findExportReferences, findDeprecatedReferences, findAdapter, fetchSpecFromGitHub, fetchSpec, fetchGitHubContext, extractStandardSchemasFromProject, extractStandardSchemas, extractSpecSummary, extractSchemaType, extractSchemaOutputType, extractPackageSpec, extractImports, extractFunctionCalls, ensureSpecCoverage, docCovConfigSchema, diffSpecWithDocs, diffHashes, detectRuntimeSchemas, detectPackageManager, detectMonorepo, detectExampleRuntimeErrors, detectExampleAssertionFailures, detectEntryPoint, detectBuildInfo, defineConfig, createSourceFile, createNodeCommandRunner, computeSnapshot, computeHealth, computeExportDrift, computeDrift, clearSpecCache, categorizeDrifts, categorizeDrift, calculateAggregateCoverage, buildRawUrl, buildExportRegistry, buildDocCovSpec, buildDisplayUrl, buildCloneUrl, blockReferencesExport, applyPatchToJSDoc, applyForgottenExportFixes, applyEdits, analyzeProject2 as analyzeProject, analyzeFile, analyzeDocsImpact, analyze, WorkspacePackage, WorkspaceConfig, VALIDATION_INFO, TypecheckValidationResult, TypecheckResult, TypecheckOptions, SummaryDriftIssue, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, SpecSummary, SpecDocDrift, SpecDiffWithDocs, SpecCacheConfig, SpecCache, SchemaExtractionResult, SchemaExtractionMode, SchemaDetectionResult, SchemaDetectionContext, SchemaAdapter, SandboxFileSystem, SPEC_CACHE_FILE, RuntimeDrift, RunValidationResult, RunExamplesWithPackageResult, RunExamplesWithPackageOptions, RunExampleOptions, ResolvedTarget, ResolvedFilters, ResolveTargetOptions, ReleaseTag, REPORT_VERSION, REPORT_EXTENSIONS, ProjectInfo, PresenceResult, ParsedGitHubUrl, PackageManagerInfo, PackageManager, PackageJson, PackageExports, OpenPkgSpec, NodeFileSystem, MonorepoType, MonorepoInfo, MemberChange, MarkdownDocFile, MarkdownCodeBlock, LLMAssertion, JSDocTag, JSDocReturn, JSDocPatch, JSDocParam, JSDocEdit, InstallResult, InstallOptions, HealthInput, HISTORY_DIR, GitHubRepoMetadata, GitHubProjectContext, GenerateForgottenExportFixesOptions, ForgottenExportResult, ForgottenExportFix, FixType, FixSuggestion, FilterSource, FilterOptions, FileSystem, FetchGitHubContextOptions, ExtractStandardSchemasOptions, ExtendedTrendAnalysis, ExportReference, ExportDriftResult, ExportCoverageData, ExampleValidationTypeError, ExampleValidationResult, ExampleValidationOptions, ExampleValidationMode, ExampleValidation, ExampleTypeError, ExampleRunResult, EntryPointSource, EntryPointInfo, DriftType, DriftSummary, DriftResult, DriftReportSummary, DriftReport, DriftCategory, DocsImpactResult, DocsImpactReference, DocsImpact, DocsConfig, DocsChangeType, DocCovReport, DocCovOptions, DocCovConfigInput, DocCovConfig, DocCov, DiffWithDocsOptions, Diagnostic, DetectedSchemaEntry, DetectedPackageManager, DRIFT_CATEGORY_LABELS, DRIFT_CATEGORY_DESCRIPTIONS, DRIFT_CATEGORIES, DEFAULT_REPORT_PATH, DEFAULT_REPORT_DIR, CoverageTrend, CoverageSummary, CoverageSnapshot, CommandRunner, CommandResult, CheckConfig, CategorizedDrift, CacheValidationResult, CacheContext, CACHE_VERSION, BuildPlanTarget, BuildPlanStepResult, BuildPlanStep, BuildPlanExecutionResult, BuildPlanEnvironment, BuildPlan, BuildInfo, BuildHints, BuildDocCovOptions, ApplyForgottenExportResult, ApplyEditsResult, AnalyzeProjectOptions, AnalyzeOptions, AnalysisResult, ALL_VALIDATIONS };
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
extractStandardSchemasFromProject,
|
|
27
27
|
findAdapter,
|
|
28
28
|
findJSDocLocation,
|
|
29
|
+
findProjectRoot,
|
|
29
30
|
formatDelta,
|
|
30
31
|
formatDriftSummaryLine,
|
|
31
32
|
generateFix,
|
|
@@ -33,6 +34,7 @@ import {
|
|
|
33
34
|
generateForgottenExportFixes,
|
|
34
35
|
generateReport,
|
|
35
36
|
generateReportFromDocCov,
|
|
37
|
+
getDoccovDir,
|
|
36
38
|
getDriftSummary,
|
|
37
39
|
getExportAnalysis,
|
|
38
40
|
getExportDrift,
|
|
@@ -64,7 +66,7 @@ import {
|
|
|
64
66
|
saveSnapshot,
|
|
65
67
|
serializeJSDoc,
|
|
66
68
|
ts
|
|
67
|
-
} from "./shared/chunk-
|
|
69
|
+
} from "./shared/chunk-fdjehkbt.js";
|
|
68
70
|
import {
|
|
69
71
|
mergeFilters,
|
|
70
72
|
parseListFlag
|
|
@@ -319,7 +321,7 @@ var CACHE_VERSION = "1.3.0";
|
|
|
319
321
|
var SPEC_CACHE_FILE = ".doccov/cache/spec.cache.json";
|
|
320
322
|
function loadSpecCache(cwd) {
|
|
321
323
|
try {
|
|
322
|
-
const cachePath = path5.
|
|
324
|
+
const cachePath = path5.join(getDoccovDir(cwd), "cache", "spec.cache.json");
|
|
323
325
|
if (!fs4.existsSync(cachePath)) {
|
|
324
326
|
return null;
|
|
325
327
|
}
|
|
@@ -355,7 +357,7 @@ function saveSpecCache(spec, context) {
|
|
|
355
357
|
specDiagnostics,
|
|
356
358
|
forgottenExports
|
|
357
359
|
};
|
|
358
|
-
const cachePath = path5.
|
|
360
|
+
const cachePath = path5.join(getDoccovDir(cwd), "cache", "spec.cache.json");
|
|
359
361
|
const dir = path5.dirname(cachePath);
|
|
360
362
|
if (!fs4.existsSync(dir)) {
|
|
361
363
|
fs4.mkdirSync(dir, { recursive: true });
|
|
@@ -390,7 +392,7 @@ function validateSpecCache(cache, context) {
|
|
|
390
392
|
return { valid: true };
|
|
391
393
|
}
|
|
392
394
|
function clearSpecCache(cwd) {
|
|
393
|
-
const cachePath = path5.
|
|
395
|
+
const cachePath = path5.join(getDoccovDir(cwd), "cache", "spec.cache.json");
|
|
394
396
|
if (fs4.existsSync(cachePath)) {
|
|
395
397
|
fs4.unlinkSync(cachePath);
|
|
396
398
|
return true;
|
|
@@ -398,7 +400,7 @@ function clearSpecCache(cwd) {
|
|
|
398
400
|
return false;
|
|
399
401
|
}
|
|
400
402
|
function getSpecCachePath(cwd) {
|
|
401
|
-
return path5.
|
|
403
|
+
return path5.join(getDoccovDir(cwd), "cache", "spec.cache.json");
|
|
402
404
|
}
|
|
403
405
|
// src/extractor.ts
|
|
404
406
|
import * as path6 from "node:path";
|
|
@@ -15420,7 +15422,7 @@ async function runExample(code, options = {}) {
|
|
|
15420
15422
|
try {
|
|
15421
15423
|
fs8.writeFileSync(tmpFile, cleanCode, "utf-8");
|
|
15422
15424
|
const startTime = Date.now();
|
|
15423
|
-
return await new Promise((
|
|
15425
|
+
return await new Promise((resolve4) => {
|
|
15424
15426
|
let stdout = "";
|
|
15425
15427
|
let stderr = "";
|
|
15426
15428
|
let killed = false;
|
|
@@ -15443,7 +15445,7 @@ async function runExample(code, options = {}) {
|
|
|
15443
15445
|
clearTimeout(timeoutId);
|
|
15444
15446
|
const duration3 = Date.now() - startTime;
|
|
15445
15447
|
if (killed) {
|
|
15446
|
-
|
|
15448
|
+
resolve4({
|
|
15447
15449
|
success: false,
|
|
15448
15450
|
stdout,
|
|
15449
15451
|
stderr: stderr || `Example timed out after ${timeout}ms`,
|
|
@@ -15451,7 +15453,7 @@ async function runExample(code, options = {}) {
|
|
|
15451
15453
|
duration: duration3
|
|
15452
15454
|
});
|
|
15453
15455
|
} else {
|
|
15454
|
-
|
|
15456
|
+
resolve4({
|
|
15455
15457
|
success: exitCode === 0,
|
|
15456
15458
|
stdout,
|
|
15457
15459
|
stderr,
|
|
@@ -15462,7 +15464,7 @@ async function runExample(code, options = {}) {
|
|
|
15462
15464
|
});
|
|
15463
15465
|
proc.on("error", (error48) => {
|
|
15464
15466
|
clearTimeout(timeoutId);
|
|
15465
|
-
|
|
15467
|
+
resolve4({
|
|
15466
15468
|
success: false,
|
|
15467
15469
|
stdout,
|
|
15468
15470
|
stderr: error48.message,
|
|
@@ -15513,7 +15515,7 @@ function getInstallCommand2(pm, packagePath) {
|
|
|
15513
15515
|
}
|
|
15514
15516
|
}
|
|
15515
15517
|
async function runCommand(cmd, args, options) {
|
|
15516
|
-
return new Promise((
|
|
15518
|
+
return new Promise((resolve4) => {
|
|
15517
15519
|
let stdout = "";
|
|
15518
15520
|
let stderr = "";
|
|
15519
15521
|
let killed = false;
|
|
@@ -15534,14 +15536,14 @@ async function runCommand(cmd, args, options) {
|
|
|
15534
15536
|
proc.on("close", (exitCode) => {
|
|
15535
15537
|
clearTimeout(timeoutId);
|
|
15536
15538
|
if (killed) {
|
|
15537
|
-
|
|
15539
|
+
resolve4({
|
|
15538
15540
|
success: false,
|
|
15539
15541
|
stdout,
|
|
15540
15542
|
stderr: stderr || `Command timed out after ${options.timeout}ms`,
|
|
15541
15543
|
exitCode: exitCode ?? 1
|
|
15542
15544
|
});
|
|
15543
15545
|
} else {
|
|
15544
|
-
|
|
15546
|
+
resolve4({
|
|
15545
15547
|
success: exitCode === 0,
|
|
15546
15548
|
stdout,
|
|
15547
15549
|
stderr,
|
|
@@ -15551,7 +15553,7 @@ async function runCommand(cmd, args, options) {
|
|
|
15551
15553
|
});
|
|
15552
15554
|
proc.on("error", (error48) => {
|
|
15553
15555
|
clearTimeout(timeoutId);
|
|
15554
|
-
|
|
15556
|
+
resolve4({
|
|
15555
15557
|
success: false,
|
|
15556
15558
|
stdout,
|
|
15557
15559
|
stderr: error48.message,
|
|
@@ -17110,6 +17112,7 @@ export {
|
|
|
17110
17112
|
getDriftSummary,
|
|
17111
17113
|
getDocumentedExports,
|
|
17112
17114
|
getDocsImpactSummary,
|
|
17115
|
+
getDoccovDir,
|
|
17113
17116
|
getDiffReportPath,
|
|
17114
17117
|
generateReportFromDocCov,
|
|
17115
17118
|
generateReport,
|
|
@@ -17120,6 +17123,7 @@ export {
|
|
|
17120
17123
|
formatDriftSummaryLine,
|
|
17121
17124
|
formatDelta,
|
|
17122
17125
|
findRemovedReferences,
|
|
17126
|
+
findProjectRoot,
|
|
17123
17127
|
findPackageByName,
|
|
17124
17128
|
findJSDocLocation,
|
|
17125
17129
|
findExportReferences,
|
|
@@ -1121,47 +1121,16 @@ var BUILTIN_GLOBALS = new Set([
|
|
|
1121
1121
|
]);
|
|
1122
1122
|
|
|
1123
1123
|
// src/analysis/drift/utils.ts
|
|
1124
|
-
function extractParamFromTag(
|
|
1125
|
-
|
|
1126
|
-
if (!trimmed) {
|
|
1127
|
-
return;
|
|
1128
|
-
}
|
|
1129
|
-
const match = trimmed.match(/^(?:\{([^}]+)\}\s+)?(\S+)(?:\s+-\s+)?/);
|
|
1130
|
-
if (!match) {
|
|
1131
|
-
return;
|
|
1132
|
-
}
|
|
1133
|
-
const [, type, rawName] = match;
|
|
1134
|
-
const isOptional = Boolean(rawName?.startsWith("[") && rawName?.endsWith("]"));
|
|
1135
|
-
const name = normalizeParamName(rawName);
|
|
1136
|
-
if (!name) {
|
|
1124
|
+
function extractParamFromTag(tag) {
|
|
1125
|
+
if (!tag.param) {
|
|
1137
1126
|
return;
|
|
1138
1127
|
}
|
|
1139
1128
|
return {
|
|
1140
|
-
name,
|
|
1141
|
-
type: type
|
|
1142
|
-
isOptional
|
|
1129
|
+
name: tag.param.name,
|
|
1130
|
+
type: tag.param.type,
|
|
1131
|
+
isOptional: tag.param.optional
|
|
1143
1132
|
};
|
|
1144
1133
|
}
|
|
1145
|
-
function normalizeParamName(raw) {
|
|
1146
|
-
if (!raw) {
|
|
1147
|
-
return;
|
|
1148
|
-
}
|
|
1149
|
-
let name = raw.trim();
|
|
1150
|
-
if (!name) {
|
|
1151
|
-
return;
|
|
1152
|
-
}
|
|
1153
|
-
if (name.startsWith("[") && name.endsWith("]")) {
|
|
1154
|
-
name = name.slice(1, -1);
|
|
1155
|
-
}
|
|
1156
|
-
const equalsIndex = name.indexOf("=");
|
|
1157
|
-
if (equalsIndex >= 0) {
|
|
1158
|
-
name = name.slice(0, equalsIndex);
|
|
1159
|
-
}
|
|
1160
|
-
if (name.endsWith(",")) {
|
|
1161
|
-
name = name.slice(0, -1);
|
|
1162
|
-
}
|
|
1163
|
-
return name;
|
|
1164
|
-
}
|
|
1165
1134
|
function extractReturnTypeFromTag(text) {
|
|
1166
1135
|
const trimmed = text.trim();
|
|
1167
1136
|
if (!trimmed) {
|
|
@@ -1640,7 +1609,7 @@ function detectParamDrift(entry) {
|
|
|
1640
1609
|
if (actualParamNames.size === 0) {
|
|
1641
1610
|
return drifts;
|
|
1642
1611
|
}
|
|
1643
|
-
const documentedParamNames = (entry.tags ?? []).filter((tag) => tag.name === "param"
|
|
1612
|
+
const documentedParamNames = (entry.tags ?? []).filter((tag) => tag.name === "param").map((tag) => extractParamFromTag(tag)?.name).filter((name) => Boolean(name));
|
|
1644
1613
|
if (documentedParamNames.length === 0) {
|
|
1645
1614
|
return drifts;
|
|
1646
1615
|
}
|
|
@@ -1712,7 +1681,7 @@ function detectOptionalityDrift(entry) {
|
|
|
1712
1681
|
if (actualOptionality.size === 0) {
|
|
1713
1682
|
return [];
|
|
1714
1683
|
}
|
|
1715
|
-
const documentedParams = (entry.tags ?? []).filter((tag) => tag.name === "param"
|
|
1684
|
+
const documentedParams = (entry.tags ?? []).filter((tag) => tag.name === "param").map((tag) => extractParamFromTag(tag)).filter((parsed) => Boolean(parsed?.name));
|
|
1716
1685
|
if (documentedParams.length === 0) {
|
|
1717
1686
|
return [];
|
|
1718
1687
|
}
|
|
@@ -1742,7 +1711,7 @@ function detectParamTypeDrift(entry) {
|
|
|
1742
1711
|
if (signatures.length === 0) {
|
|
1743
1712
|
return [];
|
|
1744
1713
|
}
|
|
1745
|
-
const documentedParams = (entry.tags ?? []).filter((tag) => tag.name === "param"
|
|
1714
|
+
const documentedParams = (entry.tags ?? []).filter((tag) => tag.name === "param").map((tag) => extractParamFromTag(tag)).filter((parsed) => Boolean(parsed?.name) && Boolean(parsed?.type));
|
|
1746
1715
|
if (documentedParams.length === 0) {
|
|
1747
1716
|
return [];
|
|
1748
1717
|
}
|
|
@@ -2863,10 +2832,52 @@ async function detectRuntimeSchemas(context) {
|
|
|
2863
2832
|
};
|
|
2864
2833
|
}
|
|
2865
2834
|
|
|
2866
|
-
// src/
|
|
2835
|
+
// src/utils/project-root.ts
|
|
2867
2836
|
import * as fs4 from "node:fs";
|
|
2868
2837
|
import * as path4 from "node:path";
|
|
2838
|
+
var PROJECT_ROOT_MARKERS = [
|
|
2839
|
+
".git",
|
|
2840
|
+
"pnpm-workspace.yaml",
|
|
2841
|
+
"pnpm-workspace.yml",
|
|
2842
|
+
"lerna.json",
|
|
2843
|
+
"nx.json",
|
|
2844
|
+
"rush.json"
|
|
2845
|
+
];
|
|
2846
|
+
function findProjectRoot(startDir) {
|
|
2847
|
+
let dir = path4.resolve(startDir);
|
|
2848
|
+
const root = path4.parse(dir).root;
|
|
2849
|
+
while (dir !== root) {
|
|
2850
|
+
for (const marker of PROJECT_ROOT_MARKERS) {
|
|
2851
|
+
const markerPath = path4.join(dir, marker);
|
|
2852
|
+
if (fs4.existsSync(markerPath)) {
|
|
2853
|
+
return dir;
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
const pkgPath = path4.join(dir, "package.json");
|
|
2857
|
+
if (fs4.existsSync(pkgPath)) {
|
|
2858
|
+
try {
|
|
2859
|
+
const pkg = JSON.parse(fs4.readFileSync(pkgPath, "utf-8"));
|
|
2860
|
+
if (pkg.workspaces) {
|
|
2861
|
+
return dir;
|
|
2862
|
+
}
|
|
2863
|
+
} catch {}
|
|
2864
|
+
}
|
|
2865
|
+
dir = path4.dirname(dir);
|
|
2866
|
+
}
|
|
2867
|
+
return path4.resolve(startDir);
|
|
2868
|
+
}
|
|
2869
|
+
function getDoccovDir(cwd) {
|
|
2870
|
+
const projectRoot = findProjectRoot(cwd);
|
|
2871
|
+
return path4.join(projectRoot, ".doccov");
|
|
2872
|
+
}
|
|
2873
|
+
|
|
2874
|
+
// src/analysis/history.ts
|
|
2875
|
+
import * as fs5 from "node:fs";
|
|
2876
|
+
import * as path5 from "node:path";
|
|
2869
2877
|
var HISTORY_DIR = ".doccov/history";
|
|
2878
|
+
function getHistoryDir(cwd) {
|
|
2879
|
+
return path5.join(getDoccovDir(cwd), "history");
|
|
2880
|
+
}
|
|
2870
2881
|
var RETENTION_DAYS = 90;
|
|
2871
2882
|
function getSnapshotFilename(timestamp) {
|
|
2872
2883
|
const pad = (n) => n.toString().padStart(2, "0");
|
|
@@ -2899,24 +2910,24 @@ function computeSnapshot(spec, options) {
|
|
|
2899
2910
|
};
|
|
2900
2911
|
}
|
|
2901
2912
|
function saveSnapshot(snapshot, cwd) {
|
|
2902
|
-
const historyDir =
|
|
2903
|
-
if (!
|
|
2904
|
-
|
|
2913
|
+
const historyDir = getHistoryDir(cwd);
|
|
2914
|
+
if (!fs5.existsSync(historyDir)) {
|
|
2915
|
+
fs5.mkdirSync(historyDir, { recursive: true });
|
|
2905
2916
|
}
|
|
2906
2917
|
const filename = getSnapshotFilename(new Date(snapshot.timestamp));
|
|
2907
|
-
const filepath =
|
|
2908
|
-
|
|
2918
|
+
const filepath = path5.join(historyDir, filename);
|
|
2919
|
+
fs5.writeFileSync(filepath, JSON.stringify(snapshot, null, 2));
|
|
2909
2920
|
}
|
|
2910
2921
|
function loadSnapshots(cwd) {
|
|
2911
|
-
const historyDir =
|
|
2912
|
-
if (!
|
|
2922
|
+
const historyDir = getHistoryDir(cwd);
|
|
2923
|
+
if (!fs5.existsSync(historyDir)) {
|
|
2913
2924
|
return [];
|
|
2914
2925
|
}
|
|
2915
|
-
const files =
|
|
2926
|
+
const files = fs5.readdirSync(historyDir).filter((f) => f.endsWith(".json")).sort().reverse();
|
|
2916
2927
|
const snapshots = [];
|
|
2917
2928
|
for (const file of files) {
|
|
2918
2929
|
try {
|
|
2919
|
-
const content =
|
|
2930
|
+
const content = fs5.readFileSync(path5.join(historyDir, file), "utf-8");
|
|
2920
2931
|
snapshots.push(JSON.parse(content));
|
|
2921
2932
|
} catch {}
|
|
2922
2933
|
}
|
|
@@ -2956,15 +2967,15 @@ function formatDelta(delta) {
|
|
|
2956
2967
|
return "→0%";
|
|
2957
2968
|
}
|
|
2958
2969
|
function pruneHistory(cwd, keepCount = 100) {
|
|
2959
|
-
const historyDir =
|
|
2960
|
-
if (!
|
|
2970
|
+
const historyDir = getHistoryDir(cwd);
|
|
2971
|
+
if (!fs5.existsSync(historyDir)) {
|
|
2961
2972
|
return 0;
|
|
2962
2973
|
}
|
|
2963
|
-
const files =
|
|
2974
|
+
const files = fs5.readdirSync(historyDir).filter((f) => f.endsWith(".json")).sort().reverse();
|
|
2964
2975
|
const toDelete = files.slice(keepCount);
|
|
2965
2976
|
for (const file of toDelete) {
|
|
2966
2977
|
try {
|
|
2967
|
-
|
|
2978
|
+
fs5.unlinkSync(path5.join(historyDir, file));
|
|
2968
2979
|
} catch {}
|
|
2969
2980
|
}
|
|
2970
2981
|
return toDelete.length;
|
|
@@ -3060,4 +3071,4 @@ function getExtendedTrend(spec, cwd, options) {
|
|
|
3060
3071
|
};
|
|
3061
3072
|
}
|
|
3062
3073
|
|
|
3063
|
-
export { isFixableDrift, generateFix, generateFixesForExport, mergeFixes, categorizeDrifts, generateForgottenExportFixes, groupFixesByFile, applyForgottenExportFixes, previewForgottenExportFixes, ts, parseJSDocToPatch, applyPatchToJSDoc, serializeJSDoc, findJSDocLocation, applyEdits, createSourceFile, isBuiltInIdentifier, detectExampleRuntimeErrors, parseAssertions, hasNonAssertionComments, detectExampleAssertionFailures, buildExportRegistry, computeDrift, computeExportDrift, computeHealth, buildDocCovSpec, DRIFT_CATEGORIES2 as DRIFT_CATEGORIES, DRIFT_CATEGORY_LABELS, DRIFT_CATEGORY_DESCRIPTIONS, categorizeDrift, groupDriftsByCategory, getDriftSummary, formatDriftSummaryLine, calculateAggregateCoverage, ensureSpecCoverage, getExportAnalysis, getExportScore, getExportDrift, getExportMissing, isExportFullyDocumented, generateReport, generateReportFromDocCov, loadCachedReport, saveReport, isCachedReportValid, renderApiSurface, extractSchemaOutputType, getRegisteredAdapters, getSupportedLibraries, extractSchemaType, extractStandardSchemas, extractStandardSchemasFromProject, findAdapter, isSchemaType, isStandardJSONSchema, resolveCompiledPath, detectRuntimeSchemas, HISTORY_DIR, computeSnapshot, saveSnapshot, loadSnapshots, getTrend, renderSparkline, formatDelta, pruneHistory, loadSnapshotsForDays, generateWeeklySummaries, getExtendedTrend };
|
|
3074
|
+
export { isFixableDrift, generateFix, generateFixesForExport, mergeFixes, categorizeDrifts, generateForgottenExportFixes, groupFixesByFile, applyForgottenExportFixes, previewForgottenExportFixes, ts, parseJSDocToPatch, applyPatchToJSDoc, serializeJSDoc, findJSDocLocation, applyEdits, createSourceFile, isBuiltInIdentifier, detectExampleRuntimeErrors, parseAssertions, hasNonAssertionComments, detectExampleAssertionFailures, buildExportRegistry, computeDrift, computeExportDrift, computeHealth, buildDocCovSpec, DRIFT_CATEGORIES2 as DRIFT_CATEGORIES, DRIFT_CATEGORY_LABELS, DRIFT_CATEGORY_DESCRIPTIONS, categorizeDrift, groupDriftsByCategory, getDriftSummary, formatDriftSummaryLine, calculateAggregateCoverage, ensureSpecCoverage, getExportAnalysis, getExportScore, getExportDrift, getExportMissing, isExportFullyDocumented, generateReport, generateReportFromDocCov, loadCachedReport, saveReport, isCachedReportValid, renderApiSurface, extractSchemaOutputType, getRegisteredAdapters, getSupportedLibraries, extractSchemaType, extractStandardSchemas, extractStandardSchemasFromProject, findAdapter, isSchemaType, isStandardJSONSchema, resolveCompiledPath, detectRuntimeSchemas, findProjectRoot, getDoccovDir, HISTORY_DIR, computeSnapshot, saveSnapshot, loadSnapshots, getTrend, renderSparkline, formatDelta, pruneHistory, loadSnapshotsForDays, generateWeeklySummaries, getExtendedTrend };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doccov/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"description": "DocCov SDK - Documentation coverage and drift detection for TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@doccov/spec": "^0.27.0",
|
|
51
|
-
"@openpkg-ts/extract": "^0.
|
|
52
|
-
"@openpkg-ts/spec": "^0.
|
|
51
|
+
"@openpkg-ts/extract": "^0.19.0",
|
|
52
|
+
"@openpkg-ts/spec": "^0.19.0",
|
|
53
53
|
"@vercel/sandbox": "^1.0.3",
|
|
54
54
|
"mdast": "^3.0.0",
|
|
55
55
|
"minimatch": "^10.1.1",
|