@zeesoft/i18n-verify 1.0.0
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/driver/adapters/cypress.js +160 -0
- package/dist/driver/adapters/nightwatch.js +95 -0
- package/dist/driver/adapters/selenium.js +94 -0
- package/dist/driver/adapters/webdriver.io.js +81 -0
- package/dist/driver/baseDriver.js +69 -0
- package/dist/driver/factory.js +27 -0
- package/dist/index.js +47 -0
- package/dist/lib/config.js +99 -0
- package/dist/lib/i18n.js +177 -0
- package/dist/lib/validator/base.js +125 -0
- package/dist/lib/validator/currency.js +94 -0
- package/dist/lib/validator/date.js +72 -0
- package/dist/lib/validator/datetime.js +72 -0
- package/dist/lib/validator/index.js +156 -0
- package/dist/lib/validator/number.js +58 -0
- package/dist/lib/validator/percentage.js +78 -0
- package/dist/lib/validator/string.js +172 -0
- package/dist/lib/validator/time.js +72 -0
- package/dist/utils/2Dgraphic.js +57 -0
- package/dist/utils/cache.js +47 -0
- package/dist/utils/common.js +18 -0
- package/dist/utils/configFile.js +64 -0
- package/dist/utils/constants.js +145 -0
- package/dist/utils/cypress.js +120 -0
- package/dist/utils/dateUtils/chronoNode.js +52 -0
- package/dist/utils/file.js +57 -0
- package/dist/utils/logs.js +61 -0
- package/dist/utils/objects/cacheData.js +91 -0
- package/dist/utils/objects/metaData.js +48 -0
- package/dist/utils/objects/reportData.js +48 -0
- package/dist/utils/objects/statData.js +365 -0
- package/dist/utils/objects/stringData.js +67 -0
- package/dist/utils/objects/stringInfo.js +51 -0
- package/dist/utils/regex.js +8 -0
- package/dist/utils/reportFactory/base.js +51 -0
- package/dist/utils/reportFactory/html/index.js +36 -0
- package/dist/utils/reportFactory/html/template/css.js +133 -0
- package/dist/utils/reportFactory/html/template/html.js +79 -0
- package/dist/utils/reportFactory/html/template/javascript.js +106 -0
- package/dist/utils/reportFactory/index.js +38 -0
- package/dist/utils/reports.js +120 -0
- package/dist/utils/reportsTable.js +71 -0
- package/dist/utils/resource.js +54 -0
- package/dist/utils/runtime.js +16 -0
- package/dist/utils/scripts/genreport.js +1 -0
- package/dist/utils/scripts/postinstall.js +21 -0
- package/package.json +59 -0
- package/readme.md +15 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _base = _interopRequireDefault(require("./base.js"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
class NumberValidator extends _base.default {
|
|
10
|
+
constructor() {
|
|
11
|
+
super('number');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @override
|
|
17
|
+
*/
|
|
18
|
+
validate(string) {
|
|
19
|
+
return this.#isDefaultNumber(string) || this.isInternationalized(string);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @override
|
|
25
|
+
*/
|
|
26
|
+
isInternationalized(string) {
|
|
27
|
+
return this.#isValidNumber(this.currentLocale(), string);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @override
|
|
33
|
+
*/
|
|
34
|
+
buildConfig() {}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* check whether the given value is a valid number of the supplied locale
|
|
38
|
+
*
|
|
39
|
+
* @param {String} locale
|
|
40
|
+
* @param {String} string
|
|
41
|
+
* @returns {Boolean}
|
|
42
|
+
*/
|
|
43
|
+
#isValidNumber(locale, string) {
|
|
44
|
+
const parser = this.getGlobalize(locale).numberParser();
|
|
45
|
+
return !isNaN(parser(string));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* check whether the given value is a valid number of default locale
|
|
50
|
+
*
|
|
51
|
+
* @param {String} string
|
|
52
|
+
* @returns {Boolean}
|
|
53
|
+
*/
|
|
54
|
+
#isDefaultNumber(string) {
|
|
55
|
+
return this.#isValidNumber(this.defaultLocale(), string);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.default = NumberValidator;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _regex = require("../../utils/regex.js");
|
|
8
|
+
var _base = _interopRequireDefault(require("./base.js"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
class PercentageValidator extends _base.default {
|
|
11
|
+
constructor() {
|
|
12
|
+
super('percentage');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @override
|
|
18
|
+
*/
|
|
19
|
+
validate(string) {
|
|
20
|
+
return this.#isDefaultPercentage(string) || this.isInternationalized(string);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @override
|
|
26
|
+
*/
|
|
27
|
+
isInternationalized(string) {
|
|
28
|
+
return this.#isValidPercentage(this.currentLocale(), string);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @override
|
|
34
|
+
*/
|
|
35
|
+
buildConfig() {}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* check whether the given value is a valid percentage of the supplied locale
|
|
39
|
+
*
|
|
40
|
+
* @param {String} locale
|
|
41
|
+
* @param {String} string
|
|
42
|
+
* @returns {Boolean}
|
|
43
|
+
*/
|
|
44
|
+
#isValidPercentage(locale, string) {
|
|
45
|
+
const hasPercentageSymbol = this.#hasPercentage(locale, string);
|
|
46
|
+
if (!hasPercentageSymbol) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const clearNumber = this.#getClearNumber(string);
|
|
50
|
+
return !isNaN(this.getGlobalize(locale).numberParser()(clearNumber));
|
|
51
|
+
}
|
|
52
|
+
#getClearNumber(string = '') {
|
|
53
|
+
return string.replace(new RegExp(`(^(?:${(0, _regex.getSpacePattern)()})*|(?:${(0, _regex.getSpacePattern)()})*$)`, 'g'), '').replace(/^-/, '').replace(/٪|%/g, '').trim();
|
|
54
|
+
}
|
|
55
|
+
#hasPercentage(locale, string) {
|
|
56
|
+
const baseNumber = '[0-9,. ]+';
|
|
57
|
+
let pattern;
|
|
58
|
+
|
|
59
|
+
// in persian and arabic contexts, percentage comes before the number
|
|
60
|
+
if (['fa-IR', 'fa-ir'].includes(locale) || locale.startsWith('ar')) {
|
|
61
|
+
pattern = new RegExp(`(?:-)?(?:${(0, _regex.getSpacePattern)()})?(?:٪|%)(?:${(0, _regex.getSpacePattern)()})?${baseNumber}`, 'g');
|
|
62
|
+
} else {
|
|
63
|
+
pattern = new RegExp(`(?:-)?(?:${(0, _regex.getSpacePattern)()})?${baseNumber}(?:${(0, _regex.getSpacePattern)()})?(?:٪|%)`, 'g');
|
|
64
|
+
}
|
|
65
|
+
return pattern.test(string);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* check whether the given value is a valid percentage of default locale
|
|
70
|
+
*
|
|
71
|
+
* @param {String} string
|
|
72
|
+
* @returns {Boolean}
|
|
73
|
+
*/
|
|
74
|
+
#isDefaultPercentage(string) {
|
|
75
|
+
return this.#isValidPercentage(this.defaultLocale(), string);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.default = PercentageValidator;
|
|
@@ -0,0 +1,172 @@
|
|
|
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 _config = _interopRequireDefault(require("../config.js"));
|
|
9
|
+
var _base = _interopRequireDefault(require("./base.js"));
|
|
10
|
+
var _tinyld = require("tinyld");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
/**
|
|
13
|
+
* String validation class
|
|
14
|
+
*/
|
|
15
|
+
class StringValidator extends _base.default {
|
|
16
|
+
constructor() {
|
|
17
|
+
super('string');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @override
|
|
23
|
+
*/
|
|
24
|
+
buildConfig() {
|
|
25
|
+
const options = _config.default.getOptions();
|
|
26
|
+
this.addToConfig('mockChars', options?.qaMock);
|
|
27
|
+
this.addToConfig('resource', _config.default.getResourceBundle(), {});
|
|
28
|
+
this.addToConfig('garbledChars', _config.default.getGarbledChars()?.filter(v => String(v).trim()).filter(Boolean), []);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @override
|
|
34
|
+
*/
|
|
35
|
+
isInternationalized(string) {
|
|
36
|
+
return this.getConfig()?.resource?.[this.defaultLocale()]?.includes(string);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @override
|
|
42
|
+
*/
|
|
43
|
+
validate(string) {
|
|
44
|
+
return typeof string === 'string'; // add more constraints
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* to check if the string is a DNT string
|
|
49
|
+
*
|
|
50
|
+
* @param {String} string
|
|
51
|
+
* @returns {Boolean}
|
|
52
|
+
*/
|
|
53
|
+
isDntText(string) {
|
|
54
|
+
return this.getConfig()?.resource?.dnt?.includes(string);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* to check if the string can be treated as an auto ingored string
|
|
59
|
+
*
|
|
60
|
+
* @param {String} string
|
|
61
|
+
* @returns {Boolean}
|
|
62
|
+
*/
|
|
63
|
+
isAutoIgnoredText(string) {
|
|
64
|
+
return this.isDefaultLocale() || this.isUserInputText(string) || this.isEmailText(string) || this.isUrlText(string);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* to check if the string is an Ignored string
|
|
69
|
+
*
|
|
70
|
+
* @param {String} string
|
|
71
|
+
* @returns {Boolean}
|
|
72
|
+
*/
|
|
73
|
+
isIgnoredText(string) {
|
|
74
|
+
return this.getConfig()?.resource?.ignore?.includes(string);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* to check if the string is a user input
|
|
79
|
+
*
|
|
80
|
+
* @param {String} string
|
|
81
|
+
* @returns {Boolean}
|
|
82
|
+
*/
|
|
83
|
+
isUserInputText(string) {
|
|
84
|
+
return string.startsWith(_constants.USER_INPUT_PRE_FIX);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* to check if the string is a email string
|
|
89
|
+
*
|
|
90
|
+
* @param {String} string
|
|
91
|
+
* @returns {Boolean}
|
|
92
|
+
*/
|
|
93
|
+
isEmailText(string) {
|
|
94
|
+
return _constants.PATTERNS.EMAIL.test(string);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* to check if the string is a Url string
|
|
99
|
+
*
|
|
100
|
+
* @param {String} string
|
|
101
|
+
* @returns {Boolean}
|
|
102
|
+
*/
|
|
103
|
+
isUrlText(string) {
|
|
104
|
+
return _constants.PATTERNS.URL.test(string);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* to check if the string is fully localized in QA
|
|
109
|
+
*
|
|
110
|
+
* @param {String} string
|
|
111
|
+
* @returns {Boolean}
|
|
112
|
+
*/
|
|
113
|
+
isFullQaLanguageText(string) {
|
|
114
|
+
const config = this.getConfig();
|
|
115
|
+
return string.slice(0, 2) === config?.mockChars?.prefix && string.slice(-2) === config?.mockChars.suffix;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* to check if the string is a DNT string
|
|
120
|
+
*
|
|
121
|
+
* @param {String} string
|
|
122
|
+
* @returns {Boolean}
|
|
123
|
+
*/
|
|
124
|
+
isPartialQaLanguageText(string) {
|
|
125
|
+
const config = this.getConfig();
|
|
126
|
+
return string.slice(0, 2) === config?.mockChars.prefix || string.slice(-2) === config?.mockChars.suffix;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* to check if the string has encoding issues
|
|
131
|
+
*
|
|
132
|
+
* @param {String} string
|
|
133
|
+
* @returns {Boolean}
|
|
134
|
+
*/
|
|
135
|
+
hasEncodingIssue(string) {
|
|
136
|
+
return this.getConfig()?.garbledChars?.length > 0 && this.getConfig().garbledChars.some(char => string.includes(char));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* to check if the string is a partially localized
|
|
141
|
+
*
|
|
142
|
+
* @param {String} string
|
|
143
|
+
* @returns {Promise<Boolean>}
|
|
144
|
+
*/
|
|
145
|
+
isPartiallyLocalizedText(string) {
|
|
146
|
+
return this.#detectLanguageCode(string) === this.currentLanguage();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* detects given string language code
|
|
151
|
+
* @param {String} string
|
|
152
|
+
*/
|
|
153
|
+
#detectLanguageCode(string) {
|
|
154
|
+
const matches = (0, _tinyld.detectAll)(string);
|
|
155
|
+
const currLang = this.currentLanguage();
|
|
156
|
+
if (matches.length && matches.find(m => m.lang === currLang)) {
|
|
157
|
+
return currLang;
|
|
158
|
+
}
|
|
159
|
+
return this.defaultLanguage();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* to check if the string is a fully localized
|
|
164
|
+
*
|
|
165
|
+
* @param {String} string
|
|
166
|
+
* @returns {Boolean}
|
|
167
|
+
*/
|
|
168
|
+
isLocalized(string) {
|
|
169
|
+
return this.getConfig()?.resource?.[this.currentLocale()]?.includes(string);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.default = StringValidator;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _luxon = require("luxon");
|
|
8
|
+
var _base = _interopRequireDefault(require("./base.js"));
|
|
9
|
+
var _chronoNode = require("../../utils/dateUtils/chronoNode.js");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
class TimeValidator extends _base.default {
|
|
12
|
+
constructor() {
|
|
13
|
+
super('time');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @override
|
|
19
|
+
*/
|
|
20
|
+
validate(string) {
|
|
21
|
+
return this.#isDefaultTime(string) || this.isInternationalized(string);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @override
|
|
27
|
+
*/
|
|
28
|
+
isInternationalized(string) {
|
|
29
|
+
return this.#isValidTime(this.isQaLocale() ? this.defaultLocale() : this.currentLocale(), string);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @override
|
|
35
|
+
*/
|
|
36
|
+
buildConfig() {}
|
|
37
|
+
#isValidTime(locale, string) {
|
|
38
|
+
return this.#verifyUsingGlobalize(locale, string) || this.#verifyUsingLuxon(locale, string) || this.#verifyUsingChrono(locale, string);
|
|
39
|
+
}
|
|
40
|
+
#isDefaultTime(string) {
|
|
41
|
+
return this.#isValidTime(this.defaultLocale(), string);
|
|
42
|
+
}
|
|
43
|
+
#verifyUsingGlobalize(locale, string) {
|
|
44
|
+
const formats = ['short', 'medium', 'long', 'full'];
|
|
45
|
+
for (let format of formats) {
|
|
46
|
+
// Try parsing as time
|
|
47
|
+
const timeParser = this.getGlobalize(locale).dateParser({
|
|
48
|
+
time: format
|
|
49
|
+
});
|
|
50
|
+
if (timeParser(string)) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
#verifyUsingLuxon(locale, string) {
|
|
57
|
+
const formats = [_luxon.DateTime.TIME_SIMPLE, _luxon.DateTime.TIME_WITH_SECONDS, _luxon.DateTime.TIME_WITH_SHORT_OFFSET, _luxon.DateTime.TIME_WITH_LONG_OFFSET, _luxon.DateTime.TIME_24_SIMPLE, _luxon.DateTime.TIME_24_WITH_LONG_OFFSET, _luxon.DateTime.TIME_24_WITH_SECONDS, _luxon.DateTime.TIME_24_WITH_SHORT_OFFSET];
|
|
58
|
+
for (let format of formats) {
|
|
59
|
+
const parsed = _luxon.DateTime.fromFormat(string, format, {
|
|
60
|
+
locale
|
|
61
|
+
});
|
|
62
|
+
if (parsed.isValid) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
#verifyUsingChrono(locale, string) {
|
|
69
|
+
return (0, _chronoNode.isValid)(this.isQaLocale() ? this.defaultLocale() : locale, string);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.default = TimeValidator;
|
|
@@ -0,0 +1,57 @@
|
|
|
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("../utils/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;
|
|
@@ -0,0 +1,47 @@
|
|
|
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 _constants = require("./constants.js");
|
|
9
|
+
var _file = require("./file.js");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
class Cache {
|
|
12
|
+
static #cachePath;
|
|
13
|
+
static init(softInit = false) {
|
|
14
|
+
!softInit && Cache.recreateDir();
|
|
15
|
+
Cache.#cachePath = Cache.generatePath(_config.default.getLastRunTimeStamp());
|
|
16
|
+
}
|
|
17
|
+
static exists() {
|
|
18
|
+
return (0, _file.fileExists)(Cache.#cachePath);
|
|
19
|
+
}
|
|
20
|
+
static save(data) {
|
|
21
|
+
(0, _file.ensureDirectoryExists)(_constants.CACHE_DIR_PATH, false);
|
|
22
|
+
(0, _file.saveToFile)(Cache.#cachePath, JSON.stringify(data));
|
|
23
|
+
}
|
|
24
|
+
static getData() {
|
|
25
|
+
if (!this.exists()) {
|
|
26
|
+
return {};
|
|
27
|
+
} else {
|
|
28
|
+
try {
|
|
29
|
+
return JSON.parse((0, _file.getFileContent)(Cache.#cachePath));
|
|
30
|
+
} catch (ex) {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
static recreateDir() {
|
|
36
|
+
(0, _file.deleteFile)(_constants.CACHE_DIR_PATH, true);
|
|
37
|
+
(0, _file.ensureDirectoryExists)(_constants.CACHE_DIR_PATH, false);
|
|
38
|
+
}
|
|
39
|
+
static delete() {
|
|
40
|
+
(0, _file.deleteFile)(Cache.#cachePath, true);
|
|
41
|
+
}
|
|
42
|
+
static generatePath = timeStamp => (0, _file.joinPaths)(_constants.CACHE_DIR_PATH, Cache.#generateFileName(timeStamp));
|
|
43
|
+
static #generateFileName(timeStamp) {
|
|
44
|
+
return `${Buffer.from(timeStamp).toString('base64')}.cache`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.default = Cache;
|
|
@@ -0,0 +1,18 @@
|
|
|
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;
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
"supportedLocales": ["en_US", "fr_FR", "ja_JP"], // set the list of supported locales
|
|
16
|
+
"defaultLocale": "en_US", // set default locale of the application
|
|
17
|
+
"qaMock": { // set the prefix and suffix characters of qa locale
|
|
18
|
+
"prefix": "à_",
|
|
19
|
+
"suffix": "_海"
|
|
20
|
+
},
|
|
21
|
+
"i18nVerify": true, // enable or disable I18n verification
|
|
22
|
+
"garbledChars": [""] // set the list of custom garbled characters
|
|
23
|
+
}`;
|
|
24
|
+
exports.getConfigTemplate = getConfigTemplate;
|
|
25
|
+
const readConfigFile = () => {
|
|
26
|
+
const rcFilePath = getConfigFilePath();
|
|
27
|
+
if (!(0, _file.fileExists)(rcFilePath)) {
|
|
28
|
+
throw new Error(`${_constants.CONFIG_FILE_NAME} file is missing. Please add the file in your project root dir`);
|
|
29
|
+
}
|
|
30
|
+
let rcFile = (0, _file.getFileContent)(rcFilePath);
|
|
31
|
+
if (!rcFile) {
|
|
32
|
+
throw new Error(`invalid ${_constants.CONFIG_FILE_NAME} file. Please add valid file in your project root dir`);
|
|
33
|
+
}
|
|
34
|
+
rcFile = rcFile.replace(/\/\/.+$/gm, ''); // strip comments
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
rcFile = JSON.parse(rcFile);
|
|
38
|
+
} catch (ex) {
|
|
39
|
+
throw new Error(`invalid ${_constants.CONFIG_FILE_NAME} file. Please add valid file in your project root dir`);
|
|
40
|
+
}
|
|
41
|
+
return rcFile;
|
|
42
|
+
};
|
|
43
|
+
exports.readConfigFile = readConfigFile;
|
|
44
|
+
const validateConfig = config => {
|
|
45
|
+
if (typeof config !== 'object' || Object.keys(config).length < 1) {
|
|
46
|
+
throw new Error(`empty ${_constants.CONFIG_FILE_NAME} file`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// add required property validations
|
|
50
|
+
const missingKeys = [];
|
|
51
|
+
if (!(0, _common.allPropertyExists)(['l10nResourcePath', 'supportedLocales', 'defaultLocale', 'type'], config, missingKeys)) {
|
|
52
|
+
throw new Error(`following properties are missing in ${_constants.CONFIG_FILE_NAME} file: ${(0, _common.arr2Txt)(missingKeys)}`);
|
|
53
|
+
}
|
|
54
|
+
if (!Object.values(_constants.SYSTEM_TYPES).includes(config?.type || '')) {
|
|
55
|
+
throw new Error(`${_constants.CONFIG_FILE_NAME} has invalid system type`);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.validateConfig = validateConfig;
|
|
59
|
+
const checkAndExportConfig = (filePath, type = '') => {
|
|
60
|
+
if (filePath && !(0, _file.fileExists)(filePath)) {
|
|
61
|
+
(0, _file.saveToFile)(filePath, getConfigTemplate(type));
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.checkAndExportConfig = checkAndExportConfig;
|