yann-vis-cli 1.9.2 → 1.10.0
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/pack/index.js +1 -1
- package/dist/tidier/index.js +1 -1
- package/package.json +1 -1
package/dist/pack/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("path"),t=require("yann-fs").default,{to:s}=require("await-to-js"),{getPackageInfo:r,scanFileFindChart:i,getPackageName:a,buildPathHandler:n,exit:o,versionHandle:c,compareVersion:l,runAsyncCmd:d,log:p}=require("../utils"),u=require("p-limit"),w=require("dayjs"),f="src/components",m="src/charts",v=async s=>{try{const r=await t.readdir(s,{withFileTypes:!0});for(const i of r){const r=e.join(s,i.name);i.isDirectory()?await v(r):i.isFile()&&i.name.endsWith(".gz")&&await t.unlink(r)}}catch(e){throw console.error(`处理目录 ${s} 时出错:`,e.message),e}},h=async(i,o,d,u,w)=>{if(i.startsWith("."))return;const h=e.resolve(o,i),[$,g]=await t.readJson(e.resolve(h,"package.json"));if($||!g)return;const[x,y]=await t.readJson(e.resolve(h,"public","base.json"));if(x||!y)return;const{isDev:F}=y;if(F)return;if(!w.includes(i)){if(!await t.exists(e.resolve(d,m,i,"index.ts")))return;return void u.add(i)}const P=await c(h);if("string"==typeof P)return;const{name:C,outDir:E}=r(P),j=`V${C}`;p.info(`开始打图表包,图表名:“${i}”,版本号:“v${P.version}”.`),await n(h);const D=e.resolve(d,m,i),L=e.resolve(D,P.version);await t.remove(L);const O=e.resolve(L,"es");await t.copy(e.resolve(h,E,"es"),O),await v(L),await t.writeFile(e.resolve(L,"index.ts"),`export { default as ${j} } from './es/index'`),await(async(r,i)=>{try{const a=await t.readdir(i,{withFileTypes:!0}),n=[];for(const e of a)e.isFile()&&e.name.endsWith(".css")&&n.push(e.name);if(n.length>0){const i=e.resolve(r,"index.ts"),[a,o]=await s(t.readFile(i,"utf-8"));if(a||!o)return;let c="";for(const e of n)c+=`import './es/${e}'\n`;c+=o,await t.writeFile(i,c)}}catch(e){throw console.error(`处理目录 ${dir} 时出错:`,e.message),e}})(L,O);const k=e.resolve(D,"index.ts");await t.ensureFile(k),u.add(i);const[q,J]=await s(t.readFile(k,"utf-8"));if(q)return;const T=`V${a(i)}`,b=`import { ${j} } from './${P.version}/index'\nexport { ${j} }\n`;if(J.includes("export")){const e=/\.\/([\d.]+)\/index/g,s=[];let r;for(;null!==(r=e.exec(J));)s.push(r[1]);if(s.includes(P.version))return;const i=`${b}\n${J}`,a=s.sort((e,t)=>l(t,e))[0];if(l(a,P.version)>0)return void await t.writeFile(k,i);const n=new RegExp(`(export\\s*\\{)\\s*(\\w+)(\\s+)(as)(\\s+)(${T})(\\s*)(\\})`,"g"),o=i.replace(n,(e,t,s,r,i,a,n,o,c)=>`${t}${j}${r}${i}${a}${n}${o}${c}`);await t.writeFile(k,o)}else await t.appendFile(k,`${b}\nexport { ${j} as ${T} }`);await t.remove(e.resolve(h,E));const A=e.resolve(d,f,i);if(await t.exists(e.resolve(A,"index.ts")))return;await Promise.all([t.ensureFile(e.resolve(A,"index.ts")),t.ensureFile(e.resolve(A,"index.vue"))]);const H=[];H.push(t.writeFile(e.resolve(A,"index.ts"),`export { default as PgChart${T} } from './index.vue'`)),H.push(t.writeFile(e.resolve(A,"index.vue"),`<template>\n <v-chart :chart="${T}" v-bind="$attrs" :data="data" :styled="styled" :option="option" :events="events" @message="emit('message', $event)"></v-chart>\n</template>\n<script setup lang="ts">\nimport { VChart } from '@/core'\nimport { ${T} } from "@/charts/${i}";\nimport { useAttrs, defineEmits, defineProps, defineOptions } from "vue";\nimport type { ChartPropsType, ChartEvents, EmitMessage, ScreenLayerOption } from "@/types";\n\nconst $attrs = useAttrs();\nconst props = defineProps<{\n styled?: ChartPropsType<typeof ${T},'style'>\n option?: Partial<ScreenLayerOption>\n data?: ChartPropsType<typeof ${T},'data'>\n events?: ChartEvents[]\n}>();\nconst emit = defineEmits<{\n (e: "message", option: EmitMessage): void;\n}>();\n \ndefineOptions({\n name: 'pg-chart-v-${i}',\n inheritAttrs: false\n})\n<\/script>`)),await Promise.all(H)};async function $(e){const[s,r]=await t.readJson(e);return s?(p.err(s?.message),!1):("sideEffects"in r&&(delete r.sideEffects,await t.outputJson(e,r,{spaces:2,EOL:"\n"})),!0)}module.exports=async function(){const r=Date.now(),a=await i();if(!a)return o("非图表库");const c=e.resolve(a.root,"../pangu-chart"),l=e.resolve(a.root,"packages"),v=e.resolve(l,"components"),[g,x]=await s(t.readdir(v));if(g)return o(g?.message);const y=new Set,F=u(3);let P=x||[];if(await t.exists(e.resolve(c,m,"index.ts")))
|
|
1
|
+
"use strict";const e=require("path"),t=require("yann-fs").default,{to:s}=require("await-to-js"),{getPackageInfo:r,scanFileFindChart:i,getPackageName:a,buildPathHandler:n,exit:o,versionHandle:c,compareVersion:l,runAsyncCmd:d,log:p}=require("../utils"),u=require("p-limit"),w=require("dayjs"),f="src/components",m="src/charts",v=async s=>{try{const r=await t.readdir(s,{withFileTypes:!0});for(const i of r){const r=e.join(s,i.name);i.isDirectory()?await v(r):i.isFile()&&i.name.endsWith(".gz")&&await t.unlink(r)}}catch(e){throw console.error(`处理目录 ${s} 时出错:`,e.message),e}},h=async(i,o,d,u,w)=>{if(i.startsWith("."))return;const h=e.resolve(o,i),[$,g]=await t.readJson(e.resolve(h,"package.json"));if($||!g)return;const[x,y]=await t.readJson(e.resolve(h,"public","base.json"));if(x||!y)return;const{isDev:F}=y;if(F)return;if(!w.includes(i)){if(!await t.exists(e.resolve(d,m,i,"index.ts")))return;return void u.add(i)}const P=await c(h);if("string"==typeof P)return;const{name:C,outDir:E}=r(P),j=`V${C}`;p.info(`开始打图表包,图表名:“${i}”,版本号:“v${P.version}”.`),await n(h);const D=e.resolve(d,m,i),L=e.resolve(D,P.version);await t.remove(L);const O=e.resolve(L,"es");await t.copy(e.resolve(h,E,"es"),O),await v(L),await t.writeFile(e.resolve(L,"index.ts"),`export { default as ${j} } from './es/index'`),await(async(r,i)=>{try{const a=await t.readdir(i,{withFileTypes:!0}),n=[];for(const e of a)e.isFile()&&e.name.endsWith(".css")&&n.push(e.name);if(n.length>0){const i=e.resolve(r,"index.ts"),[a,o]=await s(t.readFile(i,"utf-8"));if(a||!o)return;let c="";for(const e of n)c+=`import './es/${e}'\n`;c+=o,await t.writeFile(i,c)}}catch(e){throw console.error(`处理目录 ${dir} 时出错:`,e.message),e}})(L,O);const k=e.resolve(D,"index.ts");await t.ensureFile(k),u.add(i);const[q,J]=await s(t.readFile(k,"utf-8"));if(q)return;const T=`V${a(i)}`,b=`import { ${j} } from './${P.version}/index'\nexport { ${j} }\n`;if(J.includes("export")){const e=/\.\/([\d.]+)\/index/g,s=[];let r;for(;null!==(r=e.exec(J));)s.push(r[1]);if(s.includes(P.version))return;const i=`${b}\n${J}`,a=s.sort((e,t)=>l(t,e))[0];if(l(a,P.version)>0)return void await t.writeFile(k,i);const n=new RegExp(`(export\\s*\\{)\\s*(\\w+)(\\s+)(as)(\\s+)(${T})(\\s*)(\\})`,"g"),o=i.replace(n,(e,t,s,r,i,a,n,o,c)=>`${t}${j}${r}${i}${a}${n}${o}${c}`);await t.writeFile(k,o)}else await t.appendFile(k,`${b}\nexport { ${j} as ${T} }`);await t.remove(e.resolve(h,E));const A=e.resolve(d,f,i);if(await t.exists(e.resolve(A,"index.ts")))return;await Promise.all([t.ensureFile(e.resolve(A,"index.ts")),t.ensureFile(e.resolve(A,"index.vue"))]);const H=[];H.push(t.writeFile(e.resolve(A,"index.ts"),`export { default as PgChart${T} } from './index.vue'`)),H.push(t.writeFile(e.resolve(A,"index.vue"),`<template>\n <v-chart :chart="${T}" v-bind="$attrs" :data="data" :styled="styled" :option="option" :events="events" @message="emit('message', $event)"></v-chart>\n</template>\n<script setup lang="ts">\nimport { VChart } from '@/core'\nimport { ${T} } from "@/charts/${i}";\nimport { useAttrs, defineEmits, defineProps, defineOptions } from "vue";\nimport type { ChartPropsType, ChartEvents, EmitMessage, ScreenLayerOption } from "@/types";\n\nconst $attrs = useAttrs();\nconst props = defineProps<{\n styled?: ChartPropsType<typeof ${T},'style'>\n option?: Partial<ScreenLayerOption>\n data?: ChartPropsType<typeof ${T},'data'>\n events?: ChartEvents[]\n}>();\nconst emit = defineEmits<{\n (e: "message", option: EmitMessage): void;\n}>();\n \ndefineOptions({\n name: 'pg-chart-v-${i}',\n inheritAttrs: false\n})\n<\/script>`)),await Promise.all(H)};async function $(e){const[s,r]=await t.readJson(e);return s?(p.err(s?.message),!1):("sideEffects"in r&&(delete r.sideEffects,await t.outputJson(e,r,{spaces:2,EOL:"\n"})),!0)}module.exports=async function(){const r=Date.now(),a=await i();if(!a)return o("非图表库");const c=e.resolve(a.root,"../pangu-chart"),l=e.resolve(a.root,"packages"),v=e.resolve(l,"components"),[g,x]=await s(t.readdir(v));if(g)return o(g?.message);const y=new Set,F=u(3);let P=x||[];const C=new Set(process.argv.slice(3));if(await t.exists(e.resolve(c,m,"index.ts")))if(C.has("-c"))await Promise.all([t.remove(e.resolve(c,m)),t.remove(e.resolve(c,f))]);else{const e=C.has("-e");if(C.delete("-e"),C.size){const t=[...C];P=e?x.filter(e=>!t.includes(e)):t}}await Promise.allSettled(x.map(e=>F(()=>h(e,v,c,y,P))));const E=[],j=[...y].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()));for(const e of j)E.push(`export * from './${e}'\n`);const D=E.join("");await Promise.all([t.writeFile(e.resolve(c,m,"index.ts"),D),t.writeFile(e.resolve(c,f,"index.ts"),D)]),await async function(s,r){p.info("开始打图表主题包.");const i=e.resolve(s,"utils","theme");await n(i);const a=e.resolve(r,"src/theme");await t.remove(a),await t.copy(e.resolve(i,"dist"),a),await t.remove(e.resolve(i,"dist"))}(l,c);const L=`图表库打包完成:${w().format("YYYY-MM-DD HH:mm")},总耗时: ${(Date.now()-r)/1e3}s.`;p.success(L),console.log(),p.info("开始打pangu-v-chart.");const O=e.resolve(c,"package.json");await $(O),await n(c),p.success("pangu-v-chart打包完成,正在准备执行CHANGELOG和发布"),await d("npm",["run","release"],{cwd:c,stdio:"inherit"});const[k,q]=await t.readJson(O);if(k)return void p.err(k?.message);q.sideEffects=!1,await t.outputJson(O,q,{spaces:2,EOL:"\n"});const J=await Promise.race([d("npm",["publish"],{cwd:c,stdio:"inherit"}),new Promise(e=>setTimeout(()=>e({success:!1,message:"执行超时"}),6e4))]);J.success?p.success("发布成功"):p.err(J.message),await $(O),p.success("pangu-v-chart 全部执行完成.")};
|
package/dist/tidier/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("path"),
|
|
1
|
+
"use strict";const e=require("path"),t=require("yann-fs").default,{scanFileFindChart:a,exit:n,runAsyncCmd:i}=require("../utils"),s=require("p-limit");module.exports=async function(){const l=await a();if(!l)return n("非图表库");const c=l.root,d=e.resolve(c,"packages"),r=e.resolve(d,"components"),o=e.resolve(d,"tailored"),p=s(3);async function v(a){const n=await t.readdir(a);await Promise.all(n.map(n=>p(()=>(async(a,n)=>{if(a.startsWith("."))return;const[i,s]=await t.readJson(e.resolve(n,"package.json"));if(!i&&s){if(delete s.scripts["dev:example"],delete s.devDependencies["yann-chart-cli"],delete s.devDependencies["vite-plugin-compression"],delete s.devDependencies["vite-plugin-banner"],delete s.devDependencies.vite,delete s.devDependencies.vite,delete s.devDependencies.sass,delete s.devDependencies["@vitejs/plugin-vue"],delete s.devDependencies["yann-snapshot"],delete s.dependencies.vue,delete s.dependencies["yann-i18n"],s.scripts.dev="vcc dev","elementNamespace"in s){const e=s.elementNamespace;delete s.elementNamespace,s.elementConfig=e}if(await t.outputJson(e.resolve(n,"package.json"),s,{spaces:2,EOL:"\n"}),await t.remove(e.resolve(n,"example/package.json")),await t.exists(e.resolve(n,"example/index.html"))){await t.copy(e.resolve(n,"example/index.html"),e.resolve(n,"index.html"));const[a,i]=await t.readFile(e.resolve(n,"index.html"),"utf-8"),s=async()=>{await t.writeFile(e.resolve(n,"index.html"),'<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="UTF-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1.0" />\n <title>fea-chart</title>\n </head>\n <body>\n <div id="app"></div>\n <script type="module" src="./example/src/main.js"><\/script>\n </body>\n</html>\n',"utf8"),await t.remove(e.resolve(n,"example/index.html"));const[a,i]=await t.readJson(e.resolve(n,"example/package.json"));!a&&i&&(i.scripts.dev="vcc dev",i.scripts.build="vcc build",await t.outputJson(e.resolve(n,"example/package.json"),i,{spaces:2,EOL:"\n"}))},l=async()=>{await t.remove(e.resolve(n,"example/index.html"));const a=i.replace(/src="\/src\/main\.js"/g,'src="./example/src/main.js"');await t.writeFile(e.resolve(n,"index.html"),a,"utf8")};a||!i?await s():await l(),await t.remove(e.resolve(n,"example/vite.config.js"))}}})(n,e.resolve(a,n)))))}await v(r),await v(o),await i("pnpm",["i"],{cwd:c,stdio:"inherit"})};
|