diff-cover-js 0.1.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.
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.printReport = printReport;
4
+ const LINE = '─'.repeat(64);
5
+ function printReport(result) {
6
+ console.log(`\n${LINE}`);
7
+ console.log(' diff-cover-js · Diff Coverage Report');
8
+ console.log(`${LINE}\n`);
9
+ if (result.files.length === 0 && result.missingFromLcov.length === 0) {
10
+ console.log(' No changed source files found in the diff.\n');
11
+ }
12
+ // Track which missing files are already shown in the files list (strict mode)
13
+ // to avoid printing them twice in the "missing" section below.
14
+ const shownAsStrict = new Set(result.files.filter(f => !f.inLcov).map(f => f.filePath));
15
+ for (const file of result.files) {
16
+ const pct = `${file.coveragePercent}%`.padStart(4);
17
+ if (!file.inLcov) {
18
+ console.log(` ✗ ${file.filePath}`);
19
+ console.log(` 0% diff coverage (not in coverage data, all ${file.addedLines} changed lines treated as uncovered)`);
20
+ if (file.uncoveredLineNumbers.length > 0) {
21
+ console.log(` Missing lines: ${file.uncoveredLineNumbers.join(', ')}`);
22
+ }
23
+ }
24
+ else {
25
+ const icon = file.coveragePercent === 100 ? '✓' : '✗';
26
+ console.log(` ${icon} ${file.filePath}`);
27
+ console.log(` ${pct} diff coverage` +
28
+ ` (${file.coveredLines}/${file.coverableAddedLines} coverable changed lines)`);
29
+ if (file.uncoveredLineNumbers.length > 0) {
30
+ console.log(` Missing lines: ${file.uncoveredLineNumbers.join(', ')}`);
31
+ }
32
+ }
33
+ console.log();
34
+ }
35
+ // Only list files that are genuinely missing (not already shown above via --strict)
36
+ const missingToShow = result.missingFromLcov.filter(f => !shownAsStrict.has(f));
37
+ if (missingToShow.length > 0) {
38
+ console.log(' ℹ Changed files not collected for coverage (pass --strict to fail on these):');
39
+ for (const f of missingToShow) {
40
+ console.log(` ${f}`);
41
+ }
42
+ console.log();
43
+ }
44
+ console.log(LINE);
45
+ const pct = `${result.overallPercent}%`;
46
+ console.log(` Overall diff coverage: ${pct}`);
47
+ console.log(` ${result.totalCovered}/${result.totalCoverable} coverable changed lines covered`);
48
+ console.log(`${LINE}\n`);
49
+ }
50
+ //# sourceMappingURL=reporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporter.js","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":";;AAIA,kCAqDC;AAvDD,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE5B,SAAgB,WAAW,CAAE,MAA0B;IACrD,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IACzB,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;IAEzB,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrE,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;IAChE,CAAC;IAED,8EAA8E;IAC9E,+DAA+D;IAC/D,MAAM,aAAa,GAAG,IAAI,GAAG,CAC3B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CACzD,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,eAAe,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEnD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,QAAQ,EA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,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,cAAc,GAAG,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,cAAc,kCAAkC,CAAC,CAAC;IACjG,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;AAC3B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "diff-cover-js",
3
+ "version": "0.1.0",
4
+ "description": "Diff-aware test coverage checker — JS/TS equivalent of Python diff-cover. Reports coverage only for lines you changed, not the whole file.",
5
+ "license": "MIT",
6
+ "author": {
7
+ "name": "Samriddhi",
8
+ "url": "https://github.com/samriddhi512"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/samriddhi512/diff-cover-js.git"
13
+ },
14
+ "homepage": "https://github.com/samriddhi512/diff-cover-js#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/samriddhi512/diff-cover-js/issues"
17
+ },
18
+ "keywords": [
19
+ "coverage",
20
+ "diff",
21
+ "diff-cover",
22
+ "jest",
23
+ "lcov",
24
+ "test-coverage",
25
+ "incremental-coverage",
26
+ "patch-coverage",
27
+ "ci"
28
+ ],
29
+ "bin": {
30
+ "diff-cover-js": "dist/cli.js"
31
+ },
32
+ "main": "./dist/index.js",
33
+ "types": "./dist/index.d.ts",
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "scripts": {
38
+ "build": "tsc",
39
+ "dev": "ts-node src/cli.ts",
40
+ "prepublishOnly": "npm run build"
41
+ },
42
+ "dependencies": {
43
+ "commander": "^12.0.0",
44
+ "parse-diff": "^0.12.0"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^20.0.0",
48
+ "ts-node": "^10.9.0",
49
+ "typescript": "^5.0.0"
50
+ },
51
+ "engines": {
52
+ "node": ">=16.0.0"
53
+ }
54
+ }