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