From 23e479151d46707893813e307659b30c5c421c64 Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Tue, 5 Jul 2022 14:23:43 +0800 Subject: [PATCH] chore: token statistic progress (#36381) --- package.json | 1 + scripts/collect-token-statistic.js | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8f8ed95596..b7582b7d68 100644 --- a/package.json +++ b/package.json @@ -255,6 +255,7 @@ "prettier": "^2.3.2", "prettier-plugin-jsdoc": "^0.3.0", "pretty-quick": "^3.0.0", + "progress": "^2.0.3", "qs": "^6.10.1", "rc-footer": "^0.6.6", "rc-tween-one": "^3.0.3", diff --git a/scripts/collect-token-statistic.js b/scripts/collect-token-statistic.js index 2015c4d987..06a13143b0 100644 --- a/scripts/collect-token-statistic.js +++ b/scripts/collect-token-statistic.js @@ -6,6 +6,7 @@ const ReactDOMServer = require('react-dom/server'); const fs = require('fs-extra'); const glob = require('glob'); const path = require('path'); +const ProgressBar = require('progress'); const { statistic } = require('../components/theme/util/statistic'); console.log(chalk.green(`🔥 Collecting token statistics...`)); @@ -18,8 +19,18 @@ const styleFiles = glob.sync( 'components/!(version|config-provider|icon|locale-provider|auto-complete|col|row|page-header|comment|time-picker|)/style/index.tsx', ), ); + +const bar = new ProgressBar('🚀 Collecting by component: [:bar] :component (:current/:total)', { + complete: '=', + incomplete: ' ', + total: styleFiles.length, +}); + styleFiles.forEach(file => { - console.log(file); + const pathArr = file.split('/'); + const styleIndex = pathArr.lastIndexOf('style'); + const componentName = pathArr[styleIndex - 1]; + bar.tick(1, { component: componentName }); let useStyle = () => {}; if (file.includes('grid')) { const { useColStyle, useRowStyle } = require(file); @@ -42,5 +53,5 @@ styleFiles.forEach(file => { const content = `export default ${JSON.stringify(statistic, null, 2)}`; await fs.writeFile(tokenPath, content, 'utf8'); - console.log(chalk.green(`✅ Collecting token statistics done.`)); + console.log(chalk.green(`✅ Collected token statistics successfully, check it in`), tokenPath); })();