@approval-tests/approvals 7.5.11 → 7.5.13
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.d.ts +1 -1
- package/bin/index.js +1 -1
- package/package.json +9 -4
- package/bin/index.ts +0 -108
- package/lib/AUtils.ts +0 -178
- package/lib/Approvals.ts +0 -321
- package/lib/Core/Namer.ts +0 -14
- package/lib/Core/Options.ts +0 -94
- package/lib/Core/Reporter.ts +0 -13
- package/lib/Core/Writer.ts +0 -5
- package/lib/FileApprover.ts +0 -116
- package/lib/FinalMessages.ts +0 -16
- package/lib/Logs/ApprovedFileLog.ts +0 -38
- package/lib/Logs/FailedFileLog.ts +0 -36
- package/lib/Logs/LogUtils.ts +0 -44
- package/lib/ManualNamer.ts +0 -12
- package/lib/Namer.ts +0 -28
- package/lib/Providers/BeforeEachVerifierBase.ts +0 -68
- package/lib/Providers/Jest/CombinationApprovals.ts +0 -161
- package/lib/Providers/Jest/JestApprovals.ts +0 -50
- package/lib/Providers/Jest/JestNamer.ts +0 -15
- package/lib/Providers/Jest/JestReporter.ts +0 -25
- package/lib/Providers/Jest/JestSetup.ts +0 -40
- package/lib/Providers/Mocha/MochaApprovals.ts +0 -74
- package/lib/Providers/Mocha/MochaNamer.ts +0 -84
- package/lib/Providers/OptionalFramework.ts +0 -11
- package/lib/Providers/Vitest/VitestApprovals.ts +0 -39
- package/lib/Providers/Vitest/VitestNamer.ts +0 -27
- package/lib/Providers/Vitest/VitestReporter.ts +0 -25
- package/lib/Reporting/DiffReporterAggregate.ts +0 -36
- package/lib/Reporting/GenericDiffReporterBase.ts +0 -154
- package/lib/Reporting/ReportByOpeningTheReceivedFile.ts +0 -22
- package/lib/Reporting/ReportLaunchingCircuitBreaker.ts +0 -40
- package/lib/Reporting/ReporterFactory.ts +0 -85
- package/lib/Reporting/Reporters/beyondcompareReporter.ts +0 -30
- package/lib/Reporting/Reporters/codiumReporter.ts +0 -26
- package/lib/Reporting/Reporters/copycommandReporter.ts +0 -46
- package/lib/Reporting/Reporters/diffmergeReporter.ts +0 -25
- package/lib/Reporting/Reporters/donothingReporter.ts +0 -13
- package/lib/Reporting/Reporters/gitdiffReporter.ts +0 -28
- package/lib/Reporting/Reporters/icdiffReporter.ts +0 -10
- package/lib/Reporting/Reporters/kdiff3Reporter.ts +0 -10
- package/lib/Reporting/Reporters/kompareReporter.ts +0 -10
- package/lib/Reporting/Reporters/meldReporter.ts +0 -10
- package/lib/Reporting/Reporters/multiReporter.ts +0 -55
- package/lib/Reporting/Reporters/nodediffReporter.ts +0 -61
- package/lib/Reporting/Reporters/opendiffReporter.ts +0 -10
- package/lib/Reporting/Reporters/p4mergeReporter.ts +0 -39
- package/lib/Reporting/Reporters/tortoisemergeReporter.ts +0 -25
- package/lib/Reporting/Reporters/vimdiffReporter.ts +0 -25
- package/lib/Reporting/Reporters/visualstudioReporter.ts +0 -48
- package/lib/Reporting/Reporters/vscodeReporter.ts +0 -26
- package/lib/Scrubbers/DateScrubber.ts +0 -83
- package/lib/Scrubbers/Scrubbers.ts +0 -106
- package/lib/StringWriter.ts +0 -73
- package/lib/Utilities/ConsoleUtils.ts +0 -15
- package/lib/Utilities/JestUtils.ts +0 -5
- package/lib/Utilities/Logger/LoggingInstance.ts +0 -247
- package/lib/Utilities/Logger/SimpleLogger.ts +0 -83
- package/lib/Utilities/Logger/SimpleLoggerApprovals.ts +0 -15
- package/lib/Utilities/Logger/StringWrapper.ts +0 -12
- package/lib/Utilities/Logger/Wrapper.ts +0 -27
- package/lib/Utilities/Printers.ts +0 -77
- package/lib/Utilities/StringUtils.ts +0 -8
- package/lib/Writers/BinaryWriter.ts +0 -42
- package/lib/config.ts +0 -95
- package/lib/osTools.ts +0 -11
- package/lib/postRunCleanup.ts +0 -63
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import { sync } from "mkdirp";
|
|
4
|
-
import { filetypeextension } from "magic-bytes.js";
|
|
5
|
-
import { Writer } from "../Core/Writer";
|
|
6
|
-
|
|
7
|
-
export class BinaryWriter implements Writer {
|
|
8
|
-
private outputData: Buffer;
|
|
9
|
-
private _ext?: string;
|
|
10
|
-
|
|
11
|
-
constructor(outputData: Buffer) {
|
|
12
|
-
this.outputData = outputData;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
getFileExtension(): string {
|
|
16
|
-
if (!this._ext) {
|
|
17
|
-
// Use the first signature match (for example, zip before jar/docx).
|
|
18
|
-
const extension = filetypeextension(this.outputData)[0] || "blob";
|
|
19
|
-
// Keep existing JPEG and TIFF approval filenames compatible.
|
|
20
|
-
switch (extension) {
|
|
21
|
-
case "jpeg":
|
|
22
|
-
this._ext = "jpg";
|
|
23
|
-
break;
|
|
24
|
-
case "tiff":
|
|
25
|
-
this._ext = "tif";
|
|
26
|
-
break;
|
|
27
|
-
default:
|
|
28
|
-
this._ext = extension;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return this._ext;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
write(filePath: string): void {
|
|
35
|
-
const dir = path.dirname(path.normalize(filePath));
|
|
36
|
-
if (!fs.existsSync(dir)) {
|
|
37
|
-
sync(dir);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
fs.writeFileSync(filePath, this.outputData);
|
|
41
|
-
}
|
|
42
|
-
}
|
package/lib/config.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import * as os from "os";
|
|
2
|
-
import * as fs from "fs";
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
import * as _ from "lodash";
|
|
5
|
-
import * as yaml from "js-yaml";
|
|
6
|
-
import { ReportLaunchingCircuitBreaker } from "./Reporting/ReportLaunchingCircuitBreaker";
|
|
7
|
-
import { Reporter } from "./Core/Reporter";
|
|
8
|
-
|
|
9
|
-
export interface Config {
|
|
10
|
-
reporters: (string | Reporter)[];
|
|
11
|
-
normalizeLineEndingsTo: boolean | string;
|
|
12
|
-
failOnLineEndingDifferences: boolean;
|
|
13
|
-
appendEOL: boolean;
|
|
14
|
-
EOL: string;
|
|
15
|
-
errorOnStaleApprovedFiles: boolean;
|
|
16
|
-
shouldIgnoreStaleApprovedFile: (fileName?: string) => boolean;
|
|
17
|
-
stripBOM: boolean;
|
|
18
|
-
forceApproveAll: boolean;
|
|
19
|
-
blockUntilReporterExits: boolean;
|
|
20
|
-
maxLaunches: number;
|
|
21
|
-
cmdOptionOverrides?: any;
|
|
22
|
-
cmdArgs?: string[];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// begin-snippet: default_config
|
|
26
|
-
export const defaultConfig: Config = {
|
|
27
|
-
reporters: [
|
|
28
|
-
"BeyondCompare",
|
|
29
|
-
"diffmerge",
|
|
30
|
-
"p4merge",
|
|
31
|
-
"tortoisemerge",
|
|
32
|
-
"nodediff",
|
|
33
|
-
"opendiff",
|
|
34
|
-
"gitdiff",
|
|
35
|
-
],
|
|
36
|
-
normalizeLineEndingsTo: false,
|
|
37
|
-
failOnLineEndingDifferences: false,
|
|
38
|
-
appendEOL: true,
|
|
39
|
-
EOL: os.EOL,
|
|
40
|
-
errorOnStaleApprovedFiles: true,
|
|
41
|
-
shouldIgnoreStaleApprovedFile: () => false,
|
|
42
|
-
stripBOM: false,
|
|
43
|
-
forceApproveAll: false,
|
|
44
|
-
blockUntilReporterExits: false,
|
|
45
|
-
maxLaunches: 10,
|
|
46
|
-
};
|
|
47
|
-
// end-snippet
|
|
48
|
-
|
|
49
|
-
export function getHomeApprovalConfig(): Config | null {
|
|
50
|
-
const homeConfigPath = path.join(os.homedir(), ".approvalsConfig");
|
|
51
|
-
if (fs.existsSync(homeConfigPath)) {
|
|
52
|
-
const configFileData = fs.readFileSync(homeConfigPath).toString();
|
|
53
|
-
try {
|
|
54
|
-
return yaml.load(configFileData) as Config;
|
|
55
|
-
} catch (ex) {
|
|
56
|
-
throw new Error("Error parsing " + homeConfigPath + ". " + ex);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
let currentConfigObj: Config;
|
|
63
|
-
|
|
64
|
-
export function getConfig(configOverrides?: Partial<Config>): Config {
|
|
65
|
-
const homeConfig = getHomeApprovalConfig() || {};
|
|
66
|
-
const resultConfig = _.defaults(
|
|
67
|
-
configOverrides || {},
|
|
68
|
-
currentConfigObj || {},
|
|
69
|
-
homeConfig,
|
|
70
|
-
defaultConfig,
|
|
71
|
-
);
|
|
72
|
-
return resultConfig as Config;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function configure(overrideOptions?: Partial<Config>): Config {
|
|
76
|
-
currentConfigObj = getConfig(overrideOptions);
|
|
77
|
-
processConfig(currentConfigObj);
|
|
78
|
-
return currentConfigObj;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function currentConfig(): Config {
|
|
82
|
-
return currentConfigObj;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function reset(): void {
|
|
86
|
-
currentConfigObj = _.defaults({}, getHomeApprovalConfig(), defaultConfig);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
currentConfigObj = getConfig();
|
|
90
|
-
|
|
91
|
-
function processConfig(config: Config): void {
|
|
92
|
-
if (config.maxLaunches) {
|
|
93
|
-
ReportLaunchingCircuitBreaker.setMaxLaunch(config.maxLaunches);
|
|
94
|
-
}
|
|
95
|
-
}
|
package/lib/osTools.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Remove the reference path as TypeScript should be configured to recognize node types globally via `tsconfig.json`
|
|
2
|
-
|
|
3
|
-
// Detect OS-specific features using TypeScript.
|
|
4
|
-
const isWindows = process.platform.startsWith("win");
|
|
5
|
-
|
|
6
|
-
export const platform = {
|
|
7
|
-
isWindows: isWindows,
|
|
8
|
-
isMac: process.platform === "darwin",
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export let findProgramPathCommand = isWindows ? "where" : "which";
|
package/lib/postRunCleanup.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
|
|
3
|
-
function unique<T>(items: T[]): T[] {
|
|
4
|
-
return [...new Set(items)];
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function normalizeFilePath(filePath) {
|
|
8
|
-
return (filePath || "").replace(/\\/g, "/");
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const glob = require("glob");
|
|
12
|
-
|
|
13
|
-
export function postRunCleanup(
|
|
14
|
-
config,
|
|
15
|
-
approvedFilesMap,
|
|
16
|
-
glob_sync = glob.sync,
|
|
17
|
-
) {
|
|
18
|
-
const options = config;
|
|
19
|
-
if (options.errorOnStaleApprovedFiles) {
|
|
20
|
-
// Don't require glob at the top of the file.
|
|
21
|
-
// this avoids a load of glob if it's not necessary
|
|
22
|
-
|
|
23
|
-
// normalize file paths for searching (windows vs *nix)...
|
|
24
|
-
const normalizedApprovedFilePaths = approvedFilesMap.map(normalizeFilePath);
|
|
25
|
-
|
|
26
|
-
const getAllDirectoriesOfApprovedFiles = unique(
|
|
27
|
-
normalizedApprovedFilePaths.map(function (file) {
|
|
28
|
-
return path.dirname(file);
|
|
29
|
-
}),
|
|
30
|
-
); // get just the directory of each
|
|
31
|
-
|
|
32
|
-
let discoveredApprovalFiles: any = [];
|
|
33
|
-
getAllDirectoriesOfApprovedFiles.forEach(function (folder) {
|
|
34
|
-
return glob_sync(folder + "**/*.approved.*").forEach(function (file) {
|
|
35
|
-
if (discoveredApprovalFiles.indexOf(file) === -1) {
|
|
36
|
-
discoveredApprovalFiles.push(file);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}); // use 'glob' to find all .approved.* files for each folder.
|
|
40
|
-
|
|
41
|
-
discoveredApprovalFiles = discoveredApprovalFiles.map(normalizeFilePath);
|
|
42
|
-
|
|
43
|
-
const staleApprovals = discoveredApprovalFiles
|
|
44
|
-
.filter(function (file) {
|
|
45
|
-
if (typeof options.shouldIgnoreStaleApprovedFile === "function") {
|
|
46
|
-
return !options.shouldIgnoreStaleApprovedFile(file);
|
|
47
|
-
}
|
|
48
|
-
return true;
|
|
49
|
-
})
|
|
50
|
-
.filter(function (discoveredFilePath) {
|
|
51
|
-
return normalizedApprovedFilePaths.indexOf(discoveredFilePath) < 0;
|
|
52
|
-
}); // only pull the ones that aren't already in the 'normalizedApprovedFilePaths'
|
|
53
|
-
|
|
54
|
-
if (staleApprovals.length) {
|
|
55
|
-
process.exitCode = 1;
|
|
56
|
-
throw new Error(
|
|
57
|
-
"ERROR: Found stale approvals files: \n - " +
|
|
58
|
-
staleApprovals.join("\n - ") +
|
|
59
|
-
"\n",
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|