zet-lib 5.0.3 → 6.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.
@@ -516,18 +516,6 @@
516
516
  }
517
517
  })
518
518
 
519
- $('.btn-minify').on('click', function () {
520
- if (window.confirm('Minify all views in one line make your website faster ?')) {
521
- ajaxPost('/<%- routeName%>/minify', {}, function (data) {
522
- if (data.status == 0) {
523
- toastr.error(data.message, data.title)
524
- } else {
525
- toastr.success(data.title, data.message)
526
- }
527
- })
528
- }
529
- })
530
-
531
519
  $('.btn-generate-assets').on('click', function () {
532
520
  if (window.confirm('Replace javascript assets with this one ?')) {
533
521
  ajaxPost('/<%- routeName%>/generate-assets', {}, function (data) {
@@ -5,8 +5,6 @@ const csrfProtection = csrf({ cookie: true });
5
5
  const fs = require("fs-extra");
6
6
  const axios = require("axios");
7
7
  const getPm2 = require("./optionalPm2");
8
- const uglifyJS = require("uglify-js");
9
- const { minify } = require("html-minifier-terser");
10
8
  const zRoute = require("./zRoute");
11
9
  const connection = require("./connection");
12
10
  const Util = require("./Util");
@@ -614,22 +612,10 @@ const generate = async (req, res) => {
614
612
  if (!fs.existsSync(DIR_VIEW)) {
615
613
  fs.mkdirSync(DIR_VIEW);
616
614
  }
617
- let compilesJS = ["createjs.ejs", "updatejs.ejs", "importjs.ejs"];
618
615
  if (!dummy) {
619
616
  for (const q in filesKey) {
620
617
  console.log(q);
621
- if (Util.in_array(q, compilesJS)) {
622
- fs.writeFileSync(path.join(DIR_VIEW, q), filesKey[q]);
623
- } else {
624
- fs.writeFileSync(
625
- path.join(DIR_VIEW, q),
626
- await minify(filesKey[q], {
627
- minifyJS: true,
628
- minifyCSS: true,
629
- collapseWhitespace: true,
630
- })
631
- );
632
- }
618
+ fs.writeFileSync(path.join(DIR_VIEW, q), filesKey[q]);
633
619
  console.log(`The files views of ${q} is saved!`);
634
620
  }
635
621
  }
@@ -657,17 +643,11 @@ const generate = async (req, res) => {
657
643
  let relations = await zRoute.relations(req, res, MYMODEL.table);
658
644
  //add script
659
645
  let jsObj = zRoute.generateJS(req, res, MYMODEL, relations);
660
- //minify script
661
- let script = uglifyJS.minify(jsObj.script);
662
- if (script.error) {
663
- console.log(jsObj.script);
664
- throw script.error;
665
- }
666
646
  let time = new Date().getTime();
667
647
  Util.deleteAllFiles(path_script);
668
648
  Util.deleteAllFiles(path_head);
669
649
  Util.deleteAllFiles(path_end);
670
- Util.writeFile(path.join(path_script, `${time}.js`), script.code);
650
+ Util.writeFile(path.join(path_script, `${time}.js`), jsObj.script);
671
651
  Util.writeFile(path.join(path_head, "head.txt"), jsObj.head);
672
652
  Util.writeFile(path.join(path_end, "end.txt"), jsObj.end);
673
653
  }
@@ -1589,10 +1569,7 @@ router.post("/generate-assets", async (req, res) => {
1589
1569
  Util.deleteAllFiles(path_end);
1590
1570
  Util.deleteAllFiles(path_script);
1591
1571
 
1592
- //minify script
1593
- let script = uglifyJS.minify(jsObj.script);
1594
- if (script.error) throw script.error;
1595
- Util.writeFile(path.join(path_script, `${time}.js`), script.code);
1572
+ Util.writeFile(path.join(path_script, `${time}.js`), jsObj.script);
1596
1573
  Util.writeFile(path.join(path_head, "head.txt"), jsObj.head);
1597
1574
  Util.writeFile(path.join(path_end, "end.txt"), jsObj.end);
1598
1575
  }
@@ -1602,63 +1579,6 @@ router.post("/generate-assets", async (req, res) => {
1602
1579
  res.json(notifObj);
1603
1580
  });
1604
1581
 
1605
- router.post("/minify", async (req, res) => {
1606
- let notifyObj = Util.jsonSuccess("Success to cached");
1607
- try {
1608
- notifyObj = await viewsMini();
1609
- } catch (e) {
1610
- console.log(e);
1611
- notifyObj = Util.flashError(e.toString());
1612
- }
1613
- res.json(notifyObj);
1614
- });
1615
-
1616
- const viewsMini = async () => {
1617
- let notifyObj = Util.jsonSuccess("Success");
1618
- const viewDir = path.join(dirRoot, "views");
1619
- const layoutsDir = path.join(dirRoot, "views", "layouts");
1620
- let item;
1621
- try {
1622
- let views = Util.getAllFiles(viewDir);
1623
- let options = {
1624
- minifyJS: true,
1625
- minifyCSS: true,
1626
- collapseWhitespace: true,
1627
- };
1628
- const notViewDir = ["zgenerator", "layouts", "index", "zindex"];
1629
- for (const dir of views) {
1630
- console.log("dir :", dir);
1631
- if (!Util.in_array(dir, notViewDir)) {
1632
- let files = Util.getAllFiles(path.join(viewDir, dir));
1633
- //console.log(files);
1634
- for (item of files) {
1635
- if (item.includes(".ejs")) {
1636
- let filename = path.join(viewDir, dir, item);
1637
- let content = Util.readFile(filename);
1638
- let contentChange = await minify(content, options);
1639
- fs.writeFileSync(filename, contentChange);
1640
- }
1641
- }
1642
- }
1643
- }
1644
-
1645
- let layouts = Util.getAllFiles(layoutsDir);
1646
- for (item of layouts) {
1647
- if (item.includes(".ejs")) {
1648
- let filename = path.join(layoutsDir, item);
1649
- let content = Util.readFile(filename);
1650
- let contentChange = await minify(content, options);
1651
- fs.writeFileSync(filename, contentChange);
1652
- }
1653
- }
1654
- } catch (e) {
1655
- notifyObj = Util.flashError(
1656
- `error in item : ${item} , error str :${e.toString()}`
1657
- );
1658
- }
1659
- return notifyObj;
1660
- };
1661
-
1662
1582
  router.post("/load-joins", async (req, res) => {
1663
1583
  let jsonNotif = Util.jsonSuccess("Success");
1664
1584
  let html = "";
package/lib/zPage.js CHANGED
@@ -8,7 +8,6 @@ const nodemailer = require('nodemailer');
8
8
  const qs = require('qs');
9
9
  const moment = require('moment');
10
10
  const getPm2 = require('./optionalPm2');
11
- const { minify } = require('html-minifier-terser');
12
11
  const connection = require('./connection');
13
12
  const Util = require('./Util');
14
13
  const myCache = require('./cache');
@@ -159,14 +158,7 @@ zpage.createRoute = (obj, token, layoutObj) => {
159
158
  zpage.buildLayout = async (obj) => {
160
159
  let name = Util.toName(obj.name);
161
160
  if (obj.active) {
162
- let html = await minify(obj.code,{
163
- removeComments:true,
164
- minifyJS:true,
165
- minifyCSS:true,
166
- collapseWhitespace: true
167
- });
168
- console.log(path.join(dirRoot, "views", "layouts", name + ".ejs"));
169
- fs.writeFileSync(path.join(dirRoot, "views", "layouts", name + ".ejs"), html, 'utf-8');
161
+ fs.writeFileSync(path.join(dirRoot, "views", "layouts", name + ".ejs"), obj.code, 'utf-8');
170
162
  if (process.env.NODE_ENV === "production") {
171
163
  setTimeout(function () {
172
164
  const pm2 = getPm2()
package/lib/zRoute.js CHANGED
@@ -8,7 +8,6 @@ const qs = require("qs");
8
8
  //for generate PDF
9
9
  const puppeteer = require("puppeteer");
10
10
  const ejs = require("ejs");
11
- const uglifyJS = require("uglify-js");
12
11
  const Excel = require("exceljsremake");
13
12
  const fs = require("fs-extra");
14
13
  const Util = require("./Util");
@@ -4123,8 +4122,7 @@ zRoute.moduleLib = (req, res, MYMODEL, relations, zForms = "", data = {}) => {
4123
4122
  let time = new Date().getTime();
4124
4123
  Util.deleteAllFiles(path_head);
4125
4124
  Util.deleteAllFiles(path_end);
4126
- //minify js
4127
- Util.writeFile(path.join(path_script, `${time}.js`), uglifyJS.minify(jsObj.script));
4125
+ Util.writeFile(path.join(path_script, `${time}.js`), jsObj.script);
4128
4126
  Util.writeFile(path.join(path_head, "head.txt"), jsObj.head);
4129
4127
  Util.writeFile(path.join(path_end, "end.txt"), jsObj.end);
4130
4128
  end += `<script src="/runtime/script/${table}/${time}.js"></script>`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "5.0.3",
3
+ "version": "6.0.0",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"
@@ -32,10 +32,9 @@
32
32
  "dotenv": "^16.5.0",
33
33
  "dropbox": "^10.34.0",
34
34
  "ejs": "^3.1.10",
35
- "exceljsremake": "^0.1.3",
35
+ "exceljsremake": "^0.1.4",
36
36
  "express-zip": "^3.0.0",
37
37
  "fs-extra": "^11.3.4",
38
- "html-minifier-terser": "^7.2.0",
39
38
  "isomorphic-fetch": "^3.0.0",
40
39
  "js-sha256": "^0.11.1",
41
40
  "jszip": "^3.10.1",
@@ -43,12 +42,11 @@
43
42
  "node-cache": "^5.1.2",
44
43
  "nodemailer": "^8.0.5",
45
44
  "pg": "^8.16.3",
46
- "puppeteer": "^24.40.0",
45
+ "puppeteer": "^25.1.0",
47
46
  "qs": "^6.14.0",
48
47
  "randomstring": "^1.3.1",
49
48
  "read-excel-file": "^5.8.0",
50
- "socket.io": "^4.8.3",
51
- "uglify-js": "^3.19.3"
49
+ "socket.io": "^4.8.3"
52
50
  },
53
51
  "optionalDependencies": {
54
52
  "sharp": "^0.34.1"