zen-app-plugin 0.3.1 → 0.3.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.
- package/compress.js +1 -1
- package/package.json +3 -1
- package/plugin.js +1 -1
package/compress.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){const e=require("os"),t=require("
|
|
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){if(!n)return;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.
|
|
3
|
+
"version": "0.3.3",
|
|
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
|
|
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)}))}}}();
|