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