yann-vis-cli 1.1.11 → 1.2.4
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/dist/action.js +2 -2
- package/dist/auth/index.js +2 -2
- package/dist/auth/logon.js +2 -2
- package/dist/auth/select.js +2 -2
- package/dist/build/index.js +2 -2
- package/dist/config/index.js +2 -2
- package/dist/create/chart/index.js +2 -2
- package/dist/create/index.js +2 -2
- package/dist/dev/index.js +1 -1
- package/dist/index.js +2 -2
- package/dist/pack/index.js +1 -1
- package/dist/renew/index.js +2 -2
- package/dist/tar/index.js +1 -1
- package/dist/upload/index.js +2 -2
- package/dist/utils.js +2 -2
- package/dist/vpack/index.js +2 -2
- package/dist/vpack/menu.js +2 -2
- package/package.json +5 -3
- package/template/chart/README.md +1 -0
- package/template/chart/example/README.md +7 -0
- package/template/chart/example/index.html +12 -0
- package/template/chart/example/package.json +11 -0
- package/{dist/vpack → template/chart/example/src}/App.vue +2 -2
- package/template/chart/example/src/main.js +5 -0
- package/template/chart/example/src/style.css +26 -0
- package/template/chart/example/vite.config.js +10 -0
- package/template/chart/index.js +4 -0
- package/template/chart/jsconfig.json +14 -0
- package/template/chart/package.json +15 -0
- package/template/chart/public/images/index.png +0 -0
- package/template/chart/src/config.js +1 -0
- package/template/chart/src/data.js +1 -0
- package/template/chart/src/index.vue +15 -0
- package/template/chart/src/style.js +8 -0
- package/template/chart/vite.config.js +44 -0
- package/dist/replace/index.js +0 -2
package/dist/action.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";module.exports=[{command:"create",alias:"c",desc:"Create Project",examples:["pvis create <project-name>"]
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
|
+
"use strict";module.exports=[{command:"create",alias:"c",desc:"Create Project",examples:["pvis create <project-name>"]},{command:"pack",alias:"pk",desc:"Pack all charts",examples:["pvis pack"]},{command:"vpack",alias:"vp",desc:"Pack all charts",examples:["pvis vpack"]},{command:"build",alias:"b",desc:"Package Project",examples:["pvis build"]},{command:"dev",alias:"d",desc:"Launch Project",examples:["pvis dev"]},{command:"upload",alias:"u",desc:"Upload Chart Project",examples:["pvis upload"],isAuth:!0},{command:"auth",alias:"a",desc:"User Information",examples:["pvis auth"]},{command:"tar",alias:"t",desc:"tar",examples:["pvis tar"]},{command:"config",alias:"set",desc:"cli config",examples:["pvis config"]},{command:"*",alias:"",desc:"command not found",examples:[]}];
|
package/dist/auth/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const{requestToken:s,prompt:e,exit:a}=require("../utils"),
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
|
+
"use strict";const{requestToken:s,prompt:e,exit:r,log:a}=require("../utils"),t=async o=>{o++;const u=await e([{type:"text",name:"user",message:"请输入用户名: user"},{type:"password",name:"password",message:"请输入密码: password"}]),n=await s(u.user,u.password);return console.log(),n?(a.success("登录成功!"),u.user):o<3?(a.err("登录失败,请重新输入:"),await t(o)):void r("请稍后尝试!")};module.exports=async function(e=[]){const r={user:e[0]||"",password:e[1]||""};if(r.password&&r.user){if(await s(r.user,r.password))return r.user}return await t(0)};
|
package/dist/auth/logon.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const{requestToken:e,get_cli_config:t}=require("../utils");module.exports={get_token_two:async()=>{const[
|
|
1
|
+
// yann-vis-cli v1.2.2 by Yann
|
|
2
|
+
"use strict";const{requestToken:e,get_cli_config:t}=require("../utils");module.exports={get_token_two:async()=>{const[r]=await t();if(r.user&&r.password){if(await e(r.user,r.password))return!0}return console.log(),await require("./index")(),!0}};
|
package/dist/auth/select.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const e=require("opn"),{prompt:t,log:i}=require("../utils");module.exports=async function(){if("register"!==(await t([{type:"select",name:"mode",message:"
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
|
+
"use strict";const e=require("opn"),{prompt:t,log:i,wait:s}=require("../utils");module.exports=async function(){if("register"!==(await t([{type:"select",name:"mode",message:"请选择登录或注册",choices:[{title:"登录",description:"Sign in",value:"SignIn"},{title:"注册",description:"register",value:"register"}]}])).mode){return await require("./index")()}{const t="http://10.68.120.200/fea_cmty/register";console.log(),i.success(`浏览器如果未正常打开,可以手动打开:${t}`),await e(t),await s(.1),process.exit(0)}};
|
package/dist/build/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const a=require("path"),e=require("yann-fs").default,{to:t}=require("await-to-js"),{log:s,exit:o,spawnHandle:
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
|
+
"use strict";const a=require("path"),e=require("yann-fs").default,{to:t}=require("await-to-js"),{log:s,exit:o,spawnHandle:n,prompt:i,buildTarHandler:r,filterFile:c,compareVersion:p,get_cli_config:u,getPath:l}=require("../utils"),w=async(s,i=null)=>{const{name:l,version:w}=await(async t=>{const s=a.resolve(t,"public","base.json"),[n,i]=await e.readJson(s);if(n)return void o("找不到 base.json 文件");const r=i.version,c=a.resolve(t,"package.json"),[u,l]=await e.readJson(c);if(u)return void o("找不到 package.json 文件");const w=l.version,d=p(r,w);let v=r;return 1===d?(v=r,l.version=v,await e.outputJson(c,l,{spaces:2,EOL:"\n"})):-1===d&&(v=w,i.version=v,await e.outputJson(s,i,{spaces:2,EOL:"\n"})),{name:i.name,version:v}})(s);await(async a=>{await n(/^win/.test(process.platform)?"pnpm.cmd":"pnpm",["build"],{cwd:a})})(s);const d=l.split("/").at(-1)+"_v"+w,v=a.resolve(s,d);await c(v);const m=(i?`${i}/${d}`:v)+".tar.gz";await e.remove(m),await t(r(s,d,i));const[f]=await u();f.autoRemove&&await e.remove(v),f.autoUpload&&await require("../upload/index")([m])};module.exports=async function(t=[]){const s=process.cwd();if(t[0]){const a=t[0].trim();return void await w(l(a))}const n=a.resolve(s,"package.json"),[i,r]=await e.pathExists(n);i?o("找不到目录"):r&&await w(s)};
|
package/dist/config/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const{prompt:
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
|
+
"use strict";const{prompt:e,set_cli_config:o,log:t}=require("../utils");module.exports=async function(a=[]){const i=await e([{name:"autoUpload",message:"图表打包后是否自动上传泰合社区?",type:"toggle",initial:!1,active:"yes",inactive:"no"},{name:"autoRemove",message:"打包后是否自动删除打包目录?",type:"toggle",initial:!1,active:"yes",inactive:"no"}]);await o({autoUpload:i.autoUpload,autoRemove:i.autoRemove}),t.success("配置完成!"),console.log()};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const{updatePackageJson:e,getPackageName:n,outputVueName:t
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
|
+
"use strict";const{updatePackageJson:e,getPackageName:n,outputVueName:t}=require("../../utils"),a=require("yann-fs").default,o=require("path");module.exports=async function(s,i,c,p,r){await a.outputJson(o.resolve(i,"public","base.json"),{name:s,label:s,desc:"Custom Chart",version:"1.0.0",width:500,height:400,type:r||"other",author:p},{spaces:2,EOL:"\n"});const u=`\n${c&&"chart"===c.name?"import { withInstall } from '@chart/utils/vue';":"\nconst withInstall = component => {\n component.install = app => app.component(component.name, component);\n return component;\n};"}\n\n// 具名组件\nexport const ${n(s)} = withInstall(ChartComponent);\n// 图表默认数据\nexport const data = chartData;\n// 图表配置\nexport const config = chartConfig;\n// 图表样式\nexport const style = chartStyle;\n\nexport default {\n style,\n data,\n config,\n component:${n(s)}\n};\n `;await a.appendFile(o.resolve(i,"index.js"),u),await t(o.resolve(i,"src","index.vue"),s),await e(i,{name:s,author:p}),c&&"chart"===c.name?await e(i,{name:s,author:p,devDependencies:{"@chart/utils":"workspace:*"}}):(await e(i,{name:s,author:p,devDependencies:{"@vitejs/plugin-vue":"^3.2.0",sass:"^1.66.1",vite:"^4.4.9","yann-snapshot":"^0.1.0"},dependencies:{vue:"^3.3.4","yann-i18n":"^1.0.7"}}),await e(o.resolve(i,"example"),{devDependencies:{"@vitejs/plugin-vue":"^3.2.0",sass:"^1.66.1",vite:"^4.4.9"},dependencies:{vue:"^3.3.4"}}))};
|
package/dist/create/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const e=require("path"),{
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
|
+
"use strict";const e=require("path"),{scanFileFindChart:t,scanDirHandle:a,prompt:i,log:s,oraHandle:n,spawnHandle:r,wait:o,welcomeCli:l,get_cli_config:c,getGitUser:u,registerChartId:p,requestToken:m}=require("../utils"),d=require("yann-fs").default;module.exports=async function(w=[]){const g="chart",[f]=await c();let v,y=!!f.user;if(f.user&&f.password&&f.token&&(y=await m(f.user,f.password)),!y){const e=await u(),t=await i([{name:"isLogin",type:"toggle",message:"未登录,是否先登录:",initial:!0,active:"yes",inactive:"no"},{name:"user",type:(e,t)=>t.isLogin?null:"text",initial:e||"",message:"请填写泰合社区的用户名(用户名不做验证)"}]);y=t.isLogin,t.isLogin&&(v=await require("../auth/select.js")())}const h=await t(),{chartType:j}=await i([{name:"chartType",type:"select",message:"请选择图表类型:",initial:4,choices:[{title:"折线图",value:"line"},{title:"柱状图",value:"bar"},{title:"饼图",value:"pie"},{title:"表格",value:"form"},{title:"其他",value:"other"},{title:"地图",value:"map"},{title:"文本",value:"text"},{title:"指标",value:"indicator"},{title:"交互",value:"interaction"}]}]);console.log("推荐添加自定义前缀以防止和其他图表名重复并且便于后期统一管理");const{projectName:_}=await i([{name:"projectName",type:"text",message:"请输入图表名:",initial:w[0]||"custom_chart",validate:async t=>{if(((e="")=>!/^[a-z][a-z0-9_]*$/.test(e))(t))return"包名只允许以小写英文字母开头,只允许使用小写英文字母、数字和下划线";if(await(async t=>{if(h){const[i,s,n]=await Promise.all([a(h.root),a(e.join(h.root,"packages")),a(e.join(h.root,"packages","components"))]);if(i.includes(t)||s.includes(t)||n.includes(t))return!0}else if((await a(process.cwd())).includes(t))return!0;return!1})(t))return"包名重复";if(y){const[e,a]=await p(t,j);if(e||!a||!a.data||!a.data.data)return e?.data?.msg||"请重新填写"}return!0}}]),q=n("创建项目..."),x=process.cwd(),k=h?e.join(h.root,"packages","components",_):e.join(x,_);await d.ensureDir(k),await d.copy(e.resolve(__dirname,"../../template",g),k),await require(e.resolve(__dirname,g,"index.js"))(_,k,h,v,j),q.succeed("项目创建完成."),await o(.1),q.start("安装依赖.."),await r(/^win/.test(process.platform)?"pnpm.cmd":"pnpm",["install"],{cwd:`./${_}`}),await r(/^win/.test(process.platform)?"pnpm.cmd":"pnpm",["install"],{cwd:`./${_}/example`}),q.succeed("依赖安装完成."),await o(.1),q.clear();require("clear")(),await l(),console.log("\n完成. 现在可以执行:\n"),s.success(` cd ${_}`),s.success(" pnpm dev:example"),console.log()};
|
package/dist/dev/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
2
|
"use strict";const e=require("path"),s=require("yann-fs").default,{exit:r,getPath:i}=require("../utils");module.exports=async function(t=[]){let n=process.cwd();t.length>0&&(n=i(t[0]));const c=n.includes("package.json")?n:e.resolve(n,"package.json");n=e.dirname(c);const[o,a]=await s.readJson(c);if(o)r(o?.message);else{if(a.scripts){const e=require("cross-spawn");if(process.chdir(n),a.scripts.dev)return void e.sync("pnpm",["dev"],{stdio:"inherit"});if(a.scripts.serve)return void e.sync("pnpm",["serve"],{stdio:"inherit"})}r("找不到执行命令!")}};
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const e=require("./renew"),r=require("./action"),{program:a}=require("commander"),{version:s}=require("../package.json"),i=require("path"),{log:c,get_cli_config:o,exit:n}=require("./utils"),t=(e,r=[])=>{try{require(i.resolve(__dirname,e,"index.js"))(r,{})}catch(e){n(e?.message)}};r.forEach((r=>{a.command(r.command).alias(r.alias).description(r.desc).action((async()=>{
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
|
+
"use strict";const e=require("./renew"),r=require("./action"),{program:a}=require("commander"),{version:s}=require("../package.json"),i=require("path"),{log:c,get_cli_config:o,exit:n,command:m}=require("./utils"),t=(e,r=[])=>{try{require(i.resolve(__dirname,e,"index.js"))(r,{})}catch(e){n(e?.message)}};r.forEach((r=>{a.command(r.command).alias(r.alias).description(r.desc).action((async()=>{m.shell=r.command;const a=process.argv.slice(3);if(m.argv=a,await e(),"*"===r.command)c.err(r.desc);else if(r.isAuth){const[e]=await o();if(e.user)t(r.command,a);else{await require("./auth/select.js")()&&t(r.command,a)}}else t(r.command,a)}))})),a.version(s).parse(process.argv);
|
package/dist/pack/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
2
|
"use strict";const n=require("path"),a=require("yann-fs").default,{to:t}=require("await-to-js"),{spawnHandle:e,scanFileFindChart:s,getPackageName:o}=require("../utils");module.exports=async function(){const r=await s();if(r){const s=n.resolve(r.root,"packages"),i=n.resolve(s,"components"),[p,c]=await t(a.readdir(i));if(c){const t=[],p=["Core"];await Promise.all(c.map((e=>(async(t,e,s,r)=>{if(0!==t.indexOf(".")){const i=n.resolve(e,t);if(await a.isDir(i)){const[e,p]=await a.pathExists(n.resolve(i,"package.json"));if(p){const[e,p]=await a.pathExists(n.resolve(i,"index.js"));if(p){const n=o(t);r.push(n),s.push(`export { default as ${n} } from './components/${t}'`)}}}}})(e,i,t,p)))),await a.outputFile(n.resolve(s,"index.js"),t.join("\n")),await(async n=>{await e(/^win/.test(process.platform)?"pnpm.cmd":"pnpm",["build"],{cwd:n})})(s);const u=`\n# pangu-roof-chart\n\n盘古前端图表库\n\n### 打包方式\n\n打开终端执行,进入pangu-roof-chart目录下,执行命令\n\n\`\`\`bash\npv pack\n\`\`\`\n\n会在packages目录下生成 pgChart 的打包目录\n\n### 使用方式\n\n将pgChart目录迁移至任意项目的scr目录内,就可以导入使用了\n\n完整组件列表\n\`\`\`js\nimport {\n ${p.join(",\n ")}\n} from '@pangu/chart'\n\`\`\`\n\n\n使用方式\n\`\`\`js\n<script setup>\n import { Core } from '@pangu/chart';\n import '@pangu/chart/style.css';\n import { ref } from 'vue';\n\n const type = ref('Anbar');\n const chartData = ref({\n data: {\n columns: ['name', 'value'],\n data: [\n ['hz', 11],\n ['sh', 18],\n ['bj', 25]\n ]\n }\n });\n<\/script>\n\n<template>\n <Core :type="type" :data="chartData" />\n</template>\n\`\`\`\n\n `;await a.outputFile(n.resolve(r.root,"README.md"),u)}}};
|
package/dist/renew/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const{log:s,prompt:e,exit:i,welcomeCli:t}=require("../utils"),n=require("cross-spawn"),
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
|
+
"use strict";const{log:s,prompt:e,exit:i,welcomeCli:t}=require("../utils"),n=require("cross-spawn"),o=/^win/.test(process.platform);module.exports=async function(){if(!!n.sync("npm",["outdated","yann-vis-cli","-g","--registry=https://registry.npmjs.org"]).stdout.toString().replace(/[\n]/g,"")){const n=await e([{name:"updateFlag",message:"是否更新Cli工具?",type:"toggle",initial:!0,active:"yes",inactive:"no"}]),{updateFlag:r}=n;r?(await(async()=>new Promise(((e,t)=>{const{exec:n}=require("child_process");n(`${o?"npm":"sudo npm"} i -g yann-vis-cli${o?" --no-color":""} --registry=https://registry.npmjs.org`,((t,n,o)=>{t?i("异常错误,请手动执行命令更新Cli工具:npm i -g yann-vis-cli"):(console.log(),s.success("Cli工具更新成功!"),e())}))})))(),await t(),i()):i("请更新Cli工具再使用,谢谢!")}};
|
package/dist/tar/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
2
|
"use strict";const{buildTarHandler:t,exit:e}=require("../utils"),{to:i}=require("await-to-js");module.exports=async function(s=[]){if(s.length>0){const[a,r,n,o]=s,[u]=await i(t(a,r,n,o));u&&e(u?.message)}};
|
package/dist/upload/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const e=require("path"),t=require("yann-fs").default,{axios:a,exit:
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
|
+
"use strict";const e=require("path"),t=require("yann-fs").default,{axios:a,exit:s,log:r,getPath:i,get_cli_config:o,requestToken:n}=require("../utils"),{to:c}=require("await-to-js"),l=require("form-data"),u=require("p-limit")(1),d=async(e,i)=>{const o=i;console.log(`准备上传 ${o} ...`);const n=new l,c=t.createReadStream(e);n.append("file",c,{filename:o});const[u,d]=await a({url:"/cmt/chart/version/upload_pkg",method:"post",data:n,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},timeout:3e4});u?s(u?.message||u?.data?.msg||"异常错误"):(console.log(),r.success(`${o} 组件上传成功!`),console.log())};module.exports=async function(a=[]){const[r]=await o();if(r.user){if(r.user&&r.password&&r.token){await n(r.user,r.password)||await require("../auth/select.js")()}}else await require("../auth/select.js")();let l=process.cwd();if(a[0]){const t=a[0].trim();if(t.includes(".tar.gz")){const a=i(t);return void await c(d(a,e.basename(a)))}l=i(t)}const[m,w]=await c(t.readdir(l));if(m)return void s(m?.message);const p=w.filter((e=>e.includes(".tar.gz")));await Promise.all(p.map((t=>u((()=>c(d(e.resolve(l,"./",t),t)))))))};
|
package/dist/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const e=require("yann-fs").default,t=require("path"),
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
|
+
"use strict";const e=require("yann-fs").default,t=require("path"),r=require("chalk"),s=require("axios").default,{to:a}=require("await-to-js"),{camelCase:n,upperFirst:o,mergeWith:i,isArray:c}=require("lodash"),u=require("os").homedir(),l={success(e){console.log(r.green(e))},err(e){console.log(r.bold.red(e))}},p=e=>{e&&(console.log(),l.err(e)),process.exit(1)},d=t.resolve(u,".yann-vis-store");let w={};const m=async t=>{const[r,s]=await f();w={...r,...t},await e.outputJson(s,w)},f=async()=>{const r=t.resolve(d,".cli_store");if(Object.keys(w).length>0)return[w,r];const[s,a]=await e.readJson(r);return s?[{user:"",password:"",token:"",autoUpload:!1,autoRemove:!1},r]:(w=a,[a,r])},g=s.create({baseURL:"http://10.68.120.200:8080/fea_cmty/api",headers:{"Content-Type":"application/json;charset=UTF-8"},timeout:1e4});async function h(e){return a(g(e))}g.interceptors.request.use((async e=>{const[t]=await f();return t.token&&(e.headers.Authorization=`Bearer ${t.token}`),e}),(e=>Promise.reject(e))),g.interceptors.response.use((async e=>e.data.code&&200!==e.data.code?Promise.reject(e):e),(e=>Promise.reject(e)));const y=e=>{const r=process.cwd();return e.includes(r)?e:t.resolve(r,e)};const q=async(r,s=[".git",".vscode",".DS_Store",".idea"])=>{const n=r||process.cwd();if(await e.isDir(n)){const[r,s]=await a(e.readdir(n));if(r)return p(r?.message);await Promise.all(s.map((e=>q(t.resolve(n,e)))))}else for(let t=0;t<s.length;t++)if(n.includes(s[t]))return void e.remove(n)},v=async r=>{const s=process.cwd(),a=t.resolve(s,r),n=t.resolve(r,"package.json"),[o,i]=await e.readJson(n);if(i){const{name:r}=i;if("chart"===r){const[r,n]=await e.readJson(t.resolve(a,".pv_store"));if(n&&"chart"===n.name)return{type:"chart",root:a,cwd:s}}}return!1},k={user:""};module.exports={userInfo:k,getGitUser:async()=>{const e=require("cross-spawn").sync("git",["config","user.name"]);return k.user=e.stdout.toString().replace(/[\n]/g,""),k.user},scanFileFindChart:async()=>{const e=await v("./");if(e)return e;const t=await v("../");if(t)return t;const r=await v("../../");if(r)return r;return await v("../../../")},outputVueName:async(t,r)=>{const s=`\n <script>\n export default {\n name: '${r}'\n };\n <\/script>\n `;await e.appendFile(t,s)},updatePackageJson:async(r,s)=>{const a=t.join(r,"package.json"),[n,o]=await e.readJson(a);n?p():o&&(i(o,s,((e,t)=>{if(c(e))return e.concat(t)})),await e.outputJson(a,o,{spaces:2,EOL:"\n"}))},registerChartId:async(e,t)=>{const r=new(require("form-data"));return r.append("typeId",t||"other"),r.append("chartName",e),h({url:"/cmt/chart/register",method:"post",data:r,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}})},prompt:async e=>{const t=require("prompts");return await t(e,{onCancel:()=>{p("✖ 操作已取消")}})},requestToken:async(e,t)=>{const[r,s]=await h({url:"/login",method:"post",data:{username:e,password:t}});return s&&s.data&&s.data.token?(await m({user:e,password:t,token:s.data.token}),!0):(await m({user:e,password:t,token:""}),!1)},axios:h,get_cli_config:f,set_cli_config:m,packagePath:d,exit:p,log:l,welcomeCli:async()=>{const{promisify:e}=require("util"),t=e(require("figlet")),r=await t("Welcome to VisCli");console.log(),l.success(r)},wait:e=>new Promise((t=>{setTimeout((()=>{t()}),1e3*e)})),buildTarHandler:async(t,r,s=null,a=null)=>(t=y(t),s&&(s=y(s),await e.ensureDir(s)),new Promise((n=>{const o={gzip:!0,cwd:t,sync:!0},i="string"==typeof r?[r]:r,c=a||"string"==typeof r?r:"tar_"+Date.now();require("tar").c(o,i).pipe(e.createWriteStream(`${s||t}/${c}.tar.gz`)).on("finish",n)}))),getPath:y,compareVersion:function(e,t){0===e.indexOf("v")&&(e=e.slice(1)),0===t.indexOf("v")&&(t=t.slice(1)),e=e.split("."),t=t.split(".");const r=Math.max(e.length,t.length);for(;e.length<r;)e.push("0");for(;t.length<r;)t.push("0");for(let s=0;s<r;s++){const r=parseInt(e[s]),a=parseInt(t[s]);if(r>a)return 1;if(r<a)return-1}return 0},filterFile:q,spawnHandle:async(...e)=>{await a((async(...e)=>{const{spawn:t}=require("child_process");return new Promise((r=>{const s=t(...e);s.stdout.pipe(process.stdout),s.stderr.pipe(process.stderr),s.on("close",(()=>{r()}))}))})(...e))},oraHandle:e=>{const t=require("ora")(e);return t.start(),t},getPackageName:e=>{const t=n(e);return o(t)},command:{shell:"",argv:""},scanDirHandle:async r=>{const s=[];if(await e.isDir(r)){const[n,o]=await a(e.readdir(r));if(n)return p(n?.message);(await Promise.all(o.map((s=>a(e.isDir(t.resolve(r,s))))))).forEach(((e,t)=>{e[1]&&s.push(o[t])}))}return s}};
|
package/dist/vpack/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
|
+
"use strict";const e=require("path"),a=require("yann-fs").default,{to:t}=require("await-to-js"),{spawnHandle:s,scanFileFindChart:i,wait:r}=require("../utils"),{menu:o}=require("./menu"),n=require("p-limit")(3),c=o;module.exports=async function(o=[]){const l=await i();if(l){const i=e.resolve(l.root,"packages"),p=e.resolve(i,"components"),[m,u]=await t(a.readdir(p));if(u){const t=[],l=e.resolve(i,"charts");if(await a.emptyDir(l),await Promise.all(u.map((s=>(async(t,s,i)=>{if(0!==t.indexOf(".")){const r=e.resolve(s,t);if(await a.isDir(r)){const[s,o]=await a.readJson(e.resolve(r,"package.json"));if(o){const[s,n]=await a.pathExists(e.resolve(r,"index.js"));if(n){const[s,n]=await a.readJson(e.resolve(r,"public","base.json"));if(n){const{name:e,label:a,version:t,width:s,height:i,type:r}=n,o={layerType:"chart",chartType:e,name:a,version:`v${t}`,width:s,height:i},h=c.find((e=>e.type===r));h?h.children.push(o):c.find((e=>"other"===e.type)).children.push(o)}i.push([t,o.version])}}}}})(s,p,t)))),await a.outputJson(e.resolve(l,"menu.json"),c,{spaces:2,EOL:"\n"}),"false"===o[0])return;await Promise.all([t.map((a=>n((()=>(async({v:a,chartsPath:t,comPath:i})=>{await s(/^win/.test(process.platform)?"pnpm.cmd":"pnpm",["build"],{cwd:e.resolve(i,a[0])}),await r(.005),await h({v:a,chartsPath:t,comPath:i})})({v:a,chartsPath:l,comPath:p})))))])}}};const h=async({v:t,chartsPath:s,comPath:i})=>{const r=`${t[0]}_v${t[1]}`,o=e.resolve(s,t[0],r),n=e.resolve(i,t[0],r);await a.move(n,o)};
|
package/dist/vpack/menu.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";module.exports={menu:[{type:"line",name:"折线图",children:[]},{type:"bar",name:"柱状图",children:[]},{type:"pie",name:"饼图",children:[]},{type:"form",name:"表格",children:[]},{type:"other",name:"其他",children:[]},{type:"map",name:"地图",children:[]},{type:"text",name:"文本",children:[]},{type:"indicator",name:"指标",children:[]},{type:"interaction",name:"交互",children:[]}
|
|
1
|
+
// yann-vis-cli v1.2.4 by Yann
|
|
2
|
+
"use strict";module.exports={menu:[{type:"line",name:"折线图",children:[]},{type:"bar",name:"柱状图",children:[]},{type:"pie",name:"饼图",children:[]},{type:"form",name:"表格",children:[]},{type:"other",name:"其他",children:[]},{type:"map",name:"地图",children:[]},{type:"text",name:"文本",children:[]},{type:"indicator",name:"指标",children:[]},{type:"interaction",name:"交互",children:[]}]};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yann-vis-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "vis-cli",
|
|
5
5
|
"bin": {
|
|
6
6
|
"pvis": "./bin/index.js",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"lodash": "^4.17.21",
|
|
31
31
|
"opn": "^6.0.0",
|
|
32
32
|
"ora": "^5.4.1",
|
|
33
|
+
"p-limit": "^3.1.0",
|
|
33
34
|
"prompts": "^2.4.2",
|
|
34
35
|
"tar": "^6.1.13",
|
|
35
36
|
"yann-fs": "^1.6.0"
|
|
@@ -46,7 +47,8 @@
|
|
|
46
47
|
"files": [
|
|
47
48
|
"LICENSE",
|
|
48
49
|
"README.md",
|
|
49
|
-
"dist
|
|
50
|
-
"bin
|
|
50
|
+
"dist",
|
|
51
|
+
"bin",
|
|
52
|
+
"template"
|
|
51
53
|
]
|
|
52
54
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Fea Custom Chart
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Vue 3 + Vite
|
|
2
|
+
|
|
3
|
+
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
|
4
|
+
|
|
5
|
+
## Recommended IDE Setup
|
|
6
|
+
|
|
7
|
+
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>fea-chart</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="app"></div>
|
|
10
|
+
<script type="module" src="/src/main.js"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
if (baseImg) {
|
|
37
|
-
downSnapshot(baseImg);
|
|
37
|
+
downSnapshot(baseImg, 'index');
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
</script>
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
<!-- 图表具体内容 -->
|
|
47
47
|
<div class="layerMain">
|
|
48
48
|
<!-- 上面那些div不用去管,平台会自动生成 -->
|
|
49
|
-
<Chart :
|
|
49
|
+
<Chart :data="chartData" :styled="chartStyle" />
|
|
50
50
|
</div>
|
|
51
51
|
</div>
|
|
52
52
|
<button class="takeBtn" @click="takeSnapshotHandle">获取缩略图</button>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
+
font-size: 16px;
|
|
4
|
+
line-height: 24px;
|
|
5
|
+
font-weight: 400;
|
|
6
|
+
color-scheme: light dark;
|
|
7
|
+
background-color: #242424;
|
|
8
|
+
font-synthesis: none;
|
|
9
|
+
text-rendering: optimizeLegibility;
|
|
10
|
+
-webkit-font-smoothing: antialiased;
|
|
11
|
+
-moz-osx-font-smoothing: grayscale;
|
|
12
|
+
-webkit-text-size-adjust: 100%;
|
|
13
|
+
}
|
|
14
|
+
body {
|
|
15
|
+
margin: 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
width: 100vw;
|
|
18
|
+
height: 100vh;
|
|
19
|
+
display: flex;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
align-items: center;
|
|
22
|
+
}
|
|
23
|
+
#app {
|
|
24
|
+
width: 100vw;
|
|
25
|
+
height: 100vh;
|
|
26
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"paths": {
|
|
4
|
+
"@/*": ["src/*"]
|
|
5
|
+
},
|
|
6
|
+
"baseUrl": ".",
|
|
7
|
+
"target": "es2016",
|
|
8
|
+
"module": "esnext",
|
|
9
|
+
"jsx": "preserve",
|
|
10
|
+
"lib": ["esnext", "dom"],
|
|
11
|
+
"rootDir": "."
|
|
12
|
+
},
|
|
13
|
+
"exclude": ["dist", "node_modules", "**/*_v*", "example", "**/node_modules/*"]
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "demo_chart",
|
|
3
|
+
"description": "Custom Chart",
|
|
4
|
+
"private": true,
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"module": "./index.js",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "vite build",
|
|
10
|
+
"dev:example": "pnpm -C example run dev"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {},
|
|
13
|
+
"devDependencies": {},
|
|
14
|
+
"author": ""
|
|
15
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>Custom Chart</div>
|
|
3
|
+
</template>
|
|
4
|
+
<script setup>
|
|
5
|
+
import { defineProps, defineEmits } from 'vue';
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
styled: Object,
|
|
8
|
+
data: Object,
|
|
9
|
+
width: [String, Number],
|
|
10
|
+
height: [String, Number],
|
|
11
|
+
events: Object,
|
|
12
|
+
option: Object
|
|
13
|
+
});
|
|
14
|
+
const emit = defineEmits(['message']);
|
|
15
|
+
</script>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import vue from '@vitejs/plugin-vue';
|
|
3
|
+
import pkg from './package.json';
|
|
4
|
+
|
|
5
|
+
// https://vitejs.dev/config/
|
|
6
|
+
const pkgName = pkg.name.split('/').at(-1);
|
|
7
|
+
const getPackageUmdName = () => {
|
|
8
|
+
return (
|
|
9
|
+
pkgName.replace(/^\S/, s => s.toUpperCase()) +
|
|
10
|
+
'_v' +
|
|
11
|
+
pkg.version.replaceAll('.', '_')
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
export default defineConfig({
|
|
15
|
+
define: {
|
|
16
|
+
'process.env': process.env || {}
|
|
17
|
+
},
|
|
18
|
+
plugins: [
|
|
19
|
+
vue({
|
|
20
|
+
isProduction: true
|
|
21
|
+
})
|
|
22
|
+
],
|
|
23
|
+
build: {
|
|
24
|
+
outDir: `${pkgName}_v${pkg.version}`,
|
|
25
|
+
cssCodeSplit: true,
|
|
26
|
+
lib: {
|
|
27
|
+
entry: './index.js', // 设置入口文件
|
|
28
|
+
formats: ['umd'],
|
|
29
|
+
name: getPackageUmdName(), // 起个名字,安装、引入用
|
|
30
|
+
fileName: () => 'index.js'
|
|
31
|
+
},
|
|
32
|
+
rollupOptions: {
|
|
33
|
+
// 确保外部化处理那些你不想打包进库的依赖
|
|
34
|
+
external: ['vue'],
|
|
35
|
+
output: {
|
|
36
|
+
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
|
|
37
|
+
globals: {
|
|
38
|
+
vue: 'Vue'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
polyfillModulePreload: false
|
|
43
|
+
}
|
|
44
|
+
});
|
package/dist/replace/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// yann-vis-cli v1.1.3 by Yann
|
|
2
|
-
"use strict";const e=require("path"),s=require("yann-fs").default,{exit:i,getPath:t}=require("../utils"),{to:a}=require("await-to-js");module.exports=async function(t=[]){const o=process.cwd(),[r,n]=await a(s.readdir(o));if(r)return i(r?.message);const c=[];await Promise.all(n.map((i=>(async(i,t)=>{if(await s.isDir(i)){const[a,o]=await s.pathExists(e.resolve(i,"vite.config.js"));a||t.push(i)}})(e.resolve(o,i),c)))),console.log("list",c);const l=e.resolve(__dirname,"../../vite.config.js");await Promise.all(c.map((i=>s.copy(l,e.resolve(i,"vite.config.js")))))};
|