@approval-tests/approvals 7.6.0 → 7.6.3
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/bin/index.js +3 -37
- package/lib/AUtils.js +21 -48
- package/lib/Approvals.d.ts +9 -5
- package/lib/Approvals.js +44 -76
- package/lib/Core/Namer.js +1 -1
- package/lib/Core/Options.d.ts +1 -1
- package/lib/Core/Options.js +2 -2
- package/lib/FileApprover.d.ts +1 -1
- package/lib/FileApprover.js +13 -13
- package/lib/FinalMessages.d.ts +2 -0
- package/lib/FinalMessages.js +5 -1
- package/lib/Logs/ApprovedFileLog.js +9 -39
- package/lib/Logs/FailedFileLog.js +8 -38
- package/lib/Logs/LogUtils.d.ts +1 -1
- package/lib/Logs/LogUtils.js +4 -4
- package/lib/ManualNamer.js +0 -3
- package/lib/Providers/BeforeEachVerifierBase.js +21 -57
- package/lib/Providers/Jest/CombinationApprovals.js +1 -1
- package/lib/Providers/Jest/JestApprovals.js +8 -51
- package/lib/Providers/Jest/JestNamer.js +5 -4
- package/lib/Providers/Jest/JestReporter.js +6 -3
- package/lib/Providers/Jest/JestSetup.js +8 -13
- package/lib/Providers/Mocha/MochaApprovals.d.ts +1 -1
- package/lib/Providers/Mocha/MochaApprovals.js +13 -53
- package/lib/Providers/Mocha/MochaNamer.d.ts +2 -2
- package/lib/Providers/Mocha/MochaNamer.js +8 -9
- package/lib/Providers/Vitest/VitestApprovals.js +8 -40
- package/lib/Providers/Vitest/VitestNamer.js +4 -4
- package/lib/Providers/Vitest/VitestReporter.js +2 -1
- package/lib/Reporting/GenericDiffReporterBase.d.ts +1 -1
- package/lib/Reporting/GenericDiffReporterBase.js +9 -42
- package/lib/Reporting/ReportByOpeningTheReceivedFile.d.ts +1 -1
- package/lib/Reporting/ReportLaunchingCircuitBreaker.d.ts +2 -0
- package/lib/Reporting/ReportLaunchingCircuitBreaker.js +6 -0
- package/lib/Reporting/ReporterFactory.js +2 -1
- package/lib/Reporting/Reporters/beyondcompareReporter.js +1 -1
- package/lib/Reporting/Reporters/codiumReporter.js +1 -1
- package/lib/Reporting/Reporters/copycommandReporter.js +4 -5
- package/lib/Reporting/Reporters/diffmergeReporter.js +6 -36
- package/lib/Reporting/Reporters/donothingReporter.js +1 -3
- package/lib/Reporting/Reporters/gitdiffReporter.js +0 -1
- package/lib/Reporting/Reporters/kdiff3Reporter.js +1 -1
- package/lib/Reporting/Reporters/meldReporter.js +1 -1
- package/lib/Reporting/Reporters/multiReporter.js +2 -2
- package/lib/Reporting/Reporters/nodediffReporter.js +15 -26
- package/lib/Reporting/Reporters/p4mergeReporter.js +27 -26
- package/lib/Reporting/Reporters/tortoisemergeReporter.js +4 -4
- package/lib/Reporting/Reporters/vimdiffReporter.js +1 -4
- package/lib/Reporting/Reporters/visualstudioReporter.js +15 -12
- package/lib/Reporting/Reporters/vscodeReporter.js +1 -1
- package/lib/Reporting/Reporters/webstormReporter.js +1 -1
- package/lib/Scrubbers/DateScrubber.js +1 -1
- package/lib/Scrubbers/Scrubbers.js +3 -18
- package/lib/StringWriter.js +10 -40
- package/lib/Utilities/Logger/LoggingInstance.js +13 -39
- package/lib/Utilities/Logger/SimpleLogger.d.ts +1 -1
- package/lib/Utilities/Logger/SimpleLogger.js +1 -1
- package/lib/Utilities/Logger/SimpleLoggerApprovals.js +1 -1
- package/lib/Utilities/Printers.js +2 -2
- package/lib/Writers/BinaryWriter.js +15 -50
- package/lib/config.js +15 -45
- package/lib/osTools.d.ts +1 -1
- package/lib/osTools.js +0 -2
- package/lib/postRunCleanup.d.ts +1 -1
- package/lib/postRunCleanup.js +17 -17
- package/package.json +19 -6
- package/readme.md +1 -1
package/lib/StringWriter.js
CHANGED
|
@@ -1,46 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
35
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
6
|
exports.StringWriter = void 0;
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const autils = __importStar(require("./AUtils"));
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
40
9
|
const mkdirp_1 = require("mkdirp");
|
|
10
|
+
const AUtils_1 = require("./AUtils");
|
|
41
11
|
const lineEndingRegex = new RegExp("\r?\n", "g");
|
|
42
12
|
function normalizeLineEndings(lineEnding, value) {
|
|
43
|
-
if (
|
|
13
|
+
if ((0, AUtils_1.isBinaryFile)(value)) {
|
|
44
14
|
return value;
|
|
45
15
|
}
|
|
46
16
|
return value.replace(lineEndingRegex, lineEnding);
|
|
@@ -58,8 +28,8 @@ class StringWriter {
|
|
|
58
28
|
return this.ext;
|
|
59
29
|
}
|
|
60
30
|
write(filePath) {
|
|
61
|
-
const dir =
|
|
62
|
-
if (!
|
|
31
|
+
const dir = path_1.default.dirname(path_1.default.normalize(filePath));
|
|
32
|
+
if (!fs_1.default.existsSync(dir)) {
|
|
63
33
|
(0, mkdirp_1.sync)(dir);
|
|
64
34
|
}
|
|
65
35
|
if (this.config.normalizeLineEndingsTo !== false &&
|
|
@@ -75,7 +45,7 @@ class StringWriter {
|
|
|
75
45
|
this.outputText += this.config.EOL;
|
|
76
46
|
}
|
|
77
47
|
}
|
|
78
|
-
|
|
48
|
+
fs_1.default.writeFileSync(filePath, this.outputText);
|
|
79
49
|
}
|
|
80
50
|
}
|
|
81
51
|
exports.StringWriter = StringWriter;
|
|
@@ -49,26 +49,12 @@ class LoggingInstance {
|
|
|
49
49
|
return code();
|
|
50
50
|
}
|
|
51
51
|
const name = getCallingMethod(additional_stack + 1);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
parameterText = parameters();
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
parameterText = parameters;
|
|
58
|
-
}
|
|
59
|
-
this.logLine(`=> ${name}(${parameterText})`);
|
|
52
|
+
const entryParameters = typeof parameters === "function" ? parameters() : parameters;
|
|
53
|
+
this.logLine(`=> ${name}(${entryParameters})`);
|
|
60
54
|
const returnValue = this.withTabbing(code);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
parameterText = "";
|
|
66
|
-
}
|
|
67
|
-
let returnText = "";
|
|
68
|
-
if (logReturnValue) {
|
|
69
|
-
returnText = `: ${returnValue}`;
|
|
70
|
-
}
|
|
71
|
-
this.logLine(`<= ${name}(${parameterText})${returnText}`);
|
|
55
|
+
const exitParameters = typeof parameters === "function" ? parameters() : "";
|
|
56
|
+
const returnText = logReturnValue ? `: ${returnValue}` : "";
|
|
57
|
+
this.logLine(`<= ${name}(${exitParameters})${returnText}`);
|
|
72
58
|
return returnValue;
|
|
73
59
|
}
|
|
74
60
|
variable(name, value, showTypes) {
|
|
@@ -77,7 +63,7 @@ class LoggingInstance {
|
|
|
77
63
|
}
|
|
78
64
|
let toType = (_value, _spacing = "") => "";
|
|
79
65
|
if (showTypes) {
|
|
80
|
-
toType = (
|
|
66
|
+
toType = (val, spacing = " ") => `${spacing}${printType(val)}`;
|
|
81
67
|
}
|
|
82
68
|
if (Array.isArray(value)) {
|
|
83
69
|
this.logLine(`variable: ${name}${toType(value, "")}.length = ${value.length}`);
|
|
@@ -92,7 +78,7 @@ class LoggingInstance {
|
|
|
92
78
|
}
|
|
93
79
|
}
|
|
94
80
|
logLine(text, use_timestamps = true) {
|
|
95
|
-
if (this.counter
|
|
81
|
+
if (this.counter !== 0) {
|
|
96
82
|
this.logger("\n");
|
|
97
83
|
}
|
|
98
84
|
this.counter = 0;
|
|
@@ -114,14 +100,14 @@ class LoggingInstance {
|
|
|
114
100
|
return;
|
|
115
101
|
}
|
|
116
102
|
this.counter += 1;
|
|
117
|
-
if (this.counter
|
|
103
|
+
if (this.counter === 1) {
|
|
118
104
|
this.logger(`${this.getTabs()}.`);
|
|
119
105
|
}
|
|
120
|
-
else if (this.counter
|
|
106
|
+
else if (this.counter === 100) {
|
|
121
107
|
this.logger("10\n");
|
|
122
108
|
this.counter = 0;
|
|
123
109
|
}
|
|
124
|
-
else if (this.counter % 10
|
|
110
|
+
else if (this.counter % 10 === 0) {
|
|
125
111
|
const digit = this.counter / 10;
|
|
126
112
|
this.logger(`${digit}`);
|
|
127
113
|
}
|
|
@@ -158,24 +144,12 @@ class LoggingInstance {
|
|
|
158
144
|
}
|
|
159
145
|
warning(exception) {
|
|
160
146
|
const warning_stars = "*".repeat(91);
|
|
161
|
-
const text = null;
|
|
162
147
|
this.logLine(warning_stars, false);
|
|
163
148
|
if (this.logWithTimestamps) {
|
|
164
149
|
this.logLine("", true);
|
|
165
150
|
}
|
|
166
|
-
if (text) {
|
|
167
|
-
this.logLine(`Message:${text}`, false);
|
|
168
|
-
}
|
|
169
151
|
if (exception) {
|
|
170
|
-
|
|
171
|
-
if (this.logStackTraces) {
|
|
172
|
-
// todo: grab stack trace
|
|
173
|
-
stack_trace = exception.toString();
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
stack_trace = `${exception}`;
|
|
177
|
-
}
|
|
178
|
-
this.logLine(stack_trace, false);
|
|
152
|
+
this.logLine(`${exception}`, false);
|
|
179
153
|
}
|
|
180
154
|
this.logLine(warning_stars, false);
|
|
181
155
|
}
|
|
@@ -201,11 +175,11 @@ class LoggingInstance {
|
|
|
201
175
|
const time1 = this.timer();
|
|
202
176
|
const time = time1.toISOString();
|
|
203
177
|
let diff_millseconds = 0;
|
|
204
|
-
if (this.previousTimestamp
|
|
178
|
+
if (this.previousTimestamp !== null) {
|
|
205
179
|
diff_millseconds = time1.getTime() - this.previousTimestamp.getTime();
|
|
206
180
|
}
|
|
207
181
|
const diff_display = `~${String(diff_millseconds).padStart(6, "0")}ms`;
|
|
208
|
-
|
|
182
|
+
const time_text = `${time}`.replace("T", " ").substring(0, 19);
|
|
209
183
|
const timestamp = `[${time_text} ${diff_display}] `;
|
|
210
184
|
this.previousTimestamp = time1;
|
|
211
185
|
return timestamp;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Wrapper } from "./Wrapper";
|
|
2
1
|
import { LoggingInstance } from "./LoggingInstance";
|
|
3
2
|
import { StringWrapper } from "./StringWrapper";
|
|
3
|
+
import { Wrapper } from "./Wrapper";
|
|
4
4
|
export declare class SimpleLogger {
|
|
5
5
|
static _wrapper: Wrapper<LoggingInstance>;
|
|
6
6
|
static showQueries(show: boolean): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SimpleLogger = void 0;
|
|
4
|
-
const Wrapper_1 = require("./Wrapper");
|
|
5
4
|
const LoggingInstance_1 = require("./LoggingInstance");
|
|
5
|
+
const Wrapper_1 = require("./Wrapper");
|
|
6
6
|
class SimpleLogger {
|
|
7
7
|
static showQueries(show) {
|
|
8
8
|
this._wrapper.get().showQueries(show);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verifySimpleLogger = verifySimpleLogger;
|
|
4
|
-
const SimpleLogger_1 = require("./SimpleLogger");
|
|
5
4
|
const JestApprovals_1 = require("../../Providers/Jest/JestApprovals");
|
|
5
|
+
const SimpleLogger_1 = require("./SimpleLogger");
|
|
6
6
|
function verifySimpleLogger(testName, code, options) {
|
|
7
7
|
test(testName, () => {
|
|
8
8
|
const output = SimpleLogger_1.SimpleLogger.logToString();
|
|
@@ -13,7 +13,7 @@ function printArray(header, list, formatter) {
|
|
|
13
13
|
if (header) {
|
|
14
14
|
text = header + "\n\n\n";
|
|
15
15
|
}
|
|
16
|
-
for (
|
|
16
|
+
for (const t of list) {
|
|
17
17
|
text += formatter(t) + "\n";
|
|
18
18
|
}
|
|
19
19
|
return text;
|
|
@@ -35,7 +35,7 @@ function generateParameterCombinations(variations, parameterCombinations = [], i
|
|
|
35
35
|
parameterCombinations.push(currentParameterCombination);
|
|
36
36
|
return parameterCombinations;
|
|
37
37
|
}
|
|
38
|
-
for (
|
|
38
|
+
for (const nextParameter of variations[index]) {
|
|
39
39
|
generateParameterCombinations(variations, parameterCombinations, index + 1, [...currentParameterCombination, nextParameter]);
|
|
40
40
|
}
|
|
41
41
|
return parameterCombinations;
|
|
@@ -1,71 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
35
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
6
|
exports.BinaryWriter = void 0;
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const mkdirp_1 = require("mkdirp");
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
40
9
|
const magic_bytes_js_1 = require("magic-bytes.js");
|
|
10
|
+
const mkdirp_1 = require("mkdirp");
|
|
11
|
+
const legacyApprovalFileExtensions = new Map([
|
|
12
|
+
["jpeg", "jpg"],
|
|
13
|
+
["tiff", "tif"],
|
|
14
|
+
]);
|
|
41
15
|
class BinaryWriter {
|
|
42
16
|
constructor(outputData) {
|
|
43
17
|
this.outputData = outputData;
|
|
44
18
|
}
|
|
45
19
|
getFileExtension() {
|
|
20
|
+
var _a;
|
|
46
21
|
if (!this._ext) {
|
|
47
22
|
// Use the first signature match (for example, zip before jar/docx).
|
|
48
23
|
const extension = (0, magic_bytes_js_1.filetypeextension)(this.outputData)[0] || "blob";
|
|
49
|
-
|
|
50
|
-
switch (extension) {
|
|
51
|
-
case "jpeg":
|
|
52
|
-
this._ext = "jpg";
|
|
53
|
-
break;
|
|
54
|
-
case "tiff":
|
|
55
|
-
this._ext = "tif";
|
|
56
|
-
break;
|
|
57
|
-
default:
|
|
58
|
-
this._ext = extension;
|
|
59
|
-
}
|
|
24
|
+
this._ext = (_a = legacyApprovalFileExtensions.get(extension)) !== null && _a !== void 0 ? _a : extension;
|
|
60
25
|
}
|
|
61
26
|
return this._ext;
|
|
62
27
|
}
|
|
63
28
|
write(filePath) {
|
|
64
|
-
const dir =
|
|
65
|
-
if (!
|
|
29
|
+
const dir = path_1.default.dirname(path_1.default.normalize(filePath));
|
|
30
|
+
if (!fs_1.default.existsSync(dir)) {
|
|
66
31
|
(0, mkdirp_1.sync)(dir);
|
|
67
32
|
}
|
|
68
|
-
|
|
33
|
+
fs_1.default.writeFileSync(filePath, this.outputData);
|
|
69
34
|
}
|
|
70
35
|
}
|
|
71
36
|
exports.BinaryWriter = BinaryWriter;
|
package/lib/config.js
CHANGED
|
@@ -1,37 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
35
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
6
|
exports.defaultConfig = void 0;
|
|
37
7
|
exports.getHomeApprovalConfig = getHomeApprovalConfig;
|
|
@@ -39,11 +9,11 @@ exports.getConfig = getConfig;
|
|
|
39
9
|
exports.configure = configure;
|
|
40
10
|
exports.currentConfig = currentConfig;
|
|
41
11
|
exports.reset = reset;
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
13
|
+
const os_1 = __importDefault(require("os"));
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
16
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
47
17
|
const ReportLaunchingCircuitBreaker_1 = require("./Reporting/ReportLaunchingCircuitBreaker");
|
|
48
18
|
// begin-snippet: default_config
|
|
49
19
|
exports.defaultConfig = {
|
|
@@ -59,7 +29,7 @@ exports.defaultConfig = {
|
|
|
59
29
|
normalizeLineEndingsTo: false,
|
|
60
30
|
failOnLineEndingDifferences: false,
|
|
61
31
|
appendEOL: true,
|
|
62
|
-
EOL:
|
|
32
|
+
EOL: os_1.default.EOL,
|
|
63
33
|
errorOnStaleApprovedFiles: true,
|
|
64
34
|
shouldIgnoreStaleApprovedFile: () => false,
|
|
65
35
|
stripBOM: false,
|
|
@@ -69,11 +39,11 @@ exports.defaultConfig = {
|
|
|
69
39
|
};
|
|
70
40
|
// end-snippet
|
|
71
41
|
function getHomeApprovalConfig() {
|
|
72
|
-
const homeConfigPath =
|
|
73
|
-
if (
|
|
74
|
-
const configFileData =
|
|
42
|
+
const homeConfigPath = path_1.default.join(os_1.default.homedir(), ".approvalsConfig");
|
|
43
|
+
if (fs_1.default.existsSync(homeConfigPath)) {
|
|
44
|
+
const configFileData = fs_1.default.readFileSync(homeConfigPath).toString();
|
|
75
45
|
try {
|
|
76
|
-
return
|
|
46
|
+
return js_yaml_1.default.load(configFileData);
|
|
77
47
|
}
|
|
78
48
|
catch (ex) {
|
|
79
49
|
throw new Error("Error parsing " + homeConfigPath + ". " + ex);
|
|
@@ -84,7 +54,7 @@ function getHomeApprovalConfig() {
|
|
|
84
54
|
let currentConfigObj;
|
|
85
55
|
function getConfig(configOverrides) {
|
|
86
56
|
const homeConfig = getHomeApprovalConfig() || {};
|
|
87
|
-
const resultConfig =
|
|
57
|
+
const resultConfig = lodash_1.default.defaults(configOverrides || {}, currentConfigObj || {}, homeConfig, exports.defaultConfig);
|
|
88
58
|
return resultConfig;
|
|
89
59
|
}
|
|
90
60
|
function configure(overrideOptions) {
|
|
@@ -96,7 +66,7 @@ function currentConfig() {
|
|
|
96
66
|
return currentConfigObj;
|
|
97
67
|
}
|
|
98
68
|
function reset() {
|
|
99
|
-
currentConfigObj =
|
|
69
|
+
currentConfigObj = lodash_1.default.defaults({}, getHomeApprovalConfig(), exports.defaultConfig);
|
|
100
70
|
}
|
|
101
71
|
currentConfigObj = getConfig();
|
|
102
72
|
function processConfig(config) {
|
package/lib/osTools.d.ts
CHANGED
package/lib/osTools.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Remove the reference path as TypeScript should be configured to recognize node types globally via `tsconfig.json`
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.findProgramPathCommand = exports.platform = void 0;
|
|
5
|
-
// Detect OS-specific features using TypeScript.
|
|
6
4
|
const isWindows = process.platform.startsWith("win");
|
|
7
5
|
exports.platform = {
|
|
8
6
|
isWindows: isWindows,
|
package/lib/postRunCleanup.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function postRunCleanup(config: any, approvedFilesMap: any, glob_sync?:
|
|
1
|
+
export declare function postRunCleanup(config: any, approvedFilesMap: any, glob_sync?: (pattern: string) => string[]): void;
|
package/lib/postRunCleanup.js
CHANGED
|
@@ -5,32 +5,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.postRunCleanup = postRunCleanup;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const glob_1 = require("glob");
|
|
8
9
|
function unique(items) {
|
|
9
10
|
return [...new Set(items)];
|
|
10
11
|
}
|
|
11
12
|
function normalizeFilePath(filePath) {
|
|
12
13
|
return (filePath || "").replace(/\\/g, "/");
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
function findApprovedFilesInFolders(folders, glob_sync) {
|
|
16
|
+
const discoveredApprovalFiles = [];
|
|
17
|
+
folders.forEach(function (folder) {
|
|
18
|
+
return glob_sync(folder + "**/*.approved.*").forEach(function (file) {
|
|
19
|
+
if (discoveredApprovalFiles.indexOf(file) === -1) {
|
|
20
|
+
discoveredApprovalFiles.push(file);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
return discoveredApprovalFiles;
|
|
25
|
+
}
|
|
26
|
+
function postRunCleanup(config, approvedFilesMap, glob_sync = glob_1.sync) {
|
|
16
27
|
const options = config;
|
|
17
28
|
if (options.errorOnStaleApprovedFiles) {
|
|
18
|
-
// Don't require glob at the top of the file.
|
|
19
|
-
// this avoids a load of glob if it's not necessary
|
|
20
|
-
// normalize file paths for searching (windows vs *nix)...
|
|
21
29
|
const normalizedApprovedFilePaths = approvedFilesMap.map(normalizeFilePath);
|
|
22
|
-
const
|
|
30
|
+
const approvedFileFolders = unique(normalizedApprovedFilePaths.map(function (file) {
|
|
23
31
|
return path_1.default.dirname(file);
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
getAllDirectoriesOfApprovedFiles.forEach(function (folder) {
|
|
27
|
-
return glob_sync(folder + "**/*.approved.*").forEach(function (file) {
|
|
28
|
-
if (discoveredApprovalFiles.indexOf(file) === -1) {
|
|
29
|
-
discoveredApprovalFiles.push(file);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}); // use 'glob' to find all .approved.* files for each folder.
|
|
33
|
-
discoveredApprovalFiles = discoveredApprovalFiles.map(normalizeFilePath);
|
|
32
|
+
}));
|
|
33
|
+
const discoveredApprovalFiles = findApprovedFilesInFolders(approvedFileFolders, glob_sync).map(normalizeFilePath);
|
|
34
34
|
const staleApprovals = discoveredApprovalFiles
|
|
35
35
|
.filter(function (file) {
|
|
36
36
|
if (typeof options.shouldIgnoreStaleApprovedFile === "function") {
|
|
@@ -40,7 +40,7 @@ function postRunCleanup(config, approvedFilesMap, glob_sync = glob.sync) {
|
|
|
40
40
|
})
|
|
41
41
|
.filter(function (discoveredFilePath) {
|
|
42
42
|
return normalizedApprovedFilePaths.indexOf(discoveredFilePath) < 0;
|
|
43
|
-
});
|
|
43
|
+
});
|
|
44
44
|
if (staleApprovals.length) {
|
|
45
45
|
process.exitCode = 1;
|
|
46
46
|
throw new Error("ERROR: Found stale approvals files: \n - " +
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"description": "Approval Tests Library - Capturing Human Intelligence",
|
|
7
|
-
"version": "7.6.
|
|
7
|
+
"version": "7.6.3",
|
|
8
8
|
"homepage": "http://approvaltests.com",
|
|
9
9
|
"author": {
|
|
10
10
|
"name": "Jason Jarrett",
|
|
@@ -45,13 +45,20 @@
|
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "tsc",
|
|
47
47
|
"prepack": "npm run build",
|
|
48
|
-
"test": "
|
|
48
|
+
"test": "npm run --silent lint && npm run --silent test:suites --",
|
|
49
|
+
"test:suites": "node scripts/test.cjs",
|
|
49
50
|
"vitest": "node scripts/test-isolated.cjs vitest",
|
|
50
51
|
"test2": "npm run mocha && npm run lint",
|
|
51
52
|
"lint": "eslint lib test",
|
|
53
|
+
"lint:fix": "npm run lint -- --fix",
|
|
54
|
+
"lint:staged": "lint-staged",
|
|
52
55
|
"mocha": "node scripts/test-isolated.cjs mocha",
|
|
53
56
|
"coverage": "node scripts/test-isolated.cjs mocha --coverage",
|
|
54
|
-
"jest": "node scripts/test-isolated.cjs jest"
|
|
57
|
+
"jest": "node scripts/test-isolated.cjs jest",
|
|
58
|
+
"prepare": "husky"
|
|
59
|
+
},
|
|
60
|
+
"lint-staged": {
|
|
61
|
+
"*.{js,mjs,ts,mts}": "eslint --fix"
|
|
55
62
|
},
|
|
56
63
|
"dependencies": {
|
|
57
64
|
"ansi-colors": "^4.1.3",
|
|
@@ -67,8 +74,7 @@
|
|
|
67
74
|
"marked-terminal-renderer": "^2.2.0",
|
|
68
75
|
"minimist": "^1.2.8",
|
|
69
76
|
"mkdirp": "^3.0.1",
|
|
70
|
-
"shelljs": "^0.10.0"
|
|
71
|
-
"temp": "^0.9.4"
|
|
77
|
+
"shelljs": "^0.10.0"
|
|
72
78
|
},
|
|
73
79
|
"devDependencies": {
|
|
74
80
|
"@types/chai": "^5.0.1",
|
|
@@ -77,13 +83,20 @@
|
|
|
77
83
|
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
78
84
|
"@typescript-eslint/parser": "^8.17.0",
|
|
79
85
|
"chai": "^6.0.1",
|
|
86
|
+
"concurrently": "^10.0.7",
|
|
80
87
|
"eslint": "^10.2.1",
|
|
88
|
+
"eslint-plugin-import-x": "^4.18.1",
|
|
81
89
|
"eslint-plugin-promise": "^7.2.1",
|
|
90
|
+
"globals": "^17.14.0",
|
|
91
|
+
"husky": "^9.1.7",
|
|
92
|
+
"jscpd": "^5.4.3",
|
|
82
93
|
"jsdoc-to-markdown": "^9.1.1",
|
|
94
|
+
"knip": "^6.45.1",
|
|
95
|
+
"lint-staged": "^17.6.0",
|
|
83
96
|
"nyc": "^18.0.0",
|
|
84
|
-
"pre-commit": "^2.0.0",
|
|
85
97
|
"prettier": "^3.4.2",
|
|
86
98
|
"sinon": "^22.0.0",
|
|
99
|
+
"ts-morph": "^28.0.0",
|
|
87
100
|
"typescript": "^6.0.2"
|
|
88
101
|
},
|
|
89
102
|
"keywords": [
|
package/readme.md
CHANGED
|
@@ -313,7 +313,7 @@ export const defaultConfig: Config = {
|
|
|
313
313
|
maxLaunches: 10,
|
|
314
314
|
};
|
|
315
315
|
```
|
|
316
|
-
<sup><a href='/lib/config.ts#
|
|
316
|
+
<sup><a href='/lib/config.ts#L27-L49' title='Snippet source file'>snippet source</a> | <a href='#snippet-default_config' title='Start of snippet'>anchor</a></sup>
|
|
317
317
|
<!-- endSnippet -->
|
|
318
318
|
|
|
319
319
|
<a name="api" />
|