UNPKG

fa-toolkit

Version:

a devtool for fast app

1 lines 12.2 kB
"use strict";var _0x2eb81f=_0x3292;function _0x257a(){var e=["941928axAGhX","1503635VNxtWn","adaptApiFile","length","directCommit","12QkYRXv","qxml","stringify","split","srcRootPath","defineProperty","pages","miniProgramProject","subpackages","setOriginPtahObject","__esModule","versionName","Common","packageName","assets/","appConfig","projectFileSuffix","windowItems","assets","statSync","1620368iSFgdH","name","iconPath","2985171iOfDVz","error","entryPagePath","isArray","miniprogram_npm","tablebarItems","../parse/importVisitor","env","locale",".js","zh-cn","versionCode","map","lib","1050184guaRFr",'{"locale": "zh-cn"}',"target","slice","eventTargetKey","writeFileSync","transformJsFile","concat","create","package","Hello","forEach","tabBar","output","configBasename",".qjs","replace",".json","hello.ux","apiadapter4alipay.js",'configuration attribute "',"transformNodeModuleComponent","handleWxmlFile","widgets","webUrl","input","isFile","isDirectory","handleWxssImport","util","substring","log","extEnable","orientation","mkdirSync","extPages",'" in ext.json \n\n\n',"assign","VSCODE_NLS_CONFIG","renameSync","handleConfigInfo","Applets","copyDir","existsSync","require('./util/apiadapter4alipay.js');\r\n","packOptions",".css","ext.json","entry","webapp","createDirs","join","toString","getGlobleOutPutPath","copyFile","navigateToMiniProgramAppIdList","setLanguage","toLowerCase","extAppid","changeAppJsonItem","extResFile","node_modules","8375560nDOcRW","app.js","writeFile","display","swan","readFileSync","readdirSync","usingComponents","quickapp.config.json","push","basename","copyConfigFiles","path","qjs","Warning: ","list","../features/fileHandle","icon","platformFeature","projectConfigFile","parse","app.json","helloUxStr","../lib/locale.json","addSupportTypes","createTransformReportFile","indexOf","css","debug","appletType","type","../features/transformReport","permission","appJsonFile","utf-8","replacepos","window","english","228278KQZlnz","filter"];return(_0x257a=function(){return e})()}!function(){for(var e=_0x3292,t=_0x257a();;)try{if(612092==-parseInt(e(448))+-parseInt(e(475))/2+parseInt(e(450))/3+-parseInt(e(348))/4+-parseInt(e(451))/5+-parseInt(e(455))/6*(-parseInt(e(478))/7)+parseInt(e(410))/8)break;t.push(t.shift())}catch(e){t.push(t.shift())}}(),Object[_0x2eb81f(460)](exports,_0x2eb81f(465),{value:!0}),exports.setLanguage=exports[_0x2eb81f(452)]=exports[_0x2eb81f(401)]=exports[_0x2eb81f(435)]=exports[_0x2eb81f(398)]=exports[_0x2eb81f(429)]=exports.appJsonFile=exports[_0x2eb81f(407)]=exports[_0x2eb81f(402)]=exports[_0x2eb81f(421)]=exports.transformNodeModuleComponent=exports[_0x2eb81f(388)]=exports[_0x2eb81f(390)]=exports.insertStr=exports[_0x2eb81f(445)]=exports[_0x2eb81f(464)]=void 0;var path=require(_0x2eb81f(422)),fs=require("fs"),importVisitor_1=require(_0x2eb81f(484)),_require=require("../common/textDocument"),create=_require[_0x2eb81f(356)],fileHandle_1=require(_0x2eb81f(426)),commonConfig_1=require("./commonConfig"),transformReport=require(_0x2eb81f(441)),globleOutPutPath="",thirdComponents=[],originPtahObject={input:"",output:""};function setOriginPtahObject(e,t){thirdComponents=[],originPtahObject[_0x2eb81f(373)]=e,originPtahObject.output=t}function replacepos(e,t,n,o){var a=_0x2eb81f;return e[a(378)](0,t)+o+e[a(378)](n)}function _0x3292(e,t){var n=_0x257a();return(_0x3292=function(e,t){return n[e-=344]})(e,t)}function insertStr(e,t,n){var o=_0x2eb81f;return e.slice(0,t)+n+e[o(351)](t)}function copyDir(e,t){var n=_0x2eb81f,o=2<arguments.length&&void 0!==arguments[2]&&arguments[2],a=3<arguments.length&&void 0!==arguments[3]&&arguments[3];try{fs[n(391)](t)||fs[n(382)](t),a?_copyH5Pragram(e,t):_copyMiniPragram(e,t,o)}catch(e){throw e}}function handleConfigInfo(e,t){var n=_0x2eb81f,o=path[n(399)](t,"manifest.json"),a=JSON[n(430)](fs.readFileSync(o,{encoding:n(444)}));a[n(413)][n(461)][n(358)][n(381)]=e[n(381)],a.icon=a.icon+path[n(420)](e.iconPath),a[n(357)]=e.packageName,a[n(476)]=e.appName,a[n(466)]=e[n(466)],a[n(345)]=e[n(345)];a=JSON.stringify(a,null,2);fs[n(353)](o,a);o=path[n(399)](t,n(358),n(366)),a=(a=fs[n(415)](o,{encoding:n(444)})).replace(n(432),e[n(372)]);fs[n(353)](o,a),fs.existsSync(path.join(t,n(467)))||fs[n(382)](path[n(399)](t,n(467))),copyFile(path[n(399)](t,n(467),path[n(420)](e[n(477)])),e[n(477)])}function _copyH5Pragram(a,i){var r=_0x2eb81f;try{fs[r(416)](a)[r(359)](function(e){var t=r,n=path[t(399)](a,e),o=path.join(i,e),e=fs[t(474)](n);e.isFile()&&copyFile(o,n),e[t(375)]()&&copyDir(n,o,!1,!0)})}catch(e){throw e}}function _copyMiniPragram(i,r){var s=_0x2eb81f,p=2<arguments[s(453)]&&void 0!==arguments[2]&&arguments[2];try{fs[s(416)](i).forEach(function(e){var t=s,n=path[t(399)](i,e),o=path.join(r,e),a=fs.statSync(n);a[t(374)]()&&(copyFile(o,n),p||dealWithFile(o,n)),a[t(375)]()&&"node_modules"!==n&&n!==t(482)&&("node_modules"===e?copyDir(n,path[t(399)](r,"miniprogram_npm"),!0):copyDir(n,o,p))})}catch(e){throw e}}function dealWithFile(t,n){var e=_0x2eb81f,o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:commonConfig_1.Applets.appletType,a=path.extname(t);switch(a){case e(487):modifyFileContent(t,n,e(487),o);break;case e(365):modifyFileContent(t,n,".json");break;default:var i=[commonConfig_1[e(389)][e(439)]];(i=commonConfig_1[e(389)].addSupportTypes?i[e(355)](commonConfig_1[e(389)][e(434)]):i)[e(359)](function(e){dealWithMainFile(t,n,a,e)})}}function dealWithMainFile(e,t,n,o){var a=_0x2eb81f,i=commonConfig_1[a(471)][o];switch(n){case i[a(456)]:var r=e[a(364)](n,".qxml");modifyFile(e,r,i[a(456)],t,o);break;case i.css:var s=e[a(364)](n,a(394));modifyFile(e,s,i.css,null,o);break;case i[a(423)]:if(!i[a(423)])return;s=e[a(364)](n,a(363));modifyFile(e,s,i.qjs,t,o)}}function modifyFile(e,t,n,o){var a=_0x2eb81f,i=4<arguments[a(453)]&&void 0!==arguments[4]?arguments[4]:commonConfig_1[a(389)][a(439)];try{fs[a(387)](e,t),modifyFileContent(t,o,n,i)}catch(e){throw console[a(479)](e),e}}function modifyFileContent(e,t,n){var o=_0x2eb81f,a=3<arguments[o(453)]&&void 0!==arguments[3]?arguments[3]:commonConfig_1.Applets[o(439)];try{var i=fs[o(415)](e,{encoding:o(444)}).toString(),r=commonConfig_1[o(471)][a];switch(n){case r[o(456)]:i=fileHandle_1[o(370)](e,i,t,a),"tt"===a&&(i=fileHandle_1[o(370)](e,i,t,"wx"));break;case r.qjs:var s=create(e,i),i=s.getText(),p=importVisitor_1.getImportRules(i,null,!0,a)[o(449)](function(e){return"fileImport"===e[o(440)]});i=fileHandle_1.transformWxsFilePath(p,s,i,t,a);break;case r[o(437)]:i=fileHandle_1[o(376)](e,i,a),"tt"===a&&(i=fileHandle_1[o(376)](e,i,"wx"));break;case o(487):i=fileHandle_1[o(354)](e,t,i,a),"tt"===a&&(i=fileHandle_1[o(354)](e,t,i,"wx"));break;case o(365):if(!i)break;var f=JSON[o(430)](i);f[o(417)]&&handleUsingComponents(f.usingComponents),"my"===commonConfig_1.Applets[o(439)]&&changeAppJsonItem(f,commonConfig_1[o(472)]),i=JSON[o(457)](f,null,2)}fs[o(353)](e,i)}catch(e){throw e}}function dealWithNodeModuleComponent(n,o){var a=_0x2eb81f,e=fs[a(474)](n);e[a(374)]()&&dealWithFile(n,o),e[a(375)]()&&fs[a(416)](n).forEach(function(e){var t=a;dealWithNodeModuleComponent(path[t(399)](n,e),path[t(399)](o,e))})}function transformNodeModuleComponent(){var a=_0x2eb81f;thirdComponents[a(359)](function(e){var t,n=a,o=path[n(399)](originPtahObject[n(361)],"miniprogram_npm",e);fs[n(391)](o)&&(t=path[n(399)](originPtahObject[n(373)],n(482),e),fs[n(391)](t)?dealWithNodeModuleComponent(o,t):dealWithNodeModuleComponent(o,path[n(399)](originPtahObject[n(373)],n(409),e)))})}function handleUsingComponents(e){var t,n,o=_0x2eb81f;for(t in e)!e[t]||(n=e[t][o(458)]("/"))[0]&&"."!==n[0][0]&&-1===thirdComponents[o(436)](n[0])&&thirdComponents[o(419)](n[0])}function copyConfigFiles(o,a){var i=_0x2eb81f;try{fs.readdirSync(o)[i(359)](function(e){var t=i,n=path[t(399)](o,e),e=path[t(399)](a,e);fs[t(474)](n)[t(374)]()&&copyFile(e,n)})}catch(e){throw e}}function copyFile(e,t){var n=_0x2eb81f;fs[n(353)](e,fs[n(415)](t))}function changeAppJsonItem(e,t){if(e)for(var n in t)e[n]&&(e[t[n]]=e[n],delete e[n])}function appJsonFile(e,t){var n=_0x2eb81f,o=JSON[n(430)](fs[n(415)](path[n(399)](e,n(431)))[n(400)]());delete o[n(357)],delete o[n(476)],delete o.versionName,delete o[n(345)],delete o.minPlatformVersion,delete o[n(427)],delete o[n(440)],changeAppJsonItem(o[n(446)],commonConfig_1[n(472)]),changeAppJsonItem(o[n(360)],commonConfig_1[n(483)]),o[n(360)]&&o.tabBar[n(425)]&&o[n(360)][n(425)][n(359)](function(e){changeAppJsonItem(e,commonConfig_1.tablebarListItems)});o=Object[n(385)]({package:t[n(468)],name:t.appName,versionName:t.versionName,versionCode:t[n(345)],minPlatformVersion:1073,icon:n(469)+path[n(420)](t[n(477)]),type:n(397),config:{logLevel:n(379)}},o);delete o[n(371)],delete o[n(396)],delete o[n(438)],delete o[n(403)],-1!==[n(414),"my"].indexOf(commonConfig_1[n(389)].appletType)&&(o[n(428)]={enableNoDeclareCompProp:!0}),-1!==["my"][n(436)](commonConfig_1[n(389)].appletType)&&(o[n(428)][n(352)]=n(350));o=JSON[n(457)](o,null,2);fs[n(353)](path.join(e,n(431)),o)}function extJsonFile(e,t){var n=_0x2eb81f,o=path[n(399)](e,n(395));if(fs.existsSync(o)){var a=JSON.parse(fs.readFileSync(o).toString());delete a[n(406)],delete a[n(454)];o={};!(o[n(380)]=!1)===a.extEnable&&(o[n(380)]=!0),delete a[n(380)],void 0!==a.extResFile&&(o[n(408)]=a[n(408)],delete a.extResFile),o[n(470)]={};var i,r=o[n(470)],s=JSON[n(430)](fs.readFileSync(path[n(399)](e,n(431))).toString());for(i in["package","name",n(466),n(345),"type"][n(346)](function(e){r[e]=s[e]}),["ext",n(383),n(480),n(461),n(446),n(360),n(463),"subPackages","usingComponents",n(442)][n(346)](function(e){void 0!==a[e]&&(r[e]=a[e],delete a[e])}),a)transformReport.write(n(424)[n(355)](setLanguage("notSupport"),n(368))[n(355)](i,n(384)));o=Object[n(385)](o),o=JSON[n(457)](o,null,2);fs[n(353)](path.join(e,n(395)),o)}}function projectConfigFile(e){var t=_0x2eb81f,n={};commonConfig_1[t(389)][t(362)]?fs[t(391)](path[t(399)](e,commonConfig_1.Applets.configBasename))&&(n=JSON.parse(fs.readFileSync(path[t(399)](e,commonConfig_1[t(389)].configBasename)).toString())):n={};var o={quickappRoot:commonConfig_1[t(389)][t(459)],packOptions:{ignore:[]}};o[t(393)]=n[t(393)];o=JSON[t(457)](o,null,2);commonConfig_1[t(389)].configBasename&&fs[t(391)](path[t(399)](e,commonConfig_1[t(389)][t(362)]))&&fs.unlinkSync(path[t(399)](e,commonConfig_1[t(389)][t(362)])),fs[t(412)](path[t(399)](e,t(418)),o,function(e){e&&console[t(379)](e)})}function createDirs(e,t){var n=_0x2eb81f,o=2<arguments[n(453)]&&void 0!==arguments[2]&&arguments[2];fs[n(391)](e)||fs[n(382)](e),fs.existsSync(path[n(399)](e,t))||fs.mkdirSync(path[n(399)](e,t)),o||fs.existsSync(path[n(399)](e,t,"assets"))||fs.mkdirSync(path[n(399)](e,t,n(473)))}function createTransformReportFile(e,t){var n=_0x2eb81f;globleOutPutPath=path[n(399)](e,"transform.log");t=setLanguage(n(462))+t+"\n\n";fs[n(353)](globleOutPutPath,t)}function getGlobleOutPutPath(){return globleOutPutPath}function adaptApiFile(e,t){var n=_0x2eb81f;fs[n(391)](path[n(399)](e,n(377)))||fs[n(382)](path.join(e,n(377))),copyFile(path[n(399)](e,n(377),n(367)),path[n(399)](t,n(347),n(367)));t=path[n(399)](e,n(411)),e=fs[n(415)](t,{encoding:n(444)}),e=n(392)[n(355)](e);fs[n(353)](t,e)}exports[_0x2eb81f(464)]=setOriginPtahObject,exports[_0x2eb81f(445)]=replacepos,exports.insertStr=insertStr,exports.copyDir=copyDir,exports[_0x2eb81f(388)]=handleConfigInfo,exports[_0x2eb81f(369)]=transformNodeModuleComponent,exports[_0x2eb81f(421)]=copyConfigFiles,exports[_0x2eb81f(402)]=copyFile,exports[_0x2eb81f(407)]=changeAppJsonItem,exports[_0x2eb81f(443)]=appJsonFile,exports.extJsonFile=extJsonFile,exports[_0x2eb81f(429)]=projectConfigFile,exports.createDirs=createDirs,exports[_0x2eb81f(435)]=createTransformReportFile,exports.getGlobleOutPutPath=getGlobleOutPutPath,exports[_0x2eb81f(452)]=adaptApiFile;var lan=JSON[_0x2eb81f(430)](process[_0x2eb81f(485)][_0x2eb81f(386)]||_0x2eb81f(349))[_0x2eb81f(486)][_0x2eb81f(405)](),language=require(_0x2eb81f(433));function setLanguage(e,t){var n=_0x2eb81f;if(language[e]){var o=lan===n(344)?language[e].chinese:language[e][n(447)];return Array[n(481)](t)&&t[n(359)](function(e,t){o=o[n(364)]("${"+(t+1)+"}",e)}),o}return e}exports[_0x2eb81f(404)]=setLanguage;