zen-app-plugin 0.0.5 → 0.0.7

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/index.js CHANGED
@@ -1 +1 @@
1
- !function(){let e=require("terser-webpack-plugin"),{VueLoaderPlugin:s}=require("vue-loader"),o=require("path"),n=require("fs"),t=require("body-parser"),r=require("./makeIndex"),{makeRootIndex:l,makeSonIndex:i}=r,u=require("./plugin");function a(e,s){if(s.length<2)return;let t,r=s.filter(((s,r)=>(0===r&&(t=o.join(e,s),n.existsSync(t)||n.mkdirSync(t)),r>0)));a(t,r)}var c={entry:{},output:{filename:"[name].js"},watchOptions:{ignored:["node_modules","dist","debug"],poll:300},externals:{vue:"Vue","router-view":"VueRouter","element-plus":"ElementPlus"},plugins:[new s],module:{noParse:/Vue|jquery/,rules:[{test:/\.jsx?$/,exclude:/(node_modules|bower_components)/,use:{loader:"babel-loader",options:{cacheDirectory:!0,presets:[["@vue/app",{modules:"commonjs",loose:!0,useBuiltIns:"entry"}]],plugins:["@babel/plugin-syntax-jsx"]}}},{test:/\.vue$/,loader:"vue-loader"},{test:/\.css$/,use:["style-loader","css-loader"]},{test:/\.scss$/,use:["style-loader","css-loader",{loader:"sass-loader",options:{implementation:require("sass")}}]}]}};module.exports=({target:s,mode:r,ROOT:d})=>{let p,m,g,j,y;for(y=n.readdirSync(o.resolve(d,"src")),g=0,j=y.length;g<j;g++)m=y[g],-1!==m.indexOf(".js")&&(p=o.basename(m),p=p.substr(0,p.length-3),c.entry[p]=o.resolve(d,"src",m));return c.resolve={alias:{"@":o.resolve(d,"src")},extensions:[".js",".vue",".jsx",".json"]},c.mode=r,c.optimization=function(s){return"production"===s?{splitChunks:!1,minimize:!0,minimizer:[new e({parallel:!0,extractComments:!1,exclude:/node_modules/,terserOptions:{compress:{drop_console:!0,collapse_vars:!0,reduce_vars:!0,drop_debugger:!0},mangle:{reserved:["zen","$"]},output:{comments:!1,ascii_only:!0},sourceMap:!1,toplevel:!0,ie8:!1,keep_fnames:!1,safari10:!1}})]}:{}}(r),"development"===r?(c.cache={type:"memory"},c.devServer={open:!0,hot:!1,client:!1,host:"127.0.0.1",allowedHosts:"all",historyApiFallback:!0,onAfterSetupMiddleware:function(e){const{app:s}=e;s.use(t.json());const r=o.join(d,"src","pages");s.post("/coder/read",(function(e,s){const{file:t,key:l}=e.body;if(!t)return s.json({code:10001,message:"参数错误"});const i=o.join(r,t);if(!n.existsSync(i))return s.json({code:1e4,data:null});let u={code:1e4,data:n.readFileSync(i,"utf-8")};s.json(u)})),s.post("/coder/write",(function(e,s){const{file:t,content:u,type:c}=e.body;if(!t)return s.json({code:10001,message:"参数错误"});const d=t.split("/");a(r,d);const p=o.join(r,t);if(n.writeFileSync(p,u),"page"===c){const e=d.splice(0,d.length-2),s=o.join(r,e.join(o.sep));if(0===e.length)return l(r);i(s,e.join("/"),r)}s.json({code:1e4,message:"操作成功"})}))},static:{directory:o.join(d,"public")},headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"*"}}):(c.devtool=!1,c.output.clean=!0,c.output.path=o.join(d,"dist")),c.plugins.push(new u(s)),c}}();
1
+ !function(){let e=require("terser-webpack-plugin"),{VueLoaderPlugin:s}=require("vue-loader"),o=require("path"),n=require("fs"),t=require("body-parser"),r=require("./makeIndex"),{makeRootIndex:l,makeSonIndex:i}=r,u=require("./plugin");function a(e,s){if(s.length<2)return;let t,r=s.filter(((s,r)=>(0===r&&(t=o.join(e,s),n.existsSync(t)||n.mkdirSync(t)),r>0)));a(t,r)}var c={entry:{},output:{filename:"[name].js"},watchOptions:{ignored:["node_modules","dist","debug"],poll:300},externals:{vue:"Vue","router-view":"VueRouter","element-plus":"ElementPlus"},plugins:[new s],module:{noParse:/Vue|jquery/,rules:[{test:/\.jsx?$/,exclude:/(node_modules|bower_components)/,use:{loader:"babel-loader",options:{cacheDirectory:!0,presets:[["@vue/app",{modules:"commonjs",loose:!0,useBuiltIns:"entry"}]],plugins:["@babel/plugin-syntax-jsx"]}}},{test:/\.vue$/,loader:"vue-loader"},{test:/\.css$/,use:["style-loader","css-loader"]},{test:/\.scss$/,use:["style-loader","css-loader",{loader:"sass-loader",options:{implementation:require("sass")}}]}]}};module.exports=({target:s,mode:r,ROOT:d})=>{let p,m,g,j,y;for(y=n.readdirSync(o.resolve(d,"src")),g=0,j=y.length;g<j;g++)m=y[g],-1!==m.indexOf(".js")&&(p=o.basename(m),p=p.substr(0,p.length-3),c.entry[p]=o.resolve(d,"src",m));return c.resolve={alias:{"@":o.resolve(d,"src")},extensions:[".js",".vue",".jsx",".json"]},c.mode=r,c.optimization=function(s){return"production"===s?{splitChunks:!1,minimize:!0,minimizer:[new e({parallel:!0,extractComments:!1,exclude:/node_modules/,terserOptions:{compress:{drop_console:!0,collapse_vars:!0,reduce_vars:!0,drop_debugger:!0},mangle:{reserved:["zen","$"]},output:{comments:!1,ascii_only:!0},sourceMap:!1,toplevel:!0,ie8:!1,keep_fnames:!1,safari10:!1}})]}:{}}(r),"development"===r?(c.cache={type:"memory"},c.devServer={open:!0,hot:!0,client:!1,host:"127.0.0.1",allowedHosts:"all",historyApiFallback:!0,onAfterSetupMiddleware:function(e){const{app:s}=e;s.use(t.json());const r=o.join(d,"src","pages");s.post("/coder/read",(function(e,s){const{file:t,key:l}=e.body;if(!t)return s.json({code:10001,message:"参数错误"});const i=o.join(r,t);if(!n.existsSync(i))return s.json({code:1e4,data:null});let u={code:1e4,data:n.readFileSync(i,"utf-8")};s.json(u)})),s.post("/coder/write",(function(e,s){const{file:t,content:u,type:c}=e.body;if(!t)return s.json({code:10001,message:"参数错误"});const d=t.split("/");a(r,d);const p=o.join(r,t);if(n.writeFileSync(p,u),"page"===c){const e=d.splice(0,d.length-2),s=o.join(r,e.join(o.sep));if(0===e.length)return l(r);i(s,e.join("/"),r)}s.json({code:1e4,message:"操作成功"})}))},static:{directory:o.join(d,"public")},headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"*"}}):(c.devtool=!1,c.output.clean=!0,c.output.path=o.join(d,"dist")),c.plugins.push(new u(s)),c}}();
package/makeIndex.js CHANGED
@@ -1 +1 @@
1
- !function(){const n=require("path"),e=require("fs"),t=["components","blocks"];let o;import("camelcase").then((n=>{o=n.default}));const i=function(t){const o=[],i=[],r=[];e.readdirSync(t).sort(((n,e)=>n.localeCompare(e))).forEach((c=>{const u=n.join(t,c,"index.js");if(e.existsSync(u))o.push(`import ${c} from './${c}/index';`),i.push(c);else{const u=n.join(t,c,c+".vue");if(e.existsSync(u))r.push(`${c}: () => import( /* webpackChunkName: "pages/${c}" */ "./${c}/${c}.vue")`);else{if(c.indexOf(".")>-1)return;s(n.join(t,c),c)&&(o.push(`import ${c} from './${c}/index';`),i.push(c))}}}));const c=r.length>0?`const vueFiles = {\n\t${r.join(",\n\t")}\n};`:"",u=`${o.join("\n")}\n${c}\nexport default {${c?"\n\t...vueFiles,":""}\n ${i.length>0?"..."+i.join(",\n\t..."):""}\n};`;e.writeFile(n.join(t,"index.js"),u,(()=>{}))},s=function(s,r,c){const u=n.join(s,"index.js");let p=[],a=[];if(!e.existsSync(s)||"."===r[0]||t.includes(r))return!1;const l=!e.existsSync(u);if(e.readdirSync(s).sort(((n,e)=>n.localeCompare(e))).forEach((t=>{const i=n.join(s,t,t+".vue");if(t.indexOf(".")>-1||!e.existsSync(i))return;const c=o(r.replace(/\//gi,"_")+"_"+t,{pascalCase:!0});p.push(`import ${c} from "./${t}/${t}";`),a.push(`'${r}/${t}': ${c}`)})),0===p.length)return!1;const f=`${p.join("\n")}\n\nexport default {\n\t${a.join(",\n\t")}\n}`;return e.writeFileSync(u,f),l&&i(c),!0};exports.makeRootIndex=i,exports.makeSonIndex=s,exports.makeComponentIndex=function(t){let o=n.join(t,"index.js"),i=e.readdirSync(t),s=[],r=[];i.map((o=>{if(o.indexOf(".")>-1)return;let i=n.join(t,o,o+".vue");e.existsSync(i)&&(r.push(o),s.unshift(`import ${o} from "./${o}/${o}";`))}));const c=`${s.join("\n")}\nexport default {\n ${r.join(",\n\t")}\n}\n`;return e.writeFileSync(o,c)}}();
1
+ !function(){const n=require("path"),e=require("fs"),t=["components","blocks"];let o;import("camelcase").then((n=>{o=n.default}));const i=function(t){const o=[],i=[],r=[];e.readdirSync(t).sort(((n,e)=>n.localeCompare(e))).forEach((c=>{const u=n.join(t,c,"index.js");if(e.existsSync(u))o.push(`import ${c} from './${c}/index';`),i.push(c);else{const u=n.join(t,c,c+".vue");if(e.existsSync(u))r.push(`${c}: () => import( /* webpackChunkName: "pages/${c}" */ "./${c}/${c}.vue")`);else{if(c.indexOf(".")>-1)return;s(n.join(t,c),c)&&(o.push(`import ${c} from './${c}/index';`),i.push(c))}}}));const c=r.length>0?`const vueFiles = {\n\t${r.join(",\n\t")}\n};`:"",u=`${o.join("\n")}\n${c}\nexport default {${c?"\n\t...vueFiles,":""}\n ${i.length>0?"..."+i.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=[],a=[];if(!e.existsSync(s)||"."===r[0]||t.includes(r))return!1;const l=!e.existsSync(u);if(e.readdirSync(s).sort(((n,e)=>n.localeCompare(e))).forEach((t=>{const i=n.join(s,t,t+".vue");if(t.indexOf(".")>-1||!e.existsSync(i))return;const c=o(r.replace(/\//gi,"_")+"_"+t,{pascalCase:!0});p.push(`import ${c} from "./${t}/${t}";`),a.push(`'${r}/${t}': ${c}`)})),0===p.length)return!1;const f=`${p.join("\n")}\n\nexport default {\n\t${a.join(",\n\t")}\n}`;return e.writeFileSync(u,f),l&&i(c),!0};exports.makeRootIndex=i,exports.makeSonIndex=s,exports.makeComponentIndex=function(t){let o=n.join(t,"index.js"),i=e.readdirSync(t),s=[],r=[];i.map((o=>{if(o.indexOf(".")>-1)return;let i=n.join(t,o,o+".vue");e.existsSync(i)&&(r.push(o),s.unshift(`import ${o} from "./${o}/${o}";`))}));const c=`${s.join("\n")}\nexport default {\n ${r.join(",\n\t")}\n}\n`;return e.writeFileSync(o,c)}}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-app-plugin",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "app代码生成器",
5
5
  "main": "index.js",
6
6
  "author": "zen",