zen-app-plugin 0.1.9 → 0.2.1
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/plugin.js +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=t("./"),c=new RegExp("(https?:)?//((b|a)\\.(ebus))\\.vip/.+?\\.(svg|js|png|gif|jpe?g|ttf|woff2?|eot|css)","gi"),r=[".js",".css",".svg"],o=[".js",".css",".xml"],
|
|
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"),r=[".js",".css",".svg"],o=[".js",".css",".xml"],a=require("fs"),{join:u,dirname:f,resolve:l,extname:d}=require("path"),p=require("cos-nodejs-sdk-v5");let g,x,y,m;function S(e){const t=u(e,"package.json"),n=a.readFileSync(t,"utf8");return JSON.parse(n)}function O(e,t){a.readdirSync(e).forEach((n=>{if(0===n.indexOf(".")||n.indexOf(".html")>-1)return;let i=u(e,n),c=a.statSync(i);if(c.isDirectory()&&O(i,u(t,n)),c.isFile()){let e=u(t,n).replace(/\\/gi,"/"),c={Bucket:y.bucket,Region:y.region,Key:e,StorageClass:"STANDARD"},r=e.indexOf(".js")>-1;r||e.indexOf(".css")>-1?(c.Headers={"Content-Encoding":"gzip","Content-Type":r?"application/javascript":"text/css"},c.Body=Buffer.from(s.gzip(a.readFileSync(i,"utf8")))):c.Body=a.createReadStream(i),x.putObject(c,((t,n)=>{if(t)return console.log(t,n);console.log("//a.zeto.me/"+e)}))}}))}function h(e){const t=d(e);if(0===e.indexOf(".")||".html"===t)return;let i;if(i=e.indexOf("dist")>-1?g+e.substr(m.length+5):g+e.substr(m.length+7),n.mkdir("-p",f(i)),!r.includes(t))return n.cp(e,i);const l=a.readFileSync(e,"utf8").replace(c,(e=>e.indexOf("'")>-1||e.indexOf('"')>-1?e:function(e){const t=e.substr(e.indexOf(".vip")+4),s=u(g,t),i=d(s);if(!a.existsSync(s)||o.includes(i)){n.mkdir("-p",f(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(l)),"utf8")}function j(e){const t=a.readdirSync(e);for(const n of t){if(n.startsWith("."))continue;const t=u(e,n),s=a.statSync(t);s.isDirectory()?j(t):s.isFile()&&h(t)}}exports.remote=function(t){m=t,y=JSON.parse(a.readFileSync(u(e.homedir(),".cc.json"))),x=new p({SecretId:y.id,SecretKey:y.key});const s=S(t);i.branchLocal(((e,i)=>{let c=s.name;const r=function(e,t){const n=u(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 o=r||i.current;const f=u(t,"dist"),l=u(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 > "${u(l,e)}"`;console.log(t),n.exec(t)})),O(f,`${c}/${o}`),a.existsSync(l)&&O(l,`${c}/${o}`)}))},exports.locale=function(e){m=e;const t=S(e).name;g=l(e,"..",t,"src","main","resources","static");const s=u(e,"public"),i=u(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 > "${u(s,e)}"`;console.log(t),n.exec(t)})),j(i),a.existsSync(s)&&j(s)}}();
|
package/package.json
CHANGED
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){}));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),"remote"===this.target&&s(t)}),600)}))}}}();
|