@zeesoft/i18n-verify 2.1.4 → 2.1.6
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/genrc.mjs +1 -0
- package/dist/i18n.mjs +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +25 -17
- package/postinstall.js +28 -0
- package/readme.md +21 -1
- package/dist/driver/adapters/cypress.js +0 -161
- package/dist/driver/adapters/nightwatch.js +0 -160
- package/dist/driver/adapters/selenium.js +0 -90
- package/dist/driver/adapters/webdriver.io.js +0 -81
- package/dist/driver/baseDriver.js +0 -93
- package/dist/driver/factory.js +0 -27
- package/dist/index.js +0 -52
- package/dist/lib/config.js +0 -102
- package/dist/lib/i18n.js +0 -259
- package/dist/lib/reports.js +0 -140
- package/dist/lib/validator/base.js +0 -125
- package/dist/lib/validator/currency.js +0 -94
- package/dist/lib/validator/date.js +0 -72
- package/dist/lib/validator/datetime.js +0 -72
- package/dist/lib/validator/index.js +0 -156
- package/dist/lib/validator/number.js +0 -58
- package/dist/lib/validator/percentage.js +0 -78
- package/dist/lib/validator/string.js +0 -172
- package/dist/lib/validator/time.js +0 -72
- package/dist/template/report.html +0 -1678
- package/dist/utils/cache.js +0 -47
- package/dist/utils/common.js +0 -18
- package/dist/utils/configFile.js +0 -65
- package/dist/utils/constants.js +0 -148
- package/dist/utils/cypress.js +0 -120
- package/dist/utils/dateUtils/chronoNode.js +0 -52
- package/dist/utils/file.js +0 -61
- package/dist/utils/graphic.js +0 -57
- package/dist/utils/logs.js +0 -79
- package/dist/utils/objects/cacheData.js +0 -72
- package/dist/utils/objects/metaData.js +0 -29
- package/dist/utils/objects/reportData.js +0 -30
- package/dist/utils/objects/statData.js +0 -380
- package/dist/utils/objects/stringData.js +0 -64
- package/dist/utils/objects/stringInfo.js +0 -51
- package/dist/utils/regex.js +0 -8
- package/dist/utils/reportFactory/base.js +0 -59
- package/dist/utils/reportFactory/html/index.js +0 -51
- package/dist/utils/reportFactory/html/template/body.js +0 -117
- package/dist/utils/reportFactory/html/template/css.js +0 -476
- package/dist/utils/reportFactory/html/template/html.js +0 -63
- package/dist/utils/reportFactory/html/template/javascript/data.js +0 -66
- package/dist/utils/reportFactory/html/template/javascript/global.js +0 -45
- package/dist/utils/reportFactory/html/template/javascript/grid.js +0 -129
- package/dist/utils/reportFactory/html/template/javascript/index.js +0 -22
- package/dist/utils/reportFactory/html/template/javascript/insight.js +0 -248
- package/dist/utils/reportFactory/html/template/javascript/log.js +0 -19
- package/dist/utils/reportFactory/html/template/javascript/menuBar.js +0 -123
- package/dist/utils/reportFactory/html/template/javascript/overview.js +0 -818
- package/dist/utils/reportFactory/index.js +0 -36
- package/dist/utils/reportFactory/table.js +0 -95
- package/dist/utils/resource.js +0 -58
- package/dist/utils/runtime.js +0 -36
- package/dist/utils/scripts/genreport.js +0 -1
- package/dist/utils/scripts/postinstall.js +0 -22
package/dist/utils/cache.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _config = _interopRequireDefault(require("../lib/config.js"));
|
|
8
|
-
var _reports = _interopRequireDefault(require("../lib/reports.js"));
|
|
9
|
-
var _constants = require("./constants.js");
|
|
10
|
-
var _file = require("./file.js");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
class Cache {
|
|
13
|
-
/** @type {String} */
|
|
14
|
-
static #cachePath;
|
|
15
|
-
static #cacheDirPath;
|
|
16
|
-
static init() {
|
|
17
|
-
Cache.#cacheDirPath = (0, _file.joinPaths)(_reports.default.getReportPath(), _config.default.getLocale());
|
|
18
|
-
Cache.#cachePath = (0, _file.joinPaths)(Cache.#cacheDirPath, _constants.CACHE_FILE_NAME);
|
|
19
|
-
this.#ensureFileExists();
|
|
20
|
-
}
|
|
21
|
-
static exists() {
|
|
22
|
-
return (0, _file.fileExists)(Cache.#cachePath);
|
|
23
|
-
}
|
|
24
|
-
static save(data) {
|
|
25
|
-
this.#ensureFileExists();
|
|
26
|
-
const source = `!window.rawData && (window.rawData={'${_config.default.getLocale()}':{}});window.rawData['${_config.default.getLocale()}']=${JSON.stringify(data)};`;
|
|
27
|
-
(0, _file.saveToFile)(Cache.#cachePath, source);
|
|
28
|
-
}
|
|
29
|
-
static getData() {
|
|
30
|
-
if (!this.exists()) {
|
|
31
|
-
return {};
|
|
32
|
-
} else {
|
|
33
|
-
try {
|
|
34
|
-
return JSON.parse((0, _file.getFileContent)(Cache.#cachePath).replace(new RegExp(`(\\!window.rawData && \\(window\\.rawData=\\{'${_config.default.getLocale()}':\\{\\}\\}\\);window\\.rawData\\['${_config.default.getLocale()}'\\]=)|(;$)`, 'g'), ''));
|
|
35
|
-
} catch (ex) {
|
|
36
|
-
return {};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
static #ensureFileExists() {
|
|
41
|
-
(0, _file.ensureDirectoryExists)(Cache.#cacheDirPath);
|
|
42
|
-
}
|
|
43
|
-
static getCacheDirPath() {
|
|
44
|
-
return Cache.#cacheDirPath;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.default = Cache;
|
package/dist/utils/common.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.propertExists = exports.arr2Txt = exports.allPropertyExists = void 0;
|
|
7
|
-
const propertExists = (key, obj) => key in obj;
|
|
8
|
-
exports.propertExists = propertExists;
|
|
9
|
-
const allPropertyExists = (keys, obj, missingKeys = []) => keys.every(key => {
|
|
10
|
-
if (!propertExists(key, obj)) {
|
|
11
|
-
missingKeys.push(key);
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
});
|
|
16
|
-
exports.allPropertyExists = allPropertyExists;
|
|
17
|
-
const arr2Txt = (array, demiliter = ', ') => array.join(demiliter);
|
|
18
|
-
exports.arr2Txt = arr2Txt;
|
package/dist/utils/configFile.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.validateConfig = exports.readConfigFile = exports.getConfigTemplate = exports.checkAndExportConfig = void 0;
|
|
7
|
-
var _common = require("./common.js");
|
|
8
|
-
var _constants = require("./constants.js");
|
|
9
|
-
var _file = require("./file.js");
|
|
10
|
-
const getConfigFilePath = () => (0, _file.joinPaths)(process.cwd(), _constants.CONFIG_FILE_NAME);
|
|
11
|
-
const getConfigTemplate = (type = '') => `{
|
|
12
|
-
"type": "${type}", // set automation framework type ${(0, _common.arr2Txt)(Object.values(_constants.SYSTEM_TYPES))}
|
|
13
|
-
"qaLocale": "", // set the qa locale used in your project
|
|
14
|
-
"l10nResourcePath": "./l10nResources", // set the dir path of l10n resources
|
|
15
|
-
"l10nReportsPath": "./l10nReports/", // set the dir path of l10n reports
|
|
16
|
-
"supportedLocales": ["en_US", "fr_FR", "ja_JP"], // set the list of supported locales
|
|
17
|
-
"defaultLocale": "en_US", // set default locale of the application
|
|
18
|
-
"qaMock": { // set the prefix and suffix characters of qa locale
|
|
19
|
-
"prefix": "à_",
|
|
20
|
-
"suffix": "_海"
|
|
21
|
-
},
|
|
22
|
-
"i18nVerify": true, // enable or disable I18n verification
|
|
23
|
-
"garbledChars": [""] // set the list of custom garbled characters
|
|
24
|
-
}`;
|
|
25
|
-
exports.getConfigTemplate = getConfigTemplate;
|
|
26
|
-
const readConfigFile = () => {
|
|
27
|
-
const rcFilePath = getConfigFilePath();
|
|
28
|
-
if (!(0, _file.fileExists)(rcFilePath)) {
|
|
29
|
-
throw new Error(`${_constants.CONFIG_FILE_NAME} file is missing. Please add the file in your project root dir`);
|
|
30
|
-
}
|
|
31
|
-
let rcFile = (0, _file.getFileContent)(rcFilePath);
|
|
32
|
-
if (!rcFile) {
|
|
33
|
-
throw new Error(`invalid ${_constants.CONFIG_FILE_NAME} file. Please add valid file in your project root dir`);
|
|
34
|
-
}
|
|
35
|
-
rcFile = rcFile.replace(/\/\/.+$/gm, ''); // strip comments
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
rcFile = JSON.parse(rcFile);
|
|
39
|
-
} catch (ex) {
|
|
40
|
-
throw new Error(`invalid ${_constants.CONFIG_FILE_NAME} file. Please add valid file in your project root dir`);
|
|
41
|
-
}
|
|
42
|
-
return rcFile;
|
|
43
|
-
};
|
|
44
|
-
exports.readConfigFile = readConfigFile;
|
|
45
|
-
const validateConfig = config => {
|
|
46
|
-
if (typeof config !== 'object' || Object.keys(config).length < 1) {
|
|
47
|
-
throw new Error(`empty ${_constants.CONFIG_FILE_NAME} file`);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// add required property validations
|
|
51
|
-
const missingKeys = [];
|
|
52
|
-
if (!(0, _common.allPropertyExists)(['l10nResourcePath', 'l10nReportsPath', 'supportedLocales', 'defaultLocale', 'type'], config, missingKeys)) {
|
|
53
|
-
throw new Error(`following properties are missing in ${_constants.CONFIG_FILE_NAME} file: ${(0, _common.arr2Txt)(missingKeys)}`);
|
|
54
|
-
}
|
|
55
|
-
if (!Object.values(_constants.SYSTEM_TYPES).includes(config?.type || '')) {
|
|
56
|
-
throw new Error(`${_constants.CONFIG_FILE_NAME} has invalid system type`);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
exports.validateConfig = validateConfig;
|
|
60
|
-
const checkAndExportConfig = (filePath, type = '') => {
|
|
61
|
-
if (filePath && !(0, _file.fileExists)(filePath)) {
|
|
62
|
-
(0, _file.saveToFile)(filePath, getConfigTemplate(type));
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
exports.checkAndExportConfig = checkAndExportConfig;
|
package/dist/utils/constants.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.USER_INPUT_PRE_FIX = exports.SYSTEM_TYPES = exports.SUPPORTED_REPORT_TYPES = exports.STATUS_INFO = exports.STATUS_COLOR = exports.RES_FILE_EXTENSIONS = exports.REPORT_COUNTS = exports.PATTERNS = exports.I18N_STATUS = exports.GARBLED_CHARACTERS = exports.DEFAULT_REPORT_NAME = exports.DEBUG_MODE = exports.CONFIG_FILE_NAME = exports.COMMON_XPATH = exports.COLOR = exports.CACHE_FILE_NAME = void 0;
|
|
7
|
-
const SYSTEM_TYPES = exports.SYSTEM_TYPES = {
|
|
8
|
-
NIGHT_WATCH: 'nightwatch',
|
|
9
|
-
WEB_DRIVER_IO: 'webio',
|
|
10
|
-
CYPRESS: 'cypress',
|
|
11
|
-
SELENIUMJS: 'seleniumJS'
|
|
12
|
-
};
|
|
13
|
-
const COLOR = exports.COLOR = {
|
|
14
|
-
GRB_GREEN: 'rgb(0, 154, 61)',
|
|
15
|
-
GRB_RED: 'rgb(255, 0, 0)',
|
|
16
|
-
GRB_YELLOW: 'rgb(255, 255, 0)',
|
|
17
|
-
GRB_BLUE: 'rgb(0, 0, 255)',
|
|
18
|
-
GRB_ORANGE: 'rgb(255, 165, 0)',
|
|
19
|
-
HEX_GREEN: '#007C00',
|
|
20
|
-
HEX_RED: '#F70000',
|
|
21
|
-
HEX_YELLOW: '#F7F700',
|
|
22
|
-
HEX_ORANGE: '#F76300',
|
|
23
|
-
ANSI_GREEN: '\x1b[32m',
|
|
24
|
-
ANSI_RED: '\x1b[31m',
|
|
25
|
-
ANSI_YELLOW: '\x1b[33m',
|
|
26
|
-
ANSI_BLUE: '\x1b[34m',
|
|
27
|
-
ANSI_ORANGE: '\x1b[91m'
|
|
28
|
-
};
|
|
29
|
-
const I18N_STATUS = exports.I18N_STATUS = {
|
|
30
|
-
STRING_LOCALIZED: 'STRING_LOCALIZED',
|
|
31
|
-
STRING_PARTIALLY_LOCALIZED: 'STRING_PARTIALLY_LOCALIZED',
|
|
32
|
-
NUMBER_LOCALIZED: 'NUMBER_LOCALIZED',
|
|
33
|
-
CURRENCY_LOCALIZED: 'CURRENCY_LOCALIZED',
|
|
34
|
-
PERCENTAGE_LOCALIZED: 'PERCENTAGE_LOCALIZED',
|
|
35
|
-
DATE_LOCALIZED: 'DATE_LOCALIZED',
|
|
36
|
-
TIME_LOCALIZED: 'TIME_LOCALIZED',
|
|
37
|
-
DATE_TIME_LOCALIZED: 'DATE_TIME_LOCALIZED',
|
|
38
|
-
STRING_NOT_LOCALIZED: 'STRING_NOT_LOCALIZED',
|
|
39
|
-
NUMBER_NOT_LOCALIZED: 'NUMBER_NOT_LOCALIZED',
|
|
40
|
-
CURRENCY_NOT_LOCALIZED: 'CURRENCY_NOT_LOCALIZED',
|
|
41
|
-
PERCENTAGE_NOT_LOCALIZED: 'PERCENTAGE_NOT_LOCALIZED',
|
|
42
|
-
DATE_NOT_LOCALIZED: 'DATE_NOT_LOCALIZED',
|
|
43
|
-
TIME_NOT_LOCALIZED: 'TIME_NOT_LOCALIZED',
|
|
44
|
-
DATE_TIME_NOT_LOCALIZED: 'DATE_TIME_NOT_LOCALIZED',
|
|
45
|
-
TRUNCATION_ISSUE: 'TRUNCATION_ISSUE',
|
|
46
|
-
OVERLAPPING_ISSUE: 'OVERLAPPING_ISSUE',
|
|
47
|
-
ENCODING_ISSUE: 'ENCODING_ISSUE',
|
|
48
|
-
DNT: 'DNT',
|
|
49
|
-
IGNORE: 'IGNORE',
|
|
50
|
-
UNTRANSLATED: 'UNTRANSLATED',
|
|
51
|
-
AUTO_IGNORE: 'AUTO_IGNORE',
|
|
52
|
-
USER_INPUT: 'USER_INPUT',
|
|
53
|
-
REVIEWED: 'REVIEWED'
|
|
54
|
-
};
|
|
55
|
-
const REPORT_COUNTS = exports.REPORT_COUNTS = {
|
|
56
|
-
[I18N_STATUS.STRING_LOCALIZED]: 0,
|
|
57
|
-
[I18N_STATUS.STRING_NOT_LOCALIZED]: 0,
|
|
58
|
-
[I18N_STATUS.STRING_PARTIALLY_LOCALIZED]: 0,
|
|
59
|
-
[I18N_STATUS.NUMBER_LOCALIZED]: 0,
|
|
60
|
-
[I18N_STATUS.NUMBER_NOT_LOCALIZED]: 0,
|
|
61
|
-
[I18N_STATUS.DATE_LOCALIZED]: 0,
|
|
62
|
-
[I18N_STATUS.DATE_NOT_LOCALIZED]: 0,
|
|
63
|
-
[I18N_STATUS.DATE_TIME_LOCALIZED]: 0,
|
|
64
|
-
[I18N_STATUS.DATE_TIME_NOT_LOCALIZED]: 0,
|
|
65
|
-
[I18N_STATUS.TIME_LOCALIZED]: 0,
|
|
66
|
-
[I18N_STATUS.TIME_NOT_LOCALIZED]: 0,
|
|
67
|
-
[I18N_STATUS.CURRENCY_LOCALIZED]: 0,
|
|
68
|
-
[I18N_STATUS.CURRENCY_NOT_LOCALIZED]: 0,
|
|
69
|
-
[I18N_STATUS.PERCENTAGE_LOCALIZED]: 0,
|
|
70
|
-
[I18N_STATUS.PERCENTAGE_NOT_LOCALIZED]: 0,
|
|
71
|
-
[I18N_STATUS.TRUNCATION_ISSUE]: 0,
|
|
72
|
-
[I18N_STATUS.OVERLAPPING_ISSUE]: 0,
|
|
73
|
-
[I18N_STATUS.ENCODING_ISSUE]: 0,
|
|
74
|
-
[I18N_STATUS.DNT]: 0,
|
|
75
|
-
[I18N_STATUS.IGNORE]: 0,
|
|
76
|
-
[I18N_STATUS.UNTRANSLATED]: 0,
|
|
77
|
-
[I18N_STATUS.AUTO_IGNORE]: 0,
|
|
78
|
-
[I18N_STATUS.USER_INPUT]: 0,
|
|
79
|
-
[I18N_STATUS.REVIEWED]: 0
|
|
80
|
-
};
|
|
81
|
-
const STATUS_COLOR = exports.STATUS_COLOR = {
|
|
82
|
-
[I18N_STATUS.STRING_LOCALIZED]: [COLOR.GRB_GREEN, COLOR.ANSI_GREEN],
|
|
83
|
-
[I18N_STATUS.STRING_PARTIALLY_LOCALIZED]: [COLOR.GRB_YELLOW, COLOR.ANSI_YELLOW],
|
|
84
|
-
[I18N_STATUS.NUMBER_LOCALIZED]: [COLOR.GRB_GREEN, COLOR.ANSI_GREEN],
|
|
85
|
-
[I18N_STATUS.DATE_LOCALIZED]: [COLOR.GRB_GREEN, COLOR.ANSI_GREEN],
|
|
86
|
-
[I18N_STATUS.TIME_LOCALIZED]: [COLOR.GRB_GREEN, COLOR.ANSI_GREEN],
|
|
87
|
-
[I18N_STATUS.DATE_TIME_LOCALIZED]: [COLOR.GRB_GREEN, COLOR.ANSI_GREEN],
|
|
88
|
-
[I18N_STATUS.CURRENCY_LOCALIZED]: [COLOR.GRB_GREEN, COLOR.ANSI_GREEN],
|
|
89
|
-
[I18N_STATUS.PERCENTAGE_LOCALIZED]: [COLOR.GRB_GREEN, COLOR.ANSI_GREEN],
|
|
90
|
-
[I18N_STATUS.STRING_NOT_LOCALIZED]: [COLOR.GRB_RED, COLOR.ANSI_RED],
|
|
91
|
-
[I18N_STATUS.DATE_NOT_LOCALIZED]: [COLOR.GRB_RED, COLOR.ANSI_RED],
|
|
92
|
-
[I18N_STATUS.DATE_TIME_NOT_LOCALIZED]: [COLOR.GRB_RED, COLOR.ANSI_RED],
|
|
93
|
-
[I18N_STATUS.TIME_NOT_LOCALIZED]: [COLOR.GRB_RED, COLOR.ANSI_RED],
|
|
94
|
-
[I18N_STATUS.NUMBER_NOT_LOCALIZED]: [COLOR.GRB_RED, COLOR.ANSI_RED],
|
|
95
|
-
[I18N_STATUS.CURRENCY_NOT_LOCALIZED]: [COLOR.GRB_RED, COLOR.ANSI_RED],
|
|
96
|
-
[I18N_STATUS.PERCENTAGE_NOT_LOCALIZED]: [COLOR.GRB_RED, COLOR.ANSI_RED],
|
|
97
|
-
[I18N_STATUS.TRUNCATION_ISSUE]: [COLOR.GRB_RED, COLOR.ANSI_RED],
|
|
98
|
-
[I18N_STATUS.OVERLAPPING_ISSUE]: [COLOR.GRB_RED, COLOR.ANSI_RED],
|
|
99
|
-
[I18N_STATUS.ENCODING_ISSUE]: [COLOR.GRB_RED, COLOR.ANSI_RED],
|
|
100
|
-
[I18N_STATUS.DNT]: [COLOR.GRB_GREEN, COLOR.ANSI_GREEN],
|
|
101
|
-
[I18N_STATUS.IGNORE]: [COLOR.GRB_GREEN, COLOR.ANSI_GREEN],
|
|
102
|
-
[I18N_STATUS.UNTRANSLATED]: [COLOR.GRB_GREEN, COLOR.ANSI_GREEN],
|
|
103
|
-
[I18N_STATUS.AUTO_IGNORE]: [COLOR.GRB_GREEN, COLOR.ANSI_GREEN],
|
|
104
|
-
[I18N_STATUS.USER_INPUT]: [COLOR.GRB_GREEN, COLOR.ANSI_GREEN],
|
|
105
|
-
[I18N_STATUS.REVIEWED]: [COLOR.GRB_GREEN, COLOR.ANSI_GREEN]
|
|
106
|
-
};
|
|
107
|
-
const STATUS_INFO = exports.STATUS_INFO = {
|
|
108
|
-
[I18N_STATUS.STRING_LOCALIZED]: 'String is localized',
|
|
109
|
-
[I18N_STATUS.STRING_PARTIALLY_LOCALIZED]: 'String is partially localized',
|
|
110
|
-
[I18N_STATUS.NUMBER_LOCALIZED]: 'Number is localized',
|
|
111
|
-
[I18N_STATUS.DATE_LOCALIZED]: 'Date is localized',
|
|
112
|
-
[I18N_STATUS.DATE_TIME_LOCALIZED]: 'DateTime is localized',
|
|
113
|
-
[I18N_STATUS.TIME_LOCALIZED]: 'Time is localized',
|
|
114
|
-
[I18N_STATUS.CURRENCY_LOCALIZED]: 'Currency is localized',
|
|
115
|
-
[I18N_STATUS.PERCENTAGE_LOCALIZED]: 'Percentage is localized',
|
|
116
|
-
[I18N_STATUS.STRING_NOT_LOCALIZED]: 'String is not localized',
|
|
117
|
-
[I18N_STATUS.DATE_NOT_LOCALIZED]: 'Date is not localized',
|
|
118
|
-
[I18N_STATUS.DATE_TIME_NOT_LOCALIZED]: 'DateTime is not localized',
|
|
119
|
-
[I18N_STATUS.TIME_NOT_LOCALIZED]: 'Time is not localized',
|
|
120
|
-
[I18N_STATUS.NUMBER_NOT_LOCALIZED]: 'Number is not localized',
|
|
121
|
-
[I18N_STATUS.CURRENCY_NOT_LOCALIZED]: 'Currency is not localized',
|
|
122
|
-
[I18N_STATUS.PERCENTAGE_NOT_LOCALIZED]: 'Percentage is not localized',
|
|
123
|
-
[I18N_STATUS.TRUNCATION_ISSUE]: 'Truncation issue detected',
|
|
124
|
-
[I18N_STATUS.OVERLAPPING_ISSUE]: 'Overlapping issue detected',
|
|
125
|
-
[I18N_STATUS.ENCODING_ISSUE]: 'Encoding issue detected',
|
|
126
|
-
[I18N_STATUS.DNT]: 'Do not translate',
|
|
127
|
-
[I18N_STATUS.IGNORE]: 'Ignored this issue',
|
|
128
|
-
[I18N_STATUS.UNTRANSLATED]: 'String is untranslated',
|
|
129
|
-
[I18N_STATUS.AUTO_IGNORE]: 'Automatically ignored issue',
|
|
130
|
-
[I18N_STATUS.USER_INPUT]: 'User input field',
|
|
131
|
-
[I18N_STATUS.REVIEWED]: 'Issue has been reviewed'
|
|
132
|
-
};
|
|
133
|
-
const PATTERNS = exports.PATTERNS = {
|
|
134
|
-
EMAIL: /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}\b/gi,
|
|
135
|
-
URL: /^(https?:\/\/)?(www\.)?[a-zA-Z0-9-]+\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/
|
|
136
|
-
};
|
|
137
|
-
const USER_INPUT_PRE_FIX = exports.USER_INPUT_PRE_FIX = 'zqa_';
|
|
138
|
-
const RES_FILE_EXTENSIONS = exports.RES_FILE_EXTENSIONS = ['.txt', '.json'];
|
|
139
|
-
const COMMON_XPATH = exports.COMMON_XPATH = `//*[string-length(normalize-space(text())) > 0 and not(ancestor-or-self::*/@style[contains(.,'display:none')]) or @placeholder] | //input[@type='checkbox']/parent::*[text() and not(ancestor-or-self::*/@style[contains(.,'display:none')])]`;
|
|
140
|
-
const DEBUG_MODE = exports.DEBUG_MODE = true;
|
|
141
|
-
const GARBLED_CHARACTERS = exports.GARBLED_CHARACTERS = ['☐', '�', '', 'â€', 'î', 'ÃÂ', 'ÃÂ', 'ü', 'é', 'é', 'æ•°', 'æ®', 'ラã'];
|
|
142
|
-
const CONFIG_FILE_NAME = exports.CONFIG_FILE_NAME = '.i18n-verify.rc';
|
|
143
|
-
const SUPPORTED_REPORT_TYPES = exports.SUPPORTED_REPORT_TYPES = {
|
|
144
|
-
HTML: 'html',
|
|
145
|
-
ASCII_TABLE: 'ascii_table'
|
|
146
|
-
};
|
|
147
|
-
const CACHE_FILE_NAME = exports.CACHE_FILE_NAME = 'metrics.cache';
|
|
148
|
-
const DEFAULT_REPORT_NAME = exports.DEFAULT_REPORT_NAME = 'report';
|
package/dist/utils/cypress.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.xpath = void 0;
|
|
7
|
-
const xpath = ({
|
|
8
|
-
subject,
|
|
9
|
-
selector,
|
|
10
|
-
options = {},
|
|
11
|
-
driver
|
|
12
|
-
}) => {
|
|
13
|
-
if (!Cypress) {
|
|
14
|
-
driver.printOnConsole('Cypress object is inaccessible');
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/* global XPathResult */
|
|
19
|
-
const isNumber = xpathResult => xpathResult.resultType === XPathResult.NUMBER_TYPE;
|
|
20
|
-
const numberResult = xpathResult => xpathResult.numberValue;
|
|
21
|
-
const isString = xpathResult => xpathResult.resultType === XPathResult.STRING_TYPE;
|
|
22
|
-
const stringResult = xpathResult => xpathResult.stringValue;
|
|
23
|
-
const isBoolean = xpathResult => xpathResult.resultType === XPathResult.BOOLEAN_TYPE;
|
|
24
|
-
const booleanResult = xpathResult => xpathResult.booleanValue;
|
|
25
|
-
const isPrimitive = x => Cypress._.isNumber(x) || Cypress._.isString(x) || Cypress._.isBoolean(x);
|
|
26
|
-
|
|
27
|
-
// options to log later
|
|
28
|
-
const log = {
|
|
29
|
-
name: 'xpath',
|
|
30
|
-
message: selector
|
|
31
|
-
};
|
|
32
|
-
if (Cypress.dom.isElement(subject) && subject.length > 1) {
|
|
33
|
-
throw new Error('xpath() can only be called on a single element. Your subject contained ' + subject.length + ' elements.');
|
|
34
|
-
}
|
|
35
|
-
const getValue = () => {
|
|
36
|
-
let nodes = [];
|
|
37
|
-
let contextNode;
|
|
38
|
-
let withinSubject = cy.state('withinSubject');
|
|
39
|
-
if (Cypress.dom.isElement(subject)) {
|
|
40
|
-
contextNode = subject[0];
|
|
41
|
-
} else if (Cypress.dom.isDocument(subject)) {
|
|
42
|
-
contextNode = subject;
|
|
43
|
-
} else if (withinSubject) {
|
|
44
|
-
contextNode = withinSubject[0];
|
|
45
|
-
} else {
|
|
46
|
-
contextNode = cy.state('window').document;
|
|
47
|
-
}
|
|
48
|
-
let iterator = (contextNode.ownerDocument || contextNode).evaluate(selector, contextNode);
|
|
49
|
-
if (isNumber(iterator)) {
|
|
50
|
-
const result = numberResult(iterator);
|
|
51
|
-
log.consoleProps = () => {
|
|
52
|
-
return {
|
|
53
|
-
XPath: selector,
|
|
54
|
-
type: 'number',
|
|
55
|
-
result
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
if (isString(iterator)) {
|
|
61
|
-
const result = stringResult(iterator);
|
|
62
|
-
log.consoleProps = () => {
|
|
63
|
-
return {
|
|
64
|
-
XPath: selector,
|
|
65
|
-
type: 'string',
|
|
66
|
-
result
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
71
|
-
if (isBoolean(iterator)) {
|
|
72
|
-
const result = booleanResult(iterator);
|
|
73
|
-
log.consoleProps = () => {
|
|
74
|
-
return {
|
|
75
|
-
XPath: selector,
|
|
76
|
-
type: 'boolean',
|
|
77
|
-
result
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
let node = iterator.iterateNext();
|
|
84
|
-
while (node) {
|
|
85
|
-
nodes.push(node);
|
|
86
|
-
node = iterator.iterateNext();
|
|
87
|
-
}
|
|
88
|
-
log.consoleProps = () => {
|
|
89
|
-
return {
|
|
90
|
-
XPath: selector,
|
|
91
|
-
result: nodes.length === 1 ? nodes[0] : nodes
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
return nodes;
|
|
95
|
-
} catch (e) {
|
|
96
|
-
console.error('Document tree modified during iteration', e);
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
const resolveValue = () => {
|
|
101
|
-
return Cypress.Promise.try(getValue).then(value => {
|
|
102
|
-
if (!isPrimitive(value)) {
|
|
103
|
-
value = Cypress.$(value);
|
|
104
|
-
// Add the ".selector" property because Cypress uses it for error messages
|
|
105
|
-
value.selector = selector;
|
|
106
|
-
}
|
|
107
|
-
return cy.verifyUpcomingAssertions(value, options, {
|
|
108
|
-
onRetry: resolveValue
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
return resolveValue().then(value => {
|
|
113
|
-
if (options.log !== false) {
|
|
114
|
-
// TODO set found elements on the command log?
|
|
115
|
-
Cypress.log(log);
|
|
116
|
-
}
|
|
117
|
-
return value;
|
|
118
|
-
}).catch(ex => console.log(ex));
|
|
119
|
-
};
|
|
120
|
-
exports.xpath = xpath;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isValid = exports.getParser = void 0;
|
|
7
|
-
var _chronoNode = require("chrono-node");
|
|
8
|
-
const getParser = locale => {
|
|
9
|
-
let [lang = 'en', country = 'us'] = locale.split(/[-_ ]/g);
|
|
10
|
-
country = String(country).toLowerCase();
|
|
11
|
-
switch (lang) {
|
|
12
|
-
case 'en':
|
|
13
|
-
return country === 'gb' ? _chronoNode.en.GB : _chronoNode.en;
|
|
14
|
-
case 'de':
|
|
15
|
-
return _chronoNode.de;
|
|
16
|
-
case 'es':
|
|
17
|
-
return _chronoNode.es;
|
|
18
|
-
case 'fr':
|
|
19
|
-
return _chronoNode.fr;
|
|
20
|
-
case 'pt':
|
|
21
|
-
return _chronoNode.pt;
|
|
22
|
-
case 'ja':
|
|
23
|
-
return _chronoNode.ja;
|
|
24
|
-
case 'zh':
|
|
25
|
-
if (['hans', 'cn', 'sg', 'hans-cn'].includes(country)) {
|
|
26
|
-
return _chronoNode.zh.hans;
|
|
27
|
-
} else if (['hant', 'tw', 'hk', 'mo', 'hant-tw'].includes(country)) {
|
|
28
|
-
return _chronoNode.zh.hant;
|
|
29
|
-
}
|
|
30
|
-
return _chronoNode.zh;
|
|
31
|
-
case 'ru':
|
|
32
|
-
return _chronoNode.ru;
|
|
33
|
-
case 'nl':
|
|
34
|
-
return _chronoNode.nl;
|
|
35
|
-
case 'uk':
|
|
36
|
-
return _chronoNode.uk;
|
|
37
|
-
default:
|
|
38
|
-
return _chronoNode.en;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// performs strict validation rather than loose parsing
|
|
43
|
-
exports.getParser = getParser;
|
|
44
|
-
const isValid = (locale, string) => {
|
|
45
|
-
string = String(string);
|
|
46
|
-
const parsedResults = getParser(locale).parse(String(string).trim());
|
|
47
|
-
parsedResults.forEach(r => {
|
|
48
|
-
string = string.replace(r.text, '');
|
|
49
|
-
});
|
|
50
|
-
return string.replace(/[^\p{L}\p{N}]+/gu, '').trim().length === 0;
|
|
51
|
-
};
|
|
52
|
-
exports.isValid = isValid;
|
package/dist/utils/file.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.saveToFile = exports.pathExists = exports.joinPaths = exports.getFileName = exports.getFileExtenstion = exports.getFileContent = exports.getDirPath = exports.getDirContents = exports.fileExists = exports.ensureDirectoryExists = exports.dirExists = exports.deleteFile = exports.createFolder = exports.addContentToFile = void 0;
|
|
7
|
-
var _fs = require("fs");
|
|
8
|
-
var _path = require("path");
|
|
9
|
-
var _logs = _interopRequireDefault(require("./logs.js"));
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
const getFileName = path => (0, _path.basename)(path);
|
|
12
|
-
exports.getFileName = getFileName;
|
|
13
|
-
const dirExists = path => pathExists(path) && (0, _fs.statSync)(path).isDirectory();
|
|
14
|
-
exports.dirExists = dirExists;
|
|
15
|
-
const fileExists = path => pathExists(path) && (0, _fs.statSync)(path).isFile();
|
|
16
|
-
exports.fileExists = fileExists;
|
|
17
|
-
const pathExists = path => (0, _fs.existsSync)(path);
|
|
18
|
-
exports.pathExists = pathExists;
|
|
19
|
-
const createFolder = path => !pathExists(path) && (0, _fs.mkdirSync)(path, {
|
|
20
|
-
recursive: true
|
|
21
|
-
});
|
|
22
|
-
exports.createFolder = createFolder;
|
|
23
|
-
const ensureDirectoryExists = (path, log = true) => {
|
|
24
|
-
if (!pathExists(path) || !dirExists(path)) {
|
|
25
|
-
log && _logs.default.debug(`Folder doesn't exists, creating \x1b[34m${path}\x1b[0m`);
|
|
26
|
-
createFolder(path);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
exports.ensureDirectoryExists = ensureDirectoryExists;
|
|
30
|
-
const getFileContent = path => fileExists(path) ? (0, _fs.readFileSync)(path, {
|
|
31
|
-
encoding: 'utf-8'
|
|
32
|
-
}) : '';
|
|
33
|
-
exports.getFileContent = getFileContent;
|
|
34
|
-
const getDirContents = path => dirExists(path) ? (0, _fs.readdirSync)(path) : [];
|
|
35
|
-
exports.getDirContents = getDirContents;
|
|
36
|
-
const getFileExtenstion = path => fileExists(path) ? (0, _path.extname)(path) : '';
|
|
37
|
-
exports.getFileExtenstion = getFileExtenstion;
|
|
38
|
-
const joinPaths = (...paths) => (0, _path.join)(...paths);
|
|
39
|
-
exports.joinPaths = joinPaths;
|
|
40
|
-
const saveToFile = (path, content, encoding = 'utf-8') => (0, _fs.writeFileSync)(path, content, {
|
|
41
|
-
encoding
|
|
42
|
-
});
|
|
43
|
-
exports.saveToFile = saveToFile;
|
|
44
|
-
const addContentToFile = (path, content, encoding = 'utf-8') => {
|
|
45
|
-
if (!path || !content) return;
|
|
46
|
-
try {
|
|
47
|
-
(0, _fs.appendFileSync)(path, content + '\n', {
|
|
48
|
-
encoding,
|
|
49
|
-
flag: 'a'
|
|
50
|
-
});
|
|
51
|
-
} catch (err) {
|
|
52
|
-
_logs.default.error(err);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
exports.addContentToFile = addContentToFile;
|
|
56
|
-
const deleteFile = (path, recursive = false) => pathExists(path) && (0, _fs.rmSync)(path, {
|
|
57
|
-
recursive
|
|
58
|
-
});
|
|
59
|
-
exports.deleteFile = deleteFile;
|
|
60
|
-
const getDirPath = filePath => (0, _path.dirname)(filePath);
|
|
61
|
-
exports.getDirPath = getDirPath;
|
package/dist/utils/graphic.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _jimp = _interopRequireDefault(require("jimp"));
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
10
|
-
var _logs = _interopRequireDefault(require("./logs.js"));
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
class Graphic {
|
|
13
|
-
/**
|
|
14
|
-
* Draws a rectangle on an image.
|
|
15
|
-
* @param {object} eleRec - The element rectangle object.
|
|
16
|
-
* @param {string} color - The color of the rectangle border.
|
|
17
|
-
* @param {string} report_img - The path to the image file.
|
|
18
|
-
*/
|
|
19
|
-
static async drawRectangle(eleRec, color, report_img) {
|
|
20
|
-
const rectX = eleRec?.x - 2;
|
|
21
|
-
const rectY = eleRec?.y - 2;
|
|
22
|
-
const rectWidth = eleRec?.width + 2;
|
|
23
|
-
const rectHeight = eleRec?.height + 2;
|
|
24
|
-
const thickness = 2;
|
|
25
|
-
try {
|
|
26
|
-
const image = await _jimp.default.read(report_img);
|
|
27
|
-
const rectangleColor = _jimp.default.cssColorToHex(color);
|
|
28
|
-
this.drawRectangleOutline(image, rectX, rectY, rectWidth, rectHeight, rectangleColor, thickness);
|
|
29
|
-
const targetDir = _path.default.dirname(report_img);
|
|
30
|
-
const buffer = await image.getBufferAsync(_jimp.default.MIME_PNG);
|
|
31
|
-
if (!_fs.default.existsSync(targetDir)) {
|
|
32
|
-
_logs.default.debug('folder not found');
|
|
33
|
-
_fs.default.mkdirSync(targetDir, {
|
|
34
|
-
recursive: true
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
_fs.default.writeFileSync(report_img, buffer);
|
|
38
|
-
} catch (err) {
|
|
39
|
-
_logs.default.error(`Error: ${err}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
static async drawRectangleOutline(image, x, y, width, height, color, thickness) {
|
|
43
|
-
for (let i = x; i < x + width; i++) {
|
|
44
|
-
for (let t = 0; t < thickness; t++) {
|
|
45
|
-
image.setPixelColor(color, i, y + t);
|
|
46
|
-
image.setPixelColor(color, i, y + height - 1 - t);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
for (let j = y; j < y + height; j++) {
|
|
50
|
-
for (let t = 0; t < thickness; t++) {
|
|
51
|
-
image.setPixelColor(color, x + t, j);
|
|
52
|
-
image.setPixelColor(color, x + width - 1 - t, j);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.default = Graphic;
|
package/dist/utils/logs.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _constants = require("../utils/constants.js");
|
|
8
|
-
var _file = require("./file.js");
|
|
9
|
-
var _reports = _interopRequireDefault(require("../lib/reports.js"));
|
|
10
|
-
var _config = _interopRequireDefault(require("../lib/config.js"));
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
const fs = require('fs');
|
|
13
|
-
class Logger {
|
|
14
|
-
static #isLogAppending = false;
|
|
15
|
-
static #appenderInterval;
|
|
16
|
-
static #appenderQueue = [];
|
|
17
|
-
static info(message) {
|
|
18
|
-
Logger.#print('info', message);
|
|
19
|
-
}
|
|
20
|
-
static warn(message) {
|
|
21
|
-
Logger.#print('warn', message);
|
|
22
|
-
}
|
|
23
|
-
static error(message) {
|
|
24
|
-
Logger.#print('errr', message);
|
|
25
|
-
}
|
|
26
|
-
static debug(message) {
|
|
27
|
-
Logger.#print('dbug', message);
|
|
28
|
-
}
|
|
29
|
-
static #print(type, message) {
|
|
30
|
-
const colors = {
|
|
31
|
-
INFO: '\x1b[37m',
|
|
32
|
-
WARN: '\x1b[33m',
|
|
33
|
-
ERRR: '\x1b[31m',
|
|
34
|
-
DBUG: '\x1b[34m'
|
|
35
|
-
};
|
|
36
|
-
type = type.toUpperCase();
|
|
37
|
-
let color = colors[type] || colors.DEFAULT;
|
|
38
|
-
let logMessage = `[${new Date().toLocaleString()}] [${color}${type}\x1b[0m] [${_config.default.getLocale()}] - ${message}`;
|
|
39
|
-
switch (type) {
|
|
40
|
-
case 'INFO':
|
|
41
|
-
_constants.DEBUG_MODE && console.info(logMessage);
|
|
42
|
-
break;
|
|
43
|
-
case 'WARN':
|
|
44
|
-
_constants.DEBUG_MODE && console.warn(logMessage);
|
|
45
|
-
break;
|
|
46
|
-
case 'ERRR':
|
|
47
|
-
console.error(logMessage);
|
|
48
|
-
break;
|
|
49
|
-
case 'DBUG':
|
|
50
|
-
_constants.DEBUG_MODE && console.debug(logMessage);
|
|
51
|
-
break;
|
|
52
|
-
default:
|
|
53
|
-
_constants.DEBUG_MODE && console.log(logMessage);
|
|
54
|
-
}
|
|
55
|
-
logMessage = logMessage.replace(/\x1b\[\d+m/g, '');
|
|
56
|
-
Logger.#customLog(`${logMessage}\n`);
|
|
57
|
-
}
|
|
58
|
-
static #customLog = message => {
|
|
59
|
-
if (Logger.#isLogAppending) {
|
|
60
|
-
Logger.#appenderQueue.push(message);
|
|
61
|
-
Logger.#appenderInterval = setInterval(() => {
|
|
62
|
-
if (!Logger.#isLogAppending) {
|
|
63
|
-
clearInterval(Logger.#appenderInterval);
|
|
64
|
-
message = Logger.#appenderQueue.join('\n');
|
|
65
|
-
Logger.#appenderQueue = [];
|
|
66
|
-
message && Logger.#customLog(message);
|
|
67
|
-
}
|
|
68
|
-
}, 10);
|
|
69
|
-
} else {
|
|
70
|
-
Logger.#isLogAppending = true;
|
|
71
|
-
const LOGS_DIR = (0, _file.joinPaths)(_reports.default.getReportPath(), 'logs');
|
|
72
|
-
const logFilePath = (0, _file.joinPaths)(LOGS_DIR, 'log');
|
|
73
|
-
(0, _file.ensureDirectoryExists)(LOGS_DIR, _constants.DEBUG_MODE);
|
|
74
|
-
fs.appendFileSync(logFilePath, message);
|
|
75
|
-
Logger.#isLogAppending = false;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
exports.default = Logger;
|