datagrok-tools 4.13.75 → 4.13.76
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/bin/commands/add.js +96 -106
- package/bin/commands/api.js +65 -107
- package/bin/commands/check.js +264 -396
- package/bin/commands/config.js +82 -158
- package/bin/commands/create.js +65 -80
- package/bin/commands/help.js +194 -12
- package/bin/commands/init.js +73 -95
- package/bin/commands/link.js +70 -176
- package/bin/commands/publish.js +283 -484
- package/bin/commands/test-all.js +77 -291
- package/bin/commands/test.js +169 -388
- package/bin/utils/color-utils.js +8 -11
- package/bin/utils/ent-helpers.js +52 -42
- package/bin/utils/func-generation.js +25 -57
- package/bin/utils/interfaces.js +5 -1
- package/bin/utils/order-functions.js +47 -118
- package/bin/utils/test-utils.js +322 -750
- package/bin/utils/utils.js +123 -235
- package/bin/validators/config-validator.js +12 -14
- package/package.json +13 -3
package/bin/utils/ent-helpers.js
CHANGED
|
@@ -4,46 +4,56 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.help = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
7
|
+
const app = appName => `
|
|
8
|
+
The application ${appName} has been added successfully
|
|
9
|
+
Read more at https://datagrok.ai/help/develop/how-to/build-an-app
|
|
10
|
+
See application examples at https://public.datagrok.ai/apps`;
|
|
11
|
+
const connection = connectionName => `
|
|
12
|
+
The connection ${connectionName} has been added successfully
|
|
13
|
+
Read more at https://datagrok.ai/help/access/access#data-connection,
|
|
14
|
+
https://datagrok.ai/help/develop/how-to/access-data#connections
|
|
15
|
+
See examples at https://github.com/datagrok-ai/public/tree/master/packages/Chembl`;
|
|
16
|
+
const detector = semType => `
|
|
17
|
+
The detector for ${semType} has been added successfully
|
|
18
|
+
Read more at https://datagrok.ai/help/develop/how-to/define-semantic-type-detectors`;
|
|
19
|
+
const func = (funcName, isPanel = false) => {
|
|
20
|
+
return `\nThe function ${funcName} has been added successfully\n` + 'Read more at https://datagrok.ai/help/datagrok/functions/function' + (isPanel ? ',\nhttps://datagrok.ai/help/develop/how-to/add-info-panel\n' : '\n') + 'See examples at https://public.datagrok.ai/functions' + (isPanel ? ',\nhttps://public.datagrok.ai/js/samples/functions/info-panels/info-panels' : '');
|
|
21
|
+
};
|
|
22
|
+
const query = queryName => `
|
|
23
|
+
The query ${queryName} has been added successfully
|
|
24
|
+
Read more at https://datagrok.ai/help/access/access#data-query,
|
|
25
|
+
https://datagrok.ai/help/develop/how-to/access-data#queries
|
|
26
|
+
See examples at https://github.com/datagrok-ai/public/tree/master/packages/Chembl`;
|
|
27
|
+
const script = (scriptName, packageName) => `
|
|
28
|
+
The script ${scriptName} has been created. To call it from a JavaScript file, use:
|
|
29
|
+
|
|
30
|
+
await grok.functions.call('${packageName}:${scriptName}', { params });
|
|
31
|
+
|
|
32
|
+
Read more at https://datagrok.ai/help/compute/scripting
|
|
33
|
+
See examples at https://public.datagrok.ai/scripts,
|
|
34
|
+
https://public.datagrok.ai/js/samples/scripting/scripting`;
|
|
35
|
+
const view = viewName => `
|
|
36
|
+
The view ${viewName} has been added successfully
|
|
37
|
+
Read more at https://datagrok.ai/help/develop/how-to/custom-views
|
|
38
|
+
See examples at https://github.com/datagrok-ai/public/tree/master/packages/Notebooks`;
|
|
39
|
+
const viewer = viewerName => `
|
|
40
|
+
The viewer ${viewerName} has been added successfully
|
|
41
|
+
Read more at https://datagrok.ai/help/develop/how-to/develop-custom-viewer
|
|
42
|
+
See examples at https://github.com/datagrok-ai/public/tree/master/packages/Viewers,
|
|
43
|
+
https://public.datagrok.ai/js/samples/functions/custom-viewers/viewers`;
|
|
44
|
+
const _package = ts => ts ? '' : 'Consider TypeScript as a language for package development, to start over, run `grok create` with the `--ts` flag\n' + 'Likely next steps: `grok add` to add functionality, `grok publish` to upload the package';
|
|
45
|
+
const test = dir => `Tests have been added successfully to ${dir}
|
|
46
|
+
Run 'npm install' to get newly added packages
|
|
47
|
+
Read more about package testing at https://datagrok.ai/help/develop/how-to/test-packages`;
|
|
48
|
+
const help = exports.help = {
|
|
49
|
+
app,
|
|
50
|
+
connection,
|
|
51
|
+
detector,
|
|
52
|
+
func,
|
|
53
|
+
query,
|
|
54
|
+
script,
|
|
55
|
+
view,
|
|
56
|
+
viewer,
|
|
57
|
+
package: _package,
|
|
58
|
+
test
|
|
49
59
|
};
|
|
@@ -10,20 +10,17 @@ exports.generateFunc = generateFunc;
|
|
|
10
10
|
exports.generateImport = generateImport;
|
|
11
11
|
exports.getFuncAnnotation = getFuncAnnotation;
|
|
12
12
|
exports.reservedDecorators = exports.pseudoParams = exports.headerParams = void 0;
|
|
13
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
14
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
16
13
|
/* eslint-disable no-unused-vars */
|
|
17
14
|
/* eslint-disable valid-jsdoc */
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
const headerParams = exports.headerParams = ['name', 'description', 'tags', 'inputs', 'outputs'];
|
|
17
|
+
let pseudoParams = exports.pseudoParams = /*#__PURE__*/function (pseudoParams) {
|
|
21
18
|
pseudoParams["EXTENSION"] = "extension";
|
|
22
19
|
pseudoParams["EXTENSIONS"] = "extensions";
|
|
23
20
|
pseudoParams["INPUT_TYPE"] = "inputType";
|
|
24
21
|
return pseudoParams;
|
|
25
22
|
}({});
|
|
26
|
-
|
|
23
|
+
let FUNC_TYPES = exports.FUNC_TYPES = /*#__PURE__*/function (FUNC_TYPES) {
|
|
27
24
|
FUNC_TYPES["CELL_RENDERER"] = "cellRenderer";
|
|
28
25
|
FUNC_TYPES["FILE_EXPORTER"] = "fileExporter";
|
|
29
26
|
FUNC_TYPES["FILE_IMPORTER"] = "file-handler";
|
|
@@ -34,57 +31,32 @@ var FUNC_TYPES = exports.FUNC_TYPES = /*#__PURE__*/function (FUNC_TYPES) {
|
|
|
34
31
|
return FUNC_TYPES;
|
|
35
32
|
}({});
|
|
36
33
|
/** Generates an annotation header for a function based on provided metadata. */
|
|
37
|
-
function getFuncAnnotation(data) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var s = '';
|
|
44
|
-
if (data.name) s += "".concat(comment, "name: ").concat(data.name).concat(sep);
|
|
45
|
-
if (pseudoParams.EXTENSION in data && data.tags != null && data.tags.includes(FUNC_TYPES.FILE_EXPORTER)) s += "".concat(comment, "description: Save as ").concat(data[pseudoParams.EXTENSION]).concat(sep);else if (data.description) s += "".concat(comment, "description: ").concat(data.description).concat(sep);
|
|
34
|
+
function getFuncAnnotation(data, comment = '//', sep = '\n') {
|
|
35
|
+
const isFileViewer = data.tags?.includes(FUNC_TYPES.FILE_VIEWER) ?? false;
|
|
36
|
+
const isFileImporter = data.tags?.includes(FUNC_TYPES.FILE_IMPORTER) ?? false;
|
|
37
|
+
let s = '';
|
|
38
|
+
if (data.name) s += `${comment}name: ${data.name}${sep}`;
|
|
39
|
+
if (pseudoParams.EXTENSION in data && data.tags != null && data.tags.includes(FUNC_TYPES.FILE_EXPORTER)) s += `${comment}description: Save as ${data[pseudoParams.EXTENSION]}${sep}`;else if (data.description) s += `${comment}description: ${data.description}${sep}`;
|
|
46
40
|
if (data.tags) {
|
|
47
|
-
s +=
|
|
48
|
-
return 'fileViewer-' + ext;
|
|
49
|
-
})).join() : data.tags.join()).concat(sep);
|
|
41
|
+
s += `${comment}tags: ${isFileViewer && data[pseudoParams.EXTENSIONS] ? data.tags.concat(data[pseudoParams.EXTENSIONS].map(ext => 'fileViewer-' + ext)).join() : data.tags.join()}${sep}`;
|
|
50
42
|
}
|
|
51
43
|
if (data.inputs) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
56
|
-
var input = _step.value;
|
|
57
|
-
s += comment + 'input: ' + (isFileImporter && data[pseudoParams.INPUT_TYPE] ? data[pseudoParams.INPUT_TYPE] : input.type) + (input.name ? " ".concat(input.name) : '') + sep;
|
|
58
|
-
}
|
|
59
|
-
} catch (err) {
|
|
60
|
-
_iterator.e(err);
|
|
61
|
-
} finally {
|
|
62
|
-
_iterator.f();
|
|
44
|
+
for (const input of data.inputs) {
|
|
45
|
+
s += comment + 'input: ' + (isFileImporter && data[pseudoParams.INPUT_TYPE] ? data[pseudoParams.INPUT_TYPE] : input.type) + (input.name ? ` ${input.name}` : '') + sep;
|
|
63
46
|
}
|
|
64
47
|
}
|
|
65
48
|
if (data.outputs) {
|
|
66
|
-
|
|
67
|
-
_step2;
|
|
68
|
-
try {
|
|
69
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
70
|
-
var output = _step2.value;
|
|
71
|
-
s += comment + 'output: ' + output.type + (output.name ? " ".concat(output.name) : '') + sep;
|
|
72
|
-
}
|
|
73
|
-
} catch (err) {
|
|
74
|
-
_iterator2.e(err);
|
|
75
|
-
} finally {
|
|
76
|
-
_iterator2.f();
|
|
77
|
-
}
|
|
49
|
+
for (const output of data.outputs) s += comment + 'output: ' + output.type + (output.name ? ` ${output.name}` : '') + sep;
|
|
78
50
|
}
|
|
79
|
-
for (
|
|
51
|
+
for (const parameter in data) {
|
|
80
52
|
if (parameter === pseudoParams.EXTENSION || parameter === pseudoParams.INPUT_TYPE) continue;else if (parameter === pseudoParams.EXTENSIONS) {
|
|
81
53
|
if (isFileViewer) continue;
|
|
82
|
-
s +=
|
|
83
|
-
} else if (!headerParams.includes(parameter)) s +=
|
|
54
|
+
s += `${comment}meta.ext: ${data[parameter]}${sep}`;
|
|
55
|
+
} else if (!headerParams.includes(parameter)) s += `${comment}meta.${parameter}: ${data[parameter]}${sep}`;
|
|
84
56
|
}
|
|
85
57
|
return s;
|
|
86
58
|
}
|
|
87
|
-
|
|
59
|
+
const reservedDecorators = exports.reservedDecorators = {
|
|
88
60
|
viewer: {
|
|
89
61
|
metadata: {
|
|
90
62
|
tags: [FUNC_TYPES.VIEWER],
|
|
@@ -168,21 +140,17 @@ var reservedDecorators = exports.reservedDecorators = {
|
|
|
168
140
|
};
|
|
169
141
|
|
|
170
142
|
/** Generates a DG function that instantiates a class. */
|
|
171
|
-
function generateClassFunc(annotation, className) {
|
|
172
|
-
|
|
173
|
-
return annotation + "export function _".concat(className, "() {").concat(sep, " return new ").concat(className, "();").concat(sep, "}").concat(sep.repeat(2));
|
|
143
|
+
function generateClassFunc(annotation, className, sep = '\n') {
|
|
144
|
+
return annotation + `export function _${className}() {${sep} return new ${className}();${sep}}${sep.repeat(2)}`;
|
|
174
145
|
}
|
|
175
146
|
|
|
176
147
|
/** Generates a DG function. */
|
|
177
|
-
function generateFunc(annotation, funcName) {
|
|
178
|
-
|
|
179
|
-
return annotation + "export function _".concat(funcName, "() {").concat(sep, " return ").concat(funcName, "();").concat(sep, "}").concat(sep.repeat(2));
|
|
148
|
+
function generateFunc(annotation, funcName, sep = '\n') {
|
|
149
|
+
return annotation + `export function _${funcName}() {${sep} return ${funcName}();${sep}}${sep.repeat(2)}`;
|
|
180
150
|
}
|
|
181
|
-
function generateImport(className, path) {
|
|
182
|
-
|
|
183
|
-
return "import {".concat(className, "} from '").concat(path, "';").concat(sep);
|
|
151
|
+
function generateImport(className, path, sep = '\n') {
|
|
152
|
+
return `import {${className}} from '${path}';${sep}`;
|
|
184
153
|
}
|
|
185
|
-
function generateExport(className) {
|
|
186
|
-
|
|
187
|
-
return "export {".concat(className, "};").concat(sep);
|
|
154
|
+
function generateExport(className, sep = '\n') {
|
|
155
|
+
return `export {${className}};${sep}`;
|
|
188
156
|
}
|
package/bin/utils/interfaces.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -9,51 +8,25 @@ exports.setPackageAlphabeticalOrder = setPackageAlphabeticalOrder;
|
|
|
9
8
|
exports.setPackageRandomOrder = setPackageRandomOrder;
|
|
10
9
|
exports.setRandomOrder = setRandomOrder;
|
|
11
10
|
exports.setTestToBrowserOrder = setTestToBrowserOrder;
|
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
14
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
17
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
11
|
function setRandomOrder(tests, browsersAmount, testRepeats) {
|
|
20
12
|
if (browsersAmount > tests.length) browsersAmount = tests.length;
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
const repeatedTests = repeatTests(tests, testRepeats);
|
|
14
|
+
const orderedTests = shuffle(repeatedTests);
|
|
23
15
|
return splitArray(orderedTests, browsersAmount);
|
|
24
16
|
}
|
|
25
17
|
function setPackageRandomOrder(tests, browsersAmount, testRepeats) {
|
|
26
|
-
|
|
18
|
+
const packages = splitTestsByPackages(tests);
|
|
27
19
|
if (browsersAmount > packages.size) browsersAmount = packages.size;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
32
|
-
var packageName = _step.value;
|
|
33
|
-
packages.set(packageName, repeatTests(packages.get(packageName), testRepeats));
|
|
34
|
-
packages.set(packageName, shuffle(packages.get(packageName)));
|
|
35
|
-
}
|
|
36
|
-
} catch (err) {
|
|
37
|
-
_iterator.e(err);
|
|
38
|
-
} finally {
|
|
39
|
-
_iterator.f();
|
|
20
|
+
for (let packageName of packages.keys()) {
|
|
21
|
+
packages.set(packageName, repeatTests(packages.get(packageName), testRepeats));
|
|
22
|
+
packages.set(packageName, shuffle(packages.get(packageName)));
|
|
40
23
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
for (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
_step2;
|
|
48
|
-
try {
|
|
49
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
50
|
-
var packageTests = _step2.value;
|
|
51
|
-
testsArray = testsArray.concat(packageTests);
|
|
52
|
-
}
|
|
53
|
-
} catch (err) {
|
|
54
|
-
_iterator2.e(err);
|
|
55
|
-
} finally {
|
|
56
|
-
_iterator2.f();
|
|
24
|
+
const splittedPackagesArray = splitArray([...packages.values()], browsersAmount);
|
|
25
|
+
const splittedTestsArray = [];
|
|
26
|
+
for (let splitArray of splittedPackagesArray) {
|
|
27
|
+
let testsArray = [];
|
|
28
|
+
for (let packageTests of splitArray) {
|
|
29
|
+
testsArray = testsArray.concat(packageTests);
|
|
57
30
|
}
|
|
58
31
|
splittedTestsArray.push(testsArray);
|
|
59
32
|
}
|
|
@@ -61,120 +34,76 @@ function setPackageRandomOrder(tests, browsersAmount, testRepeats) {
|
|
|
61
34
|
}
|
|
62
35
|
function setAlphabeticalOrder(tests, browsersAmount, testRepeats) {
|
|
63
36
|
if (browsersAmount > tests.length) browsersAmount = tests.length;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return
|
|
37
|
+
const repeatedTests = repeatTests(tests, testRepeats);
|
|
38
|
+
const orderedTests = repeatedTests.sort((test1, test2) => {
|
|
39
|
+
return `${test1.category}: ${test1.name}s`.localeCompare(`${test2.category}: ${test2.name}s`);
|
|
67
40
|
});
|
|
68
41
|
return splitArray(orderedTests, browsersAmount);
|
|
69
42
|
}
|
|
70
43
|
function setPackageAlphabeticalOrder(tests, browsersAmount, testRepeats) {
|
|
71
|
-
|
|
44
|
+
const packages = splitTestsByPackages(tests);
|
|
72
45
|
if (browsersAmount > packages.size) browsersAmount = packages.size;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
77
|
-
var packageName = _step3.value;
|
|
78
|
-
packages.set(packageName, repeatTests(packages.get(packageName), testRepeats));
|
|
79
|
-
packages.set(packageName, packages.get(packageName).sort(alphabeticalSortFunction));
|
|
80
|
-
}
|
|
81
|
-
} catch (err) {
|
|
82
|
-
_iterator3.e(err);
|
|
83
|
-
} finally {
|
|
84
|
-
_iterator3.f();
|
|
46
|
+
for (let packageName of packages.keys()) {
|
|
47
|
+
packages.set(packageName, repeatTests(packages.get(packageName), testRepeats));
|
|
48
|
+
packages.set(packageName, packages.get(packageName).sort(alphabeticalSortFunction));
|
|
85
49
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
for (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
_step4;
|
|
93
|
-
try {
|
|
94
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
95
|
-
var packageTests = _step4.value;
|
|
96
|
-
testsArray = testsArray.concat(packageTests);
|
|
97
|
-
}
|
|
98
|
-
} catch (err) {
|
|
99
|
-
_iterator4.e(err);
|
|
100
|
-
} finally {
|
|
101
|
-
_iterator4.f();
|
|
50
|
+
const splittedPackagesArray = splitArray([...packages.values()], browsersAmount);
|
|
51
|
+
const splittedTestsArray = [];
|
|
52
|
+
for (let splitArray of splittedPackagesArray) {
|
|
53
|
+
let testsArray = [];
|
|
54
|
+
for (let packageTests of splitArray) {
|
|
55
|
+
testsArray = testsArray.concat(packageTests);
|
|
102
56
|
}
|
|
103
57
|
splittedTestsArray.push(testsArray);
|
|
104
58
|
}
|
|
105
59
|
return splittedTestsArray;
|
|
106
60
|
}
|
|
107
61
|
function setTestToBrowserOrder(tests, browsersAmount, testRepeats) {
|
|
108
|
-
|
|
62
|
+
let splittedTestsArray = [];
|
|
109
63
|
if (browsersAmount > tests.length) browsersAmount = tests.length;
|
|
110
|
-
|
|
111
|
-
for (
|
|
64
|
+
const orderedTests = shuffle(tests);
|
|
65
|
+
for (let i = 0; i < browsersAmount; i++) {
|
|
112
66
|
splittedTestsArray.push([]);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
var test = _step5.value;
|
|
118
|
-
splittedTestsArray[splittedTestsArray.length - 1].push(_objectSpread({}, test));
|
|
119
|
-
}
|
|
120
|
-
} catch (err) {
|
|
121
|
-
_iterator5.e(err);
|
|
122
|
-
} finally {
|
|
123
|
-
_iterator5.f();
|
|
67
|
+
for (let test of orderedTests) {
|
|
68
|
+
splittedTestsArray[splittedTestsArray.length - 1].push({
|
|
69
|
+
...test
|
|
70
|
+
});
|
|
124
71
|
}
|
|
125
72
|
splittedTestsArray[splittedTestsArray.length - 1] = shuffle(repeatTests(splittedTestsArray[splittedTestsArray.length - 1], testRepeats));
|
|
126
73
|
}
|
|
127
74
|
return splittedTestsArray;
|
|
128
75
|
}
|
|
129
76
|
function alphabeticalSortFunction(test1, test2) {
|
|
130
|
-
return
|
|
77
|
+
return `${test1.category}: ${test1.name}s`.localeCompare(`${test2.category}: ${test2.name}s`);
|
|
131
78
|
}
|
|
132
79
|
function splitTestsByPackages(tests) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
138
|
-
var test = _step6.value;
|
|
139
|
-
if (resultMap.has(test.packageName)) resultMap.get(test.packageName).push(test);else resultMap.set(test.packageName, [test]);
|
|
140
|
-
}
|
|
141
|
-
} catch (err) {
|
|
142
|
-
_iterator6.e(err);
|
|
143
|
-
} finally {
|
|
144
|
-
_iterator6.f();
|
|
80
|
+
let resultMap = new Map();
|
|
81
|
+
for (let test of tests) {
|
|
82
|
+
if (resultMap.has(test.packageName)) resultMap.get(test.packageName).push(test);else resultMap.set(test.packageName, [test]);
|
|
145
83
|
}
|
|
146
84
|
return resultMap;
|
|
147
85
|
}
|
|
148
86
|
function repeatTests(tests, testRepeats) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
for (var i = 0; i < testRepeats; i++) {
|
|
156
|
-
repeatedTests.push(_objectSpread({}, test));
|
|
157
|
-
}
|
|
87
|
+
let repeatedTests = [];
|
|
88
|
+
for (let test of tests) {
|
|
89
|
+
for (let i = 0; i < testRepeats; i++) {
|
|
90
|
+
repeatedTests.push({
|
|
91
|
+
...test
|
|
92
|
+
});
|
|
158
93
|
}
|
|
159
|
-
} catch (err) {
|
|
160
|
-
_iterator7.e(err);
|
|
161
|
-
} finally {
|
|
162
|
-
_iterator7.f();
|
|
163
94
|
}
|
|
164
95
|
return repeatedTests;
|
|
165
96
|
}
|
|
166
97
|
function shuffle(array) {
|
|
167
|
-
|
|
168
|
-
newArr.sort(
|
|
169
|
-
return Math.random() - 0.5;
|
|
170
|
-
});
|
|
98
|
+
const newArr = array.slice();
|
|
99
|
+
newArr.sort(() => Math.random() - 0.5);
|
|
171
100
|
return newArr;
|
|
172
101
|
}
|
|
173
102
|
;
|
|
174
103
|
function splitArray(arr, countOfParts) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
for (
|
|
104
|
+
const result = [];
|
|
105
|
+
const partSize = Math.ceil(arr.length / countOfParts);
|
|
106
|
+
for (let i = 0; i < arr.length; i += partSize) {
|
|
178
107
|
result.push(arr.slice(i, i + partSize));
|
|
179
108
|
}
|
|
180
109
|
return result;
|