zen-app-plugin 0.3.1 → 0.3.2

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 CHANGED
@@ -1 +1 @@
1
- !function(){const e=require("os"),t=require("simple-git"),n=require("shelljs"),s=require("pako"),i=t("./"),c=new RegExp("(https?:)?//((b|a)\\.(ebus))\\.vip/.+?\\.(svg|js|png|gif|jpe?g|ttf|woff2?|eot|css)","gi"),o=[".js",".css",".svg"],r=[".js",".css",".xml"],a=require("fs"),{join:f,dirname:l,resolve:u,extname:d}=require("path"),p=require("cos-nodejs-sdk-v5");let g,y,S,h;function x(e){const t=f(e,"package.json"),n=a.readFileSync(t,"utf8");return JSON.parse(n)}function m(e,t){a.readdirSync(e).forEach((n=>{if(0===n.indexOf(".")||n.indexOf(".html")>-1)return;let i=f(e,n),c=a.statSync(i);if(c.isDirectory()&&m(i,f(t,n)),c.isFile()){let e=f(t,n).replace(/\\/gi,"/"),c={Bucket:S.bucket,Region:S.region,Key:e,StorageClass:"STANDARD"},o=e.indexOf(".js")>-1;o||e.indexOf(".css")>-1?(c.Headers={"Content-Encoding":"gzip","Content-Type":o?"application/javascript":"text/css"},c.Body=Buffer.from(s.gzip(a.readFileSync(i,"utf8")))):c.Body=a.createReadStream(i),y.putObject(c,((t,n)=>{if(t)return console.log(t,n);console.log("//a.zeto.me/"+e)}))}}))}function O(e){const t=d(e);if(0===e.indexOf(".")||".html"===t)return;let i;if(i=e.indexOf("dist")>-1?g+e.substr(h.length+5):g+e.substr(h.length+7),n.mkdir("-p",l(i)),!o.includes(t))return n.cp(e,i);const u=a.readFileSync(e,"utf8").replace(c,(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=f(g,t),i=d(s);if(!a.existsSync(s)||r.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 c=n.exec(i);if(0!==c.code)return console.error(`Failed to download ${i}: ${c.stderr}`),e}return t}(e)));a.writeFileSync(i,Buffer.from(s.gzip(u)),"utf8")}function b(e){const t=a.readdirSync(e);for(const n of t){if(n.startsWith("."))continue;const t=f(e,n),s=a.statSync(t);s.isDirectory()?b(t):s.isFile()&&O(t)}}function j(e,t){const n=a.readdirSync(e);for(const s of n){const n=f(e,s);if(a.statSync(n).isDirectory())j(n,t);else if(e.indexOf(".lowcode")>-1&&"data"===s){const e=a.readFileSync(n,"utf8"),{path:s,basic:i,actions:c=[]}=JSON.parse(e);if(!s)continue;const o=[];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)),o.push(i)})),c.forEach((({_id:e,label:t,mode:n,href:s})=>{const i={id:e+"",label:t};"link"===n&&s&&(i.link=s.substr(1)),o.push(i)})),o.length>0&&(t[s]=o)}}}exports.remote=function(t){h=t,S=JSON.parse(a.readFileSync(f(e.homedir(),".cc.json"))),y=new p({SecretId:S.id,SecretKey:S.key});const s=x(t);i.branchLocal(((e,i)=>{let c=s.name;const o=function(e,t){const n=f(e,"..",t,"src","main","resources","config","app");try{const e=a.readFileSync(n,"utf8");return JSON.parse(e).tag}catch(e){return""}}(t,c);let r=o||i.current;const l=f(t,"dist"),u=f(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 > "${f(u,e)}"`;console.log(t),n.exec(t)})),m(l,`${c}/${r}`),a.existsSync(u)&&m(u,`${c}/${r}`)}))},exports.locale=function(e){h=e;const t=x(e).name;g=u(e,"..",t,"src","main","resources","static");const s=f(e,"public"),i=f(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 > "${f(s,e)}"`;console.log(t),n.exec(t)})),b(i),a.existsSync(s)&&b(s);const c={};j(f(e,"src"),c),a.writeFileSync(f(g,"..","config","points"),JSON.stringify(c),"utf8")}}();
1
+ !function(){const e=require("os"),t=require("shelljs"),s=require("pako"),n=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"),d="//a.zeto.me/",l=require("cos-nodejs-sdk-v5"),p=require("ali-oss"),{TosClient:g}=require("@volcengine/tos-sdk");let y,S,x,O,h;function b(e){const t=r(e,"package.json"),s=c.readFileSync(t,"utf8");return JSON.parse(s)}function m(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(c.readFileSync(t,"utf8")))):n.Body=c.createReadStream(t),S.putObject(n,((t,s)=>{if(t)return console.log(t,s);console.log(d+e)}))}function j(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(c.readFileSync(t,"utf8")))):n.body=c.createReadStream(t),S.putObject(n,((t,s)=>{if(t)return console.log(t,s);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(c.readFileSync(t,"utf8")))):(n=c.createReadStream(t),i={}),S.put(e,n,{headers:i})}function k(e,t){c.readdirSync(e).forEach((s=>{if(0===s.indexOf(".")||s.indexOf(".html")>-1)return;let n=r(e,s),i=c.statSync(n);if(i.isDirectory()&&k(n,r(t,s)),i.isFile()){let e=r(t,s).replace(/\\/gi,"/");h(e,n)}}))}function w(e){const f=u(e);if(0===e.indexOf(".")||".html"===f)return;let d;if(d=e.indexOf("dist")>-1?y+e.substr(O.length+5):y+e.substr(O.length+7),t.mkdir("-p",a(d)),!i.includes(f))return t.cp(e,d);const l=c.readFileSync(e,"utf8").replace(n,(e=>e.indexOf("'")>-1||e.indexOf('"')>-1?e:function(e){let s=e.substr(e.indexOf(".vip")+4);s.startsWith("/f01")&&(s=s.substr(4));const n=r(y,s),i=u(n);if(!c.existsSync(n)||o.includes(i)){t.mkdir("-p",a(n));const s=e.indexOf(":")>-1?e:`https:${e}`;let i=`wget --timeout=15 -O "${n}" "${s}"`;(n.indexOf(".js")>-1||n.indexOf(".css")>-1)&&(i=`wget -qO- "${s}" | gzip > "${n}"`);const o=t.exec(i);if(0!==o.code)return console.error(`Failed to download ${i}: ${o.stderr}`),e}return s}(e)));c.writeFileSync(d,Buffer.from(s.gzip(l)),"utf8")}function $(e){const t=c.readdirSync(e);for(const s of t){if(s.startsWith("."))continue;const t=r(e,s),n=c.statSync(t);n.isDirectory()?$(t):n.isFile()&&w(t)}}function F(e,t){const s=c.readdirSync(e);for(const n of s){const s=r(e,n);if(c.statSync(s).isDirectory())F(s,t);else if(e.indexOf(".lowcode")>-1&&"data"===n){const e=c.readFileSync(s,"utf8"),{path:n,basic:i,actions:o=[]}=JSON.parse(e);if(!n)continue;const r=[];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)),r.push(i)})),o.forEach((({_id:e,label:t,mode:s,href:n})=>{const i={id:e+"",label:t};"link"===s&&n&&(i.link=n.substr(1)),r.push(i)})),r.length>0&&(t[n]=r)}}}exports.remote=function(s,n){O=s,x=JSON.parse(c.readFileSync(r(e.homedir(),".cc.json"))),"tos"===n?(S=new g({accessKeyId:x.tosId,accessKeySecret:x.tosSecret,region:x.tosRegion,endpoint:x.tosEndpoint}),h=j):"oss"===n?(S=new p({region:x.ossRegion,accessKeyId:x.ossId,accessKeySecret:x.ossSecret,bucket:x.ossBucket,authorizationV4:!0}),h=z):(S=new l({SecretId:x.id,SecretKey:x.key}),h=m);let i=b(s).name;const o=function(e,t){const s=r(e,"..",t,"src","main","resources","config","app");try{const e=c.readFileSync(s,"utf8");return JSON.parse(e).tag}catch(e){return""}}(s,i),a=r(s,"dist"),f=r(s,"public");["zen.js","zen.css","zen.wap.js","zen.wap.css"].forEach((e=>{const s=`wget --timeout=15 "https://b.ebus.vip/zeto/latest/${e}" -O - | gunzip > "${r(f,e)}"`;console.log(s),t.exec(s)})),k(a,`${i}/${o}`),c.existsSync(f)&&k(f,`${i}/${o}`)},exports.locale=function(e){O=e;const s=b(e).name;y=f(e,"..",s,"src","main","resources","static");const n=r(e,"public"),i=r(e,"dist");["zen.js","zen.css","zen.wap.js","zen.wap.css"].forEach((e=>{const s=`wget --timeout=15 "https://b.ebus.vip/zeto/latest/${e}" -O - | gunzip > "${r(n,e)}"`;console.log(s),t.exec(s)})),$(i),c.existsSync(n)&&$(n);const o={};F(r(e,"src"),o),c.writeFileSync(r(y,"..","config","points"),JSON.stringify(o),"utf8")}}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-app-plugin",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "app代码生成器",
5
5
  "main": "index.js",
6
6
  "author": "zen",
@@ -13,6 +13,8 @@
13
13
  "camelcase": "^8.0.0",
14
14
  "chokidar": "^3.5.3",
15
15
  "cos-nodejs-sdk-v5": "^2.14.5",
16
+ "ali-oss": "^6.23.0",
17
+ "@volcengine/tos-sdk": "^2.7.4",
16
18
  "js-beautify": "^1.14.0",
17
19
  "pako": "^2.1.0",
18
20
  "shelljs": "^0.8.5",
package/plugin.js CHANGED
@@ -1 +1 @@
1
- !function(){const e=require("path"),n=require("fs"),t=require("chokidar"),o=require("./makeIndex"),{remote:s,locale:i}=require("./compress"),{makeRootIndex:r,makeSonIndex:p,makeComponentIndex:c}=o,l=["components","blocks"];module.exports=class{constructor(e){this.target=e,this.watchList=[]}init(o){const s=e.join(o,"src","pages"),i=e.join(o,"src"),a=e.join(i,"pages"),d=t.watch(a,{depth:2,usePolling:!1});this.watchList.push(d),d.on("addDir",(t=>{const o=e.join(t,"index.js");if(n.existsSync(o)||t.indexOf(".lowcode")>-1)return;const i=e.resolve(t).split(e.sep),r=i.pop(),c=i[i.length-1],a=e.join(t,r+".vue");if(n.existsSync(a)||"pages"===c||l.includes(r)||l.includes(c))return;n.writeFileSync(a,"<template>\n <div>Zen Page</div>\n</template>\n\n<script>\nexport default {\n data() {\n return {};\n },\n created() { },\n};\n<\/script>"),p(i.join(e.sep),c,s)})),d.on("unlinkDir",(n=>{const t=e.resolve(n).split(e.sep);t.pop();const o=t.join(e.sep),i=t.pop();"pages"===i?r(s):p(o,i)})),r(s),d.on("error",(function(e){console.error("webpack AutoCodePlugin Error happened: ",e)}));const u=e.join(i,"components"),h=t.watch(u,{depth:1,usePolling:!1});this.watchList.push(h),h.on("addDir",(t=>{const o=e.resolve(t).split(e.sep),s=o.pop(),i=e.join(t,s+".vue"),r=e.join(t,s+".js");if(n.existsSync(i)||n.existsSync(r)||"components"===s||"components"!==o[o.length-1])return;n.writeFileSync(i,"<template>\n <div>Zen Component</div>\n</template>\n\n<script>\nexport default {\n data() {\n return {};\n },\n created() { },\n};\n<\/script>"),c(u)})),h.on("unlinkDir",(n=>{const t=e.resolve(n).split(e.sep);"components"===t[t.length-2]&&c(u)}))}apply(e){const{mode:n,context:t}=e.options;if("development"===n)return this.init(t);e.hooks.done.tap("ZenAppPlugin",(e=>{e.compilation.errors.length>0||setTimeout((()=>{"local"===this.target&&i(t),"remote"===this.target&&s(t)}),600)}))}}}();
1
+ !function(){const e=require("path"),n=require("fs"),t=require("chokidar"),o=require("./makeIndex"),{remote:s,locale:i}=require("./compress"),{makeRootIndex:r,makeSonIndex:p,makeComponentIndex:c}=o,l=["components","blocks"];module.exports=class{constructor(e){this.target=e,this.watchList=[]}init(o){const s=e.join(o,"src","pages"),i=e.join(o,"src"),a=e.join(i,"pages"),d=t.watch(a,{depth:2,usePolling:!1});this.watchList.push(d),d.on("addDir",(t=>{const o=e.join(t,"index.js");if(n.existsSync(o)||t.indexOf(".lowcode")>-1)return;const i=e.resolve(t).split(e.sep),r=i.pop(),c=i[i.length-1],a=e.join(t,r+".vue");if(n.existsSync(a)||"pages"===c||l.includes(r)||l.includes(c))return;n.writeFileSync(a,"<template>\n <div>Zen Page</div>\n</template>\n\n<script>\nexport default {\n data() {\n return {};\n },\n created() { },\n};\n<\/script>"),p(i.join(e.sep),c,s)})),d.on("unlinkDir",(n=>{const t=e.resolve(n).split(e.sep);t.pop();const o=t.join(e.sep),i=t.pop();"pages"===i?r(s):p(o,i)})),r(s),d.on("error",(function(e){console.error("webpack AutoCodePlugin Error happened: ",e)}));const u=e.join(i,"components"),h=t.watch(u,{depth:1,usePolling:!1});this.watchList.push(h),h.on("addDir",(t=>{const o=e.resolve(t).split(e.sep),s=o.pop(),i=e.join(t,s+".vue"),r=e.join(t,s+".js");if(n.existsSync(i)||n.existsSync(r)||"components"===s||"components"!==o[o.length-1])return;n.writeFileSync(i,"<template>\n <div>Zen Component</div>\n</template>\n\n<script>\nexport default {\n data() {\n return {};\n },\n created() { },\n};\n<\/script>"),c(u)})),h.on("unlinkDir",(n=>{const t=e.resolve(n).split(e.sep);"components"===t[t.length-2]&&c(u)}))}apply(e){const{mode:n,context:t}=e.options;if("development"===n)return this.init(t);e.hooks.done.tap("ZenAppPlugin",(e=>{e.compilation.errors.length>0||setTimeout((()=>{"local"===this.target?i(t):s(t,this.target)}),600)}))}}}();