zen-app-plugin 0.0.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 -0
- package/index.js +1 -0
- package/makeIndex.js +1 -0
- package/package.json +20 -0
- package/plugin.js +1 -0
- package/zen-app-plugin-0.0.1.tgz +0 -0
package/compress.js
ADDED
|
@@ -0,0 +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=require("fs"),{join:a,dirname:u,resolve:f,extname:d}=require("path"),p=require("cos-nodejs-sdk-v5");let l,g,m,x;function y(e){const t=a(e,"package.json"),n=o.readFileSync(t,"utf8");return JSON.parse(n)}function S(e,t){o.readdirSync(e).forEach((n=>{if(0===n.indexOf(".")||n.indexOf(".html")>-1)return;let i=a(e,n),c=o.statSync(i);if(c.isDirectory()&&S(i,a(t,n)),c.isFile()){let e=a(t,n).replace(/\\/gi,"/"),c={Bucket:m.bucket,Region:m.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(o.readFileSync(i,"utf8")))):c.Body=o.createReadStream(i),g.putObject(c,((e,t)=>{}))}}))}function O(e){const t=d(e);if(0===e.indexOf(".")||".html"===t)return;let i;if(i=e.indexOf("dist")>-1?l+e.substr(x.length+5):l+e.substr(x.length+7),n.mkdir("-p",u(i)),!r.includes(t))return n.cp(e,i);const f=o.readFileSync(e,"utf8").replace(c,(e=>e.indexOf("'")>-1||e.indexOf('"')>-1?e:function(e){const t=e.substr(e.indexOf(".vip")+4),s=a(l,t);n.mkdir("-p",u(s));const i=`wget --timeout=15 -O "${s}" "${e.indexOf(":")>-1?e:`https:${e}`}"`;return 0!==n.exec(i).code?e:t}(e)));o.writeFileSync(i,Buffer.from(s.gzip(f)),"utf8")}function h(e){const t=o.readdirSync(e);for(const n of t){if(n.startsWith("."))continue;const t=a(e,n),s=o.statSync(t);s.isDirectory()?h(t):s.isFile()&&O(t)}}exports.remote=function(t){x=t,m=JSON.parse(o.readFileSync(a(e.homedir(),".cos.json"))),g=new p({SecretId:m.id,SecretKey:m.key});const n=y(t);i.branchLocal(((e,s)=>{let i=n.name,c=s.current;const r=a(t,"dist"),u=a(t,"public");S(r,`${i}/${c}`),o.existsSync(u)&&S(u,`${i}/${c}`)}))},exports.locale=function(e){x=e;const t=y(e).name;n.exec(`rm -rf ../${t}/src/main/resources/static`),l=f(e,"..",t,"src","main","resources","static");const s=a(e,"public"),i=a(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 > "${a(s,e)}"`;n.exec(t)})),h(i),o.existsSync(s)&&h(s),n.exec(`cd ../${t} &&mvn clean&&mvn package -Dlocal=true -f pom.xml`)}}();
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(){let TerserPlugin=require("terser-webpack-plugin"),{VueLoaderPlugin:VueLoaderPlugin}=require("vue-loader"),path=require("path"),fs=require("fs"),bodyParser=require("body-parser"),makeIndex=require("./makeIndex"),{makeRootIndex:makeRootIndex,makeSonIndex:makeSonIndex}=makeIndex,ZenAppPlugin=require("./plugin");function makeDir(e,o){if(o.length<2)return;let t,n=o.filter(((o,n)=>(0===n&&(t=path.join(e,o),fs.existsSync(t)||fs.mkdirSync(t)),n>0)));makeDir(t,n)}function optimization(e){return"production"===e?{splitChunks:!1,minimize:!0,minimizer:[new TerserPlugin({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}})]}:{}}var webpackConfig={entry:{},output:{filename:"[name].js"},watchOptions:{ignored:["node_modules","dist","debug"],poll:300},externals:{vue:"Vue","router-view":"VueRouter","element-plus":"ElementPlus"},plugins:[new VueLoaderPlugin],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:target,mode:mode,ROOT:ROOT})=>{let basename,file,i,len,sourceList;for(sourceList=fs.readdirSync(path.resolve(ROOT,"src")),i=0,len=sourceList.length;i<len;i++)file=sourceList[i],-1!==file.indexOf(".js")&&(basename=path.basename(file),basename=basename.substr(0,basename.length-3),webpackConfig.entry[basename]=path.resolve(ROOT,"src",file));return webpackConfig.resolve={alias:{"@":path.resolve(ROOT,"src")},extensions:[".js",".vue",".jsx",".json"]},webpackConfig.mode=mode,webpackConfig.optimization=optimization(mode),"development"===mode?(webpackConfig.cache={type:"memory"},webpackConfig.devServer={open:!0,hot:!1,client:!1,host:"127.0.0.1",allowedHosts:"all",historyApiFallback:!0,onAfterSetupMiddleware:function(devServer){const{app:app}=devServer;app.use(bodyParser.json());const pagesRoot=path.join(ROOT,"src","pages");app.post("/coder/read",(function(req,res){const{file:file,key:key}=req.body;if(!file)return res.json({code:10001,message:"参数错误"});const fileFullPath=path.join(pagesRoot,file);if(!fs.existsSync(fileFullPath))return res.json({code:1e4,data:null});let content=fs.readFileSync(fileFullPath,"utf-8");"dict.js"===file&&(content=content.length>16?content.substr(15).replace(/[\r\n\s]+/g,"").replace(/,}/g,"}").replace(/,\]/g,"]"):"[]",content=eval(content),key&&(content=content.filter((e=>e.key.indexOf(key)>-1))));let result={code:1e4,data:content};res.json(result)})),app.post("/coder/write",(function(e,o){const{file:t,content:n,type:s}=e.body;if(!t)return o.json({code:10001,message:"参数错误"});const r=t.split("/");makeDir(pagesRoot,r);const a=path.join(pagesRoot,t);if(fs.writeFileSync(a,n),"page"===s){const e=r.splice(0,r.length-2),o=path.join(pagesRoot,e.join(path.sep));if(0===e.length)return makeRootIndex(pagesRoot);makeSonIndex(o,e.join("/"),pagesRoot)}o.json({code:1e4,message:"操作成功"})}))},static:{directory:path.join(ROOT,"public")},headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"*"}}):(webpackConfig.devtool=!1,webpackConfig.output.clean=!0,webpackConfig.output.path=path.join(ROOT,"dist")),webpackConfig.plugins.push(new ZenAppPlugin(target)),webpackConfig}}();
|
package/makeIndex.js
ADDED
|
@@ -0,0 +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)}}();
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zen-app-plugin",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "app代码生成器",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"author": "zen",
|
|
7
|
+
"license": "AAL",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"body-parser": "^1.20.3",
|
|
10
|
+
"camelcase": "^8.0.0",
|
|
11
|
+
"chokidar": "^3.5.3",
|
|
12
|
+
"cos-nodejs-sdk-v5": "^2.14.5",
|
|
13
|
+
"js-beautify": "^1.14.0",
|
|
14
|
+
"pako": "^2.1.0",
|
|
15
|
+
"shelljs": "^0.8.5",
|
|
16
|
+
"simple-git": "^3.25.0",
|
|
17
|
+
"terser-webpack-plugin": "^5.3.10",
|
|
18
|
+
"vue-loader": "^17.4.2"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/plugin.js
ADDED
|
@@ -0,0 +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)}))}}}();
|
|
Binary file
|