test-progress-tracker 2.0.7 → 2.0.8
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/README.md +0 -4
- package/cjs/_virtual/_rolldown/runtime.js +23 -0
- package/cjs/append.d.ts +6 -2
- package/cjs/append.js +30 -38
- package/cjs/append.js.map +1 -1
- package/cjs/compress.js +6 -6
- package/cjs/compress.js.map +1 -1
- package/cjs/constants.js +7 -5
- package/cjs/constants.js.map +1 -1
- package/cjs/index.d.ts +6 -5
- package/cjs/index.js +9 -22
- package/cjs/init.d.ts +6 -2
- package/cjs/init.js +16 -16
- package/cjs/init.js.map +1 -1
- package/cjs/interface.d.ts +32 -29
- package/cjs/load.d.ts +6 -2
- package/cjs/load.js +37 -49
- package/cjs/load.js.map +1 -1
- package/cjs/minify.js +87 -71
- package/cjs/minify.js.map +1 -1
- package/cjs/monitor.d.ts +26 -24
- package/cjs/monitor.js +42 -42
- package/cjs/monitor.js.map +1 -1
- package/cjs/store.js +12 -9
- package/cjs/store.js.map +1 -1
- package/package.json +34 -44
- package/ts/append.ts +19 -19
- package/ts/compress.ts +3 -3
- package/ts/init.ts +6 -6
- package/ts/interface.ts +24 -24
- package/ts/load.ts +28 -29
- package/ts/minify.ts +84 -73
- package/ts/monitor.ts +58 -46
- package/ts/store.ts +7 -7
- package/ts/testResultsExamples.ts +90 -90
- package/cjs/compress.d.ts +0 -3
- package/cjs/constants.d.ts +0 -2
- package/cjs/index.js.map +0 -1
- package/cjs/interface.js +0 -3
- package/cjs/interface.js.map +0 -1
- package/cjs/minify.d.ts +0 -41
- package/cjs/store.d.ts +0 -3
package/cjs/minify.js
CHANGED
|
@@ -1,80 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unminify = exports.minify = void 0;
|
|
1
|
+
//#region ts/minify.ts
|
|
4
2
|
function minify(testResults) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (coverage) {
|
|
20
|
-
result.c = minifyCoverage(coverage);
|
|
21
|
-
}
|
|
22
|
-
return result;
|
|
3
|
+
const { duration, filtered, numFailedTests, numFailedTestSuites, numPassedTests, numPassedTestSuites, numTotalTests, numTotalTestSuites, startTime, coverage } = testResults;
|
|
4
|
+
const result = {
|
|
5
|
+
d: duration,
|
|
6
|
+
f: numFailedTests,
|
|
7
|
+
fs: numFailedTestSuites,
|
|
8
|
+
p: numPassedTests,
|
|
9
|
+
ps: numPassedTestSuites,
|
|
10
|
+
t: numTotalTests,
|
|
11
|
+
ts: numTotalTestSuites,
|
|
12
|
+
s: startTime
|
|
13
|
+
};
|
|
14
|
+
if (filtered) result.fl = filtered;
|
|
15
|
+
if (coverage) result.c = minifyCoverage(coverage);
|
|
16
|
+
return result;
|
|
23
17
|
}
|
|
24
|
-
exports.minify = minify;
|
|
25
18
|
function minifyCoverage(coverage) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
19
|
+
const { branches, functions, lines, statements } = coverage;
|
|
20
|
+
const result = {
|
|
21
|
+
b: {
|
|
22
|
+
c: branches.covered,
|
|
23
|
+
s: branches.skipped,
|
|
24
|
+
t: branches.total
|
|
25
|
+
},
|
|
26
|
+
f: {
|
|
27
|
+
c: functions.covered,
|
|
28
|
+
s: functions.skipped,
|
|
29
|
+
t: functions.total
|
|
30
|
+
},
|
|
31
|
+
l: {
|
|
32
|
+
c: lines.covered,
|
|
33
|
+
s: lines.skipped,
|
|
34
|
+
t: lines.total
|
|
35
|
+
},
|
|
36
|
+
s: {
|
|
37
|
+
c: statements.covered,
|
|
38
|
+
s: statements.skipped,
|
|
39
|
+
t: statements.total
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
if (branches.pct) result.b.p = branches.pct;
|
|
43
|
+
if (functions.pct) result.f.p = functions.pct;
|
|
44
|
+
if (lines.pct) result.l.p = lines.pct;
|
|
45
|
+
if (statements.pct) result.s.p = statements.pct;
|
|
46
|
+
return result;
|
|
42
47
|
}
|
|
43
48
|
function unminify(minified) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (minified.c) {
|
|
58
|
-
result.coverage = unminifyCoverage(minified.c);
|
|
59
|
-
}
|
|
60
|
-
return result;
|
|
49
|
+
const result = {
|
|
50
|
+
duration: minified.d,
|
|
51
|
+
numFailedTests: minified.f,
|
|
52
|
+
numFailedTestSuites: minified.fs,
|
|
53
|
+
numPassedTests: minified.p,
|
|
54
|
+
numPassedTestSuites: minified.ps,
|
|
55
|
+
numTotalTests: minified.t,
|
|
56
|
+
numTotalTestSuites: minified.ts,
|
|
57
|
+
startTime: minified.s
|
|
58
|
+
};
|
|
59
|
+
if (minified.fl) result.filtered = minified.fl;
|
|
60
|
+
if (minified.c) result.coverage = unminifyCoverage(minified.c);
|
|
61
|
+
return result;
|
|
61
62
|
}
|
|
62
|
-
exports.unminify = unminify;
|
|
63
63
|
function unminifyCoverage(c) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
64
|
+
const result = {
|
|
65
|
+
branches: {
|
|
66
|
+
covered: c.b.c,
|
|
67
|
+
skipped: c.b.s,
|
|
68
|
+
total: c.b.t
|
|
69
|
+
},
|
|
70
|
+
functions: {
|
|
71
|
+
covered: c.f.c,
|
|
72
|
+
skipped: c.f.s,
|
|
73
|
+
total: c.f.t
|
|
74
|
+
},
|
|
75
|
+
lines: {
|
|
76
|
+
covered: c.l.c,
|
|
77
|
+
skipped: c.l.s,
|
|
78
|
+
total: c.l.t
|
|
79
|
+
},
|
|
80
|
+
statements: {
|
|
81
|
+
covered: c.s.c,
|
|
82
|
+
skipped: c.s.s,
|
|
83
|
+
total: c.s.t
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
if (c.b.p !== void 0) result.branches.pct = c.b.p;
|
|
87
|
+
if (c.f.p !== void 0) result.functions.pct = c.f.p;
|
|
88
|
+
if (c.l.p !== void 0) result.lines.pct = c.l.p;
|
|
89
|
+
if (c.s.p !== void 0) result.statements.pct = c.s.p;
|
|
90
|
+
return result;
|
|
79
91
|
}
|
|
92
|
+
//#endregion
|
|
93
|
+
exports.minify = minify;
|
|
94
|
+
exports.unminify = unminify;
|
|
95
|
+
|
|
80
96
|
//# sourceMappingURL=minify.js.map
|
package/cjs/minify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minify.js","
|
|
1
|
+
{"version":3,"file":"minify.js","names":[],"sources":["../ts/minify.ts"],"sourcesContent":["import type { CoverageSummary, TestResults } from './interface'\n\nexport interface MinifiedTestResult {\n\td: number\n\tfl?: boolean\n\tf: number\n\tfs: number\n\tp: number\n\tps: number\n\tt: number\n\tts: number\n\ts: number\n\tc?: MinifiedCoverageSummary\n}\nexport interface MinifiedCoverageSummary {\n\tb: { c: number; s: number; t: number; p?: number }\n\tf: { c: number; s: number; t: number; p?: number }\n\tl: { c: number; s: number; t: number; p?: number }\n\ts: { c: number; s: number; t: number; p?: number }\n}\n\nexport function minify(testResults: TestResults) {\n\tconst {\n\t\tduration,\n\t\tfiltered,\n\t\tnumFailedTests,\n\t\tnumFailedTestSuites,\n\t\tnumPassedTests,\n\t\tnumPassedTestSuites,\n\t\tnumTotalTests,\n\t\tnumTotalTestSuites,\n\t\tstartTime,\n\t\tcoverage\n\t} = testResults\n\n\tconst result: MinifiedTestResult = {\n\t\td: duration,\n\t\tf: numFailedTests,\n\t\tfs: numFailedTestSuites,\n\t\tp: numPassedTests,\n\t\tps: numPassedTestSuites,\n\t\tt: numTotalTests,\n\t\tts: numTotalTestSuites,\n\t\ts: startTime\n\t}\n\tif (filtered) {\n\t\tresult.fl = filtered\n\t}\n\tif (coverage) {\n\t\tresult.c = minifyCoverage(coverage)\n\t}\n\treturn result\n}\n\nfunction minifyCoverage(coverage: CoverageSummary) {\n\tconst { branches, functions, lines, statements } = coverage\n\n\tconst result: MinifiedCoverageSummary = {\n\t\tb: { c: branches.covered, s: branches.skipped, t: branches.total },\n\t\tf: { c: functions.covered, s: functions.skipped, t: functions.total },\n\t\tl: { c: lines.covered, s: lines.skipped, t: lines.total },\n\t\ts: { c: statements.covered, s: statements.skipped, t: statements.total }\n\t}\n\n\tif (branches.pct) result.b.p = branches.pct\n\tif (functions.pct) result.f.p = functions.pct\n\tif (lines.pct) result.l.p = lines.pct\n\tif (statements.pct) result.s.p = statements.pct\n\treturn result\n}\n\nexport function unminify(minified: MinifiedTestResult) {\n\tconst result: TestResults = {\n\t\tduration: minified.d,\n\t\tnumFailedTests: minified.f,\n\t\tnumFailedTestSuites: minified.fs,\n\t\tnumPassedTests: minified.p,\n\t\tnumPassedTestSuites: minified.ps,\n\t\tnumTotalTests: minified.t,\n\t\tnumTotalTestSuites: minified.ts,\n\t\tstartTime: minified.s\n\t}\n\tif (minified.fl) {\n\t\tresult.filtered = minified.fl\n\t}\n\tif (minified.c) {\n\t\tresult.coverage = unminifyCoverage(minified.c)\n\t}\n\treturn result\n}\n\nfunction unminifyCoverage(c: MinifiedCoverageSummary) {\n\tconst result: CoverageSummary = {\n\t\tbranches: { covered: c.b.c, skipped: c.b.s, total: c.b.t },\n\t\tfunctions: { covered: c.f.c, skipped: c.f.s, total: c.f.t },\n\t\tlines: { covered: c.l.c, skipped: c.l.s, total: c.l.t },\n\t\tstatements: { covered: c.s.c, skipped: c.s.s, total: c.s.t }\n\t}\n\n\tif (c.b.p !== undefined) result.branches.pct = c.b.p\n\tif (c.f.p !== undefined) result.functions.pct = c.f.p\n\tif (c.l.p !== undefined) result.lines.pct = c.l.p\n\tif (c.s.p !== undefined) result.statements.pct = c.s.p\n\treturn result\n}\n"],"mappings":";AAqBA,SAAgB,OAAO,aAA0B;CAChD,MAAM,EACL,UACA,UACA,gBACA,qBACA,gBACA,qBACA,eACA,oBACA,WACA,aACG;CAEJ,MAAM,SAA6B;EAClC,GAAG;EACH,GAAG;EACH,IAAI;EACJ,GAAG;EACH,IAAI;EACJ,GAAG;EACH,IAAI;EACJ,GAAG;CACJ;CACA,IAAI,UACH,OAAO,KAAK;CAEb,IAAI,UACH,OAAO,IAAI,eAAe,QAAQ;CAEnC,OAAO;AACR;AAEA,SAAS,eAAe,UAA2B;CAClD,MAAM,EAAE,UAAU,WAAW,OAAO,eAAe;CAEnD,MAAM,SAAkC;EACvC,GAAG;GAAE,GAAG,SAAS;GAAS,GAAG,SAAS;GAAS,GAAG,SAAS;EAAM;EACjE,GAAG;GAAE,GAAG,UAAU;GAAS,GAAG,UAAU;GAAS,GAAG,UAAU;EAAM;EACpE,GAAG;GAAE,GAAG,MAAM;GAAS,GAAG,MAAM;GAAS,GAAG,MAAM;EAAM;EACxD,GAAG;GAAE,GAAG,WAAW;GAAS,GAAG,WAAW;GAAS,GAAG,WAAW;EAAM;CACxE;CAEA,IAAI,SAAS,KAAK,OAAO,EAAE,IAAI,SAAS;CACxC,IAAI,UAAU,KAAK,OAAO,EAAE,IAAI,UAAU;CAC1C,IAAI,MAAM,KAAK,OAAO,EAAE,IAAI,MAAM;CAClC,IAAI,WAAW,KAAK,OAAO,EAAE,IAAI,WAAW;CAC5C,OAAO;A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: AwaitWriteFinishOptions | boolean;
|
|
1
|
+
import { TestResults } from "./interface.js";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import readline from "node:readline";
|
|
4
|
+
//#region ts/monitor.d.ts
|
|
5
|
+
interface MonitorContext {
|
|
6
|
+
fs: Pick<typeof fs, 'watch'>;
|
|
7
|
+
rootDir: string;
|
|
8
|
+
awaitWriteFinish: AwaitWriteFinishOptions | boolean;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
interface AwaitWriteFinishOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Amount of time in milliseconds for a file size to remain constant before emitting its event.
|
|
13
|
+
*/
|
|
14
|
+
stabilityThreshold?: number;
|
|
15
|
+
/**
|
|
16
|
+
* File size polling interval.
|
|
17
|
+
*/
|
|
18
|
+
pollInterval?: number;
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
interface MonitorSubscription {
|
|
21
|
+
close(): Promise<void>;
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
declare function monitor(context: Partial<MonitorContext & GetLastLineContext> | undefined, callback: (err: any, testResults?: TestResults) => void): MonitorSubscription;
|
|
24
|
+
interface GetLastLineContext {
|
|
25
|
+
fs: Pick<typeof fs, 'createReadStream' | 'WriteStream'>;
|
|
26
|
+
readline: Pick<typeof readline, 'createInterface'>;
|
|
28
27
|
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { AwaitWriteFinishOptions, GetLastLineContext, MonitorContext, MonitorSubscription, monitor };
|
|
30
|
+
//# sourceMappingURL=monitor.d.ts.map
|
package/cjs/monitor.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_compress = require("./compress.js");
|
|
3
|
+
const require_constants = require("./constants.js");
|
|
4
|
+
const require_minify = require("./minify.js");
|
|
5
|
+
const require_store = require("./store.js");
|
|
6
|
+
let node_fs = require("node:fs");
|
|
7
|
+
node_fs = require_runtime.__toESM(node_fs);
|
|
8
|
+
let node_path = require("node:path");
|
|
9
|
+
node_path = require_runtime.__toESM(node_path);
|
|
10
|
+
let unpartial = require("unpartial");
|
|
11
|
+
let chokidar = require("chokidar");
|
|
12
|
+
chokidar = require_runtime.__toESM(chokidar);
|
|
13
|
+
let node_readline = require("node:readline");
|
|
14
|
+
node_readline = require_runtime.__toESM(node_readline);
|
|
15
|
+
//#region ts/monitor.ts
|
|
16
16
|
function monitor(context, callback) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
const c = (0, unpartial.unpartial)({
|
|
18
|
+
fs: node_fs.default,
|
|
19
|
+
readline: node_readline.default,
|
|
20
|
+
rootDir: require_store.store.value.rootDir,
|
|
21
|
+
awaitWriteFinish: true
|
|
22
|
+
}, context);
|
|
23
|
+
const filepath = node_path.default.join(c.rootDir, require_constants.PROGRESS_FOLDER, require_constants.TEST_RESULT_FILENAME);
|
|
24
|
+
const w = chokidar.default.watch(filepath, { awaitWriteFinish: c.awaitWriteFinish });
|
|
25
|
+
w.on("add", (path) => invokeCallback(c, path, callback));
|
|
26
|
+
w.on("change", (path) => invokeCallback(c, path, callback));
|
|
27
|
+
return { close: () => w.close() };
|
|
28
28
|
}
|
|
29
|
-
exports.monitor = monitor;
|
|
30
29
|
function invokeCallback(context, filename, callback) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
getLastLine(context, filename).then((line) => {
|
|
31
|
+
callback(void 0, require_minify.unminify(require_compress.decompress(line)));
|
|
32
|
+
}).catch((e) => callback(e));
|
|
34
33
|
}
|
|
35
34
|
function getLastLine({ fs, readline }, filename) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
rl.on('close', () => a(lastline));
|
|
47
|
-
});
|
|
35
|
+
const inStream = fs.createReadStream(filename);
|
|
36
|
+
return new Promise((a, r) => {
|
|
37
|
+
const rl = readline.createInterface(inStream);
|
|
38
|
+
let lastline = "";
|
|
39
|
+
rl.on("line", (line) => {
|
|
40
|
+
if (line.length) lastline = line;
|
|
41
|
+
});
|
|
42
|
+
rl.on("error", r);
|
|
43
|
+
rl.on("close", () => a(lastline));
|
|
44
|
+
});
|
|
48
45
|
}
|
|
46
|
+
//#endregion
|
|
47
|
+
exports.monitor = monitor;
|
|
48
|
+
|
|
49
49
|
//# sourceMappingURL=monitor.js.map
|
package/cjs/monitor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.js","
|
|
1
|
+
{"version":3,"file":"monitor.js","names":["store","path","PROGRESS_FOLDER","TEST_RESULT_FILENAME","unminify","decompress"],"sources":["../ts/monitor.ts"],"sourcesContent":["import chokidar from 'chokidar'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport readline from 'node:readline'\nimport { unpartial } from 'unpartial'\nimport { decompress } from './compress'\nimport { PROGRESS_FOLDER, TEST_RESULT_FILENAME } from './constants'\nimport type { TestResults } from './interface'\nimport { unminify } from './minify'\nimport { store } from './store'\n\nexport interface MonitorContext {\n\tfs: Pick<typeof fs, 'watch'>\n\trootDir: string\n\tawaitWriteFinish: AwaitWriteFinishOptions | boolean\n}\n\nexport interface AwaitWriteFinishOptions {\n\t/**\n\t * Amount of time in milliseconds for a file size to remain constant before emitting its event.\n\t */\n\tstabilityThreshold?: number\n\n\t/**\n\t * File size polling interval.\n\t */\n\tpollInterval?: number\n}\n\nexport interface MonitorSubscription {\n\tclose(): Promise<void>\n}\n\nexport function monitor(\n\tcontext: Partial<MonitorContext & GetLastLineContext> | undefined,\n\tcallback: (err: any, testResults?: TestResults) => void\n): MonitorSubscription {\n\tconst c = unpartial<MonitorContext & GetLastLineContext>(\n\t\t{\n\t\t\tfs,\n\t\t\treadline,\n\t\t\trootDir: store.value.rootDir,\n\t\t\tawaitWriteFinish: true\n\t\t},\n\t\tcontext\n\t)\n\tconst filepath = path.join(c.rootDir, PROGRESS_FOLDER, TEST_RESULT_FILENAME)\n\n\tconst w = chokidar.watch(filepath, { awaitWriteFinish: c.awaitWriteFinish })\n\tw.on('add', (path) => invokeCallback(c, path, callback))\n\tw.on('change', (path) => invokeCallback(c, path, callback))\n\treturn { close: () => w.close() }\n}\n\nfunction invokeCallback(\n\tcontext: GetLastLineContext,\n\tfilename: string,\n\tcallback: (err: any, testResults?: TestResults) => void\n) {\n\tgetLastLine(context, filename)\n\t\t.then((line) => {\n\t\t\tcallback(undefined, unminify(decompress(line)))\n\t\t})\n\t\t.catch((e) => callback(e))\n}\n\nexport interface GetLastLineContext {\n\tfs: Pick<typeof fs, 'createReadStream' | 'WriteStream'>\n\treadline: Pick<typeof readline, 'createInterface'>\n}\n\nfunction getLastLine({ fs, readline }: GetLastLineContext, filename: string) {\n\tconst inStream = fs.createReadStream(filename)\n\treturn new Promise<string>((a, r) => {\n\t\tconst rl = readline.createInterface(inStream)\n\t\tlet lastline = ''\n\t\trl.on('line', (line: string) => {\n\t\t\tif (line.length) {\n\t\t\t\tlastline = line\n\t\t\t}\n\t\t})\n\t\trl.on('error', r)\n\t\trl.on('close', () => a(lastline))\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,SAAgB,QACf,SACA,UACsB;CACtB,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ore)({
|
|
3
|
+
moduleName: "test-progress-tracker",
|
|
4
|
+
version: "1.0.0",
|
|
5
|
+
key: "eb969cee-8646-5b9c-9084-9093804d4121",
|
|
6
|
+
initializer: (current) => ({
|
|
7
|
+
rootDir: ".",
|
|
8
|
+
...current
|
|
9
|
+
})
|
|
10
10
|
});
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.store = store;
|
|
13
|
+
|
|
11
14
|
//# sourceMappingURL=store.js.map
|
package/cjs/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","
|
|
1
|
+
{"version":3,"file":"store.js","names":["createStore"],"sources":["../ts/store.ts"],"sourcesContent":["import { createStore } from 'global-store'\n\nexport const store = createStore<{ rootDir: string }>({\n\tmoduleName: 'test-progress-tracker',\n\tversion: '1.0.0',\n\tkey: 'eb969cee-8646-5b9c-9084-9093804d4121',\n\tinitializer: (current) => ({\n\t\trootDir: '.',\n\t\t...current\n\t})\n})\n"],"mappings":";AAEA,MAAa,SAAA,yBAAQA,CAAAA,CAAAA,YAAAA,CAAiC;CACrD,YAAY;CACZ,SAAS;CACT,KAAK;CACL,cAAc,aAAa;EAC1B,SAAS;EACT,GAAG;CACJ;AACD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "test-progress-tracker",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "Keep track of test progress over time",
|
|
5
5
|
"homepage": "https://github.com/cyberuni/test-progress-tracker",
|
|
6
6
|
"bugs": {
|
|
@@ -19,58 +19,48 @@
|
|
|
19
19
|
"!**/*.{spec,test,unit,accept,integrate,system,perf,stress,study,stories}.*"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"chokidar": "^3.
|
|
23
|
-
"global-store": "^1.0.0-beta.
|
|
22
|
+
"chokidar": "^3.6.0",
|
|
23
|
+
"global-store": "^1.0.0-beta.21",
|
|
24
24
|
"mkdirp": "^1.0.4",
|
|
25
|
-
"unpartial": "^0.
|
|
25
|
+
"unpartial": "^1.0.7"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@
|
|
29
|
-
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
30
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
31
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
32
|
-
"@babel/preset-env": "^7.16.4",
|
|
33
|
-
"@babel/preset-typescript": "^7.16.0",
|
|
28
|
+
"@biomejs/biome": "^2.5.7",
|
|
34
29
|
"@changesets/cli": "^3.0.0",
|
|
35
|
-
"@commitlint/cli": "^
|
|
36
|
-
"@commitlint/config-conventional": "^
|
|
37
|
-
"@
|
|
38
|
-
"@types/jest": "^27.0.3",
|
|
30
|
+
"@commitlint/cli": "^21.0.0",
|
|
31
|
+
"@commitlint/config-conventional": "^21.0.0",
|
|
32
|
+
"@repobuddy/biome": "^2.3.1",
|
|
39
33
|
"@types/mkdirp": "^1.0.2",
|
|
40
|
-
"@types/node": "^
|
|
41
|
-
"@
|
|
42
|
-
"assertron": "^
|
|
43
|
-
"delay": "^
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"jest-watch-suspend": "^1.1.2",
|
|
53
|
-
"jest-watch-toggle-config": "^2.0.1",
|
|
54
|
-
"jest-watch-typeahead": "^1.0.0",
|
|
55
|
-
"npm-run-all": "^4.1.5",
|
|
56
|
-
"rimraf": "^3.0.0",
|
|
57
|
-
"typescript": "^4.5.2"
|
|
34
|
+
"@types/node": "^24.12.2",
|
|
35
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
36
|
+
"assertron": "^11.5.4",
|
|
37
|
+
"delay": "^7.0.0",
|
|
38
|
+
"depcheck": "^1.4.7",
|
|
39
|
+
"husky": "^9.1.7",
|
|
40
|
+
"npm-run-all2": "^9.0.0",
|
|
41
|
+
"rimraf": "^6.0.1",
|
|
42
|
+
"tsdown": "^0.22.14",
|
|
43
|
+
"turbo": "^2.10.3",
|
|
44
|
+
"typescript": "^7.0.2",
|
|
45
|
+
"vitest": "^4.0.18"
|
|
58
46
|
},
|
|
59
47
|
"scripts": {
|
|
60
|
-
"build": "
|
|
61
|
-
"
|
|
62
|
-
"
|
|
48
|
+
"build": "tsdown",
|
|
49
|
+
"check": "biome check",
|
|
50
|
+
"check:fix": "biome check --fix",
|
|
51
|
+
"clean": "rimraf cjs coverage .turbo",
|
|
52
|
+
"coverage": "vitest run --coverage",
|
|
63
53
|
"cs": "changeset",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
54
|
+
"depcheck": "depcheck",
|
|
55
|
+
"format": "biome format . --write",
|
|
56
|
+
"lint": "biome lint .",
|
|
57
|
+
"nuke": "pnpm clean && rimraf node_modules",
|
|
68
58
|
"release": "changeset publish",
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"verify": "run-p verify:
|
|
72
|
-
"verify:
|
|
59
|
+
"test": "vitest run",
|
|
60
|
+
"typecheck": "tsc",
|
|
61
|
+
"verify": "run-p lint verify:pkg",
|
|
62
|
+
"verify:pkg": "turbo run build typecheck coverage depcheck",
|
|
73
63
|
"version": "changeset version",
|
|
74
|
-
"watch": "
|
|
64
|
+
"watch": "vitest"
|
|
75
65
|
}
|
|
76
66
|
}
|
package/ts/append.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import { unpartial } from 'unpartial'
|
|
4
|
-
import { promisify } from 'util'
|
|
5
|
-
import { compress } from './compress'
|
|
6
|
-
import { PROGRESS_FOLDER, TEST_RESULT_FILENAME } from './constants'
|
|
7
|
-
import { FSContext, TestResults } from './interface'
|
|
8
|
-
import { minify } from './minify'
|
|
9
|
-
import { store } from './store'
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { unpartial } from 'unpartial'
|
|
4
|
+
import { promisify } from 'node:util'
|
|
5
|
+
import { compress } from './compress'
|
|
6
|
+
import { PROGRESS_FOLDER, TEST_RESULT_FILENAME } from './constants'
|
|
7
|
+
import type { FSContext, TestResults } from './interface'
|
|
8
|
+
import { minify } from './minify'
|
|
9
|
+
import { store } from './store'
|
|
10
10
|
|
|
11
11
|
let appendFile = fs.appendFile
|
|
12
12
|
let promisifiedAppendFile = promisify(fs.appendFile)
|
|
13
13
|
|
|
14
14
|
export async function append(context: Partial<FSContext<'appendFile'>> | undefined, results: TestResults) {
|
|
15
|
-
|
|
15
|
+
const c = unpartial<FSContext<'appendFile'>>({ fs, rootDir: store.value.rootDir }, context)
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const filepath = path.join(c.rootDir, PROGRESS_FOLDER, TEST_RESULT_FILENAME)
|
|
18
|
+
const minified = minify(results)
|
|
19
|
+
const compressed = compress(minified)
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
// istanbul ignore next
|
|
22
|
+
if (c.fs.appendFile !== appendFile) {
|
|
23
|
+
appendFile = c.fs.appendFile
|
|
24
|
+
promisifiedAppendFile = promisify(appendFile)
|
|
25
|
+
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
await promisifiedAppendFile(filepath, compressed + '\n')
|
|
28
28
|
}
|
package/ts/compress.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { MinifiedTestResult } from './minify'
|
|
1
|
+
import type { MinifiedTestResult } from './minify'
|
|
2
2
|
|
|
3
3
|
export function compress(obj: MinifiedTestResult) {
|
|
4
|
-
|
|
4
|
+
return JSON.stringify(obj)
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export function decompress(str: string): MinifiedTestResult {
|
|
8
|
-
|
|
8
|
+
return JSON.parse(str) as MinifiedTestResult
|
|
9
9
|
}
|
package/ts/init.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { PROGRESS_FOLDER } from './constants'
|
|
4
|
-
import { store } from './store'
|
|
1
|
+
import mkdirp from 'mkdirp'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { PROGRESS_FOLDER } from './constants'
|
|
4
|
+
import { store } from './store'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Initialize environment.
|
|
8
8
|
* @param options optional options. Mostly for testing purpose.
|
|
9
9
|
*/
|
|
10
10
|
export function init(options = { rootDir: '.' }) {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
mkdirp.sync(path.join(options.rootDir, PROGRESS_FOLDER))
|
|
12
|
+
store.value.rootDir = options.rootDir
|
|
13
13
|
}
|