zen-app-plugin 0.5.3 → 0.5.5
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:u,resolve:f,extname:l}=require("path");let d="/";const p=require("cos-nodejs-sdk-v5"),g=require("ali-oss"),{TosClient:S}=require("@volcengine/tos-sdk");let y,x,h,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:h.bucket,Region:h.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),x.putObject(n,((t,n)=>{if(t)return console.log(t,n);console.log(d+e)}))}function w(e,t){let n={bucket:h.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),x.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={}),x.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=l(e);if(0===e.indexOf(".")||".html"===t)return;let f;if(f=e.indexOf("dist")>-1?y+e.substr(m.length+5):y+e.substr(m.length+7),n.mkdir("-p",u(f)),!o.includes(t))return n.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 s=a(y,t),i=l(s);if(!r.existsSync(s)||c.includes(i)){n.mkdir("-p",u(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(f,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){const n=r.readdirSync(e);for(const s of n){const n=a(e,s);if(r.statSync(n).isDirectory())v(n,t);else if(e.indexOf(".lowcode")>-1&&"data"===s){const e=r.readFileSync(n,"utf8"),{path:s,basic:i,actions:o=[]}=JSON.parse(e);if(!s)continue;const c=[];i.actions.forEach((({_id:e,label:t,mode:n,href:s})=>{const i={id:e+"",label:t};"link"===n&&s&&(i.link=s.substr(1)),c.push(i)})),o.forEach((({_id:e,label:t,mode:n,href:s})=>{const i={id:e+"",label:t};"link"===n&&s&&(i.link=s.substr(1)),c.push(i)})),c.length>0&&(t[s]=c)}}}function q(e){if(r.existsSync(y))return;const t={};v(a(e,"src"),t);const n=a(y,"..","points");r.writeFileSync(n,JSON.stringify(t),"utf8")}async function D(){if(r.existsSync(y))try{return(await t.branchLocal()).current}catch(e){return"01"}const e=a(y,"..","config","app");
|
|
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:u,resolve:f,extname:l}=require("path");let d="/";const p=require("cos-nodejs-sdk-v5"),g=require("ali-oss"),{TosClient:S}=require("@volcengine/tos-sdk");let y,x,h,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:h.bucket,Region:h.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),x.putObject(n,((t,n)=>{if(t)return console.log(t,n);console.log(d+e)}))}function w(e,t){let n={bucket:h.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),x.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={}),x.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=l(e);if(0===e.indexOf(".")||".html"===t)return;let f;if(f=e.indexOf("dist")>-1?y+e.substr(m.length+5):y+e.substr(m.length+7),n.mkdir("-p",u(f)),!o.includes(t))return n.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 s=a(y,t),i=l(s);if(!r.existsSync(s)||c.includes(i)){n.mkdir("-p",u(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(f,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){const n=r.readdirSync(e);for(const s of n){const n=a(e,s);if(r.statSync(n).isDirectory())v(n,t);else if(e.indexOf(".lowcode")>-1&&"data"===s){const e=r.readFileSync(n,"utf8"),{path:s,basic:i,actions:o=[]}=JSON.parse(e);if(!s)continue;const c=[];i.actions.forEach((({_id:e,label:t,mode:n,href:s})=>{const i={id:e+"",label:t};"link"===n&&s&&(i.link=s.substr(1)),c.push(i)})),o.forEach((({_id:e,label:t,mode:n,href:s})=>{const i={id:e+"",label:t};"link"===n&&s&&(i.link=s.substr(1)),c.push(i)})),c.length>0&&(t[s]=c)}}}function q(e){if(!r.existsSync(y))return;const t={};v(a(e,"src"),t);const n=a(y,"..","points");r.writeFileSync(n,JSON.stringify(t),"utf8")}async function D(){if(!r.existsSync(y))try{return(await t.branchLocal()).current}catch(e){return"01"}const e=a(y,"..","config","app");e||r.existsSync(e)||n.mkdir("-p",u(e));try{const t=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 n={};return r.existsSync(e)&&(n=JSON.parse(r.readFileSync(e,"utf8"))),n["fd"]=t,r.writeFileSync(e,JSON.stringify(n),"utf8"),t}catch(e){return""}}exports.remote=async function(t,s){if(!s)return;m=t,h=JSON.parse(r.readFileSync(a(e.homedir(),".cc.json"))),"tos"===s?(x=new S({accessKeyId:h.tosId,accessKeySecret:h.tosSecret,region:h.tosRegion,endpoint:h.tosEndpoint}),d=h.tosDomain+"/",O=w):"oss"===s?(x=new g({region:h.ossRegion,accessKeyId:h.ossId,accessKeySecret:h.ossSecret,bucket:h.ossBucket,authorizationV4:!0}),d=h.ossDomain+"/",O=z):(x=new p({SecretId:h.id,SecretKey:h.key}),d=h.cosDomain+"/",O=j);let i,o,c=b(t).name;i=a(t,"dist"),o=a(t,"public");["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),n.exec(t)})),y=f(t,"..",c,"src","main","resources","static");const u=await D();q(t),k(i,`${c}/${u}`),r.existsSync(o)&&k(o,`${c}/${u}`)},exports.locale=async function(e){m=e;const t=b(e).name;y=f(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)}}();
|