zen-app-plugin 0.5.1 → 0.5.3

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.
Files changed (2) hide show
  1. package/compress.js +1 -1
  2. package/package.json +1 -1
package/compress.js CHANGED
@@ -1 +1 @@
1
- !function(){const e=require("os"),t=(require("simple-git")("./"),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:f,extname:u}=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,m,h;function O(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),h(e,s)}}))}function k(e){const f=u(e);if(0===e.indexOf(".")||".html"===f)return;let l;if(l=e.indexOf("dist")>-1?S+e.substr(m.length+5):S+e.substr(m.length+7),t.mkdir("-p",a(l)),!i.includes(f))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=u(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){const n=c.readdirSync(e);for(const s of n){const n=r(e,s);if(c.statSync(n).isDirectory())$(n,t);else if(e.indexOf(".lowcode")>-1&&"data"===s){const e=c.readFileSync(n,"utf8"),{path:s,basic:i,actions:o=[]}=JSON.parse(e);if(!s)continue;const r=[];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)),r.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)),r.push(i)})),r.length>0&&(t[s]=r)}}}function v(e){const t={};$(r(e,"src"),t);const n=r(S,"..","points");c.writeFileSync(n,JSON.stringify(t),"utf8")}async function q(){const e=r(S,"..","config","app");c.existsSync(e)||t.mkdir("-p",a(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 c.existsSync(e)&&(n=JSON.parse(c.readFileSync(e,"utf8"))),n["fd"]=t,c.writeFileSync(e,JSON.stringify(n),"utf8"),t}catch(e){return""}}exports.remote=async function(n,s){if(!s)return;m=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+"/",h=j):"oss"===s?(y=new p({region:x.ossRegion,accessKeyId:x.ossId,accessKeySecret:x.ossSecret,bucket:x.ossBucket,authorizationV4:!0}),l=x.ossDomain+"/",h=w):(y=new d({SecretId:x.id,SecretKey:x.key}),l=x.cosDomain+"/",h=b);let i,o,a=O(n).name;i=r(n,"dist"),o=r(n,"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(o,e)}"`;console.log(n),t.exec(n)})),S=f(n,"..",a,"src","main","resources","static");const u=await q();v(n),z(i,`${a}/${u}`),c.existsSync(o)&&z(o,`${a}/${u}`)},exports.locale=async function(e){m=e;const n=O(e).name;S=f(e,"..",n,"src","main","resources","static"),v(e),await q();const s=r(e,"public"),i=r(e,"dist");["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(s,e)}"`;console.log(n),t.exec(n)})),F(i),c.existsSync(s)&&F(s)}}();
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");y||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)}}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-app-plugin",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "app代码生成器",
5
5
  "main": "index.js",
6
6
  "author": "zen",