zet-lib 1.0.1 → 1.0.2

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/lib/Util.js CHANGED
@@ -234,7 +234,6 @@ Util.replaceAll = function (str, find, replace) {
234
234
  for (let i = 0; i < find.length; i++) {
235
235
  if (str.indexOf(find[i]) > -1) {
236
236
  t = str.replace(new RegExp(Util.escapeRegExp(find[i]), 'g'), replace);
237
- //console.log(t)
238
237
  }
239
238
  }
240
239
  } else {
@@ -502,25 +501,7 @@ Util.getKey = function (obj, field) {
502
501
  return t;
503
502
  };
504
503
 
505
- /**
506
- * Camelize a string, cutting the string by multiple separators like
507
- * hyphens, underscores and spaces.
508
- *
509
- * @param {text} string Text to camelize
510
- * @return string Camelized text
511
- *
512
- * // someDatabaseFieldName
513
- console.log(camelize("some_database_field_name"));
514
504
 
515
- // someLabelThatNeedsToBeCamelized
516
- console.log(camelize("Some label that needs to be camelized"));
517
-
518
- // someJavascriptProperty
519
- console.log(camelize("some-javascript-property"));
520
-
521
- // someMixedStringWithSpacesUnderscoresAndHyphens
522
- console.log(camelize("some-mixed_string with spaces_underscores-and-hyphens"));
523
- */
524
505
  Util.camelize = function (text) {
525
506
  return text.replace(/^([A-Z])|[\s-_]+(\w)/g, function (match, p1, p2, offset) {
526
507
  if (p2) return p2.toUpperCase();
@@ -528,28 +509,13 @@ Util.camelize = function (text) {
528
509
  });
529
510
  }
530
511
 
531
- /**
532
- * Decamelizes a string with/without a custom separator (underscore by default).
533
- *
534
- * @param str String in camelcase
535
- * @param separator Separator for the new decamelized string.
536
- *
537
- * // some database field name (separate with an empty space)
538
- console.log(decamelize("someDatabaseFieldName", " "));
539
-
540
- // some-label-that-needs-to-be-camelized (separate with an hyphen)
541
- console.log(decamelize("someLabelThatNeedsToBeCamelized", "-"));
542
-
543
- // some_javascript_property (separate with underscore)
544
- console.log(decamelize("someJavascriptPraroperty", "_"));
545
- */
546
512
  Util.decamelize = function (str, separator) {
547
513
  separator = typeof separator === 'undefined' ? '_' : separator;
548
514
  return str
549
- .replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2')
550
- .replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2')
551
- .replace("_", separator)
552
- .toLowerCase();
515
+ .replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2')
516
+ .replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2')
517
+ .replace("_", separator)
518
+ .toLowerCase();
553
519
  }
554
520
 
555
521
  /*
@@ -608,20 +574,20 @@ Util.asyncWrap = (fn) => {
608
574
  Util.capitalizeAfterSpace = function (str) {
609
575
  str = Util.replaceAll(str, "_", " ");
610
576
  return str.replace(
611
- /\w\S*/g,
612
- function (txt) {
613
- return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
614
- }
577
+ /\w\S*/g,
578
+ function (txt) {
579
+ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
580
+ }
615
581
  );
616
582
  };
617
583
 
618
584
  Util.capitalizeAfterSpaceTitle = function (str) {
619
585
  str = Util.replaceAll(str, " ", "_");
620
586
  return str.replace(
621
- /\w\S*/g,
622
- function (txt) {
623
- return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
624
- }
587
+ /\w\S*/g,
588
+ function (txt) {
589
+ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
590
+ }
625
591
  );
626
592
  };
627
593
 
@@ -682,21 +648,6 @@ Util.formatNumber = function (num, thousandSeparator='.') {
682
648
  }
683
649
  };
684
650
 
685
- Util.dumpError = function (err) {
686
- if (typeof err === 'object') {
687
- if (err.message) {
688
- console.log('\nMessage: ' + err.message)
689
- }
690
- if (err.stack) {
691
- console.log('\nStacktrace:')
692
- console.log('====================')
693
- console.log(err.stack);
694
- }
695
- } else {
696
- console.log(err);
697
- }
698
- };
699
-
700
651
  Util.fileAttribute = function (filename) {
701
652
  filename = filename.toLowerCase() || "";
702
653
  let ext = filename.split('.').pop();
@@ -751,7 +702,6 @@ Util.fileView = function (dir, file, attributes={}) {
751
702
  let withIcon = attributes.hasOwnProperty('withIcon') ? true : false;
752
703
  let obj = Util.fileExtension(filename);
753
704
  let className = attributes.hasOwnProperty('class') ? ` class="${attributes.class}" ` : '';
754
- //console.log(JSON.stringify(obj))
755
705
  if(filename.includes('https')) {
756
706
  html = `<img src="${file}" ${className} class="img-responsive">`
757
707
  } else {
@@ -1046,7 +996,6 @@ Util.readFile = function (filename) {
1046
996
  return data;
1047
997
  }
1048
998
  } catch (err) {
1049
- console.error(err)
1050
999
  }
1051
1000
  return ""
1052
1001
 
@@ -1056,7 +1005,6 @@ Util.dirExist = (dir, create = false) =>{
1056
1005
  try {
1057
1006
  if(create) {
1058
1007
  fs.ensureDir(dir, err => {
1059
- console.log(err); // => null
1060
1008
  });
1061
1009
  }
1062
1010
  // check if directory exists
@@ -1064,7 +1012,6 @@ Util.dirExist = (dir, create = false) =>{
1064
1012
  return true;
1065
1013
  }
1066
1014
  } catch (e) {
1067
- console.log(e);
1068
1015
  }
1069
1016
  return false;
1070
1017
  };
@@ -1083,7 +1030,6 @@ Util.getAllFiles = (dir) => {
1083
1030
  files = fs.readdirSync(dir);
1084
1031
  }
1085
1032
  } catch (e) {
1086
- console.log('error',e.toString());
1087
1033
  return [];
1088
1034
  }
1089
1035
  return files;
@@ -1096,7 +1042,6 @@ Util.writeFile = (filename, content) => {
1096
1042
  fs.writeFileSync(filename, content);
1097
1043
  return true
1098
1044
  } catch (e) {
1099
- console.log(e)
1100
1045
  return false
1101
1046
  }
1102
1047
  };
@@ -1106,13 +1051,11 @@ Util.deleteAllFiles = (dir) => {
1106
1051
  fs.emptyDirSync(dir);
1107
1052
  return true
1108
1053
  } catch (e) {
1109
- console.log(e)
1110
1054
  return false
1111
1055
  }
1112
1056
  };
1113
1057
 
1114
1058
  Util.findFilesName = (arr,filename) => {
1115
- console.log(filename)
1116
1059
  arr = arr || [];
1117
1060
  return arr.filter((item) => item.includes(filename));
1118
1061
  };
@@ -1132,12 +1075,8 @@ Util.getFiles = function (dir, token = "") {
1132
1075
  <p class="text-ellipsis ui-selectee">${item}</p>
1133
1076
  </div>`;
1134
1077
  } else {
1135
- console.log(dir);
1136
1078
  let explode = dir.split(token);
1137
- console.log(token)
1138
1079
  let path = explode[1] || "";
1139
-
1140
- console.log(path)
1141
1080
  let state = "";
1142
1081
  if (path == "") {
1143
1082
  state = "/" + item;
package/lib/zRoute.js CHANGED
@@ -43,9 +43,10 @@ zRoute.ROUTES = () => {
43
43
  let arr = [];
44
44
  const dir = `${dirRoot}/routes`;
45
45
  let routes = Util.getAllFiles(dir);
46
+ let nots = ['index','zindex','auth'];
46
47
  for (const item of routes) {
47
48
  let name = item.replace('.js', '');
48
- if (name != "index"){
49
+ if(!nots.includes(name)){
49
50
  arr.push(name)
50
51
  }
51
52
  }
@@ -714,10 +715,10 @@ zRoute.dataTableFilter = (MYMODEL, relations, filter) => {
714
715
  types[key] = 'input';
715
716
  break;
716
717
 
717
- /*case "json" :
718
- dataTable[key] = `<input type="number" class="form-control form-control-sm" value="${value}" id="data_table_${key}" >`;
719
- types[key] = 'input';
720
- break;*/
718
+ /*case "json" :
719
+ dataTable[key] = `<input type="number" class="form-control form-control-sm" value="${value}" id="data_table_${key}" >`;
720
+ types[key] = 'input';
721
+ break;*/
721
722
 
722
723
  case "virtual" :
723
724
  dataTable[key] = ``;
@@ -2393,7 +2394,7 @@ zRoute.generateJS = (req, res, MYMODEL, relations, zForms = "", data = {}) => {
2393
2394
  let obj = {};
2394
2395
  const MYMODELS = myCache.get('MYMODELS');
2395
2396
  let widgets = MYMODEL.widgets,
2396
- widgetsArray = Object.keys(widgets) || [];
2397
+ widgetsArray = Object.keys(widgets) || [];
2397
2398
  let hasDatePicker = false;
2398
2399
  let hasNumber = false;
2399
2400
  let hasClockPicker = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"