UNPKG

fa-toolkit

Version:

a devtool for fast app

1 lines 15.3 kB
"use strict";var _0x32048c=_0x48b4;function _0x48b4(r,e){var t=_0x344b();return(_0x48b4=function(r,e){return t[r-=117]})(r,e)}function _typeof(r){var t=_0x48b4;return(_typeof="function"==typeof Symbol&&t(248)==typeof Symbol[t(193)]?function(r){return typeof r}:function(r){var e=t;return r&&"function"==typeof Symbol&&r[e(123)]===Symbol&&r!==Symbol.prototype?e(248):typeof r})(r)}function _regeneratorRuntime(){var f=_0x48b4;_regeneratorRuntime=function(){return c};var c={},r=Object.prototype,s=r[f(128)],p=Object.defineProperty||function(r,e,t){r[e]=t.value},e=f(201)==typeof Symbol?Symbol:{},a=e[f(193)]||f(244),t=e.asyncIterator||f(167),n=e[f(165)]||f(178);function i(r,e,t){return Object[f(219)](r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}),r[e]}try{i({},"")}catch(r){i=function(r,e,t){return r[e]=t}}function u(r,e,t,n){var a,o,c,u,s,e=e&&e.prototype instanceof v?e:v,e=Object.create(e[f(262)]),n=new x(n||[]);return p(e,"_invoke",{value:(a=r,o=t,c=n,s=(u=f)(141),function(r,e){var t=u;if(t(231)===s)throw new Error(t(212));if(t(121)===s){if(t(183)===r)throw e;return S()}for(c.method=r,c[t(203)]=e;;){var n=c[t(156)];if(n){var i=function r(e,t){var n=f,i=t[n(259)],a=e.iterator[i];if(void 0===a)return t[n(156)]=null,n(183)===i&&e[n(193)][n(214)]&&(t[n(259)]=n(214),t[n(203)]=void 0,r(e,t),n(183)===t[n(259)])||n(214)!==i&&(t[n(259)]="throw",t[n(203)]=new TypeError(n(146)+i+"' method")),h;a=l(a,e[n(193)],t[n(203)]);if(n(183)===a[n(162)])return t[n(259)]="throw",t.arg=a.arg,t[n(156)]=null,h;var a=a[n(203)];return a?a.done?(t[e[n(129)]]=a[n(199)],t.next=e.nextLoc,n(214)!==t[n(259)]&&(t[n(259)]=n(179),t[n(203)]=void 0),t[n(156)]=null,h):a:(t.method=n(183),t[n(203)]=new TypeError(n(132)),t[n(156)]=null,h)}(n,c);if(i){if(i===h)continue;return i}}if(t(179)===c.method)c[t(186)]=c[t(153)]=c[t(203)];else if(t(183)===c.method){if(t(141)===s)throw s="completed",c[t(203)];c[t(161)](c[t(203)])}else t(214)===c[t(259)]&&c.abrupt(t(214),c[t(203)]);s=t(231);i=l(a,o,c);if(t(170)===i.type){if(s=c[t(235)]?t(121):"suspendedYield",i[t(203)]===h)continue;return{value:i[t(203)],done:c[t(235)]}}t(183)===i.type&&(s=t(121),c[t(259)]="throw",c.arg=i[t(203)])}})}),e}function l(r,e,t){var n=f;try{return{type:"normal",arg:r[n(172)](e,t)}}catch(r){return{type:n(183),arg:r}}}c[f(218)]=u;var h={};function v(){}function o(){}function y(){}var g={};i(g,a,function(){return this});e=Object[f(163)],e=e&&e(e(w([])));e&&e!==r&&s.call(e,a)&&(g=e);var _=y[f(262)]=v[f(262)]=Object.create(g);function d(r){var e=f;[e(179),e(183),e(214)][e(234)](function(e){i(r,e,function(r){return this[_0x48b4(122)](e,r)})})}function b(c,u){var e,i=f;p(this,i(122),{value:function(t,n){function r(){return new u(function(r,e){!function e(r,t,n,i){var a=_0x48b4,r=l(c[r],c,t);if(a(183)!==r.type){var o=r[a(203)],t=o.value;return t&&a(215)==_typeof(t)&&s[a(172)](t,a(120))?u[a(223)](t.__await)[a(127)](function(r){e(a(179),r,n,i)},function(r){e(a(183),r,n,i)}):u.resolve(t)[a(127)](function(r){o.value=r,n(o)},function(r){return e(a(183),r,n,i)})}i(r.arg)}(t,n,r,e)})}return e=e?e[i(127)](r,r):r()}})}function m(r){var e=f,t={tryLoc:r[0]};1 in r&&(t[e(211)]=r[1]),2 in r&&(t.finallyLoc=r[2],t[e(209)]=r[3]),this.tryEntries.push(t)}function k(r){var e=f,t=r.completion||{};t[e(162)]="normal",delete t[e(203)],r[e(137)]=t}function x(r){var e=f;this[e(243)]=[{tryLoc:e(181)}],r[e(234)](m,this),this[e(197)](!0)}function w(t){var n=f;if(t){var r=t[a];if(r)return r[n(172)](t);if("function"==typeof t.next)return t;if(!isNaN(t[n(190)])){var i=-1,r=function r(){for(var e=n;++i<t[e(190)];)if(s[e(172)](t,i))return r[e(199)]=t[i],r[e(235)]=!1,r;return r[e(199)]=void 0,r[e(235)]=!0,r};return r[n(179)]=r}}return{next:S}}function S(){return{value:void 0,done:!0}}return o.prototype=y,p(_,f(123),{value:y,configurable:!0}),p(y,f(123),{value:o,configurable:!0}),o[f(247)]=i(y,n,f(119)),c.isGeneratorFunction=function(r){var e=f,r=e(201)==typeof r&&r[e(123)];return!!r&&(r===o||e(119)===(r.displayName||r.name))},c.mark=function(r){var e=f;return Object[e(147)]?Object.setPrototypeOf(r,y):(r[e(143)]=y,i(r,n,"GeneratorFunction")),r.prototype=Object[e(206)](_),r},c[f(171)]=function(r){return{__await:r}},d(b[f(262)]),i(b[f(262)],t,function(){return this}),c[f(182)]=b,c[f(175)]=function(r,e,t,n,i){var a=f;void 0===i&&(i=Promise);var o=new b(u(r,e,t,n),i);return c[a(200)](e)?o:o[a(179)]()[a(127)](function(r){var e=a;return r[e(235)]?r.value:o[e(179)]()})},d(_),i(_,n,f(253)),i(_,a,function(){return this}),i(_,f(239),function(){return f(149)}),c.keys=function(r){var e,n=f,i=Object(r),a=[];for(e in i)a.push(e);return a[n(256)](),function r(){for(var e=n;a.length;){var t=a[e(180)]();if(t in i)return r[e(199)]=t,r.done=!1,r}return r.done=!0,r}},c[f(155)]=w,x[f(262)]={constructor:x,reset:function(r){var e=f;if(this[e(184)]=0,this.next=0,this[e(186)]=this[e(153)]=void 0,this[e(235)]=!1,this[e(156)]=null,this[e(259)]=e(179),this[e(203)]=void 0,this[e(243)][e(234)](k),!r)for(var t in this)"t"===t.charAt(0)&&s.call(this,t)&&!isNaN(+t[e(204)](1))&&(this[t]=void 0)},stop:function(){var r=f;this[r(235)]=!0;var e=this[r(243)][0][r(137)];if("throw"===e[r(162)])throw e[r(203)];return this.rval},dispatchException:function(n){var i=f;if(this[i(235)])throw n;var a=this;function r(r,e){var t=i;return o.type=t(183),o.arg=n,a[t(179)]=r,e&&(a[t(259)]="next",a[t(203)]=void 0),!!e}for(var e=this[i(243)][i(190)]-1;0<=e;--e){var t=this[i(243)][e],o=t[i(137)];if(i(181)===t[i(138)])return r(i(257));if(t.tryLoc<=this.prev){var c=s[i(172)](t,i(211)),u=s[i(172)](t,i(258));if(c&&u){if(this.prev<t[i(211)])return r(t[i(211)],!0);if(this[i(184)]<t[i(258)])return r(t[i(258)])}else if(c){if(this[i(184)]<t[i(211)])return r(t[i(211)],!0)}else{if(!u)throw new Error(i(173));if(this[i(184)]<t[i(258)])return r(t[i(258)])}}}},abrupt:function(r,e){for(var t=f,n=this[t(243)][t(190)]-1;0<=n;--n){var i=this[t(243)][n];if(i[t(138)]<=this[t(184)]&&s.call(i,t(258))&&this.prev<i[t(258)]){var a=i;break}}var o=(a=a&&("break"===r||"continue"===r)&&a[t(138)]<=e&&e<=a[t(258)]?null:a)?a[t(137)]:{};return o[t(162)]=r,o[t(203)]=e,a?(this[t(259)]=t(179),this[t(179)]=a[t(258)],h):this[t(142)](o)},complete:function(r,e){var t=f;if(t(183)===r[t(162)])throw r.arg;return t(164)===r[t(162)]||"continue"===r.type?this[t(179)]=r[t(203)]:t(214)===r[t(162)]?(this[t(227)]=this[t(203)]=r[t(203)],this[t(259)]=t(214),this[t(179)]=t(257)):t(170)===r[t(162)]&&e&&(this.next=e),h},finish:function(r){for(var e=f,t=this.tryEntries[e(190)]-1;0<=t;--t){var n=this[e(243)][t];if(n[e(258)]===r)return this[e(142)](n[e(137)],n.afterLoc),k(n),h}},catch:function(r){for(var e=f,t=this[e(243)].length-1;0<=t;--t){var n=this[e(243)][t];if(n[e(138)]===r){var i,a=n[e(137)];return e(183)===a[e(162)]&&(i=a[e(203)],k(n)),i}}throw new Error(e(124))},delegateYield:function(r,e,t){var n=f;return this.delegate={iterator:w(r),resultName:e,nextLoc:t},n(179)===this[n(259)]&&(this[n(203)]=void 0),h}},c}function asyncGeneratorStep(r,e,t,n,i,a,o){var c=_0x48b4;try{var u=r[a](o),s=u[c(199)]}catch(r){return void t(r)}u[c(235)]?e(s):Promise[c(223)](s)[c(127)](n,i)}function _asyncToGenerator(c){return function(){var r=this,o=arguments;return new Promise(function(e,t){var n=c.apply(r,o);function i(r){asyncGeneratorStep(n,e,t,i,a,"next",r)}function a(r){asyncGeneratorStep(n,e,t,i,a,"throw",r)}i(void 0)})}}!function(){for(var r=_0x48b4,e=_0x344b();;)try{if(917216==-parseInt(r(148))+parseInt(r(202))/2*(parseInt(r(254))/3)+-parseInt(r(233))/4+parseInt(r(189))/5*(parseInt(r(125))/6)+-parseInt(r(225))/7*(-parseInt(r(160))/8)+parseInt(r(191))/9+parseInt(r(220))/10*(-parseInt(r(176))/11))break;e.push(e.shift())}catch(r){e.push(e.shift())}}();var fs=require("fs"),path=require(_0x32048c(139)),JsZip=require(_0x32048c(130)),faCoreUtils=require(_0x32048c(246)),_require=require("../common/utils"),clearResource=_require[_0x32048c(208)],_require2=require(_0x32048c(145)),mkdirsSync=_require2[_0x32048c(207)],signUtils=require(_0x32048c(144)),REQUIRED_KEY=[_0x32048c(250),_0x32048c(242),"passwordDigest",_0x32048c(261)],REGEXP_ICON=/^{{\$t\('(.+)'\)}}$/g,MANIFEST=_0x32048c(152),rpkOutPath="";function _0x344b(){var r=["20dmELBo","every","code","resolve","exports","679YAZVNb","stop","rval","Can not resolve certificate file: ","loadAsync","join","executing","../common/icon-handler","819856kOpgzh","forEach","done","Can not resolve rpk file: ","includes","parse","toString","stringify","concat","userName","tryEntries","@@iterator","generatePkgDef","@hw-quickapp/fa-core-utils","displayName","symbol","string","keyId","sync","package","Generator","18wpHpQs","certFilePath","reverse","end","finallyLoc","method","quickapp.config.js","encryptPassword","prototype","utf8","rpkBuffer","GeneratorFunction","__await","completed","_invoke","constructor","illegal catch attempt","1296618pLiCNB","getResources","then","hasOwnProperty","resultName","jszip","subPkgs","iterator result is not an object","/*.json","versionName","dirname","utf-8","completion","tryLoc","path","apply","suspendedStart","complete","__proto__","../../sign-tools/rpk-sign-utils","../fa-compiler/utils","The iterator does not provide a '","setPrototypeOf","225660ncktDM","[object Generator]","privKeyFilePath","icon","manifest.json","_sent","unzip","values","delegate","trim","writeFileSync","readFileSync","26968zJOUrw","dispatchException","type","getPrototypeOf","break","toStringTag","existsSync","@@asyncIterator","getSignInfo","addWatermark","normal","awrap","call","try statement without catch or finally","reduce","async","8096924oqPWnC","mark","@@toStringTag","next","pop","root","AsyncIterator","throw","prev","private.pem","sent","file","i18n","20zYIgHh","length","12506175UxbMEC","glob","iterator","sign","abrupt","keys","reset","build","value","isGeneratorFunction","function","79678QSgdLV","arg","slice","mainPkg","create","mkdirsSync","clearResource","afterLoc","dist","catchLoc","Generator is already running","files","return","object",".rpk","beta","wrap","defineProperty"];return(_0x344b=function(){return r})()}function rpkHandler(l,h){var v,t;return new Promise((v=_0x48b4,t=_asyncToGenerator(_regeneratorRuntime()[v(177)](function r(t,n){var i,a,o,c,u,s,f,p=v;return _regeneratorRuntime()[p(218)](function(r){for(var e=p;;)switch(r[e(184)]=r[e(179)]){case 0:if(fs.existsSync(l)){r[e(179)]=4;break}return r[e(195)]("return",n(new Error(e(236)[e(241)](l))));case 4:if(fs[e(166)](h)){r[e(179)]=6;break}return r[e(195)](e(214),n(new Error(e(228).concat(h))));case 6:return r[e(179)]=8,getManifest(l);case 8:if(isNullObject(i=r[e(186)]))return r[e(195)](e(214),n(new Error("Invalid rpk file.")));r[e(179)]=11;break;case 11:if(a=path[e(135)](h),o=resolveFilePath(a,e(185)),c=null,o){r.next=18;break}if(isNullObject(c=getSignConfig(a)))return r[e(195)](e(214),n(new Error("Missing private key or signature configuration.")));r[e(179)]=18;break;case 18:return s=i.package,u=path.dirname(l),f=path.join(u,s),u=path[e(230)](f,e(198)),s=path[e(230)](f,e(210)),r[e(179)]=25,extractRpk(l,u);case 25:return r[e(179)]=27,processFile(u);case 27:return f={privKeyFilePath:o,certFilePath:h,projectSignCfg:c},r[e(179)]=30,repackRpk(i,s,u,f);case 30:return r.abrupt(e(214),t(rpkOutPath));case 31:case"end":return r.stop()}},r)})),function(r,e){return t[v(140)](this,arguments)}))}function repackRpk(r,e,t,n){return _repackRpk[_0x32048c(140)](this,arguments)}function _repackRpk(){var r=_0x32048c;return(_repackRpk=_asyncToGenerator(_regeneratorRuntime().mark(function r(t,n,i,a){var o,c,u,s,f,p,l=_0x48b4;return _regeneratorRuntime()[l(218)](function(r){for(var e=l;;)switch(r[e(184)]=r[e(179)]){case 0:return mkdirsSync(n),o=t[e(252)],c=t[e(134)],s=a[e(150)],u=a[e(255)],f=a.projectSignCfg,u=fs[e(159)](u),s=f?f[e(250)]:fs.readFileSync(s),r.next=7,signUtils[e(168)](u,s,f);case 7:return u=r[e(186)],s=signUtils[e(126)](i),p=signUtils[e(245)]([]),f=p[e(205)],p=p[e(131)],signUtils.addResourceToPkg(s,i,f,p),r[e(179)]=13,signUtils.signPkgs(o,u,f,p);case 13:p=r.sent,p=p[e(118)],rpkOutPath=path.join(n,""[e(241)](o,"_beta_")[e(241)](c,e(216))),fs[e(158)](rpkOutPath,p);case 17:case"end":return r[e(226)]()}},r)})))[r(140)](this,arguments)}function getManifest(r){return _getManifest[_0x32048c(140)](this,arguments)}function _getManifest(){var e=_0x32048c;return(_getManifest=_asyncToGenerator(_regeneratorRuntime()[e(177)](function r(t){var n,i,a=e;return _regeneratorRuntime()[a(218)](function(r){for(var e=a;;)switch(r[e(184)]=r[e(179)]){case 0:return n=new JsZip,r[e(179)]=3,n[e(229)](fs.readFileSync(t));case 3:if((i=r[e(186)])&&i[e(213)][MANIFEST]){r[e(179)]=6;break}return r[e(195)]("return",{});case 6:return r[e(179)]=8,n[e(187)](MANIFEST)[e(175)](e(249));case 8:return i=r[e(186)],r[e(195)](e(214),JSON[e(238)](i)||{});case 10:case e(257):return r[e(226)]()}},r)})))[e(140)](this,arguments)}function getSignConfig(r){for(var e=_0x32048c,t=path.join(r,".."),n=["quickapp.config.json",e(260)],i={},a=0;a<n.length;a++){var o=resolveFilePath(t,n[a]);if(fs.existsSync(o)){i=require(o);break}}return checkSignCfg(i)?i[e(194)]:{}}function checkSignCfg(r){var t=_0x32048c;if(r&&r[t(194)]){var n=r.sign;return REQUIRED_KEY[t(221)](function(r){var e=t;return Object[e(196)](n)[e(237)](r)&&n[r]})}return!1}function resolveFilePath(r,e){var t=_0x32048c,n=2<arguments[t(190)]&&void 0!==arguments[2]?arguments[2]:1,i=path[t(230)](r,e);return fs[t(166)](i)?i:n<2?resolveFilePath(path[t(230)](r,".."),e,n+1):""}function isNullObject(r){var e=_0x32048c;return 0===Object[e(196)](r)[e(190)]}function processFile(r){return _processFile[_0x32048c(140)](this,arguments)}function _processFile(){var e=_0x32048c;return(_processFile=_asyncToGenerator(_regeneratorRuntime()[e(177)](function r(t){var n,i,a,o,c,u=e;return _regeneratorRuntime()[u(218)](function(r){for(var e=u;;)switch(r[e(184)]=r.next){case 0:if(n=path[e(230)](t,e(152)),(i=JSON[e(238)](fs.readFileSync(n,e(136)))).versionType=e(217),fs.writeFileSync(n,JSON[e(240)](i,null,2)),!(0<(i=getLogoPath(i[e(151)],t)).length)){r[e(179)]=15;break}c=require(e(232)),a=c[e(169)],o=0;case 8:if(o<i[e(190)])return c=i[o],r[e(179)]=12,a(c,c);r.next=15;break;case 12:o++,r[e(179)]=8;break;case 15:case e(257):return r[e(226)]()}},r)})))[e(140)](this,arguments)}function getLogoPath(r,n){var i=_0x32048c,e=r[i(157)]()||"";if(!e.match(REGEXP_ICON))return[path[i(230)](n,e)];var t=path[i(230)](n,i(188));if(!fs.existsSync(t))return[];var r=require(i(192)),t=t.replace(/\\/g,"/"),a=e.replace(REGEXP_ICON,"$1");return r[i(251)](""[i(241)](t,i(133)))[i(174)](function(r,e){var t=i,t=JSON[t(238)](fs[t(159)](e,t(117)));return t[a]&&r.push(path.join(n,t[a])),r},[])}function extractRpk(r,e){return _extractRpk.apply(this,arguments)}function _extractRpk(){var r=_0x32048c;return(_extractRpk=_asyncToGenerator(_regeneratorRuntime()[r(177)](function r(t,n){var i,a;return _regeneratorRuntime().wrap(function(r){for(var e=_0x48b4;;)switch(r.prev=r[e(179)]){case 0:return r.next=2,clearResource([path[e(135)](n)]);case 2:return mkdirsSync(n),r[e(179)]=5,faCoreUtils[e(154)](t,n,{overwrite:!0});case 5:if(i=r[e(186)],a=i[e(222)],i=i.message,0===a)return a=path[e(230)](n,"META-INF"),r[e(179)]=12,clearResource([a]);r.next=14;break;case 12:r[e(179)]=15;break;case 14:throw i;case 15:case e(257):return r[e(226)]()}},r)}))).apply(this,arguments)}module[_0x32048c(224)]={rpkHandler:rpkHandler,processFile:processFile};