mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 01:19:45 +08:00
8e27cf986f
* chore: rm component less file * refactor: less file * refactor: rm less * refactor: rm page-header and comment * chore: rm less in components * chore: update dist config * chore: update image test * chore: update dekko * chore: rm lib dekko * chore: update dist dekko * chore: udpate bundle size * test: update snapshot * test: rm theme test * test: update snapshot * test: update snapshot * chore: copy reset.css * test: update image test * chore: copy reset.css to es * chore: update site script
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
/* eslint-disable import/no-unresolved,no-console,global-require,import/no-dynamic-require */
|
|
|
|
const chalk = require('chalk');
|
|
const React = require('react');
|
|
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...`));
|
|
|
|
const EmptyElement = React.createElement('div');
|
|
|
|
const styleFiles = glob.sync(
|
|
path.join(
|
|
process.cwd(),
|
|
'components/!(version|config-provider|icon|locale-provider|auto-complete|col|row|time-picker|)/style/index.tsx',
|
|
),
|
|
);
|
|
|
|
const bar = new ProgressBar('🚀 Collecting by component: [:bar] :component (:current/:total)', {
|
|
complete: '=',
|
|
incomplete: ' ',
|
|
total: styleFiles.length,
|
|
});
|
|
|
|
styleFiles.forEach(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);
|
|
useStyle = () => {
|
|
useRowStyle();
|
|
useColStyle();
|
|
};
|
|
} else {
|
|
useStyle = require(file).default;
|
|
}
|
|
const Component = () => {
|
|
useStyle('file');
|
|
return EmptyElement;
|
|
};
|
|
ReactDOMServer.renderToString(React.createElement(Component));
|
|
});
|
|
|
|
(async () => {
|
|
const tokenPath = `${process.cwd()}/components/version/token.tsx`;
|
|
const content = `export default ${JSON.stringify(statistic, null, 2)}`;
|
|
await fs.writeFile(tokenPath, content, 'utf8');
|
|
|
|
console.log(chalk.green(`✅ Collected token statistics successfully, check it in`), tokenPath);
|
|
})();
|