@zeesoft/i18n-verify 3.2.6 → 3.2.7
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/executor.mjs +22 -11
- package/package.json +1 -1
- package/readme.md +2 -0
package/dist/executor.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import fs, { existsSync, statSync, readFileSync,
|
|
1
|
+
import fs, { existsSync, statSync, readFileSync, writeFileSync, readdirSync, mkdirSync, appendFileSync, copyFileSync } from "fs";
|
|
2
2
|
import path, { join, dirname, extname } from "path";
|
|
3
3
|
import { Table } from "console-table-printer";
|
|
4
4
|
import CDP from "chrome-remote-interface";
|
|
@@ -175,7 +175,6 @@ const SMART_SELECTOR = `//*[not(self::script or self::style or self::noscript)]
|
|
|
175
175
|
or @hidden
|
|
176
176
|
])]
|
|
177
177
|
`;
|
|
178
|
-
const DEBUG_MODE = true;
|
|
179
178
|
const GARBLED_CHARACTERS = [
|
|
180
179
|
"☐",
|
|
181
180
|
"�",
|
|
@@ -4981,14 +4980,14 @@ class Reports {
|
|
|
4981
4980
|
"screenshots",
|
|
4982
4981
|
String(type).toLowerCase()
|
|
4983
4982
|
);
|
|
4984
|
-
ensureDirectoryExists(_screenshotPath,
|
|
4983
|
+
ensureDirectoryExists(_screenshotPath, Config.isDebugMode());
|
|
4985
4984
|
if (str !== null && str !== void 0) {
|
|
4986
4985
|
const _stringsPath = joinPaths(
|
|
4987
4986
|
Reports.#baseReportPath,
|
|
4988
4987
|
toFileNameFormat(Config.getLocale()),
|
|
4989
4988
|
"strings"
|
|
4990
4989
|
);
|
|
4991
|
-
ensureDirectoryExists(_stringsPath,
|
|
4990
|
+
ensureDirectoryExists(_stringsPath, Config.isDebugMode());
|
|
4992
4991
|
let content = "";
|
|
4993
4992
|
const filePath = joinPaths(_stringsPath, type + ".txt");
|
|
4994
4993
|
if (pathExists(filePath)) {
|
|
@@ -5017,7 +5016,7 @@ class Reports {
|
|
|
5017
5016
|
toFileNameFormat(Config.getLocale()),
|
|
5018
5017
|
"contexts"
|
|
5019
5018
|
);
|
|
5020
|
-
ensureDirectoryExists(contextPath,
|
|
5019
|
+
ensureDirectoryExists(contextPath, Config.isDebugMode());
|
|
5021
5020
|
return contextPath;
|
|
5022
5021
|
};
|
|
5023
5022
|
static #generateReport(type) {
|
|
@@ -5047,16 +5046,20 @@ class Logger {
|
|
|
5047
5046
|
Logger.#print("dbug", message);
|
|
5048
5047
|
}
|
|
5049
5048
|
static #print(type, message, additionalObj = "") {
|
|
5049
|
+
if (type === "dbug" && !Config.isDebugMode()) {
|
|
5050
|
+
return;
|
|
5051
|
+
}
|
|
5050
5052
|
const colors = {
|
|
5051
5053
|
INFO: "\x1B[37m",
|
|
5052
5054
|
WARN: "\x1B[33m",
|
|
5053
5055
|
ERRR: "\x1B[31m",
|
|
5054
5056
|
DBUG: "\x1B[34m"
|
|
5055
5057
|
};
|
|
5058
|
+
const locale = Config.getLocale();
|
|
5056
5059
|
type = type.toUpperCase();
|
|
5057
5060
|
let color = colors[type] || colors.DEFAULT;
|
|
5058
5061
|
additionalObj = additionalObj ? ` reason: ${additionalObj.toString()}` : "";
|
|
5059
|
-
let logMessage = `[${(/* @__PURE__ */ new Date()).toLocaleString()}] [${color}${type}\x1B[0m] [${
|
|
5062
|
+
let logMessage = `[${(/* @__PURE__ */ new Date()).toLocaleString()}] [${color}${type}\x1B[0m]${locale ? `[${locale}]` : ""} - ${message}${additionalObj}`;
|
|
5060
5063
|
switch (type) {
|
|
5061
5064
|
case "INFO":
|
|
5062
5065
|
console.info(logMessage);
|
|
@@ -5090,10 +5093,12 @@ class Logger {
|
|
|
5090
5093
|
}, 10);
|
|
5091
5094
|
} else {
|
|
5092
5095
|
Logger.#isLogAppending = true;
|
|
5093
|
-
const
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5096
|
+
const logsDir = joinPaths(Reports.getReportPath(), "logs");
|
|
5097
|
+
if (logsDir) {
|
|
5098
|
+
const logFilePath = joinPaths(logsDir, "log");
|
|
5099
|
+
ensureDirectoryExists(logsDir, Config.isDebugMode());
|
|
5100
|
+
fs.appendFileSync(logFilePath, message);
|
|
5101
|
+
}
|
|
5097
5102
|
Logger.#isLogAppending = false;
|
|
5098
5103
|
}
|
|
5099
5104
|
};
|
|
@@ -6696,7 +6701,8 @@ const getConfigTemplate = (type = "") => `{
|
|
|
6696
6701
|
"suffix": "_海"
|
|
6697
6702
|
},
|
|
6698
6703
|
"mode": "${RUN_MODE.I18N}", // should be one of the following: ${Object.values(RUN_MODE).join(", ")}
|
|
6699
|
-
"garbledChars": [""]
|
|
6704
|
+
"garbledChars": [""],
|
|
6705
|
+
"debug": false // set to true to enable debug mode (verbose logging)
|
|
6700
6706
|
}`;
|
|
6701
6707
|
const readConfigFile = () => {
|
|
6702
6708
|
const rcFilePath = getConfigFilePath();
|
|
@@ -6768,6 +6774,7 @@ class Config {
|
|
|
6768
6774
|
static #ssCount;
|
|
6769
6775
|
static #appName;
|
|
6770
6776
|
static #isLoaded;
|
|
6777
|
+
static #isDebugMode;
|
|
6771
6778
|
static init() {
|
|
6772
6779
|
try {
|
|
6773
6780
|
const config = readConfigFile();
|
|
@@ -6778,6 +6785,7 @@ class Config {
|
|
|
6778
6785
|
Config.#appName = config?.appName;
|
|
6779
6786
|
Config.#options = config;
|
|
6780
6787
|
Config.#ssCount = 0;
|
|
6788
|
+
Config.#isDebugMode = config?.debug ?? false;
|
|
6781
6789
|
Config.getGarbledChars();
|
|
6782
6790
|
} catch (ex) {
|
|
6783
6791
|
Logger.error(ex.message);
|
|
@@ -6875,6 +6883,9 @@ class Config {
|
|
|
6875
6883
|
static setIsLoaded(value) {
|
|
6876
6884
|
Config.#isLoaded = value;
|
|
6877
6885
|
}
|
|
6886
|
+
static isDebugMode() {
|
|
6887
|
+
return Config.#isDebugMode;
|
|
6888
|
+
}
|
|
6878
6889
|
}
|
|
6879
6890
|
class BaseRunner {
|
|
6880
6891
|
/**
|
package/package.json
CHANGED
package/readme.md
CHANGED