@doccov/sdk 0.29.2 → 0.30.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/analysis/index.d.ts +10 -4
- package/dist/analysis/index.js +1 -1
- package/dist/index.d.ts +51 -11
- package/dist/index.js +20 -15
- package/dist/shared/{chunk-0048g7g0.js → chunk-8jre4296.js} +57 -15
- package/package.json +1 -1
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
|
@@ -664,7 +664,7 @@ declare function hashFiles(filePaths: string[], cwd: string): Record<string, str
|
|
|
664
664
|
declare function diffHashes(cached: Record<string, string>, current: Record<string, string>): string[];
|
|
665
665
|
import { OpenPkg as OpenPkg3 } from "@openpkg-ts/spec";
|
|
666
666
|
/** Current cache format version - bump when spec extraction logic changes */
|
|
667
|
-
declare const CACHE_VERSION = "1.
|
|
667
|
+
declare const CACHE_VERSION = "1.3.0";
|
|
668
668
|
/** Default cache file path */
|
|
669
669
|
declare const SPEC_CACHE_FILE = ".doccov/cache/spec.cache.json";
|
|
670
670
|
/**
|
|
@@ -680,6 +680,7 @@ interface CachedDiagnostic {
|
|
|
680
680
|
message: string;
|
|
681
681
|
severity: "error" | "warning" | "info";
|
|
682
682
|
suggestion?: string;
|
|
683
|
+
code?: string;
|
|
683
684
|
location?: {
|
|
684
685
|
file: string;
|
|
685
686
|
line?: number;
|
|
@@ -766,13 +767,17 @@ interface CacheContext {
|
|
|
766
767
|
/**
|
|
767
768
|
* Load cached spec from disk.
|
|
768
769
|
*
|
|
769
|
-
*
|
|
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)
|
|
770
773
|
* @returns Cached spec, or null if not found or invalid JSON
|
|
771
774
|
*/
|
|
772
775
|
declare function loadSpecCache(cwd: string): SpecCache | null;
|
|
773
776
|
/**
|
|
774
777
|
* Save spec to cache.
|
|
775
778
|
*
|
|
779
|
+
* Uses project root for cache location (walks up from cwd to find root).
|
|
780
|
+
*
|
|
776
781
|
* @param spec - OpenPkg spec to cache
|
|
777
782
|
* @param context - Cache context with file paths and config
|
|
778
783
|
*/
|
|
@@ -796,14 +801,18 @@ declare function validateSpecCache(cache: SpecCache, context: CacheContext): Cac
|
|
|
796
801
|
/**
|
|
797
802
|
* Clear the spec cache.
|
|
798
803
|
*
|
|
799
|
-
*
|
|
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)
|
|
800
807
|
* @returns True if cache was deleted, false if it didn't exist
|
|
801
808
|
*/
|
|
802
809
|
declare function clearSpecCache(cwd: string): boolean;
|
|
803
810
|
/**
|
|
804
811
|
* Get cache file path for a given working directory.
|
|
805
812
|
*
|
|
806
|
-
*
|
|
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)
|
|
807
816
|
* @returns Absolute path to cache file
|
|
808
817
|
*/
|
|
809
818
|
declare function getSpecCachePath(cwd: string): string;
|
|
@@ -988,6 +997,7 @@ interface Diagnostic {
|
|
|
988
997
|
message: string;
|
|
989
998
|
severity: "error" | "warning" | "info";
|
|
990
999
|
suggestion?: string;
|
|
1000
|
+
code?: string;
|
|
991
1001
|
location?: {
|
|
992
1002
|
file: string;
|
|
993
1003
|
line?: number;
|
|
@@ -2024,7 +2034,7 @@ interface DetectedSchemaEntry {
|
|
|
2024
2034
|
vendor: string;
|
|
2025
2035
|
}
|
|
2026
2036
|
import { OpenPkg as OpenPkg6 } from "@openpkg-ts/spec";
|
|
2027
|
-
/** Directory for storing history snapshots */
|
|
2037
|
+
/** Directory for storing history snapshots (relative to .doccov) */
|
|
2028
2038
|
declare const HISTORY_DIR = ".doccov/history";
|
|
2029
2039
|
/**
|
|
2030
2040
|
* A historical coverage snapshot.
|
|
@@ -2117,14 +2127,18 @@ declare function computeSnapshot(spec: OpenPkg6, options?: {
|
|
|
2117
2127
|
/**
|
|
2118
2128
|
* Save a coverage snapshot to history.
|
|
2119
2129
|
*
|
|
2130
|
+
* Uses project root for .doccov location (walks up from cwd to find root).
|
|
2131
|
+
*
|
|
2120
2132
|
* @param snapshot - The snapshot to save
|
|
2121
|
-
* @param cwd - Working directory
|
|
2133
|
+
* @param cwd - Working directory (will resolve to project root)
|
|
2122
2134
|
*/
|
|
2123
2135
|
declare function saveSnapshot(snapshot: CoverageSnapshot, cwd: string): void;
|
|
2124
2136
|
/**
|
|
2125
2137
|
* Load all historical snapshots.
|
|
2126
2138
|
*
|
|
2127
|
-
*
|
|
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)
|
|
2128
2142
|
* @returns Array of snapshots sorted by timestamp (most recent first)
|
|
2129
2143
|
*/
|
|
2130
2144
|
declare function loadSnapshots(cwd: string): CoverageSnapshot[];
|
|
@@ -2157,7 +2171,9 @@ declare function formatDelta(delta: number): string;
|
|
|
2157
2171
|
/**
|
|
2158
2172
|
* Prune old snapshots to keep history manageable.
|
|
2159
2173
|
*
|
|
2160
|
-
*
|
|
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)
|
|
2161
2177
|
* @param keepCount - Number of snapshots to keep (default: 100)
|
|
2162
2178
|
* @returns Number of snapshots deleted
|
|
2163
2179
|
*/
|
|
@@ -2616,7 +2632,7 @@ interface SpecSummary {
|
|
|
2616
2632
|
* ```
|
|
2617
2633
|
*/
|
|
2618
2634
|
declare function extractSpecSummary(openpkg: OpenPkg8, doccov: DocCovSpec4): SpecSummary;
|
|
2619
|
-
import { OpenPkg as
|
|
2635
|
+
import { OpenPkg as OpenPkg_clqpwbmpdv } from "@openpkg-ts/spec";
|
|
2620
2636
|
/**
|
|
2621
2637
|
* Build Plan types for AI-powered repository scanning.
|
|
2622
2638
|
*/
|
|
@@ -2713,7 +2729,7 @@ interface BuildPlanExecutionResult {
|
|
|
2713
2729
|
/** Whether all required steps succeeded */
|
|
2714
2730
|
success: boolean;
|
|
2715
2731
|
/** Generated OpenPkg spec (if successful) */
|
|
2716
|
-
spec?:
|
|
2732
|
+
spec?: OpenPkg_clqpwbmpdv;
|
|
2717
2733
|
/** Results for each step */
|
|
2718
2734
|
stepResults: BuildPlanStepResult[];
|
|
2719
2735
|
/** Total execution time in milliseconds */
|
|
@@ -2721,4 +2737,28 @@ interface BuildPlanExecutionResult {
|
|
|
2721
2737
|
/** Overall error message if failed */
|
|
2722
2738
|
error?: string;
|
|
2723
2739
|
}
|
|
2724
|
-
|
|
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-8jre4296.js";
|
|
68
70
|
import {
|
|
69
71
|
mergeFilters,
|
|
70
72
|
parseListFlag
|
|
@@ -251,7 +253,8 @@ async function runAnalysis(input) {
|
|
|
251
253
|
specDiagnostics.push({
|
|
252
254
|
message: diag.message,
|
|
253
255
|
severity: diag.severity,
|
|
254
|
-
suggestion: diag.suggestion
|
|
256
|
+
suggestion: diag.suggestion,
|
|
257
|
+
code: diag.code
|
|
255
258
|
});
|
|
256
259
|
}
|
|
257
260
|
const sourceFiles = program.getSourceFiles().filter((sf) => !sf.isDeclarationFile && sf.fileName.startsWith(baseDir)).map((sf) => sf.fileName);
|
|
@@ -314,11 +317,11 @@ function diffHashes(cached, current) {
|
|
|
314
317
|
// src/cache/spec-cache.ts
|
|
315
318
|
import * as fs4 from "node:fs";
|
|
316
319
|
import * as path5 from "node:path";
|
|
317
|
-
var CACHE_VERSION = "1.
|
|
320
|
+
var CACHE_VERSION = "1.3.0";
|
|
318
321
|
var SPEC_CACHE_FILE = ".doccov/cache/spec.cache.json";
|
|
319
322
|
function loadSpecCache(cwd) {
|
|
320
323
|
try {
|
|
321
|
-
const cachePath = path5.
|
|
324
|
+
const cachePath = path5.join(getDoccovDir(cwd), "cache", "spec.cache.json");
|
|
322
325
|
if (!fs4.existsSync(cachePath)) {
|
|
323
326
|
return null;
|
|
324
327
|
}
|
|
@@ -354,7 +357,7 @@ function saveSpecCache(spec, context) {
|
|
|
354
357
|
specDiagnostics,
|
|
355
358
|
forgottenExports
|
|
356
359
|
};
|
|
357
|
-
const cachePath = path5.
|
|
360
|
+
const cachePath = path5.join(getDoccovDir(cwd), "cache", "spec.cache.json");
|
|
358
361
|
const dir = path5.dirname(cachePath);
|
|
359
362
|
if (!fs4.existsSync(dir)) {
|
|
360
363
|
fs4.mkdirSync(dir, { recursive: true });
|
|
@@ -389,7 +392,7 @@ function validateSpecCache(cache, context) {
|
|
|
389
392
|
return { valid: true };
|
|
390
393
|
}
|
|
391
394
|
function clearSpecCache(cwd) {
|
|
392
|
-
const cachePath = path5.
|
|
395
|
+
const cachePath = path5.join(getDoccovDir(cwd), "cache", "spec.cache.json");
|
|
393
396
|
if (fs4.existsSync(cachePath)) {
|
|
394
397
|
fs4.unlinkSync(cachePath);
|
|
395
398
|
return true;
|
|
@@ -397,7 +400,7 @@ function clearSpecCache(cwd) {
|
|
|
397
400
|
return false;
|
|
398
401
|
}
|
|
399
402
|
function getSpecCachePath(cwd) {
|
|
400
|
-
return path5.
|
|
403
|
+
return path5.join(getDoccovDir(cwd), "cache", "spec.cache.json");
|
|
401
404
|
}
|
|
402
405
|
// src/extractor.ts
|
|
403
406
|
import * as path6 from "node:path";
|
|
@@ -15419,7 +15422,7 @@ async function runExample(code, options = {}) {
|
|
|
15419
15422
|
try {
|
|
15420
15423
|
fs8.writeFileSync(tmpFile, cleanCode, "utf-8");
|
|
15421
15424
|
const startTime = Date.now();
|
|
15422
|
-
return await new Promise((
|
|
15425
|
+
return await new Promise((resolve4) => {
|
|
15423
15426
|
let stdout = "";
|
|
15424
15427
|
let stderr = "";
|
|
15425
15428
|
let killed = false;
|
|
@@ -15442,7 +15445,7 @@ async function runExample(code, options = {}) {
|
|
|
15442
15445
|
clearTimeout(timeoutId);
|
|
15443
15446
|
const duration3 = Date.now() - startTime;
|
|
15444
15447
|
if (killed) {
|
|
15445
|
-
|
|
15448
|
+
resolve4({
|
|
15446
15449
|
success: false,
|
|
15447
15450
|
stdout,
|
|
15448
15451
|
stderr: stderr || `Example timed out after ${timeout}ms`,
|
|
@@ -15450,7 +15453,7 @@ async function runExample(code, options = {}) {
|
|
|
15450
15453
|
duration: duration3
|
|
15451
15454
|
});
|
|
15452
15455
|
} else {
|
|
15453
|
-
|
|
15456
|
+
resolve4({
|
|
15454
15457
|
success: exitCode === 0,
|
|
15455
15458
|
stdout,
|
|
15456
15459
|
stderr,
|
|
@@ -15461,7 +15464,7 @@ async function runExample(code, options = {}) {
|
|
|
15461
15464
|
});
|
|
15462
15465
|
proc.on("error", (error48) => {
|
|
15463
15466
|
clearTimeout(timeoutId);
|
|
15464
|
-
|
|
15467
|
+
resolve4({
|
|
15465
15468
|
success: false,
|
|
15466
15469
|
stdout,
|
|
15467
15470
|
stderr: error48.message,
|
|
@@ -15512,7 +15515,7 @@ function getInstallCommand2(pm, packagePath) {
|
|
|
15512
15515
|
}
|
|
15513
15516
|
}
|
|
15514
15517
|
async function runCommand(cmd, args, options) {
|
|
15515
|
-
return new Promise((
|
|
15518
|
+
return new Promise((resolve4) => {
|
|
15516
15519
|
let stdout = "";
|
|
15517
15520
|
let stderr = "";
|
|
15518
15521
|
let killed = false;
|
|
@@ -15533,14 +15536,14 @@ async function runCommand(cmd, args, options) {
|
|
|
15533
15536
|
proc.on("close", (exitCode) => {
|
|
15534
15537
|
clearTimeout(timeoutId);
|
|
15535
15538
|
if (killed) {
|
|
15536
|
-
|
|
15539
|
+
resolve4({
|
|
15537
15540
|
success: false,
|
|
15538
15541
|
stdout,
|
|
15539
15542
|
stderr: stderr || `Command timed out after ${options.timeout}ms`,
|
|
15540
15543
|
exitCode: exitCode ?? 1
|
|
15541
15544
|
});
|
|
15542
15545
|
} else {
|
|
15543
|
-
|
|
15546
|
+
resolve4({
|
|
15544
15547
|
success: exitCode === 0,
|
|
15545
15548
|
stdout,
|
|
15546
15549
|
stderr,
|
|
@@ -15550,7 +15553,7 @@ async function runCommand(cmd, args, options) {
|
|
|
15550
15553
|
});
|
|
15551
15554
|
proc.on("error", (error48) => {
|
|
15552
15555
|
clearTimeout(timeoutId);
|
|
15553
|
-
|
|
15556
|
+
resolve4({
|
|
15554
15557
|
success: false,
|
|
15555
15558
|
stdout,
|
|
15556
15559
|
stderr: error48.message,
|
|
@@ -17109,6 +17112,7 @@ export {
|
|
|
17109
17112
|
getDriftSummary,
|
|
17110
17113
|
getDocumentedExports,
|
|
17111
17114
|
getDocsImpactSummary,
|
|
17115
|
+
getDoccovDir,
|
|
17112
17116
|
getDiffReportPath,
|
|
17113
17117
|
generateReportFromDocCov,
|
|
17114
17118
|
generateReport,
|
|
@@ -17119,6 +17123,7 @@ export {
|
|
|
17119
17123
|
formatDriftSummaryLine,
|
|
17120
17124
|
formatDelta,
|
|
17121
17125
|
findRemovedReferences,
|
|
17126
|
+
findProjectRoot,
|
|
17122
17127
|
findPackageByName,
|
|
17123
17128
|
findJSDocLocation,
|
|
17124
17129
|
findExportReferences,
|
|
@@ -2863,10 +2863,52 @@ async function detectRuntimeSchemas(context) {
|
|
|
2863
2863
|
};
|
|
2864
2864
|
}
|
|
2865
2865
|
|
|
2866
|
-
// src/
|
|
2866
|
+
// src/utils/project-root.ts
|
|
2867
2867
|
import * as fs4 from "node:fs";
|
|
2868
2868
|
import * as path4 from "node:path";
|
|
2869
|
+
var PROJECT_ROOT_MARKERS = [
|
|
2870
|
+
".git",
|
|
2871
|
+
"pnpm-workspace.yaml",
|
|
2872
|
+
"pnpm-workspace.yml",
|
|
2873
|
+
"lerna.json",
|
|
2874
|
+
"nx.json",
|
|
2875
|
+
"rush.json"
|
|
2876
|
+
];
|
|
2877
|
+
function findProjectRoot(startDir) {
|
|
2878
|
+
let dir = path4.resolve(startDir);
|
|
2879
|
+
const root = path4.parse(dir).root;
|
|
2880
|
+
while (dir !== root) {
|
|
2881
|
+
for (const marker of PROJECT_ROOT_MARKERS) {
|
|
2882
|
+
const markerPath = path4.join(dir, marker);
|
|
2883
|
+
if (fs4.existsSync(markerPath)) {
|
|
2884
|
+
return dir;
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
const pkgPath = path4.join(dir, "package.json");
|
|
2888
|
+
if (fs4.existsSync(pkgPath)) {
|
|
2889
|
+
try {
|
|
2890
|
+
const pkg = JSON.parse(fs4.readFileSync(pkgPath, "utf-8"));
|
|
2891
|
+
if (pkg.workspaces) {
|
|
2892
|
+
return dir;
|
|
2893
|
+
}
|
|
2894
|
+
} catch {}
|
|
2895
|
+
}
|
|
2896
|
+
dir = path4.dirname(dir);
|
|
2897
|
+
}
|
|
2898
|
+
return path4.resolve(startDir);
|
|
2899
|
+
}
|
|
2900
|
+
function getDoccovDir(cwd) {
|
|
2901
|
+
const projectRoot = findProjectRoot(cwd);
|
|
2902
|
+
return path4.join(projectRoot, ".doccov");
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2905
|
+
// src/analysis/history.ts
|
|
2906
|
+
import * as fs5 from "node:fs";
|
|
2907
|
+
import * as path5 from "node:path";
|
|
2869
2908
|
var HISTORY_DIR = ".doccov/history";
|
|
2909
|
+
function getHistoryDir(cwd) {
|
|
2910
|
+
return path5.join(getDoccovDir(cwd), "history");
|
|
2911
|
+
}
|
|
2870
2912
|
var RETENTION_DAYS = 90;
|
|
2871
2913
|
function getSnapshotFilename(timestamp) {
|
|
2872
2914
|
const pad = (n) => n.toString().padStart(2, "0");
|
|
@@ -2899,24 +2941,24 @@ function computeSnapshot(spec, options) {
|
|
|
2899
2941
|
};
|
|
2900
2942
|
}
|
|
2901
2943
|
function saveSnapshot(snapshot, cwd) {
|
|
2902
|
-
const historyDir =
|
|
2903
|
-
if (!
|
|
2904
|
-
|
|
2944
|
+
const historyDir = getHistoryDir(cwd);
|
|
2945
|
+
if (!fs5.existsSync(historyDir)) {
|
|
2946
|
+
fs5.mkdirSync(historyDir, { recursive: true });
|
|
2905
2947
|
}
|
|
2906
2948
|
const filename = getSnapshotFilename(new Date(snapshot.timestamp));
|
|
2907
|
-
const filepath =
|
|
2908
|
-
|
|
2949
|
+
const filepath = path5.join(historyDir, filename);
|
|
2950
|
+
fs5.writeFileSync(filepath, JSON.stringify(snapshot, null, 2));
|
|
2909
2951
|
}
|
|
2910
2952
|
function loadSnapshots(cwd) {
|
|
2911
|
-
const historyDir =
|
|
2912
|
-
if (!
|
|
2953
|
+
const historyDir = getHistoryDir(cwd);
|
|
2954
|
+
if (!fs5.existsSync(historyDir)) {
|
|
2913
2955
|
return [];
|
|
2914
2956
|
}
|
|
2915
|
-
const files =
|
|
2957
|
+
const files = fs5.readdirSync(historyDir).filter((f) => f.endsWith(".json")).sort().reverse();
|
|
2916
2958
|
const snapshots = [];
|
|
2917
2959
|
for (const file of files) {
|
|
2918
2960
|
try {
|
|
2919
|
-
const content =
|
|
2961
|
+
const content = fs5.readFileSync(path5.join(historyDir, file), "utf-8");
|
|
2920
2962
|
snapshots.push(JSON.parse(content));
|
|
2921
2963
|
} catch {}
|
|
2922
2964
|
}
|
|
@@ -2956,15 +2998,15 @@ function formatDelta(delta) {
|
|
|
2956
2998
|
return "→0%";
|
|
2957
2999
|
}
|
|
2958
3000
|
function pruneHistory(cwd, keepCount = 100) {
|
|
2959
|
-
const historyDir =
|
|
2960
|
-
if (!
|
|
3001
|
+
const historyDir = getHistoryDir(cwd);
|
|
3002
|
+
if (!fs5.existsSync(historyDir)) {
|
|
2961
3003
|
return 0;
|
|
2962
3004
|
}
|
|
2963
|
-
const files =
|
|
3005
|
+
const files = fs5.readdirSync(historyDir).filter((f) => f.endsWith(".json")).sort().reverse();
|
|
2964
3006
|
const toDelete = files.slice(keepCount);
|
|
2965
3007
|
for (const file of toDelete) {
|
|
2966
3008
|
try {
|
|
2967
|
-
|
|
3009
|
+
fs5.unlinkSync(path5.join(historyDir, file));
|
|
2968
3010
|
} catch {}
|
|
2969
3011
|
}
|
|
2970
3012
|
return toDelete.length;
|
|
@@ -3060,4 +3102,4 @@ function getExtendedTrend(spec, cwd, options) {
|
|
|
3060
3102
|
};
|
|
3061
3103
|
}
|
|
3062
3104
|
|
|
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 };
|
|
3105
|
+
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 };
|