zen-app-plugin 0.3.3 → 0.3.4
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/compress.js +1 -1
- package/package.json +1 -1
package/compress.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){const e=require("os"),t=require("shelljs"),s=require("pako"),n=new RegExp("(https?:)?//((b|a)\\.(ebus))\\.vip/.+?\\.(svg|js|png|gif|jpe?g|ttf|woff2?|eot|css)","gi"),i=[".js",".css",".svg"],o=[".js",".css",".xml"],c=require("fs"),{join:r,dirname:a,resolve:f,extname:u}=require("path"),d="//a.zeto.me/",l=require("cos-nodejs-sdk-v5"),p=require("ali-oss"),{TosClient:g}=require("@volcengine/tos-sdk");let y,S,x,O
|
|
1
|
+
!function(){const e=require("os"),t=require("shelljs"),s=require("pako"),n=new RegExp("(https?:)?//((b|a)\\.(ebus))\\.vip/.+?\\.(svg|js|png|gif|jpe?g|ttf|woff2?|eot|css)","gi"),i=[".js",".css",".svg"],o=[".js",".css",".xml"],c=require("fs"),{join:r,dirname:a,resolve:f,extname:u}=require("path"),d="//a.zeto.me/",l=require("cos-nodejs-sdk-v5"),p=require("ali-oss"),{TosClient:g}=require("@volcengine/tos-sdk");let y,S,x,h,O;function b(e){const t=r(e,"package.json"),s=c.readFileSync(t,"utf8");return JSON.parse(s)}function m(e,t){let n={Bucket:x.bucket,Region:x.region,Key:e,StorageClass:"STANDARD"},i=e.indexOf(".js")>-1;i||e.indexOf(".css")>-1?(n.Headers={"Content-Encoding":"gzip","Content-Type":i?"application/javascript":"text/css"},n.Body=Buffer.from(s.gzip(c.readFileSync(t,"utf8")))):n.Body=c.createReadStream(t),S.putObject(n,((t,s)=>{if(t)return console.log(t,s);console.log(d+e)}))}function j(e,t){let n={bucket:x.tosBucket,key:e},i=e.indexOf(".js")>-1;i||e.indexOf(".css")>-1?(n.headers={"Content-Encoding":"gzip","Content-Type":i?"application/javascript":"text/css"},n.body=Buffer.from(s.gzip(c.readFileSync(t,"utf8")))):n.body=c.createReadStream(t),S.putObject(n,((t,s)=>{if(t)return console.log(t,s);console.log(d+e)}))}function z(e,t){let n,i,o=e.indexOf(".js")>-1;o||e.indexOf(".css")>-1?(i={"Content-Encoding":"gzip","Content-Type":o?"application/javascript":"text/css"},n=Buffer.from(s.gzip(c.readFileSync(t,"utf8")))):(n=c.createReadStream(t),i={}),S.put(e,n,{headers:i})}function k(e,t){c.readdirSync(e).forEach((s=>{if(0===s.indexOf(".")||s.indexOf(".html")>-1)return;let n=r(e,s),i=c.statSync(n);if(i.isDirectory()&&k(n,r(t,s)),i.isFile()){let e=r(t,s).replace(/\\/gi,"/");O(e,n)}}))}function w(e){const f=u(e);if(0===e.indexOf(".")||".html"===f)return;let d;if(d=e.indexOf("dist")>-1?y+e.substr(h.length+5):y+e.substr(h.length+7),t.mkdir("-p",a(d)),!i.includes(f))return t.cp(e,d);const l=c.readFileSync(e,"utf8").replace(n,(e=>e.indexOf("'")>-1||e.indexOf('"')>-1?e:function(e){let s=e.substr(e.indexOf(".vip")+4);s.startsWith("/f01")&&(s=s.substr(4));const n=r(y,s),i=u(n);if(!c.existsSync(n)||o.includes(i)){t.mkdir("-p",a(n));const s=e.indexOf(":")>-1?e:`https:${e}`;let i=`wget --timeout=15 -O "${n}" "${s}"`;(n.indexOf(".js")>-1||n.indexOf(".css")>-1)&&(i=`wget -qO- "${s}" | gzip > "${n}"`);const o=t.exec(i);if(0!==o.code)return console.error(`Failed to download ${i}: ${o.stderr}`),e}return s}(e)));c.writeFileSync(d,Buffer.from(s.gzip(l)),"utf8")}function $(e){const t=c.readdirSync(e);for(const s of t){if(s.startsWith("."))continue;const t=r(e,s),n=c.statSync(t);n.isDirectory()?$(t):n.isFile()&&w(t)}}function F(e,t){const s=c.readdirSync(e);for(const n of s){const s=r(e,n);if(c.statSync(s).isDirectory())F(s,t);else if(e.indexOf(".lowcode")>-1&&"data"===n){const e=c.readFileSync(s,"utf8"),{path:n,basic:i,actions:o=[]}=JSON.parse(e);if(!n)continue;const r=[];i.actions.forEach((({_id:e,label:t,mode:s,href:n})=>{const i={id:e+"",label:t};"link"===s&&n&&(i.link=n.substr(1)),r.push(i)})),o.forEach((({_id:e,label:t,mode:s,href:n})=>{const i={id:e+"",label:t};"link"===s&&n&&(i.link=n.substr(1)),r.push(i)})),r.length>0&&(t[n]=r)}}}exports.remote=function(s,n){if(!n)return;h=s,x=JSON.parse(c.readFileSync(r(e.homedir(),".cc.json"))),"tos"===n?(S=new g({accessKeyId:x.tosId,accessKeySecret:x.tosSecret,region:x.tosRegion,endpoint:x.tosEndpoint}),O=j):"oss"===n?(S=new p({region:x.ossRegion,accessKeyId:x.ossId,accessKeySecret:x.ossSecret,bucket:x.ossBucket,authorizationV4:!0}),O=z):(S=new l({SecretId:x.id,SecretKey:x.key}),O=m);let i=b(s).name;const o=function(e,t){const s=r(e,"..",t,"src","main","resources","config","app");try{const e=c.readFileSync(s,"utf8");return JSON.parse(e).tag}catch(e){return""}}(s,i),a=r(s,"dist"),f=r(s,"public");["zen.js","zen.css","zen.wap.js","zen.wap.css"].forEach((e=>{const s=`wget --timeout=15 "https://b.ebus.vip/zeto/latest/${e}" -O - | gunzip > "${r(f,e)}"`;console.log(s),t.exec(s)})),k(a,`${i}/${o}`),c.existsSync(f)&&k(f,`${i}/${o}`)},exports.locale=function(e){h=e;const s=b(e).name;y=f(e,"..",s,"src","main","resources","static");const n=r(e,"public"),i=r(e,"dist");["zen.js","zen.css","zen.wap.js","zen.wap.css"].forEach((e=>{const s=`wget --timeout=15 "https://b.ebus.vip/zeto/latest/${e}" -O - | gunzip > "${r(n,e)}"`;console.log(s),t.exec(s)})),$(i),c.existsSync(n)&&$(n);const o={};F(r(e,"src"),o),c.writeFileSync(r(y,"..","config","points"),JSON.stringify(o),"utf8")}}();
|