utiller 1.0.195 → 1.0.196

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.
@@ -2290,6 +2290,27 @@ var Utiller = /*#__PURE__*/function () {
2290
2290
  return _lodash["default"].toUpper(_cryptoJs["default"].SHA256(checkValue).toString(_cryptoJs["default"].enc.Hex));
2291
2291
  }
2292
2292
 
2293
+ /**
2294
+ * 把一段html文字轉換成類似document的結構 處理後再回傳文字
2295
+ // const result = utiller.getStringOfHandleHtml('<form id="_form_aiochk" action="https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5" method="post"><input type="hidden" name="MerchantTradeNo" id="MerchantTradeNo" value="sO6E2IilSGYpCChDqrI2" /><input type="hidden" name="MerchantTradeDate" id="MerchantTradeDate" value="2022/07/02 05:16:32" />' +
2296
+ // '<input type="hidden" name="TotalAmount" id="TotalAmount" value="350" /><input type="hidden" name="TradeDesc" id="TradeDesc" value="綠界第三方支付(明悅科技-線上支付)" /><input type="hidden" name="ItemName" id="ItemName" value="iphone13 pro x 2 = 200 元#iphone11 x 3 = 150 元#總價 350 元##※備註: 無備註內容" /><input type="hidden" name="ReturnURL" id="ReturnURL" value="https://us-central1-davidtu-dev.cloudfunctions.net/confirmedByByECPay" /><input type="hidden" name="ClientBackURL" id="ClientBackURL" value="https://www.google.com/" /><input type="hidden" name="ExpireDate" id="ExpireDate" value="1" /><input type="hidden" name="PaymentInfoURL" id="PaymentInfoURL" value="https://us-central1-davidtu-dev.cloudfunctions.net/paymentInfoByECPay" /><input type="hidden" name="ChoosePayment" id="ChoosePayment" value="ALL" /><input type="hidden" name="PlatformID" id="PlatformID" value="" /><input type="hidden" name="MerchantID" id="MerchantID" value="2000132" /><input type="hidden" name="InvoiceMark" id="InvoiceMark" value="N" /><input type="hidden" name="IgnorePayment" id="IgnorePayment" value="BARCODE#AndroidPay#ApplePay" /><input type="hidden" name="DeviceSource" id="DeviceSource" value="" /><input type="hidden" name="EncryptType" id="EncryptType" value="1" /><input type="hidden" name="PaymentType" id="PaymentType" value="aio" />' +
2297
+ // '<input type="hidden" name="CheckMacValue" id="CheckMacValue" value="D55E9E48C6AB83C063E0E13AD1B8C2EE8FA6547A7D7FCB33860B532E97D808BC" /><script type="text/javascript">document.getElementById("_form_aiochk").submit();</script></form>'
2298
+ // , (document) => {
2299
+ // const element = document.getElementById('CheckMacValue');
2300
+ // element.setAttribute('value', '123456');
2301
+ // })
2302
+ */
2303
+ }, {
2304
+ key: "getStringOfHandledHtml",
2305
+ value: function getStringOfHandledHtml(string) {
2306
+ var predicate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (document) {
2307
+ console.log(document);
2308
+ };
2309
+ var document = parse(string);
2310
+ predicate(document);
2311
+ return document.toString();
2312
+ }
2313
+
2293
2314
  /**
2294
2315
  * @param content = object
2295
2316
  * @param rules {KEY:predicate} | 'KEY', rules如果只放字串, rule = KEY就代表這個欄位不得為isUndefinedEmpty(), 如果是物件 => {key:predicate}
@@ -1720,26 +1720,35 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
1720
1720
  this.appendFile(destination, content, true, true);
1721
1721
  this.appendInfo("rewrite from:".concat(from, " => dest:").concat(destination, " succeed"));
1722
1722
  }
1723
+ }, {
1724
+ key: "getStringOfHeadOfFile",
1725
+ value: function getStringOfHeadOfFile(path) {
1726
+ if (this.isPathExist(path)) {
1727
+ var context = this.getFileContextInRaw(path);
1728
+ return _lodash["default"].head(context.split("\n"));
1729
+ }
1730
+ return "";
1731
+ }
1723
1732
 
1724
- /**
1725
- * 把一段html文字轉換成類似document的結構 處理後再回傳文字
1726
- // const result = utiller.getStringOfHandleHtml('<form id="_form_aiochk" action="https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5" method="post"><input type="hidden" name="MerchantTradeNo" id="MerchantTradeNo" value="sO6E2IilSGYpCChDqrI2" /><input type="hidden" name="MerchantTradeDate" id="MerchantTradeDate" value="2022/07/02 05:16:32" />' +
1727
- // '<input type="hidden" name="TotalAmount" id="TotalAmount" value="350" /><input type="hidden" name="TradeDesc" id="TradeDesc" value="綠界第三方支付(明悅科技-線上支付)" /><input type="hidden" name="ItemName" id="ItemName" value="iphone13 pro x 2 = 200 元#iphone11 x 3 = 150 元#總價 350 元##※備註: 無備註內容" /><input type="hidden" name="ReturnURL" id="ReturnURL" value="https://us-central1-davidtu-dev.cloudfunctions.net/confirmedByByECPay" /><input type="hidden" name="ClientBackURL" id="ClientBackURL" value="https://www.google.com/" /><input type="hidden" name="ExpireDate" id="ExpireDate" value="1" /><input type="hidden" name="PaymentInfoURL" id="PaymentInfoURL" value="https://us-central1-davidtu-dev.cloudfunctions.net/paymentInfoByECPay" /><input type="hidden" name="ChoosePayment" id="ChoosePayment" value="ALL" /><input type="hidden" name="PlatformID" id="PlatformID" value="" /><input type="hidden" name="MerchantID" id="MerchantID" value="2000132" /><input type="hidden" name="InvoiceMark" id="InvoiceMark" value="N" /><input type="hidden" name="IgnorePayment" id="IgnorePayment" value="BARCODE#AndroidPay#ApplePay" /><input type="hidden" name="DeviceSource" id="DeviceSource" value="" /><input type="hidden" name="EncryptType" id="EncryptType" value="1" /><input type="hidden" name="PaymentType" id="PaymentType" value="aio" />' +
1728
- // '<input type="hidden" name="CheckMacValue" id="CheckMacValue" value="D55E9E48C6AB83C063E0E13AD1B8C2EE8FA6547A7D7FCB33860B532E97D808BC" /><script type="text/javascript">document.getElementById("_form_aiochk").submit();</script></form>'
1729
- // , (document) => {
1730
- // const element = document.getElementById('CheckMacValue');
1731
- // element.setAttribute('value', '123456');
1732
- // })
1733
- */
1733
+ /** 因為code gen有很多要persistent, 沒有修改過{const edit = true}的index persist就不要理它 */
1734
1734
  }, {
1735
- key: "getStringOfHandledHtml",
1736
- value: function getStringOfHandledHtml(string) {
1737
- var predicate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (document) {
1738
- console.log(document);
1739
- };
1740
- var document = (0, _nodeHtmlParser.parse)(string);
1741
- predicate(document);
1742
- return document.toString();
1735
+ key: "isFileEditSucceed",
1736
+ value: function isFileEditSucceed(path) {
1737
+ var stringOfObj = _lodash["default"].trim(this.getStringOfHeadOfFile(path));
1738
+ try {
1739
+ var first = _lodash["default"].tail(stringOfObj.split(" ")).join(" ");
1740
+ var second = this.getNormalizedStringNotEndWith(first, ";");
1741
+ var splits = second.split("=").map(function (each) {
1742
+ return _lodash["default"].trim(each);
1743
+ });
1744
+ var result = "\"".concat(splits.shift(), "\" : ").concat(splits.pop());
1745
+ var json = JSON.parse("{".concat(result, "}"));
1746
+ if (_lodash["default"].isEqual(this.getObjectValue(json), true)) return true;
1747
+ } catch (error) {
1748
+ this.appendError("66445411 ".concat(error.message));
1749
+ return false;
1750
+ }
1751
+ return false;
1743
1752
  }
1744
1753
  }]);
1745
1754
  }(_index["default"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utiller",
3
- "version": "1.0.195",
3
+ "version": "1.0.196",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,7 @@
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
13
  "configerer": "^1.0.11",
14
- "utiller": "^1.0.194",
14
+ "utiller": "^1.0.195",
15
15
  "linepayer": "^1.0.4",
16
16
  "databazer": "^1.0.12",
17
17
  "lodash": "^4.17.20",