@zeesoft/i18n-verify 3.3.5 → 3.3.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 +89 -58
- package/dist/genrc.mjs +1 -1
- package/dist/index.mjs +9 -1
- package/package.json +1 -1
package/dist/executor.mjs
CHANGED
|
@@ -425,8 +425,9 @@ class BaseReport {
|
|
|
425
425
|
}
|
|
426
426
|
export(path2, name = DEFAULT_REPORT_NAME) {
|
|
427
427
|
this.write(path2, name, this.$generatedContent);
|
|
428
|
+
const runMode = Config.getMode();
|
|
428
429
|
Logger.info(
|
|
429
|
-
`Exported consolidated
|
|
430
|
+
`Exported consolidated ${runMode} Verification ${this.$type} report in ${path2}`
|
|
430
431
|
);
|
|
431
432
|
}
|
|
432
433
|
write(path2, name, data2) {
|
|
@@ -4077,82 +4078,118 @@ class HtmlReport extends BaseReport {
|
|
|
4077
4078
|
saveToFile(joinPaths(path2, `${name}.html`), data2, "utf-8");
|
|
4078
4079
|
}
|
|
4079
4080
|
}
|
|
4081
|
+
function createTableStyle(colorCode = "\x1B[94m") {
|
|
4082
|
+
return {
|
|
4083
|
+
headerTop: {
|
|
4084
|
+
left: `${colorCode}╔\x1B[0m`,
|
|
4085
|
+
mid: `${colorCode}╦\x1B[0m`,
|
|
4086
|
+
right: `${colorCode}╗\x1B[0m`,
|
|
4087
|
+
other: `${colorCode}═`
|
|
4088
|
+
},
|
|
4089
|
+
headerBottom: {
|
|
4090
|
+
left: `${colorCode}╟\x1B[0m`,
|
|
4091
|
+
mid: `${colorCode}╬\x1B[0m`,
|
|
4092
|
+
right: `${colorCode}╢\x1B[0m`,
|
|
4093
|
+
other: `${colorCode}═`
|
|
4094
|
+
},
|
|
4095
|
+
tableBottom: {
|
|
4096
|
+
left: `${colorCode}╚\x1B[0m`,
|
|
4097
|
+
mid: `${colorCode}╩\x1B[0m`,
|
|
4098
|
+
right: `${colorCode}╝\x1B[0m`,
|
|
4099
|
+
other: `${colorCode}═\x1B[0m`
|
|
4100
|
+
},
|
|
4101
|
+
vertical: `${colorCode}║\x1B[0m`
|
|
4102
|
+
};
|
|
4103
|
+
}
|
|
4104
|
+
function genSummaryTable(pageCount, locales, runMode = "Sanity") {
|
|
4105
|
+
const mode = runMode.toLowerCase();
|
|
4106
|
+
let summaryLine = "";
|
|
4107
|
+
if (mode === "i18n") {
|
|
4108
|
+
summaryLine = `${runMode} run completed localization verification for locales: ${locales}.`;
|
|
4109
|
+
} else if (["sanity", "context"].includes(mode)) {
|
|
4110
|
+
summaryLine = `${runMode} run has successfully verified ${pageCount} pages for locales: ${locales}.`;
|
|
4111
|
+
} else {
|
|
4112
|
+
summaryLine = `${runMode} run completed successfully for ${pageCount} pages for locales: ${locales}.`;
|
|
4113
|
+
}
|
|
4114
|
+
const summaryPrinter = new Table({
|
|
4115
|
+
style: createTableStyle("\x1B[92m"),
|
|
4116
|
+
columns: [
|
|
4117
|
+
{ name: "RUN MODE", alignment: "left" },
|
|
4118
|
+
{ name: "DETAILS", alignment: "left" }
|
|
4119
|
+
]
|
|
4120
|
+
});
|
|
4121
|
+
summaryPrinter.addRow({ "RUN MODE": runMode, DETAILS: summaryLine });
|
|
4122
|
+
summaryPrinter.printTable();
|
|
4123
|
+
}
|
|
4080
4124
|
class TableReport extends BaseReport {
|
|
4081
|
-
/**
|
|
4082
|
-
* @type {Table}
|
|
4083
|
-
*/
|
|
4125
|
+
/** @type {Table} */
|
|
4084
4126
|
#printer;
|
|
4085
|
-
/**
|
|
4086
|
-
* @type {Boolean}
|
|
4087
|
-
*/
|
|
4127
|
+
/** @type {boolean} */
|
|
4088
4128
|
#hasData = false;
|
|
4089
4129
|
static #column1 = "STATUS";
|
|
4090
4130
|
static #column2 = "COUNTS";
|
|
4091
|
-
|
|
4131
|
+
/**
|
|
4132
|
+
* @param {string} runMode - optional, defaults to 'sanity'
|
|
4133
|
+
*/
|
|
4134
|
+
constructor(runMode = "sanity") {
|
|
4092
4135
|
super(SUPPORTED_REPORT_TYPES.ASCII_TABLE);
|
|
4136
|
+
this.runMode = String(runMode).toLowerCase();
|
|
4093
4137
|
this.#preparePrinter();
|
|
4094
4138
|
}
|
|
4139
|
+
/**
|
|
4140
|
+
* Allow changing run mode after construction
|
|
4141
|
+
* @param {string} runMode
|
|
4142
|
+
*/
|
|
4143
|
+
setRunMode(runMode) {
|
|
4144
|
+
this.runMode = String(runMode).toLowerCase();
|
|
4145
|
+
if (!this.#printer) this.#preparePrinter();
|
|
4146
|
+
}
|
|
4095
4147
|
#preparePrinter() {
|
|
4096
4148
|
this.#printer = new Table({
|
|
4097
|
-
style:
|
|
4098
|
-
headerTop: {
|
|
4099
|
-
left: "\x1B[94m╔\x1B[0m",
|
|
4100
|
-
mid: "\x1B[94m╦\x1B[0m",
|
|
4101
|
-
right: "\x1B[94m╗\x1B[0m",
|
|
4102
|
-
other: "\x1B[94m═"
|
|
4103
|
-
},
|
|
4104
|
-
headerBottom: {
|
|
4105
|
-
left: "\x1B[94m╟\x1B[0m",
|
|
4106
|
-
mid: "\x1B[94m╬\x1B[0m",
|
|
4107
|
-
right: "\x1B[94m╢\x1B[0m",
|
|
4108
|
-
other: "\x1B[94m═"
|
|
4109
|
-
},
|
|
4110
|
-
tableBottom: {
|
|
4111
|
-
left: "\x1B[94m╚\x1B[0m",
|
|
4112
|
-
mid: "\x1B[94m╩\x1B[0m",
|
|
4113
|
-
right: "\x1B[94m╝\x1B[0m",
|
|
4114
|
-
other: "\x1B[94m═\x1B[0m"
|
|
4115
|
-
},
|
|
4116
|
-
vertical: "\x1B[94m║\x1B[0m"
|
|
4117
|
-
},
|
|
4149
|
+
style: createTableStyle("\x1B[94m"),
|
|
4118
4150
|
columns: [
|
|
4119
4151
|
{ name: TableReport.#column1, alignment: "left" },
|
|
4120
4152
|
{ name: TableReport.#column2, alignment: "center" }
|
|
4121
4153
|
]
|
|
4122
4154
|
});
|
|
4123
4155
|
}
|
|
4124
|
-
/**
|
|
4125
|
-
* @override
|
|
4126
|
-
*/
|
|
4156
|
+
/** @override */
|
|
4127
4157
|
buildContent() {
|
|
4128
|
-
if (
|
|
4158
|
+
if (this.runMode !== "i18n") {
|
|
4159
|
+
this.#hasData = false;
|
|
4160
|
+
return;
|
|
4161
|
+
}
|
|
4162
|
+
const reviewedCount = REPORT_COUNTS[I18N_STATUS.REVIEWED] || 0;
|
|
4163
|
+
if (reviewedCount > 0) {
|
|
4129
4164
|
this.#hasData = true;
|
|
4130
4165
|
for (const key in REPORT_COUNTS) {
|
|
4131
|
-
if (key
|
|
4132
|
-
|
|
4133
|
-
this.#printer.addRows([
|
|
4134
|
-
{ STATUS: key, COUNTS: `${REPORT_COUNTS[key]}` }
|
|
4135
|
-
]);
|
|
4136
|
-
}
|
|
4137
|
-
} else {
|
|
4166
|
+
if (!Object.prototype.hasOwnProperty.call(REPORT_COUNTS, key)) continue;
|
|
4167
|
+
if (key === I18N_STATUS.REVIEWED) {
|
|
4138
4168
|
this.#printer.addRows([
|
|
4139
4169
|
{
|
|
4140
4170
|
STATUS: "\x1B[94m" + "═".repeat(28) + "\x1B[0m",
|
|
4141
4171
|
COUNTS: "\x1B[94m" + "═".repeat(8) + "\x1B[0m"
|
|
4142
|
-
}
|
|
4172
|
+
},
|
|
4173
|
+
{ STATUS: "OVERALL_REVIEWED", COUNTS: `${reviewedCount}` }
|
|
4143
4174
|
]);
|
|
4175
|
+
} else {
|
|
4144
4176
|
this.#printer.addRows([
|
|
4145
|
-
{ STATUS:
|
|
4177
|
+
{ STATUS: key, COUNTS: `${REPORT_COUNTS[key]}` }
|
|
4146
4178
|
]);
|
|
4147
4179
|
}
|
|
4148
4180
|
}
|
|
4181
|
+
} else {
|
|
4182
|
+
this.#hasData = false;
|
|
4149
4183
|
}
|
|
4150
4184
|
}
|
|
4151
|
-
/**
|
|
4152
|
-
* @override
|
|
4153
|
-
*/
|
|
4185
|
+
/** @override */
|
|
4154
4186
|
export() {
|
|
4155
|
-
|
|
4187
|
+
if (this.runMode !== "i18n") return;
|
|
4188
|
+
if (this.#hasData) {
|
|
4189
|
+
this.#printer.printTable();
|
|
4190
|
+
} else {
|
|
4191
|
+
Logger.info("There are no visible elements with UI strings");
|
|
4192
|
+
}
|
|
4156
4193
|
}
|
|
4157
4194
|
}
|
|
4158
4195
|
class ReportFactory {
|
|
@@ -4161,7 +4198,7 @@ class ReportFactory {
|
|
|
4161
4198
|
case SUPPORTED_REPORT_TYPES.HTML:
|
|
4162
4199
|
return new HtmlReport();
|
|
4163
4200
|
case SUPPORTED_REPORT_TYPES.ASCII_TABLE:
|
|
4164
|
-
return new TableReport();
|
|
4201
|
+
return new TableReport(Config.getMode());
|
|
4165
4202
|
default:
|
|
4166
4203
|
throw new Error("unsupported report type requested");
|
|
4167
4204
|
}
|
|
@@ -4975,14 +5012,7 @@ class Reports {
|
|
|
4975
5012
|
}
|
|
4976
5013
|
}
|
|
4977
5014
|
static #dateTime() {
|
|
4978
|
-
|
|
4979
|
-
const year = now.getFullYear();
|
|
4980
|
-
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
4981
|
-
const day = String(now.getDate()).padStart(2, "0");
|
|
4982
|
-
const hours = String(now.getHours()).padStart(2, "0");
|
|
4983
|
-
const minutes = String(now.getMinutes()).padStart(2, "0");
|
|
4984
|
-
const timeStamp = `${year}-${month}-${day}-${hours}-${minutes}`;
|
|
4985
|
-
return timeStamp;
|
|
5015
|
+
return Date.now().toString();
|
|
4986
5016
|
}
|
|
4987
5017
|
static #generateFullReportPath = (type, str, imgName) => {
|
|
4988
5018
|
const _screenshotPath = joinPaths(
|
|
@@ -7459,10 +7489,11 @@ export {
|
|
|
7459
7489
|
Logger as L,
|
|
7460
7490
|
Reports as R,
|
|
7461
7491
|
SYSTEM_TYPES as S,
|
|
7462
|
-
|
|
7463
|
-
|
|
7492
|
+
getRootProjectMainDir as a,
|
|
7493
|
+
getRootProjectPackageJson as b,
|
|
7464
7494
|
checkAndExportConfig as c,
|
|
7465
|
-
|
|
7495
|
+
CONFIG_FILE_NAME as d,
|
|
7496
|
+
genSummaryTable as g,
|
|
7466
7497
|
joinPaths as j,
|
|
7467
7498
|
loadDependencies as l
|
|
7468
7499
|
};
|
package/dist/genrc.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as getRootProjectMainDir, b as getRootProjectPackageJson, c as checkAndExportConfig, j as joinPaths, d as CONFIG_FILE_NAME, S as SYSTEM_TYPES } from "./executor.mjs";
|
|
2
2
|
const projectDir = getRootProjectMainDir();
|
|
3
3
|
const packageJson = getRootProjectPackageJson(projectDir);
|
|
4
4
|
let type = "";
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Config, L as Logger, S as SYSTEM_TYPES, l as loadDependencies, R as Reports, E as Executor } from "./executor.mjs";
|
|
1
|
+
import { C as Config, L as Logger, S as SYSTEM_TYPES, l as loadDependencies, R as Reports, g as genSummaryTable, E as Executor } from "./executor.mjs";
|
|
2
2
|
const logger = Logger;
|
|
3
3
|
const systems = SYSTEM_TYPES;
|
|
4
4
|
const setRuntime = (driver) => {
|
|
@@ -13,6 +13,14 @@ const setLocale = (locale) => {
|
|
|
13
13
|
const genReportTable = () => {
|
|
14
14
|
Reports.generateAsciiTable();
|
|
15
15
|
Reports.generateHtml();
|
|
16
|
+
try {
|
|
17
|
+
const pageCount = Config.getSSCount();
|
|
18
|
+
const locales = getLocale();
|
|
19
|
+
const runMode = Config.getMode();
|
|
20
|
+
genSummaryTable(pageCount, locales, runMode);
|
|
21
|
+
} catch (err) {
|
|
22
|
+
Logger.debug("Could not print summary table: " + err.message);
|
|
23
|
+
}
|
|
16
24
|
};
|
|
17
25
|
const getLocale = () => {
|
|
18
26
|
return Config.getLocale();
|
package/package.json
CHANGED