datagrok-tools 4.12.15 → 4.12.17
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/check.js
CHANGED
|
@@ -297,20 +297,62 @@ function checkFuncSignatures(packagePath, files) {
|
|
|
297
297
|
value: value,
|
|
298
298
|
message: message
|
|
299
299
|
};
|
|
300
|
+
},
|
|
301
|
+
params: function params(_ref8) {
|
|
302
|
+
var inputs = _ref8.inputs,
|
|
303
|
+
outputs = _ref8.outputs;
|
|
304
|
+
var value = true;
|
|
305
|
+
var message = '';
|
|
306
|
+
var _iterator4 = _createForOfIteratorHelper(inputs),
|
|
307
|
+
_step4;
|
|
308
|
+
try {
|
|
309
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
310
|
+
var input = _step4.value;
|
|
311
|
+
if (!(input.name && input.type)) {
|
|
312
|
+
value = false;
|
|
313
|
+
message += "Function has no name or type of input parameter\n";
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
} catch (err) {
|
|
317
|
+
_iterator4.e(err);
|
|
318
|
+
} finally {
|
|
319
|
+
_iterator4.f();
|
|
320
|
+
}
|
|
321
|
+
var _iterator5 = _createForOfIteratorHelper(outputs),
|
|
322
|
+
_step5;
|
|
323
|
+
try {
|
|
324
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
325
|
+
var output = _step5.value;
|
|
326
|
+
if (!(output.name && output.type)) {
|
|
327
|
+
value = false;
|
|
328
|
+
message += "Function has no name or type of output parameter\n";
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
} catch (err) {
|
|
332
|
+
_iterator5.e(err);
|
|
333
|
+
} finally {
|
|
334
|
+
_iterator5.f();
|
|
335
|
+
}
|
|
336
|
+
return {
|
|
337
|
+
value: value,
|
|
338
|
+
message: message
|
|
339
|
+
};
|
|
300
340
|
}
|
|
301
341
|
};
|
|
302
342
|
var functionRoles = Object.keys(checkFunctions);
|
|
303
|
-
var
|
|
304
|
-
|
|
343
|
+
var _iterator6 = _createForOfIteratorHelper(files),
|
|
344
|
+
_step6;
|
|
305
345
|
try {
|
|
306
|
-
for (
|
|
307
|
-
var file =
|
|
346
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
347
|
+
var file = _step6.value;
|
|
308
348
|
var content = _fs["default"].readFileSync(_path["default"].join(packagePath, file), {
|
|
309
349
|
encoding: 'utf-8'
|
|
310
350
|
});
|
|
311
351
|
var functions = getFuncMetadata(content);
|
|
312
352
|
var _loop = function _loop() {
|
|
313
353
|
var f = _functions[_i];
|
|
354
|
+
var paramsCheck = checkFunctions.params(f);
|
|
355
|
+
if (!paramsCheck.value) warnings.push("File ".concat(file, ", function ").concat(f.name, ":\n").concat(paramsCheck.message));
|
|
314
356
|
var roles = functionRoles.filter(function (role) {
|
|
315
357
|
var _f$tags;
|
|
316
358
|
return (_f$tags = f.tags) === null || _f$tags === void 0 ? void 0 : _f$tags.includes(role);
|
|
@@ -327,9 +369,9 @@ function checkFuncSignatures(packagePath, files) {
|
|
|
327
369
|
}
|
|
328
370
|
}
|
|
329
371
|
} catch (err) {
|
|
330
|
-
|
|
372
|
+
_iterator6.e(err);
|
|
331
373
|
} finally {
|
|
332
|
-
|
|
374
|
+
_iterator6.f();
|
|
333
375
|
}
|
|
334
376
|
return warnings;
|
|
335
377
|
}
|
|
@@ -356,17 +398,17 @@ function checkPackageFile(packagePath, json, options) {
|
|
|
356
398
|
var isPublicPackage = _path["default"].basename(_path["default"].dirname(packagePath)) === 'packages' && _path["default"].basename(_path["default"].dirname(_path["default"].dirname(packagePath))) === 'public';
|
|
357
399
|
if (!json.description) warnings.push('File "package.json": "description" field is empty. Provide a package description.');
|
|
358
400
|
if (Array.isArray(json.properties) && json.properties.length > 0) {
|
|
359
|
-
var
|
|
360
|
-
|
|
401
|
+
var _iterator7 = _createForOfIteratorHelper(json.properties),
|
|
402
|
+
_step7;
|
|
361
403
|
try {
|
|
362
|
-
for (
|
|
363
|
-
var propInfo =
|
|
404
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
405
|
+
var propInfo = _step7.value;
|
|
364
406
|
if ((0, _typeof2["default"])(propInfo) !== 'object') warnings.push('File "package.json": Invalid property annotation in the "properties" field.');else if (!propInfo.name) warnings.push('File "package.json": Add a property name for each property in the "properties" field.');else if (!utils.propertyTypes.includes(propInfo.propertyType)) warnings.push("File \"package.json\": Invalid property type for property ".concat(propInfo.name, "."));
|
|
365
407
|
}
|
|
366
408
|
} catch (err) {
|
|
367
|
-
|
|
409
|
+
_iterator7.e(err);
|
|
368
410
|
} finally {
|
|
369
|
-
|
|
411
|
+
_iterator7.f();
|
|
370
412
|
}
|
|
371
413
|
}
|
|
372
414
|
if (json.repository == null && isPublicPackage) warnings.push('File "package.json": add the "repository" field.');
|
|
@@ -379,11 +421,11 @@ function checkPackageFile(packagePath, json, options) {
|
|
|
379
421
|
var dt = (_json$devDependencies = (_json$devDependencies2 = json.devDependencies) === null || _json$devDependencies2 === void 0 ? void 0 : _json$devDependencies2['datagrok-tools']) !== null && _json$devDependencies !== void 0 ? _json$devDependencies : (_json$dependencies2 = json.dependencies) === null || _json$dependencies2 === void 0 ? void 0 : _json$dependencies2['datagrok-tools'];
|
|
380
422
|
if (dt && dt !== 'latest') warnings.push('File "package.json": "datagrok-tools" dependency must be "latest" version.');
|
|
381
423
|
if (Array.isArray(json.sources) && json.sources.length > 0) {
|
|
382
|
-
var
|
|
383
|
-
|
|
424
|
+
var _iterator8 = _createForOfIteratorHelper(json.sources),
|
|
425
|
+
_step8;
|
|
384
426
|
try {
|
|
385
|
-
for (
|
|
386
|
-
var source =
|
|
427
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
428
|
+
var source = _step8.value;
|
|
387
429
|
if (typeof source !== 'string') warnings.push("File \"package.json\": Only file paths and URLs are allowed in sources. Modify the source ".concat(source));
|
|
388
430
|
if (utils.absUrlRegex.test(source)) continue;
|
|
389
431
|
if (source.startsWith('common/')) {
|
|
@@ -409,9 +451,9 @@ function checkPackageFile(packagePath, json, options) {
|
|
|
409
451
|
if (!_fs["default"].existsSync(_path["default"].join(packagePath, source))) warnings.push("Source ".concat(source, " not found in the package."));
|
|
410
452
|
}
|
|
411
453
|
} catch (err) {
|
|
412
|
-
|
|
454
|
+
_iterator8.e(err);
|
|
413
455
|
} finally {
|
|
414
|
-
|
|
456
|
+
_iterator8.f();
|
|
415
457
|
}
|
|
416
458
|
}
|
|
417
459
|
return warnings;
|
|
@@ -432,17 +474,17 @@ function checkChangelog(packagePath, json) {
|
|
|
432
474
|
var h2 = clf.match(regex);
|
|
433
475
|
if (!h2) return ['No versions found in CHANGELOG.md\n'];
|
|
434
476
|
regex = /^## \d+\.\d+\.\d+ \((\d{4}-\d{2}-\d{2}|WIP)\)$/;
|
|
435
|
-
var
|
|
436
|
-
|
|
477
|
+
var _iterator9 = _createForOfIteratorHelper(h2),
|
|
478
|
+
_step9;
|
|
437
479
|
try {
|
|
438
|
-
for (
|
|
439
|
-
var h =
|
|
440
|
-
if (!regex.test(h)) warnings.push("CHANGELOG: '".concat(h, "' does not match the h2 format, expected: ## <version> (<
|
|
480
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
481
|
+
var h = _step9.value;
|
|
482
|
+
if (!regex.test(h)) warnings.push("CHANGELOG: '".concat(h, "' does not match the h2 format, expected: ## <version> (<yyyy-mm-dd> | WIP)\n"));
|
|
441
483
|
}
|
|
442
484
|
} catch (err) {
|
|
443
|
-
|
|
485
|
+
_iterator9.e(err);
|
|
444
486
|
} finally {
|
|
445
|
-
|
|
487
|
+
_iterator9.f();
|
|
446
488
|
}
|
|
447
489
|
regex = /^## (\d+\.\d+\.\d+)/;
|
|
448
490
|
var v1 = (_h2$0$match = h2[0].match(regex)) === null || _h2$0$match === void 0 ? void 0 : _h2$0$match[1];
|
|
@@ -463,27 +505,30 @@ function getFuncMetadata(script) {
|
|
|
463
505
|
inputs: [],
|
|
464
506
|
outputs: []
|
|
465
507
|
};
|
|
466
|
-
var
|
|
467
|
-
|
|
508
|
+
var _iterator10 = _createForOfIteratorHelper(script.split('\n')),
|
|
509
|
+
_step10;
|
|
468
510
|
try {
|
|
469
|
-
for (
|
|
470
|
-
var line =
|
|
511
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
512
|
+
var line = _step10.value;
|
|
471
513
|
if (!line) continue;
|
|
472
514
|
var match = line.match(utils.paramRegex);
|
|
473
515
|
if (match) {
|
|
516
|
+
var _line$match;
|
|
474
517
|
if (!isHeader) isHeader = true;
|
|
475
518
|
var param = match[1];
|
|
476
|
-
if (param === 'name') data.name = match[2];else if (param === 'description') data.description = match[2];else if (param === 'input') data.inputs.push({
|
|
477
|
-
type: match[2]
|
|
519
|
+
if (param === 'name') data.name = (_line$match = line.match(utils.nameAnnRegex)) === null || _line$match === void 0 ? void 0 : _line$match[2];else if (param === 'description') data.description = match[2];else if (param === 'input') data.inputs.push({
|
|
520
|
+
type: match[2],
|
|
521
|
+
name: match[3]
|
|
478
522
|
});else if (param === 'output') data.outputs.push({
|
|
479
|
-
type: match[2]
|
|
523
|
+
type: match[2],
|
|
524
|
+
name: match[3]
|
|
480
525
|
});else if (param === 'tags') data.tags = match.input && match[3] ? match.input.split(':')[1].split(',').map(function (t) {
|
|
481
526
|
return t.trim();
|
|
482
527
|
}) : [match[2]];
|
|
483
528
|
}
|
|
484
529
|
if (isHeader) {
|
|
485
530
|
var nm = line.match(utils.nameRegex);
|
|
486
|
-
if (nm && !
|
|
531
|
+
if (nm && !match) {
|
|
487
532
|
data.name = data.name || nm[1];
|
|
488
533
|
funcData.push(data);
|
|
489
534
|
data = {
|
|
@@ -496,9 +541,9 @@ function getFuncMetadata(script) {
|
|
|
496
541
|
}
|
|
497
542
|
}
|
|
498
543
|
} catch (err) {
|
|
499
|
-
|
|
544
|
+
_iterator10.e(err);
|
|
500
545
|
} finally {
|
|
501
|
-
|
|
546
|
+
_iterator10.f();
|
|
502
547
|
}
|
|
503
548
|
return funcData;
|
|
504
549
|
}
|
package/bin/commands/test.js
CHANGED
|
@@ -22,7 +22,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
22
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
23
|
function test(args) {
|
|
24
24
|
var options = Object.keys(args).slice(1);
|
|
25
|
-
var commandOptions = ['host', 'csv', 'gui', 'catchUnhandled', 'report', 'skip-build', 'skip-publish', 'category', 'record', 'verbose'];
|
|
25
|
+
var commandOptions = ['host', 'csv', 'gui', 'catchUnhandled', 'report', 'skip-build', 'skip-publish', 'category', 'record', 'verbose', 'benchmark'];
|
|
26
26
|
var nArgs = args['_'].length;
|
|
27
27
|
var curDir = process.cwd();
|
|
28
28
|
var grokDir = _path["default"].join(_os["default"].homedir(), '.grok');
|
|
@@ -161,6 +161,7 @@ function test(args) {
|
|
|
161
161
|
console.log("Testing ".concat(targetPackage, " package...\n"));
|
|
162
162
|
_context2.next = 11;
|
|
163
163
|
return page.evaluate(function (targetPackage, options, testContext) {
|
|
164
|
+
if (options.benchmark) window.DG.Test.isInBenchmark = true;
|
|
164
165
|
return new Promise(function (resolve, reject) {
|
|
165
166
|
window.grok.functions.call("".concat(targetPackage, ":test"), {
|
|
166
167
|
'category': options.category,
|
|
@@ -206,8 +207,9 @@ function test(args) {
|
|
|
206
207
|
failReport += "Test result : Failed : ".concat(cTime.get(i), " : ").concat(targetPackage, ".").concat(cCat.get(i), ".").concat(cName.get(i), " : ").concat(cMessage.get(i), "\n");
|
|
207
208
|
}
|
|
208
209
|
}
|
|
209
|
-
|
|
210
|
-
|
|
210
|
+
if (!options.verbose) df.rows.removeWhere(function (r) {
|
|
211
|
+
return r.get('success');
|
|
212
|
+
});
|
|
211
213
|
var csv = df.toCsv();
|
|
212
214
|
resolve({
|
|
213
215
|
failReport: failReport,
|
|
@@ -278,7 +280,8 @@ function test(args) {
|
|
|
278
280
|
verbose: args.verbose,
|
|
279
281
|
catchUnhandled: args.catchUnhandled,
|
|
280
282
|
report: args.report,
|
|
281
|
-
record: args.record
|
|
283
|
+
record: args.record,
|
|
284
|
+
benchmark: args.benchmark
|
|
282
285
|
});
|
|
283
286
|
case 12:
|
|
284
287
|
r = _context3.sent;
|
package/bin/utils/utils.js
CHANGED
|
@@ -18,7 +18,7 @@ exports.isEmpty = isEmpty;
|
|
|
18
18
|
exports.isPackageDir = isPackageDir;
|
|
19
19
|
exports.kebabToCamelCase = kebabToCamelCase;
|
|
20
20
|
exports.mapURL = mapURL;
|
|
21
|
-
exports.queryWrapperTemplate = exports.queryExtension = exports.propertyTypes = exports.paramRegex = exports.namespaceTemplate = exports.nameRegex = void 0;
|
|
21
|
+
exports.queryWrapperTemplate = exports.queryExtension = exports.propertyTypes = exports.paramRegex = exports.namespaceTemplate = exports.nameRegex = exports.nameAnnRegex = void 0;
|
|
22
22
|
exports.removeScope = removeScope;
|
|
23
23
|
exports.scriptWrapperTemplate = exports.scriptLangExtMap = exports.scriptExtensions = exports.replacers = void 0;
|
|
24
24
|
exports.spaceToCamelCase = spaceToCamelCase;
|
|
@@ -225,12 +225,14 @@ var dgToTsTypeMap = {
|
|
|
225
225
|
file: 'DG.FileInfo'
|
|
226
226
|
};
|
|
227
227
|
exports.dgToTsTypeMap = dgToTsTypeMap;
|
|
228
|
-
var propertyTypes = ['
|
|
228
|
+
var propertyTypes = ['int', 'bigint', 'double', 'num', 'bool', 'string'];
|
|
229
229
|
exports.propertyTypes = propertyTypes;
|
|
230
|
-
var headerTags = ['name', 'description', 'help-url', 'input', 'output', 'tags', 'sample', 'language', 'returns', 'test', 'sidebar', 'condition', 'top-menu', 'environment', 'require', 'editor-for', 'schedule', 'reference', 'editor'];
|
|
230
|
+
var headerTags = ['name', 'description', 'help-url', 'input', 'output', 'tags', 'sample', 'language', 'returns', 'test', 'sidebar', 'condition', 'top-menu', 'environment', 'require', 'editor-for', 'schedule', 'reference', 'editor', 'meta'];
|
|
231
231
|
exports.headerTags = headerTags;
|
|
232
|
-
var paramRegex = new RegExp("//\\s*(".concat(headerTags.join('|'), "
|
|
232
|
+
var paramRegex = new RegExp("//\\s*(".concat(headerTags.join('|'), "\\.[^:]*): *([^\\s\\[\\{]+) ?([^\\s\\[\\{]+)?"));
|
|
233
233
|
exports.paramRegex = paramRegex;
|
|
234
|
+
var nameAnnRegex = /\/\/\s*(name[^:]*): ([^\n\r\[\{]+)/;
|
|
235
|
+
exports.nameAnnRegex = nameAnnRegex;
|
|
234
236
|
var nameRegex = /(?:|static|export\s+function|export\s+async\s+function)\s+([a-zA-Z_][a-zA-Z0-9_$]*)\s*\((.*?)\).*/;
|
|
235
237
|
exports.nameRegex = nameRegex;
|
|
236
238
|
var absUrlRegex = new RegExp('^(?:[a-z+]+:)?//', 'i');
|
package/package.json
CHANGED