@zeesoft/i18n-verify 3.2.5 → 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 +62 -52
- 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
|
"�",
|
|
@@ -4156,6 +4155,9 @@ class ReportFactory {
|
|
|
4156
4155
|
}
|
|
4157
4156
|
}
|
|
4158
4157
|
static export(type, path2, name) {
|
|
4158
|
+
if (type === SUPPORTED_REPORT_TYPES.HTML && !path2) {
|
|
4159
|
+
return;
|
|
4160
|
+
}
|
|
4159
4161
|
const builder = ReportFactory.#build(type);
|
|
4160
4162
|
const reportData = new ReportData({
|
|
4161
4163
|
appName: Config.getAppName(),
|
|
@@ -4978,14 +4980,14 @@ class Reports {
|
|
|
4978
4980
|
"screenshots",
|
|
4979
4981
|
String(type).toLowerCase()
|
|
4980
4982
|
);
|
|
4981
|
-
ensureDirectoryExists(_screenshotPath,
|
|
4983
|
+
ensureDirectoryExists(_screenshotPath, Config.isDebugMode());
|
|
4982
4984
|
if (str !== null && str !== void 0) {
|
|
4983
4985
|
const _stringsPath = joinPaths(
|
|
4984
4986
|
Reports.#baseReportPath,
|
|
4985
4987
|
toFileNameFormat(Config.getLocale()),
|
|
4986
4988
|
"strings"
|
|
4987
4989
|
);
|
|
4988
|
-
ensureDirectoryExists(_stringsPath,
|
|
4990
|
+
ensureDirectoryExists(_stringsPath, Config.isDebugMode());
|
|
4989
4991
|
let content = "";
|
|
4990
4992
|
const filePath = joinPaths(_stringsPath, type + ".txt");
|
|
4991
4993
|
if (pathExists(filePath)) {
|
|
@@ -5014,7 +5016,7 @@ class Reports {
|
|
|
5014
5016
|
toFileNameFormat(Config.getLocale()),
|
|
5015
5017
|
"contexts"
|
|
5016
5018
|
);
|
|
5017
|
-
ensureDirectoryExists(contextPath,
|
|
5019
|
+
ensureDirectoryExists(contextPath, Config.isDebugMode());
|
|
5018
5020
|
return contextPath;
|
|
5019
5021
|
};
|
|
5020
5022
|
static #generateReport(type) {
|
|
@@ -5044,16 +5046,20 @@ class Logger {
|
|
|
5044
5046
|
Logger.#print("dbug", message);
|
|
5045
5047
|
}
|
|
5046
5048
|
static #print(type, message, additionalObj = "") {
|
|
5049
|
+
if (type === "dbug" && !Config.isDebugMode()) {
|
|
5050
|
+
return;
|
|
5051
|
+
}
|
|
5047
5052
|
const colors = {
|
|
5048
5053
|
INFO: "\x1B[37m",
|
|
5049
5054
|
WARN: "\x1B[33m",
|
|
5050
5055
|
ERRR: "\x1B[31m",
|
|
5051
5056
|
DBUG: "\x1B[34m"
|
|
5052
5057
|
};
|
|
5058
|
+
const locale = Config.getLocale();
|
|
5053
5059
|
type = type.toUpperCase();
|
|
5054
5060
|
let color = colors[type] || colors.DEFAULT;
|
|
5055
5061
|
additionalObj = additionalObj ? ` reason: ${additionalObj.toString()}` : "";
|
|
5056
|
-
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}`;
|
|
5057
5063
|
switch (type) {
|
|
5058
5064
|
case "INFO":
|
|
5059
5065
|
console.info(logMessage);
|
|
@@ -5087,10 +5093,12 @@ class Logger {
|
|
|
5087
5093
|
}, 10);
|
|
5088
5094
|
} else {
|
|
5089
5095
|
Logger.#isLogAppending = true;
|
|
5090
|
-
const
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
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
|
+
}
|
|
5094
5102
|
Logger.#isLogAppending = false;
|
|
5095
5103
|
}
|
|
5096
5104
|
};
|
|
@@ -5763,7 +5771,6 @@ class BaseValidator {
|
|
|
5763
5771
|
}
|
|
5764
5772
|
#getCompatibleLocale(locale) {
|
|
5765
5773
|
if (this.isQaLocale()) {
|
|
5766
|
-
Logger.warn(`Detected QA lcoale so defaulting to 'en'.`);
|
|
5767
5774
|
return "en";
|
|
5768
5775
|
}
|
|
5769
5776
|
locale = locale.replace(/[-_ ]/g, "-");
|
|
@@ -5777,9 +5784,6 @@ class BaseValidator {
|
|
|
5777
5784
|
if (firstMatch) {
|
|
5778
5785
|
suitableLocale = firstMatch;
|
|
5779
5786
|
} else {
|
|
5780
|
-
Logger.warn(
|
|
5781
|
-
`No suitable locale found for ${locale}. Defaulting to 'en'.`
|
|
5782
|
-
);
|
|
5783
5787
|
suitableLocale = "en";
|
|
5784
5788
|
}
|
|
5785
5789
|
}
|
|
@@ -6651,8 +6655,8 @@ const loadDependencies = () => {
|
|
|
6651
6655
|
if (Config.getDriver() && !Config.isLoaded() && Config.getLocale()) {
|
|
6652
6656
|
Config.build();
|
|
6653
6657
|
Resource.load();
|
|
6654
|
-
Validator.load();
|
|
6655
6658
|
Reports.setup();
|
|
6659
|
+
Validator.load();
|
|
6656
6660
|
Cache.init();
|
|
6657
6661
|
Config.setIsLoaded(true);
|
|
6658
6662
|
}
|
|
@@ -6697,7 +6701,8 @@ const getConfigTemplate = (type = "") => `{
|
|
|
6697
6701
|
"suffix": "_海"
|
|
6698
6702
|
},
|
|
6699
6703
|
"mode": "${RUN_MODE.I18N}", // should be one of the following: ${Object.values(RUN_MODE).join(", ")}
|
|
6700
|
-
"garbledChars": [""]
|
|
6704
|
+
"garbledChars": [""],
|
|
6705
|
+
"debug": false // set to true to enable debug mode (verbose logging)
|
|
6701
6706
|
}`;
|
|
6702
6707
|
const readConfigFile = () => {
|
|
6703
6708
|
const rcFilePath = getConfigFilePath();
|
|
@@ -6769,43 +6774,45 @@ class Config {
|
|
|
6769
6774
|
static #ssCount;
|
|
6770
6775
|
static #appName;
|
|
6771
6776
|
static #isLoaded;
|
|
6777
|
+
static #isDebugMode;
|
|
6772
6778
|
static init() {
|
|
6773
6779
|
try {
|
|
6774
6780
|
const config = readConfigFile();
|
|
6775
6781
|
validateConfig(config);
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6782
|
+
Config.#type = config?.type;
|
|
6783
|
+
Config.#mode = config?.mode;
|
|
6784
|
+
Config.#qaLocale = config?.qaLocale;
|
|
6785
|
+
Config.#appName = config?.appName;
|
|
6786
|
+
Config.#options = config;
|
|
6787
|
+
Config.#ssCount = 0;
|
|
6788
|
+
Config.#isDebugMode = config?.debug ?? false;
|
|
6789
|
+
Config.getGarbledChars();
|
|
6783
6790
|
} catch (ex) {
|
|
6784
6791
|
Logger.error(ex.message);
|
|
6785
6792
|
throw ex;
|
|
6786
6793
|
}
|
|
6787
6794
|
}
|
|
6788
6795
|
static build() {
|
|
6789
|
-
|
|
6790
|
-
|
|
6796
|
+
Config.#driver = build$1(Config.#type, Config.#driver);
|
|
6797
|
+
Config.resetCounter();
|
|
6791
6798
|
}
|
|
6792
6799
|
static getGarbledChars() {
|
|
6793
|
-
return [...
|
|
6800
|
+
return [...Config.#options.garbledChars || [], ...GARBLED_CHARACTERS];
|
|
6794
6801
|
}
|
|
6795
6802
|
static getL10nReportsPath() {
|
|
6796
|
-
return
|
|
6803
|
+
return Config.#options.l10nReportsPath;
|
|
6797
6804
|
}
|
|
6798
6805
|
static setDriver(driver) {
|
|
6799
|
-
|
|
6806
|
+
Config.#driver = driver;
|
|
6800
6807
|
}
|
|
6801
6808
|
static setType(type) {
|
|
6802
|
-
|
|
6809
|
+
Config.#type = type;
|
|
6803
6810
|
}
|
|
6804
6811
|
static setLocale(locale) {
|
|
6805
|
-
|
|
6812
|
+
Config.#locale = locale;
|
|
6806
6813
|
}
|
|
6807
6814
|
static setOptions(options) {
|
|
6808
|
-
|
|
6815
|
+
Config.#options = options;
|
|
6809
6816
|
}
|
|
6810
6817
|
static getExecutor() {
|
|
6811
6818
|
if (Config.#executor) {
|
|
@@ -6816,65 +6823,68 @@ class Config {
|
|
|
6816
6823
|
"Unable to initialize process executor, driver is missing"
|
|
6817
6824
|
);
|
|
6818
6825
|
}
|
|
6819
|
-
|
|
6820
|
-
return
|
|
6826
|
+
Config.#executor = new Executor(Config.#driver);
|
|
6827
|
+
return Config.#executor;
|
|
6821
6828
|
}
|
|
6822
6829
|
static getDriver() {
|
|
6823
|
-
return
|
|
6830
|
+
return Config.#driver;
|
|
6824
6831
|
}
|
|
6825
6832
|
static getLocale() {
|
|
6826
|
-
return
|
|
6833
|
+
return Config.#locale;
|
|
6827
6834
|
}
|
|
6828
6835
|
static getDefaultLocale() {
|
|
6829
|
-
return
|
|
6836
|
+
return Config.#options.defaultLocale;
|
|
6830
6837
|
}
|
|
6831
6838
|
static getType() {
|
|
6832
|
-
return
|
|
6839
|
+
return Config.#type;
|
|
6833
6840
|
}
|
|
6834
6841
|
static getOptions() {
|
|
6835
|
-
return
|
|
6842
|
+
return Config.#options;
|
|
6836
6843
|
}
|
|
6837
6844
|
static setQALocale(locale) {
|
|
6838
|
-
|
|
6845
|
+
Config.#qaLocale = locale;
|
|
6839
6846
|
}
|
|
6840
6847
|
static getQALocale() {
|
|
6841
|
-
return
|
|
6848
|
+
return Config.#qaLocale;
|
|
6842
6849
|
}
|
|
6843
6850
|
static setResourceBundle(resources) {
|
|
6844
|
-
|
|
6851
|
+
Config.#resources = resources;
|
|
6845
6852
|
}
|
|
6846
6853
|
static getResourceBundle(value) {
|
|
6847
|
-
return
|
|
6854
|
+
return Config.#resources?.[value] || Config.#resources || [];
|
|
6848
6855
|
}
|
|
6849
6856
|
static incrementCounter() {
|
|
6850
|
-
|
|
6857
|
+
Config.#ssCount++;
|
|
6851
6858
|
}
|
|
6852
6859
|
static resetCounter() {
|
|
6853
|
-
|
|
6860
|
+
Config.#ssCount = 0;
|
|
6854
6861
|
}
|
|
6855
6862
|
static getSSCount(incrementCount = false) {
|
|
6856
|
-
return incrementCount ? ++
|
|
6863
|
+
return incrementCount ? ++Config.#ssCount : Config.#ssCount;
|
|
6857
6864
|
}
|
|
6858
6865
|
static getMode() {
|
|
6859
|
-
return
|
|
6866
|
+
return Config.#mode;
|
|
6860
6867
|
}
|
|
6861
6868
|
static isSanityRun() {
|
|
6862
|
-
return
|
|
6869
|
+
return Config.#mode === RUN_MODE.SANITY;
|
|
6863
6870
|
}
|
|
6864
6871
|
static isI18nVerificationRun() {
|
|
6865
|
-
return
|
|
6872
|
+
return Config.#mode === RUN_MODE.I18N;
|
|
6866
6873
|
}
|
|
6867
6874
|
static isContextRun() {
|
|
6868
|
-
return
|
|
6875
|
+
return Config.#mode === RUN_MODE.CONTEXT;
|
|
6869
6876
|
}
|
|
6870
6877
|
static getAppName() {
|
|
6871
|
-
return
|
|
6878
|
+
return Config.#appName;
|
|
6872
6879
|
}
|
|
6873
6880
|
static isLoaded() {
|
|
6874
|
-
return
|
|
6881
|
+
return Config.#isLoaded;
|
|
6875
6882
|
}
|
|
6876
6883
|
static setIsLoaded(value) {
|
|
6877
|
-
|
|
6884
|
+
Config.#isLoaded = value;
|
|
6885
|
+
}
|
|
6886
|
+
static isDebugMode() {
|
|
6887
|
+
return Config.#isDebugMode;
|
|
6878
6888
|
}
|
|
6879
6889
|
}
|
|
6880
6890
|
class BaseRunner {
|
package/package.json
CHANGED
package/readme.md
CHANGED