datagrok-tools 4.13.5 → 4.13.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/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Datagrok-tools changelog
2
2
 
3
3
 
4
+ ## 4.13.6 (2024-07-15)
5
+
6
+ ### Bug Fixes
7
+
8
+ * Splitt warnings and errors in grok check command
9
+
4
10
  ## 4.13.4 (2024-06-25)
5
11
 
6
12
  ### Bug Fixes
@@ -9,6 +9,7 @@ exports.check = check;
9
9
  exports.checkChangelog = checkChangelog;
10
10
  exports.checkFuncSignatures = checkFuncSignatures;
11
11
  exports.checkImportStatements = checkImportStatements;
12
+ exports.checkNpmIgnore = checkNpmIgnore;
12
13
  exports.checkPackageFile = checkPackageFile;
13
14
  exports.checkSourceMap = checkSourceMap;
14
15
  exports.extractExternals = extractExternals;
@@ -50,6 +51,7 @@ function runChecks(packagePath) {
50
51
  var funcFiles = jsTsFiles.filter(function (f) {
51
52
  return packageFiles.includes(f);
52
53
  });
54
+ var errors = [];
53
55
  var warnings = [];
54
56
  var packageFilePath = _path["default"].join(packagePath, 'package.json');
55
57
  var json = JSON.parse(_fs["default"].readFileSync(packageFilePath, {
@@ -63,19 +65,25 @@ function runChecks(packagePath) {
63
65
  encoding: 'utf-8'
64
66
  });
65
67
  externals = extractExternals(content);
66
- if (externals) warnings.push.apply(warnings, (0, _toConsumableArray2["default"])(checkImportStatements(packagePath, jsTsFiles, externals)));
68
+ if (externals) errors.push.apply(errors, (0, _toConsumableArray2["default"])(checkImportStatements(packagePath, jsTsFiles, externals)));
67
69
  }
68
- warnings.push.apply(warnings, (0, _toConsumableArray2["default"])(checkSourceMap(packagePath)));
69
- warnings.push.apply(warnings, (0, _toConsumableArray2["default"])(checkFuncSignatures(packagePath, funcFiles)));
70
- warnings.push.apply(warnings, (0, _toConsumableArray2["default"])(checkPackageFile(packagePath, json, {
70
+ errors.push.apply(errors, (0, _toConsumableArray2["default"])(checkSourceMap(packagePath)));
71
+ errors.push.apply(errors, (0, _toConsumableArray2["default"])(checkNpmIgnore(packagePath)));
72
+ warnings.push.apply(warnings, (0, _toConsumableArray2["default"])(checkScriptNames(packagePath)));
73
+ errors.push.apply(errors, (0, _toConsumableArray2["default"])(checkFuncSignatures(packagePath, funcFiles)));
74
+ errors.push.apply(errors, (0, _toConsumableArray2["default"])(checkPackageFile(packagePath, json, {
71
75
  isWebpack: isWebpack,
72
76
  externals: externals
73
77
  })));
74
78
  warnings.push.apply(warnings, (0, _toConsumableArray2["default"])(checkChangelog(packagePath, json)));
75
79
  if (warnings.length) {
76
- console.log("Checking package ".concat(_path["default"].basename(packagePath), "..."));
80
+ console.log("".concat(_path["default"].basename(packagePath), " warnings"));
77
81
  warn(warnings);
78
- if (json.version.startsWith('0') || warnings.every(function (w) {
82
+ }
83
+ if (errors.length) {
84
+ console.log("Checking package ".concat(_path["default"].basename(packagePath), "..."));
85
+ showError(errors);
86
+ if (json.version.startsWith('0') || errors.every(function (w) {
79
87
  return warns.some(function (ww) {
80
88
  return w.includes(ww);
81
89
  });
@@ -513,6 +521,66 @@ function checkSourceMap(packagePath) {
513
521
  }
514
522
  return warnings;
515
523
  }
524
+ function checkNpmIgnore(packagePath) {
525
+ var warnings = [];
526
+ if (_fs["default"].existsSync(packagePath + '\\.npmignore')) {
527
+ var npmIgnoreContent = _fs["default"].readFileSync(packagePath + '\\.npmignore', {
528
+ encoding: 'utf-8'
529
+ });
530
+ var _iterator10 = _createForOfIteratorHelper(npmIgnoreContent.split('\n')),
531
+ _step10;
532
+ try {
533
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
534
+ var _row$match;
535
+ var row = _step10.value;
536
+ if ((((_row$match = row.match(new RegExp('\\s*dist\\/?\\s*$'))) === null || _row$match === void 0 ? void 0 : _row$match.length) || -1) > 0) {
537
+ warnings.push('there is dist directory in .npmignore');
538
+ break;
539
+ }
540
+ }
541
+ } catch (err) {
542
+ _iterator10.e(err);
543
+ } finally {
544
+ _iterator10.f();
545
+ }
546
+ } else warnings.push('.npmignore doesnt exists');
547
+ return warnings;
548
+ }
549
+ function checkScriptNames(packagePath) {
550
+ var warnings = [];
551
+ try {
552
+ if (_fs["default"].existsSync(packagePath)) {
553
+ var filesInDirectory = getAllFilesInDirectory(packagePath);
554
+ for (var _i2 = 0, _filesInDirectory = filesInDirectory; _i2 < _filesInDirectory.length; _i2++) {
555
+ var _fileName$match;
556
+ var fileName = _filesInDirectory[_i2];
557
+ if (((_fileName$match = fileName.match(new RegExp('^[A-Za-z0-9._-]*$'))) === null || _fileName$match === void 0 ? void 0 : _fileName$match.length) !== 1) warnings.push("".concat(fileName, ": file name contains inappropriate symbols"));
558
+ }
559
+ }
560
+ } catch (err) {}
561
+ return warnings;
562
+ }
563
+ function getAllFilesInDirectory(directoryPath) {
564
+ var excludedFilesToCheck = ['node_modules', 'dist'];
565
+ var fileNames = [];
566
+ var entries = _fs["default"].readdirSync(directoryPath);
567
+ entries.forEach(function (entry) {
568
+ var entryPath = _path["default"].join(directoryPath, entry);
569
+ var stat = _fs["default"].statSync(entryPath);
570
+ if (stat.isFile()) {
571
+ fileNames.push(entry);
572
+ } else if (stat.isDirectory() && !excludedFilesToCheck.includes(entry)) {
573
+ var subDirectoryFiles = getAllFilesInDirectory(entryPath);
574
+ fileNames = fileNames.concat(subDirectoryFiles);
575
+ }
576
+ });
577
+ return fileNames;
578
+ }
579
+ function showError(errors) {
580
+ errors.forEach(function (w) {
581
+ return color.error(w);
582
+ });
583
+ }
516
584
  function warn(warnings) {
517
585
  warnings.forEach(function (w) {
518
586
  return color.warn(w);
@@ -526,11 +594,11 @@ function getFuncMetadata(script) {
526
594
  inputs: [],
527
595
  outputs: []
528
596
  };
529
- var _iterator10 = _createForOfIteratorHelper(script.split('\n')),
530
- _step10;
597
+ var _iterator11 = _createForOfIteratorHelper(script.split('\n')),
598
+ _step11;
531
599
  try {
532
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
533
- var line = _step10.value;
600
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
601
+ var line = _step11.value;
534
602
  if (!line) continue;
535
603
  var match = line.match(utils.paramRegex);
536
604
  if (match) {
@@ -562,9 +630,9 @@ function getFuncMetadata(script) {
562
630
  }
563
631
  }
564
632
  } catch (err) {
565
- _iterator10.e(err);
633
+ _iterator11.e(err);
566
634
  } finally {
567
- _iterator10.f();
635
+ _iterator11.f();
568
636
  }
569
637
  return funcData;
570
638
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datagrok-tools",
3
- "version": "4.13.5",
3
+ "version": "4.13.6",
4
4
  "description": "Utility to upload and publish packages to Datagrok",
5
5
  "homepage": "https://github.com/datagrok-ai/public/tree/master/tools#readme",
6
6
  "dependencies": {