yann-vis-cli 1.6.10 → 1.8.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/dist/action.js +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/select.js +1 -1
- 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 +2 -2
- package/dist/pack/new.js +2 -0
- 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 +1 -1
- package/package.json +9 -9
- package/template/chart/example/{src/App.vue → App.vue} +2 -2
- package/template/chart/{example/index.html → index.html} +2 -2
- package/template/chart/package.json +1 -1
- package/template/ts/tsconfig.app.json +5 -12
- package/template/chart/example/README.md +0 -7
- package/template/chart/example/package.json +0 -11
- package/template/chart/example/vite.config.js +0 -10
- package/template/ts/vite.config.ts +0 -49
- /package/template/chart/example/{src/main.js → main.js} +0 -0
- /package/template/chart/example/{src/style.css → style.css} +0 -0
package/dist/action.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
1
|
+
// yann-vis-cli v1.8.1 by Yann
|
|
2
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"],option:["--full"]},{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.
|
|
1
|
+
// yann-vis-cli v1.8.1 by Yann
|
|
2
2
|
"use strict";const{requestToken:s,prompt:e,exit:r,log:a}=require("../utils"),t=require("js-md5"),o=async u=>{u++;const i=await e([{type:"text",name:"user",message:"请输入用户名: user"},{type:"password",name:"password",message:"请输入密码: password"}]),n=await s(i.user,t(i.password));return console.log(),n?(a.success("登录成功!"),i.user):u<3?(a.err("登录失败,请重新输入:"),await o(u)):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,t(r.password)))return r.user}return await o(0)};
|
package/dist/auth/select.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
1
|
+
// yann-vis-cli v1.8.1 by Yann
|
|
2
2
|
"use strict";const e=require("opn"),{prompt:i,log:t,wait:s,API_IP:r}=require("../utils");module.exports=async function(){if("register"!==(await i([{type:"select",name:"mode",message:"请选择登录或注册",choices:[{title:"登录",description:"Sign in",value:"SignIn"},{title:"注册",description:"register",value:"register"}]}])).mode){return await require("./index")()}{const i=r;console.log(),t.success(`浏览器如果未正常打开,可以手动打开:${i}`),await e(i),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
|
|
1
|
+
// yann-vis-cli v1.8.1 by Yann
|
|
2
|
+
"use strict";const e=require("path"),t=require("yann-fs").default,{to:a}=require("await-to-js"),{log:i,exit:o,spawnHandle:r,prompt:s,buildTarHandler:n,filterFile:l,compareVersion:c,get_cli_config:u,getPath:w,get_delete_es:d,buildPathHandler:p,versionHandle:v}=require("../utils"),m=async(i,r=null)=>{const s=await v(i);if("string"==typeof s)return o(s);const{name:c,version:w}=s;await p(i);const m=c.split("/").at(-1)+"_v"+w,f=e.resolve(i,m);await d()&&await t.remove(e.resolve(f,"es")),await l(f);const g=(r?`${r}/${m}`:f)+".tar.gz";await t.remove(g),await a(n(i,m,r));const[q]=await u();q.autoRemove&&await t.remove(f),q.autoUpload&&await require("../upload/index")([g])};module.exports=async function(a=[]){const i=process.cwd();if(a[0]){const e=a[0].trim();return void await m(w(e))}const r=e.resolve(i,"package.json"),[s,n]=await t.pathExists(r);s?o("找不到目录"):n&&await m(i)};
|
package/dist/config/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const{prompt:e,set_cli_config:o,log:
|
|
1
|
+
// yann-vis-cli v1.8.1 by Yann
|
|
2
|
+
"use strict";const{prompt:e,set_cli_config:o,get_cli_config:t,log:a}=require("../utils");module.exports=async function(i=[]){const[s]=await t(),n=(e,o,t)=>o in e?e[o]:t,c=await e([{name:"autoUpload",message:"图表打包后是否自动上传泰合社区?",type:"toggle",initial:n(s,"autoUpload",!1),active:"yes",inactive:"no"},{name:"autoRemove",message:"打包后是否自动删除打包目录?",type:"toggle",initial:n(s,"autoRemove",!0),active:"yes",inactive:"no"},{name:"autoRemoveEs",message:"打包后是否移除es目录?",type:"toggle",initial:n(s,"autoRemoveEs",!0),active:"yes",inactive:"no"}]);await o({autoUpload:c.autoUpload,autoRemove:c.autoRemove,autoRemoveEs:c.autoRemoveEs}),a.success("配置完成!"),console.log()};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const{updatePackageJson:e,getPackageName:a,outputVueName:s,get_plugin_version:
|
|
1
|
+
// yann-vis-cli v1.8.1 by Yann
|
|
2
|
+
"use strict";const{updatePackageJson:e,getPackageName:a,outputVueName:s,get_plugin_version:t}=require("../../utils"),n=require("yann-fs").default,r=require("path");module.exports=async function(i,o,c,l,u,v,p){await n.outputJson(r.resolve(o,"public","base.json"),{name:i,label:i,desc:"Custom Chart",version:"1.0.0",width:480,height:240,type:u||"other",author:l,id:v},{spaces:2,EOL:"\n"});const d=`\nexport const ${a(i)} = component`;if(await n.appendFile(r.resolve(o,"index.js"),d),await s(r.resolve(o,"src","index.vue"),i),await e(o,{name:i,author:l}),c&&"chart"===c.type?await e(o,{name:i,author:l,devDependencies:{"@chart/utils":"workspace:*"}}):await e(o,{name:i,author:l,devDependencies:{"@vitejs/plugin-vue":"^3.2.0",sass:"^1.69.7",vite:"^4.5.5","yann-snapshot":"^0.1.0","yann-chart-cli":"^"+t("yann-chart-cli")||"1.0.13","vite-plugin-compression":"^0.5.1","vite-plugin-banner":"^0.7.1"},dependencies:{vue:"^3.4.4","yann-i18n":"1.0.7"}}),!p)return;const h=r.resolve(o,"src"),m=r.resolve(o,"render.js"),w=r.resolve(o,"render.ts"),g=r.resolve(h,"config.js"),y=r.resolve(h,"config.ts"),j=r.resolve(h,"data.js"),f=r.resolve(h,"data.ts"),b=r.resolve(h,"style.js"),x=r.resolve(h,"style.ts");await n.rename(m,w),await n.rename(g,y),await n.rename(j,f),await n.rename(b,x),await n.remove(r.resolve(o,"jsconfig.json"))};
|
package/dist/create/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const e=require("path"),{scanFileFindChart:t,scanDirHandle:a,prompt:i,log:s,oraHandle:n,spawnHandle:o,wait:r,welcomeCli:l,get_cli_config:c,getGitUser:
|
|
1
|
+
// yann-vis-cli v1.8.1 by Yann
|
|
2
|
+
"use strict";const e=require("path"),{scanFileFindChart:t,scanDirHandle:a,prompt:i,log:s,oraHandle:n,spawnHandle:o,wait:r,welcomeCli:l,get_cli_config:c,getGitUser:u,registerChartId:d,requestToken:p,exit:m}=require("../utils"),w=require("yann-fs").default;module.exports=async function(m=[]){const g="chart",[v]=await c();let f,y=!1;if(v.user&&v.password&&v.token&&(y=await p(v.user,v.password)),!y){const e=await u(),t=await i([{name:"isLogin",type:"toggle",message:"未登录,是否先登录:",initial:!1,active:"yes",inactive:"no"},{name:"user",type:(e,t)=>t.isLogin?null:"text",initial:e||"",message:"请填写泰合社区的用户名"}]);y=t.isLogin,f=t.isLogin?await require("../auth/index.js")():t.user}const h=await t(),{chartType:j,isTs:_}=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"}]},{name:"isTs",type:"toggle",message:"是否使用ts",initial:!1,active:"yes",inactive:"no"}]);s.info("推荐添加自定义前缀以防止和其他图表名重复并且便于后期统一管理");let k=Date.now();const{projectName:q}=await i([{name:"projectName",type:"text",message:"请输入图表名:",initial:m[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")),a(e.join(h.root,"packages","tailored"))]);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 d(t,j);if("ECONNABORTED"===e?.code)return console.log(),console.log("暂时无法连接到服务器!"),!0;if(e||!a||!a.data||!a.data.data)return e?.data?.msg||"请重新填写";k=a.data.data}return!0}}]),x=n("创建项目..."),T=process.cwd(),C=h?T.includes("tailored")?e.join(h.root,"packages","tailored",q):e.join(h.root,"packages","components",q):e.join(T,q);await w.ensureDir(C),await w.copy(e.resolve(__dirname,"../../template",g),C),_&&await w.copy(e.resolve(__dirname,"../../template","ts"),C),await require(e.resolve(__dirname,g,"index.js"))(q,C,h,f,j,k,_),x.succeed("项目创建完成."),await r(.1),x.start("安装依赖.."),await o(/^win/.test(process.platform)?"pnpm.cmd":"pnpm",["install"],{cwd:C}),x.succeed("依赖安装完成."),await r(.1),x.clear();require("clear")(),await l(),console.log("\n完成. 现在可以执行:\n"),s.success(` cd ${q}`),s.success(" pnpm dev"),console.log()};
|
package/dist/dev/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
1
|
+
// yann-vis-cli v1.8.1 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:o}=require("commander"),{version:s}=require("../package.json"),a=require("chalk"),i=require("path"),{log:c,get_cli_config:n,exit:t,command:m}=require("./utils"),d=(e,r=[])=>{try{require(i.resolve(__dirname,e,"index.js"))(r,{})}catch(e){t(e?.message)}};r.forEach(
|
|
1
|
+
// yann-vis-cli v1.8.1 by Yann
|
|
2
|
+
"use strict";const e=require("./renew"),r=require("./action"),{program:o}=require("commander"),{version:s}=require("../package.json"),a=require("chalk"),i=require("path"),{log:c,get_cli_config:n,exit:t,command:m}=require("./utils"),d=(e,r=[])=>{try{require(i.resolve(__dirname,e,"index.js"))(r,{})}catch(e){t(e?.message)}};r.forEach(r=>{(r.option?o.option(...r.option):o).command(r.command).alias(r.alias).description(r.desc).action(async()=>{m.shell=r.command;const o=process.argv.slice(3);if(m.argv=o,await e(),"*"===r.command)c.err(r.desc);else if(r.isAuth){const[e]=await n();if(e.user)d(r.command,o);else{await require("./auth/index.js")()&&d(r.command,o)}}else d(r.command,o)})}),"-v"===process.argv[2]&&(console.log(s),t()),o.version(s).parse(process.argv),process.on("uncaughtException",function(e){console.log(a.bold.red("err:"),a.bold.red(e?.message||"异常错误!")),process.exit(1)});
|
package/dist/pack/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const e=require("path"),
|
|
1
|
+
// yann-vis-cli v1.8.1 by Yann
|
|
2
|
+
"use strict";const e=require("path"),r=require("yann-fs").default,{to:t}=require("await-to-js"),{getPackageInfo:o,scanFileFindChart:s,getPackageName:i,buildPathHandler:n,exit:a,versionHandle:l,compareVersion:c}=require("../utils");require("lodash").orderBy;const u=require("p-limit"),d="core";module.exports=async function(){const p=await s();if(!p)return a("非图表库");const f=e.resolve(p.root,"dist"),v=e.resolve(p.root,"packages"),w=e.resolve(v,"components"),[$,m]=await t(r.readdir(w));if($)return a($?.message);const g=new Set,x=u(1);await Promise.allSettled(m.map(s=>x(()=>(async(s,u,p,f)=>{if(s.startsWith("."))return;const v=e.resolve(u,s),[w,$]=await r.readJson(e.resolve(v,"package.json"));if(w||!$)return;const[m,g]=await r.readJson(e.resolve(v,"public","base.json"));if(m||!g)return;const{isDev:x,isVip:h,label:F}=g;if(x)return;const b=await l(v);if("string"==typeof b)return;const{name:j,outDir:q}=o(b);console.log("🚀 ~ buildCurrentChart ~ name: ",j),console.log("🚀 ~ buildCurrentChart ~ outDir: ",q),await n(v),f.add(s);const y=e.resolve(p,d,s);await r.remove(e.resolve(y,b.version)),await r.copy(e.resolve(v,q),e.resolve(y,b.version));const C=e.resolve(y,"index.js");await r.ensureFile(C);const[k,P]=await t(r.readFile(C,"utf-8"));if(k)return;const D=i(s),H=`import { default as ${j} } from './${b.version}/es/index'\nexport { ${j} }\n`;if(P.includes("export")){const e=/\.\/([\d.]+)\/es\/index/g,t=[];let o;for(;null!==(o=e.exec(P));)t.push(o[1]);if(t.includes(b.version))return;const s=`${H}\n${P}`,i=t.sort((e,r)=>c(r,e))[0];if(c(i,b.version)>0)return void await r.writeFile(C,s);const n=new RegExp(`(export\\s*\\{)\\s*(\\w+)(\\s+)(as)(\\s+)(${D})(\\s*)(\\})`,"g"),a=s.replace(n,(e,r,t,o,s,i,n,a,l)=>`${r}${j}${o}${s}${i}${n}${a}${l}`);await r.writeFile(C,a)}else await r.appendFile(C,`${H}\nexport { ${j} as ${D} }`);await r.remove(e.resolve(v,q)),a("end")})(s,w,f,g))));const h=[];for(const e of g)h.push(`export * from './${e}'\n`);await r.writeFile(e.resolve(f,d,"index.js"),`${h.join("")}`)};
|
package/dist/pack/new.js
ADDED
package/dist/renew/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
2
|
-
"use strict";const{log:
|
|
1
|
+
// yann-vis-cli v1.8.1 by Yann
|
|
2
|
+
"use strict";const{log:t,prompt:e,exit:i,welcomeCli:n,get_update_log:s,set_update_log:a}=require("../utils"),c=/^win/.test(process.platform),r=()=>{const{execSync:t}=require("child_process");try{return t("npm config get registry",{encoding:"utf8"}).trim()}catch(t){return""}},o=async()=>{const s=await e([{name:"updateFlag",message:"是否更新Cli工具?",type:"toggle",initial:!0,active:"yes",inactive:"no"}]),{updateFlag:o}=s;o?(await(async()=>new Promise(e=>{const{exec:n}=require("child_process"),s=r(),a=[];s&&a.push(`--registry=${s}`),n(`${c?"npm":"sudo npm"} i -g yann-vis-cli${c?" --no-color":""}`,...a,(n,s,a)=>{n?i("异常错误,请手动执行命令更新Cli工具:npm i -g yann-vis-cli"):(console.log(),t.success("Cli工具更新成功!"),e())})}))(),await a(),await n(),i()):await a()};module.exports=async function(){if(1===await(async()=>await s()>Date.now()?0:1)())return;(()=>{const t=require("cross-spawn"),e=r(),i=[];return e&&i.push(`--registry=${e}`),!!t.sync("npm",["outdated","yann-vis-cli","-g",...i]).stdout.toString().replace(/[\n]/g,"")})()?await o():await a()};
|
package/dist/tar/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
1
|
+
// yann-vis-cli v1.8.1 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:s,log:i,getPath:r,get_cli_config:o,requestToken:n}=require("../utils"),{to:u}=require("await-to-js"),c=require("form-data"),l=require("p-limit")(1),d=async(e,r)=>{const o=r;console.log(`准备上传 ${o} ...`);const n=new c,u=t.createReadStream(e);n.append("file",u,{filename:o});const[l,d]=await a({url:"/chart/version/upload_pkg",method:"post",data:n,headers:{"Content-Type":"multipart/form-data"},timeout:3e4});l?s(l?.message||l?.data?.msg||"异常错误"):(console.log(),i.success(`${o} 组件上传成功!`),console.log())};module.exports=async function(a=[]){const[i]=await o();if(i.user){if(i.user&&i.password&&i.token){await n(i.user,i.password)||await require("../auth/index.js")()}}else await require("../auth/index.js")();let c=process.cwd();if(a[0]){const t=a[0].trim();if(t.includes(".tar.gz")){const a=r(t);return void await u(d(a,e.basename(a)))}c=r(t)}const[m,f]=await u(t.readdir(c));if(m)return void s(m?.message);const p=f.filter(
|
|
1
|
+
// yann-vis-cli v1.8.1 by Yann
|
|
2
|
+
"use strict";const e=require("path"),t=require("yann-fs").default,{axios:a,exit:s,log:i,getPath:r,get_cli_config:o,requestToken:n}=require("../utils"),{to:u}=require("await-to-js"),c=require("form-data"),l=require("p-limit")(1),d=async(e,r)=>{const o=r;console.log(`准备上传 ${o} ...`);const n=new c,u=t.createReadStream(e);n.append("file",u,{filename:o});const[l,d]=await a({url:"/chart/version/upload_pkg",method:"post",data:n,headers:{"Content-Type":"multipart/form-data"},timeout:3e4});l?s(l?.message||l?.data?.msg||"异常错误"):(console.log(),i.success(`${o} 组件上传成功!`),console.log())};module.exports=async function(a=[]){const[i]=await o();if(i.user){if(i.user&&i.password&&i.token){await n(i.user,i.password)||await require("../auth/index.js")()}}else await require("../auth/index.js")();let c=process.cwd();if(a[0]){const t=a[0].trim();if(t.includes(".tar.gz")){const a=r(t);return void await u(d(a,e.basename(a)))}c=r(t)}const[m,f]=await u(t.readdir(c));if(m)return void s(m?.message);const p=f.filter(e=>e.includes(".tar.gz"));await Promise.all(p.map(t=>l(()=>u(d(e.resolve(c,"./",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.8.1 by Yann
|
|
2
|
+
"use strict";const e=require("yann-fs").default,t=require("path"),s=require("chalk"),r=require("axios").default,{to:n}=require("await-to-js"),{camelCase:a,upperFirst:o,mergeWith:i,isArray:c}=require("lodash"),u=require("os").homedir(),l={success(e){console.log(s.green(e))},err(e){console.log(s.bold.red(e))},info(e){console.log(s.blue(e))}},p=e=>{e&&(console.log(),l.err(e)),process.exit(1)},d=t.resolve(u,".yann-vis-store");let m={};const w=async t=>{const[s,r]=await g();m={...s,...t},await e.outputJson(r,m)},g=async()=>{const s=t.resolve(d,".cli_store");if(Object.keys(m).length>0)return[m,s];const[r,n]=await e.readJson(s);return r?[{user:"",password:"",token:"",autoUpload:!1,autoRemove:!1,autoRemoveEs:!0},s]:(m=n,[n,s])};const f="http://10.11.11.100",h=`${f}/thpower/api`,v=r.create({baseURL:h,headers:{"Content-Type":"application/json;charset=UTF-8"},timeout:1e4});async function y(e){return n(v(e))}v.interceptors.request.use(async e=>{const[t]=await g();return t.token&&(e.headers.Authorization=`${t.token}`),e},e=>Promise.reject(e)),v.interceptors.response.use(async e=>e.data?.code&&200!==e.data?.code?Promise.reject(e):e,e=>(function(e){r.isCancel(e)||(e&&e.response,e?.message?.includes("timeout"))}(e),Promise.reject(e)));const _=e=>{const s=process.cwd();return e.includes(s)?e:t.resolve(s,e)};function k(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 s=Math.max(e.length,t.length);for(;e.length<s;)e.push("0");for(;t.length<s;)t.push("0");for(let r=0;r<s;r++){const s=parseInt(e[r]),n=parseInt(t[r]);if(s>n)return 1;if(s<n)return-1}return 0}const P=async(s,r=[".git",".vscode",".DS_Store",".idea"])=>{const a=s||process.cwd();if(await e.isDir(a)){const[s,r]=await n(e.readdir(a));if(s)return p(s?.message);await Promise.all(r.map(e=>P(t.resolve(a,e))))}else for(let t=0;t<r.length;t++)if(a.includes(r[t]))return void e.remove(a)},q=async(...e)=>{await n((async(...e)=>{const{spawn:t}=require("child_process");return new Promise(s=>{const r=t(...e);r.stdout.pipe(process.stdout),r.stderr.pipe(process.stderr),r.on("close",()=>{s()})})})(...e))},j=async s=>{const r=process.cwd(),n=t.resolve(r,s),a=t.resolve(s,"package.json"),[o,i]=await e.readJson(a);if(i){const{name:s}=i;if("chart"===s){const[s,a]=await e.readJson(t.resolve(n,".pv_store"));if(a&&"chart"===a.name)return{type:"chart",root:n,cwd:r}}}return!1},b={user:""};module.exports={versionHandle:async s=>{const r=t.resolve(s,"public","base.json"),[n,a]=await e.readJson(r);if(n)return"找不到 base.json 文件";const o=a.version,i=t.resolve(s,"package.json"),[c,u]=await e.readJson(i);if(c)return"找不到 package.json 文件";const l=u.version,p=k(o,l);let d=o;return 1===p?(d=o,u.version=d,await e.outputJson(i,u,{spaces:2,EOL:"\n"})):-1===p&&(d=l,a.version=d,await e.outputJson(r,a,{spaces:2,EOL:"\n"})),{name:a.name,version:d}},getPackageInfo:e=>{const t=e.name.split("/").at(-1);return{name:t.replace(/^\S/,e=>e.toUpperCase())+"_v"+e.version.replaceAll(".","_"),outDir:`${t}_v${e.version}`}},buildPathHandler:async e=>{await q(/^win/.test(process.platform)?"pnpm.cmd":"pnpm",["build"],{cwd:e})},get_delete_es:async()=>{const[e]=await g();return!("autoRemoveEs"in e)||e.autoRemoveEs},userInfo:b,getGitUser:async()=>{const e=require("cross-spawn").sync("git",["config","user.name"]);return b.user=e.stdout.toString().replace(/[\n]/g,""),b.user},scanFileFindChart:async()=>{const e=await j("./");if(e)return e;const t=await j("../");if(t)return t;const s=await j("../../");if(s)return s;return await j("../../../")},outputVueName:async(t,s)=>{const r=`\n<script setup>\n import { defineProps, defineEmits, defineOptions } from 'vue';\n defineProps({\n styled: Object,\n data: Object,\n width: Number,\n height: Number,\n events: Array,\n option: Object\n });\n defineEmits(['message']);\n defineOptions({\n name: '${s}'\n })\n<\/script>`;await e.appendFile(t,r)},updatePackageJson:async(s,r)=>{const n=t.join(s,"package.json"),[a,o]=await e.readJson(n);a?p():o&&(i(o,r,(e,t)=>{if(c(e))return e.concat(t)}),await e.outputJson(n,o,{spaces:2,EOL:"\n"}))},registerChartId:async(e,t)=>y({url:"/chart/register",method:"post",data:{enName:e,typeId:t}}),prompt:async e=>{const t=require("prompts");return await t(e,{onCancel:()=>{p("✖ 操作已取消")}})},requestToken:async(e,t)=>{const[s,r]=await y({url:"/auth/login",method:"post",data:{account:e,password:t}});return r&&r.data&&r.data.data.token?(await w({user:e,password:t,token:r.data.data.token}),!0):(await w({user:e,password:t,token:""}),!1)},axios:y,get_cli_config:g,set_cli_config:w,packagePath:d,exit:p,log:l,welcomeCli:async()=>{const{promisify:e}=require("util"),t=e(require("figlet")),s=await t("Welcome to VisCli");console.log(),l.success(s)},wait:e=>new Promise(t=>{setTimeout(()=>{t()},1e3*e)}),buildTarHandler:async(t,s,r=null,n=null)=>(t=_(t),r&&(r=_(r),await e.ensureDir(r)),new Promise(a=>{const o={gzip:!0,cwd:t,sync:!0},i="string"==typeof s?[s]:s,c=n||"string"==typeof s?s:"tar_"+Date.now();require("tar").c(o,i).pipe(e.createWriteStream(`${r||t}/${c}.tar.gz`)).on("finish",a)})),getPath:_,compareVersion:k,filterFile:P,spawnHandle:q,oraHandle:e=>{const t=require("ora")(e);return t.start(),t},getPackageName:e=>{const t=a(e);return o(t)},command:{shell:"",argv:""},scanDirHandle:async s=>{const r=[];if(await e.isDir(s)){const[a,o]=await n(e.readdir(s));if(a)return p(a?.message);(await Promise.all(o.map(r=>n(e.isDir(t.resolve(s,r)))))).forEach((e,t)=>{e[1]&&r.push(o[t])})}return r},get_update_log:async()=>{const[s,r]=await e.readJson(t.resolve(d,".update_log"));return s?0:r.time},set_update_log:async()=>{const s=Date.now()+6048e5;await e.outputJson(t.resolve(d,".update_log"),{time:s})},API_IP:f,get_plugin_version:e=>{if(!e)return;return require("cross-spawn").sync("npm",["view",e,"version"]).stdout.toString().replace(/[\n]/g,"")}};
|
package/dist/vpack/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// yann-vis-cli v1.
|
|
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")(
|
|
1
|
+
// yann-vis-cli v1.8.1 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")(2),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 l=[],m=e.resolve(i,"charts");if(await a.emptyDir(m),await Promise.all(u.map(t=>(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])}}}}})(t,p,l))),await a.outputJson(e.resolve(m,"menu.json"),c,{spaces:2,EOL:"\n"}),"false"===o[0])return;await Promise.all([l.map(a=>n(()=>(async({v:a,chartsPath:i,comPath:o})=>{await t(s(/^win/.test(process.platform)?"pnpm.cmd":"pnpm",["build"],{cwd:e.resolve(o,a[0])})),await r(.005),await h({v:a,chartsPath:i,comPath:o})})({v:a,chartsPath:m,comPath:p})))])}}};const h=async({v:t,chartsPath:s,comPath:i})=>{const r=`${t[0]}_v${t[1]}`,o=e.resolve(s,t[0]),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.
|
|
1
|
+
// yann-vis-cli v1.8.1 by Yann
|
|
2
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.8.1",
|
|
4
4
|
"description": "vis-cli",
|
|
5
5
|
"bin": {
|
|
6
6
|
"pvis": "./bin/index.js",
|
|
@@ -15,21 +15,21 @@
|
|
|
15
15
|
"main": "./dist/index.js",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"await-to-js": "^3.0.0",
|
|
18
|
-
"axios": "^1.
|
|
18
|
+
"axios": "^1.13.2",
|
|
19
19
|
"chalk": "^4.1.2",
|
|
20
20
|
"clear": "^0.1.0",
|
|
21
21
|
"commander": "^10.0.1",
|
|
22
|
-
"cross-spawn": "^7.0.
|
|
23
|
-
"figlet": "^1.
|
|
24
|
-
"form-data": "^4.0.
|
|
25
|
-
"fs-extra": "^11.3.
|
|
22
|
+
"cross-spawn": "^7.0.6",
|
|
23
|
+
"figlet": "^1.9.3",
|
|
24
|
+
"form-data": "^4.0.4",
|
|
25
|
+
"fs-extra": "^11.3.2",
|
|
26
26
|
"js-md5": "^0.8.3",
|
|
27
27
|
"lodash": "^4.17.21",
|
|
28
28
|
"opn": "^6.0.0",
|
|
29
29
|
"ora": "^5.4.1",
|
|
30
30
|
"p-limit": "^3.1.0",
|
|
31
31
|
"prompts": "^2.4.2",
|
|
32
|
-
"semver": "^7.
|
|
32
|
+
"semver": "^7.7.3",
|
|
33
33
|
"tar": "^6.2.1",
|
|
34
34
|
"yann-fs": "^1.6.0"
|
|
35
35
|
},
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@rollup/plugin-commonjs": "^18.1.0",
|
|
38
38
|
"@rollup/plugin-json": "^6.1.0",
|
|
39
39
|
"@types/fs-extra": "^11.0.4",
|
|
40
|
-
"prettier": "^3.
|
|
41
|
-
"rollup": "^2.79.
|
|
40
|
+
"prettier": "^3.6.2",
|
|
41
|
+
"rollup": "^2.79.2",
|
|
42
42
|
"rollup-plugin-babel": "^4.4.0",
|
|
43
43
|
"rollup-plugin-banner": "^0.2.1",
|
|
44
44
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, ref } from 'vue';
|
|
3
|
-
import ChartInfo from '
|
|
4
|
-
import base from '
|
|
3
|
+
import ChartInfo from '../index';
|
|
4
|
+
import base from '../public/base.json';
|
|
5
5
|
import { takeSnapshot, downSnapshot } from 'yann-snapshot';
|
|
6
6
|
|
|
7
7
|
const { component: Chart, data, style } = ChartInfo;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!doctype html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
9
|
<div id="app"></div>
|
|
10
|
-
<script type="module" src="/
|
|
10
|
+
<script type="module" src="./example/main.js"></script>
|
|
11
11
|
</body>
|
|
12
12
|
</html>
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"include": [
|
|
3
|
-
|
|
4
|
-
"src/**/*",
|
|
5
|
-
"src/**/*.vue"
|
|
6
|
-
],
|
|
7
|
-
"exclude": [
|
|
8
|
-
"src/**/__tests__/*"
|
|
9
|
-
],
|
|
2
|
+
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
|
|
3
|
+
"exclude": ["src/**/__tests__/*"],
|
|
10
4
|
"compilerOptions": {
|
|
11
5
|
"composite": true,
|
|
12
6
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
13
7
|
"baseUrl": ".",
|
|
8
|
+
"strict": true,
|
|
14
9
|
"paths": {
|
|
15
|
-
"@/*": [
|
|
16
|
-
"./src/*"
|
|
17
|
-
]
|
|
10
|
+
"@/*": ["./src/*"]
|
|
18
11
|
}
|
|
19
12
|
}
|
|
20
|
-
}
|
|
13
|
+
}
|
|
@@ -1,7 +0,0 @@
|
|
|
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)
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import compression from 'vite-plugin-compression';
|
|
2
|
-
import { getPackageInfo } from "yann-chart-cli";
|
|
3
|
-
import { fileURLToPath, URL } from 'node:url';
|
|
4
|
-
import banner from 'vite-plugin-banner';
|
|
5
|
-
import vue from '@vitejs/plugin-vue';
|
|
6
|
-
import config from "./package.json";
|
|
7
|
-
import { defineConfig } from 'vite';
|
|
8
|
-
|
|
9
|
-
const { outDir,name} = getPackageInfo(config)
|
|
10
|
-
// https://vite.dev/config/
|
|
11
|
-
export default defineConfig({
|
|
12
|
-
plugins: [
|
|
13
|
-
vue(),
|
|
14
|
-
compression({
|
|
15
|
-
ext: '.gz', deleteOriginFile: false
|
|
16
|
-
}),
|
|
17
|
-
banner({
|
|
18
|
-
outDir,
|
|
19
|
-
content: `${config.name} v${config.version} ${config.author ? 'Author: ' + config.author : ''} Date: ${Date.now()}`
|
|
20
|
-
})
|
|
21
|
-
],
|
|
22
|
-
resolve: {
|
|
23
|
-
alias: {
|
|
24
|
-
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
build: {
|
|
28
|
-
reportCompressedSize: false,
|
|
29
|
-
emptyOutDir: true,
|
|
30
|
-
outDir,
|
|
31
|
-
cssCodeSplit: true,
|
|
32
|
-
lib: {
|
|
33
|
-
entry: './index.ts', // 设置入口文件
|
|
34
|
-
formats: ['umd'],
|
|
35
|
-
name, // 起个名字,安装、引入用
|
|
36
|
-
fileName: ()=> "index.js"
|
|
37
|
-
},
|
|
38
|
-
rollupOptions: {
|
|
39
|
-
// 确保外部化处理那些你不想打包进库的依赖
|
|
40
|
-
external: ['vue'],
|
|
41
|
-
output: {
|
|
42
|
-
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
|
|
43
|
-
globals: {
|
|
44
|
-
vue: 'Vue'
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
})
|
|
File without changes
|
|
File without changes
|