@doccov/sdk 0.30.6 → 0.31.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 +292 -15
- package/dist/analysis/index.js +14 -2
- package/dist/index.d.ts +630 -144
- package/dist/index.js +137 -21
- package/dist/shared/{chunk-fdjehkbt.js → chunk-ee3ctqje.js} +549 -136
- package/dist/types/index.d.ts +45 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEFAULT_REQUIREMENTS,
|
|
2
3
|
DRIFT_CATEGORIES,
|
|
3
4
|
DRIFT_CATEGORY_DESCRIPTIONS,
|
|
4
5
|
DRIFT_CATEGORY_LABELS,
|
|
5
6
|
HISTORY_DIR,
|
|
7
|
+
IncrementalAnalyzer,
|
|
8
|
+
PRESETS,
|
|
6
9
|
applyEdits,
|
|
7
10
|
applyForgottenExportFixes,
|
|
8
11
|
applyPatchToJSDoc,
|
|
9
12
|
buildDocCovSpec,
|
|
10
13
|
buildExportRegistry,
|
|
14
|
+
buildModuleGraph,
|
|
11
15
|
calculateAggregateCoverage,
|
|
12
16
|
categorizeDrift,
|
|
13
17
|
categorizeDrifts,
|
|
18
|
+
cleanupOrphanedTempFiles,
|
|
14
19
|
computeDrift,
|
|
15
20
|
computeExportDrift,
|
|
16
21
|
computeHealth,
|
|
@@ -26,7 +31,9 @@ import {
|
|
|
26
31
|
extractStandardSchemasFromProject,
|
|
27
32
|
findAdapter,
|
|
28
33
|
findJSDocLocation,
|
|
34
|
+
findOrphanedTempFiles,
|
|
29
35
|
findProjectRoot,
|
|
36
|
+
findSymbolModule,
|
|
30
37
|
formatDelta,
|
|
31
38
|
formatDriftSummaryLine,
|
|
32
39
|
generateFix,
|
|
@@ -48,6 +55,7 @@ import {
|
|
|
48
55
|
groupFixesByFile,
|
|
49
56
|
hasNonAssertionComments,
|
|
50
57
|
isBuiltInIdentifier,
|
|
58
|
+
isExportDocumented,
|
|
51
59
|
isExportFullyDocumented,
|
|
52
60
|
isFixableDrift,
|
|
53
61
|
isSchemaType,
|
|
@@ -62,11 +70,13 @@ import {
|
|
|
62
70
|
renderApiSurface,
|
|
63
71
|
renderSparkline,
|
|
64
72
|
resolveCompiledPath,
|
|
73
|
+
resolveRequirements,
|
|
65
74
|
saveReport,
|
|
66
75
|
saveSnapshot,
|
|
67
76
|
serializeJSDoc,
|
|
77
|
+
symbolExistsInGraph,
|
|
68
78
|
ts
|
|
69
|
-
} from "./shared/chunk-
|
|
79
|
+
} from "./shared/chunk-ee3ctqje.js";
|
|
70
80
|
import {
|
|
71
81
|
mergeFilters,
|
|
72
82
|
parseListFlag
|
|
@@ -82,6 +92,55 @@ import {
|
|
|
82
92
|
getDiffReportPath,
|
|
83
93
|
getReportPath
|
|
84
94
|
} from "./shared/chunk-r4wa72ae.js";
|
|
95
|
+
// src/analysis/batch.ts
|
|
96
|
+
function createPackageResult(openpkg, doccov, entryPath) {
|
|
97
|
+
const totalExports = doccov.summary.totalExports;
|
|
98
|
+
const documented = doccov.summary.health?.completeness.documented ?? 0;
|
|
99
|
+
const health = doccov.summary.health?.score ?? doccov.summary.score;
|
|
100
|
+
const driftCount = doccov.summary.drift.total;
|
|
101
|
+
const coverageScore = doccov.summary.score;
|
|
102
|
+
return {
|
|
103
|
+
name: openpkg.meta.name,
|
|
104
|
+
version: openpkg.meta.version,
|
|
105
|
+
entryPath,
|
|
106
|
+
totalExports,
|
|
107
|
+
documented,
|
|
108
|
+
health,
|
|
109
|
+
driftCount,
|
|
110
|
+
coverageScore,
|
|
111
|
+
openpkg,
|
|
112
|
+
doccov
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function aggregateResults(packages) {
|
|
116
|
+
if (packages.length === 0) {
|
|
117
|
+
return {
|
|
118
|
+
packages: [],
|
|
119
|
+
aggregate: {
|
|
120
|
+
totalExports: 0,
|
|
121
|
+
documented: 0,
|
|
122
|
+
health: 0,
|
|
123
|
+
driftCount: 0,
|
|
124
|
+
coverageScore: 0
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const totalExports = packages.reduce((sum, p) => sum + p.totalExports, 0);
|
|
129
|
+
const documented = packages.reduce((sum, p) => sum + p.documented, 0);
|
|
130
|
+
const driftCount = packages.reduce((sum, p) => sum + p.driftCount, 0);
|
|
131
|
+
const weightedHealth = totalExports > 0 ? Math.round(packages.reduce((sum, p) => sum + p.health * p.totalExports, 0) / totalExports) : 0;
|
|
132
|
+
const weightedCoverage = totalExports > 0 ? Math.round(packages.reduce((sum, p) => sum + p.coverageScore * p.totalExports, 0) / totalExports) : 0;
|
|
133
|
+
return {
|
|
134
|
+
packages,
|
|
135
|
+
aggregate: {
|
|
136
|
+
totalExports,
|
|
137
|
+
documented,
|
|
138
|
+
health: weightedHealth,
|
|
139
|
+
driftCount,
|
|
140
|
+
coverageScore: weightedCoverage
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
85
144
|
// src/analyzer.ts
|
|
86
145
|
import * as fsSync from "node:fs";
|
|
87
146
|
import * as fs5 from "node:fs/promises";
|
|
@@ -109,7 +168,7 @@ function findRepoRoot(startDir) {
|
|
|
109
168
|
}
|
|
110
169
|
return startDir;
|
|
111
170
|
}
|
|
112
|
-
var DEFAULT_MAX_TYPE_DEPTH =
|
|
171
|
+
var DEFAULT_MAX_TYPE_DEPTH = 4;
|
|
113
172
|
var DEFAULT_OPTIONS = {
|
|
114
173
|
includePrivate: false,
|
|
115
174
|
followImports: true,
|
|
@@ -226,13 +285,7 @@ async function runAnalysis(input) {
|
|
|
226
285
|
const packageJsonPath = findNearestPackageJson(baseDir);
|
|
227
286
|
const hasNodeModules = canResolveExternalModules(program, baseDir);
|
|
228
287
|
const resolveExternalTypes = options.resolveExternalTypes !== undefined ? options.resolveExternalTypes : hasNodeModules;
|
|
229
|
-
const diagnostics =
|
|
230
|
-
if (d.code === 5053)
|
|
231
|
-
return false;
|
|
232
|
-
const msg = ts.flattenDiagnosticMessageText(d.messageText, `
|
|
233
|
-
`);
|
|
234
|
-
return !/allowJs/i.test(msg);
|
|
235
|
-
});
|
|
288
|
+
const diagnostics = [];
|
|
236
289
|
const specDiagnostics = [];
|
|
237
290
|
if (!hasNodeModules && hasExternalImports(context.sourceFile)) {
|
|
238
291
|
specDiagnostics.push({
|
|
@@ -14479,12 +14532,26 @@ var apiSurfaceConfigSchema = exports_external.object({
|
|
|
14479
14532
|
warnBelow: exports_external.number().min(0).max(100).optional(),
|
|
14480
14533
|
ignore: exports_external.array(exports_external.string()).optional()
|
|
14481
14534
|
});
|
|
14535
|
+
var stylePresetSchema = exports_external.enum([
|
|
14536
|
+
"minimal",
|
|
14537
|
+
"verbose",
|
|
14538
|
+
"types-only"
|
|
14539
|
+
]);
|
|
14540
|
+
var docRequirementsSchema = exports_external.object({
|
|
14541
|
+
description: exports_external.boolean().optional(),
|
|
14542
|
+
params: exports_external.boolean().optional(),
|
|
14543
|
+
returns: exports_external.boolean().optional(),
|
|
14544
|
+
examples: exports_external.boolean().optional(),
|
|
14545
|
+
since: exports_external.boolean().optional()
|
|
14546
|
+
});
|
|
14482
14547
|
var checkConfigSchema = exports_external.object({
|
|
14483
14548
|
examples: exampleModesSchema.optional(),
|
|
14484
14549
|
minHealth: exports_external.number().min(0).max(100).optional(),
|
|
14485
14550
|
minCoverage: exports_external.number().min(0).max(100).optional(),
|
|
14486
14551
|
maxDrift: exports_external.number().min(0).max(100).optional(),
|
|
14487
|
-
apiSurface: apiSurfaceConfigSchema.optional()
|
|
14552
|
+
apiSurface: apiSurfaceConfigSchema.optional(),
|
|
14553
|
+
style: stylePresetSchema.optional(),
|
|
14554
|
+
require: docRequirementsSchema.optional()
|
|
14488
14555
|
});
|
|
14489
14556
|
var docCovConfigSchema = exports_external.object({
|
|
14490
14557
|
include: stringList.optional(),
|
|
@@ -14517,12 +14584,24 @@ var normalizeConfig = (input) => {
|
|
|
14517
14584
|
}
|
|
14518
14585
|
let check2;
|
|
14519
14586
|
if (input.check) {
|
|
14587
|
+
let require2;
|
|
14588
|
+
if (input.check.require) {
|
|
14589
|
+
require2 = {
|
|
14590
|
+
description: input.check.require.description,
|
|
14591
|
+
params: input.check.require.params,
|
|
14592
|
+
returns: input.check.require.returns,
|
|
14593
|
+
examples: input.check.require.examples,
|
|
14594
|
+
since: input.check.require.since
|
|
14595
|
+
};
|
|
14596
|
+
}
|
|
14520
14597
|
check2 = {
|
|
14521
14598
|
examples: input.check.examples,
|
|
14522
14599
|
minHealth: input.check.minHealth,
|
|
14523
14600
|
minCoverage: input.check.minCoverage,
|
|
14524
14601
|
maxDrift: input.check.maxDrift,
|
|
14525
|
-
apiSurface: input.check.apiSurface
|
|
14602
|
+
apiSurface: input.check.apiSurface,
|
|
14603
|
+
style: input.check.style,
|
|
14604
|
+
require: require2
|
|
14526
14605
|
};
|
|
14527
14606
|
}
|
|
14528
14607
|
return {
|
|
@@ -14658,6 +14737,7 @@ function getPrimaryBuildScript(buildInfo) {
|
|
|
14658
14737
|
return buildInfo.scripts[0] ?? null;
|
|
14659
14738
|
}
|
|
14660
14739
|
// src/detect/entry-point.ts
|
|
14740
|
+
import * as nodePath from "node:path";
|
|
14661
14741
|
async function detectEntryPoint(fs6, packagePath = ".") {
|
|
14662
14742
|
const pkgJson = await readPackageJson(fs6, packagePath);
|
|
14663
14743
|
if (!pkgJson) {
|
|
@@ -14781,9 +14861,31 @@ async function resolveToSource(fs6, basePath, filePath, tsConfig) {
|
|
|
14781
14861
|
}
|
|
14782
14862
|
return null;
|
|
14783
14863
|
}
|
|
14864
|
+
async function findEntryPointForFile(fs6, filePath) {
|
|
14865
|
+
let currentDir = nodePath.dirname(filePath);
|
|
14866
|
+
while (currentDir !== nodePath.dirname(currentDir)) {
|
|
14867
|
+
const hasPackageJson = await fs6.exists(nodePath.join(currentDir, "package.json"));
|
|
14868
|
+
if (hasPackageJson) {
|
|
14869
|
+
try {
|
|
14870
|
+
const entryPoint = await detectEntryPoint(fs6, currentDir);
|
|
14871
|
+
return { entryPoint, packagePath: currentDir };
|
|
14872
|
+
} catch {}
|
|
14873
|
+
}
|
|
14874
|
+
currentDir = nodePath.dirname(currentDir);
|
|
14875
|
+
}
|
|
14876
|
+
return null;
|
|
14877
|
+
}
|
|
14878
|
+
async function isPackageEntryPoint(fs6, filePath) {
|
|
14879
|
+
const result = await findEntryPointForFile(fs6, filePath);
|
|
14880
|
+
if (!result)
|
|
14881
|
+
return false;
|
|
14882
|
+
const entryAbsolute = nodePath.resolve(result.packagePath, result.entryPoint.path);
|
|
14883
|
+
const fileAbsolute = nodePath.resolve(filePath);
|
|
14884
|
+
return entryAbsolute === fileAbsolute;
|
|
14885
|
+
}
|
|
14784
14886
|
// src/detect/filesystem.ts
|
|
14785
14887
|
import * as fs6 from "node:fs";
|
|
14786
|
-
import * as
|
|
14888
|
+
import * as nodePath2 from "node:path";
|
|
14787
14889
|
import { Writable } from "node:stream";
|
|
14788
14890
|
|
|
14789
14891
|
class NodeFileSystem {
|
|
@@ -14792,7 +14894,7 @@ class NodeFileSystem {
|
|
|
14792
14894
|
this.basePath = basePath;
|
|
14793
14895
|
}
|
|
14794
14896
|
resolve(relativePath) {
|
|
14795
|
-
return
|
|
14897
|
+
return nodePath2.join(this.basePath, relativePath);
|
|
14796
14898
|
}
|
|
14797
14899
|
async exists(relativePath) {
|
|
14798
14900
|
return fs6.existsSync(this.resolve(relativePath));
|
|
@@ -15422,7 +15524,7 @@ async function runExample(code, options = {}) {
|
|
|
15422
15524
|
try {
|
|
15423
15525
|
fs8.writeFileSync(tmpFile, cleanCode, "utf-8");
|
|
15424
15526
|
const startTime = Date.now();
|
|
15425
|
-
return await new Promise((
|
|
15527
|
+
return await new Promise((resolve5) => {
|
|
15426
15528
|
let stdout = "";
|
|
15427
15529
|
let stderr = "";
|
|
15428
15530
|
let killed = false;
|
|
@@ -15445,7 +15547,7 @@ async function runExample(code, options = {}) {
|
|
|
15445
15547
|
clearTimeout(timeoutId);
|
|
15446
15548
|
const duration3 = Date.now() - startTime;
|
|
15447
15549
|
if (killed) {
|
|
15448
|
-
|
|
15550
|
+
resolve5({
|
|
15449
15551
|
success: false,
|
|
15450
15552
|
stdout,
|
|
15451
15553
|
stderr: stderr || `Example timed out after ${timeout}ms`,
|
|
@@ -15453,7 +15555,7 @@ async function runExample(code, options = {}) {
|
|
|
15453
15555
|
duration: duration3
|
|
15454
15556
|
});
|
|
15455
15557
|
} else {
|
|
15456
|
-
|
|
15558
|
+
resolve5({
|
|
15457
15559
|
success: exitCode === 0,
|
|
15458
15560
|
stdout,
|
|
15459
15561
|
stderr,
|
|
@@ -15464,7 +15566,7 @@ async function runExample(code, options = {}) {
|
|
|
15464
15566
|
});
|
|
15465
15567
|
proc.on("error", (error48) => {
|
|
15466
15568
|
clearTimeout(timeoutId);
|
|
15467
|
-
|
|
15569
|
+
resolve5({
|
|
15468
15570
|
success: false,
|
|
15469
15571
|
stdout,
|
|
15470
15572
|
stderr: error48.message,
|
|
@@ -15515,7 +15617,7 @@ function getInstallCommand2(pm, packagePath) {
|
|
|
15515
15617
|
}
|
|
15516
15618
|
}
|
|
15517
15619
|
async function runCommand(cmd, args, options) {
|
|
15518
|
-
return new Promise((
|
|
15620
|
+
return new Promise((resolve5) => {
|
|
15519
15621
|
let stdout = "";
|
|
15520
15622
|
let stderr = "";
|
|
15521
15623
|
let killed = false;
|
|
@@ -15536,14 +15638,14 @@ async function runCommand(cmd, args, options) {
|
|
|
15536
15638
|
proc.on("close", (exitCode) => {
|
|
15537
15639
|
clearTimeout(timeoutId);
|
|
15538
15640
|
if (killed) {
|
|
15539
|
-
|
|
15641
|
+
resolve5({
|
|
15540
15642
|
success: false,
|
|
15541
15643
|
stdout,
|
|
15542
15644
|
stderr: stderr || `Command timed out after ${options.timeout}ms`,
|
|
15543
15645
|
exitCode: exitCode ?? 1
|
|
15544
15646
|
});
|
|
15545
15647
|
} else {
|
|
15546
|
-
|
|
15648
|
+
resolve5({
|
|
15547
15649
|
success: exitCode === 0,
|
|
15548
15650
|
stdout,
|
|
15549
15651
|
stderr,
|
|
@@ -15553,7 +15655,7 @@ async function runCommand(cmd, args, options) {
|
|
|
15553
15655
|
});
|
|
15554
15656
|
proc.on("error", (error48) => {
|
|
15555
15657
|
clearTimeout(timeoutId);
|
|
15556
|
-
|
|
15658
|
+
resolve5({
|
|
15557
15659
|
success: false,
|
|
15558
15660
|
stdout,
|
|
15559
15661
|
stderr: error48.message,
|
|
@@ -17050,6 +17152,7 @@ export {
|
|
|
17050
17152
|
validateExamples,
|
|
17051
17153
|
typecheckExamples,
|
|
17052
17154
|
typecheckExample,
|
|
17155
|
+
symbolExistsInGraph,
|
|
17053
17156
|
shouldValidate,
|
|
17054
17157
|
serializeJSDoc,
|
|
17055
17158
|
saveSpecCache,
|
|
@@ -17060,6 +17163,7 @@ export {
|
|
|
17060
17163
|
runExamples,
|
|
17061
17164
|
runExample,
|
|
17062
17165
|
resolveTarget,
|
|
17166
|
+
resolveRequirements,
|
|
17063
17167
|
resolveCompiledPath,
|
|
17064
17168
|
renderSparkline,
|
|
17065
17169
|
renderApiSurface,
|
|
@@ -17083,8 +17187,10 @@ export {
|
|
|
17083
17187
|
listWorkspacePackages,
|
|
17084
17188
|
isStandardJSONSchema,
|
|
17085
17189
|
isSchemaType,
|
|
17190
|
+
isPackageEntryPoint,
|
|
17086
17191
|
isFixableDrift,
|
|
17087
17192
|
isExportFullyDocumented,
|
|
17193
|
+
isExportDocumented,
|
|
17088
17194
|
isExecutableLang,
|
|
17089
17195
|
installDependencies,
|
|
17090
17196
|
hashString,
|
|
@@ -17122,11 +17228,14 @@ export {
|
|
|
17122
17228
|
formatPackageList,
|
|
17123
17229
|
formatDriftSummaryLine,
|
|
17124
17230
|
formatDelta,
|
|
17231
|
+
findSymbolModule,
|
|
17125
17232
|
findRemovedReferences,
|
|
17126
17233
|
findProjectRoot,
|
|
17127
17234
|
findPackageByName,
|
|
17235
|
+
findOrphanedTempFiles,
|
|
17128
17236
|
findJSDocLocation,
|
|
17129
17237
|
findExportReferences,
|
|
17238
|
+
findEntryPointForFile,
|
|
17130
17239
|
findDeprecatedReferences,
|
|
17131
17240
|
findAdapter,
|
|
17132
17241
|
fetchSpecFromGitHub,
|
|
@@ -17153,16 +17262,19 @@ export {
|
|
|
17153
17262
|
detectBuildInfo,
|
|
17154
17263
|
defineConfig,
|
|
17155
17264
|
createSourceFile,
|
|
17265
|
+
createPackageResult,
|
|
17156
17266
|
createNodeCommandRunner,
|
|
17157
17267
|
computeSnapshot,
|
|
17158
17268
|
computeHealth,
|
|
17159
17269
|
computeExportDrift,
|
|
17160
17270
|
computeDrift,
|
|
17161
17271
|
clearSpecCache,
|
|
17272
|
+
cleanupOrphanedTempFiles,
|
|
17162
17273
|
categorizeDrifts,
|
|
17163
17274
|
categorizeDrift,
|
|
17164
17275
|
calculateAggregateCoverage,
|
|
17165
17276
|
buildRawUrl,
|
|
17277
|
+
buildModuleGraph,
|
|
17166
17278
|
buildExportRegistry,
|
|
17167
17279
|
buildDocCovSpec,
|
|
17168
17280
|
buildDisplayUrl,
|
|
@@ -17175,17 +17287,21 @@ export {
|
|
|
17175
17287
|
analyzeFile,
|
|
17176
17288
|
analyzeDocsImpact,
|
|
17177
17289
|
analyze,
|
|
17290
|
+
aggregateResults,
|
|
17178
17291
|
VALIDATION_INFO,
|
|
17179
17292
|
SandboxFileSystem,
|
|
17180
17293
|
SPEC_CACHE_FILE,
|
|
17181
17294
|
REPORT_VERSION,
|
|
17182
17295
|
REPORT_EXTENSIONS,
|
|
17296
|
+
PRESETS,
|
|
17183
17297
|
NodeFileSystem,
|
|
17298
|
+
IncrementalAnalyzer,
|
|
17184
17299
|
HISTORY_DIR,
|
|
17185
17300
|
DocCov,
|
|
17186
17301
|
DRIFT_CATEGORY_LABELS,
|
|
17187
17302
|
DRIFT_CATEGORY_DESCRIPTIONS,
|
|
17188
17303
|
DRIFT_CATEGORIES,
|
|
17304
|
+
DEFAULT_REQUIREMENTS,
|
|
17189
17305
|
DEFAULT_REPORT_PATH,
|
|
17190
17306
|
DEFAULT_REPORT_DIR,
|
|
17191
17307
|
CACHE_VERSION,
|