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