zen-app-plugin 0.5.11 → 0.5.13

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/makeIndex.js CHANGED
@@ -1 +1 @@
1
- !function(){const n=require("path"),e=require("fs"),t=["components","blocks"],{camelCase:i}=require("./camelcase"),o=function(t){const i=[],o=[],r=[];e.readdirSync(t).sort(((n,e)=>n.localeCompare(e))).forEach((c=>{const u=n.join(t,c,"index.js");if(e.existsSync(u))i.push(`import ${c} from './${c}/index';`),o.push(c);else{const u=n.join(t,c,c+".vue");if(e.existsSync(u))r.push(`${c}: () => import("./${c}/${c}.vue")`);else{if(c.indexOf(".")>-1)return;s(n.join(t,c),c)&&(i.push(`import ${c} from './${c}/index';`),o.push(c))}}}));const c=r.length>0?`const vueFiles = {\n\t${r.join(",\n\t")}\n};`:"",u=`${i.join("\n")}\n${c}\nexport default {${c?"\n\t...vueFiles,":""}\n ${o.length>0?"..."+o.join(",\n\t..."):""}\n};`;e.writeFileSync(n.join(t,"index.js"),u,(()=>{}))},s=function(s,r,c){const u=n.join(s,"index.js");let p=[],l=[];if(!e.existsSync(s)||"."===r[0]||t.includes(r))return!1;const a=!e.existsSync(u);if(e.readdirSync(s).sort(((n,e)=>n.localeCompare(e))).forEach((t=>{const o=n.join(s,t,t+".vue");if(t.indexOf(".")>-1||!e.existsSync(o))return;const c=i(r.replace(/\//gi,"_")+"_"+t,{pascalCase:!0});p.push(`import ${c} from "./${t}/${t}";`),l.push(`'${r}/${t}': ${c}`)})),0===p.length)return!1;const f=`${p.join("\n")}\n\nexport default {\n\t${l.join(",\n\t")}\n}`;return e.writeFileSync(u,f),a&&o(c),!0};exports.makeRootIndex=o,exports.makeSonIndex=s,exports.makeComponentIndex=function(t){let i=n.join(t,"index.js"),o=e.readdirSync(t),s=[],r=[];o.map((i=>{if(i.indexOf(".")>-1)return;let o=n.join(t,i,i+".vue");e.existsSync(o)&&(r.push(i),s.unshift(`import ${i} from "./${i}/${i}";`))}));const c=`${s.join("\n")}\nexport default {\n ${r.join(",\n\t")}\n}\n`;return e.writeFileSync(i,c)}}();
1
+ !function(){const n=require("path"),e=require("fs"),i=["components","blocks"],{camelCase:t}=require("./camelcase"),o=function(i){const t=[],o=[],r=[];e.readdirSync(i).sort(((n,e)=>n.localeCompare(e))).forEach((c=>{const u=n.join(i,c,"index.js");if(e.existsSync(u))t.push(`import ${c} from './${c}/index';`),o.push(c);else{const u=n.join(i,c,c+".vue");if(e.existsSync(u))r.push(`${c}: () => import("./${c}/${c}.vue")`);else{if(c.indexOf(".")>-1)return;s(n.join(i,c),c)&&(t.push(`import ${c} from './${c}/index';`),o.push(c))}}}));const c=r.length>0?`const vueFiles = {\n\t${r.join(",\n\t")}\n};`:"",u=`${t.join("\n")}\n${c}\nexport default {${c?"\n\t...vueFiles,":""}\n ${o.length>0?"..."+o.join(",\n\t..."):""}\n};`;e.writeFileSync(n.join(i,"index.js"),u,(()=>{}))},s=function(s,r,c){const u=n.join(s,"index.js");let p=[],$=[];if(!e.existsSync(s)||"."===r[0]||i.includes(r))return!1;const f=!e.existsSync(u);if(e.readdirSync(s).sort(((n,e)=>n.localeCompare(e))).forEach((i=>{const o=n.join(s,i,"index.js"),c=[];if(e.existsSync(o))return c.push(i),p.push(`import ${i} from "./${i}/index.js";`),void $.push(`...${i}`);const u=n.join(s,i,i+".vue");if(i.indexOf(".")>-1||!e.existsSync(u))return;const f=t(r.replace(/\//gi,"_")+"_"+i,{pascalCase:!0});p.push(`import ${f} from "./${i}/${i}";`),$.push(`'${r}/${i}': ${f}`)})),0===p.length)return!1;const x=`${p.join("\n")}\n\nexport default {\n\t${$.join(",\n\t")}\n}`;return e.writeFileSync(u,x),o(c),f&&o(c),!0};exports.makeRootIndex=o,exports.makeSonIndex=s,exports.makeComponentIndex=function(i){let t=n.join(i,"index.js"),o=e.readdirSync(i),s=[],r=[];o.map((t=>{if(t.indexOf(".")>-1)return;let o=n.join(i,t,t+".vue");e.existsSync(o)&&(r.push(t),s.unshift(`import ${t} from "./${t}/${t}";`))}));const c=`${s.join("\n")}\nexport default {\n ${r.join(",\n\t")}\n}\n`;return e.writeFileSync(t,c)}}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-app-plugin",
3
- "version": "0.5.11",
3
+ "version": "0.5.13",
4
4
  "description": "app代码生成器",
5
5
  "main": "index.js",
6
6
  "author": "zen",
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"),i=e.join(o,"src","pages");if(n.existsSync(i)){const o=t.watch(i,{depth:2,usePolling:!1});this.watchList.push(o),o.on("addDir",(t=>{const o=e.join(t,"index.js");if(n.existsSync(o)||t.indexOf(".lowcode")>-1)return;const s=e.resolve(t).split(e.sep),r=s.pop(),c=s[s.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(s.join(e.sep),c,i)})),o.on("unlinkDir",(n=>{const t=e.resolve(n).split(e.sep);t.pop();const o=t.join(e.sep),s=t.pop();"pages"===s?r(i):p(o,s)})),r(i),o.on("error",(function(e){console.error("webpack AutoCodePlugin Error happened: ",e)}))}const a=e.join(s,"components"),d=t.watch(a,{depth:1,usePolling:!1});this.watchList.push(d),d.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(a)})),d.on("unlinkDir",(n=>{const t=e.resolve(n).split(e.sep);"components"===t[t.length-2]&&c(a)}))}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)}))}}}();
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"),i=e.join(o,"src","pages");if(n.existsSync(i)){const o=t.watch(i,{depth:2,usePolling:!1});this.watchList.push(o),o.on("addDir",(t=>{const o=e.join(t,"index.js");if(n.existsSync(o)||t.indexOf(".lowcode")>-1)return;const s=e.resolve(t).split(e.sep),r=s.pop();let c=s[s.length-1];const a=e.join(t,r+".vue");if(n.existsSync(a)||"pages"===c||l.includes(r)||l.includes(c))return;s.length-s.indexOf(c)==1&&(c=s[s.length-2]+e.sep+c),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(s.join(e.sep),c,i)})),o.on("unlinkDir",(n=>{const t=e.resolve(n).split(e.sep);t.pop();const o=t.join(e.sep);let s=t.pop();"pages"===s?r(i):(t.length-t.indexOf("pages")==2&&(s=t.pop()+e.sep+s),p(o,s))})),r(i),o.on("error",(function(e){console.error("webpack AutoCodePlugin Error happened: ",e)}))}const a=e.join(s,"components"),d=t.watch(a,{depth:1,usePolling:!1});this.watchList.push(d),d.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(a)})),d.on("unlinkDir",(n=>{const t=e.resolve(n).split(e.sep);"components"===t[t.length-2]&&c(a)}))}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)}))}}}();