chore: add notice before publish to npm / remove progress (#48323)

* chore: add notice before publish to npm

* chore: remove progress
This commit is contained in:
afc163 2024-04-07 22:45:53 +08:00 committed by GitHub
parent b63a94108f
commit a125dfee8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 14 deletions

View File

@ -286,6 +286,7 @@
"minimist": "^1.2.8",
"mockdate": "^3.0.5",
"node-fetch": "^3.3.2",
"node-notifier": "^10.0.1",
"nprogress": "^0.2.0",
"open": "^10.1.0",
"ora": "^8.0.1",
@ -295,7 +296,6 @@
"prettier-plugin-jsdoc": "^1.3.0",
"pretty-format": "^29.7.0",
"prismjs": "^1.29.0",
"progress": "^2.0.3",
"puppeteer": "^22.6.2",
"qs": "^6.12.0",
"rc-footer": "^0.6.8",

View File

@ -2,7 +2,7 @@
import React from 'react';
import chalk from 'chalk';
import fs from 'fs-extra';
import ProgressBar from 'progress';
import cliProgress from 'cli-progress';
import ReactDOMServer from 'react-dom/server';
import { DesignTokenContext } from '../components/theme/internal';
@ -10,19 +10,22 @@ import seedToken from '../components/theme/themes/seed';
import { statistic } from '../components/theme/util/statistic';
import { generateCssinjs, styleFiles } from './generate-cssinjs';
console.log(chalk.green(`🔥 Collecting token statistics...`));
console.log(`🪄 Collecting token statistics...`);
const bar = new ProgressBar('🚀 Collecting by component: [:bar] :component (:current/:total)', {
complete: '=',
incomplete: ' ',
total: styleFiles.length,
});
const bar = new cliProgress.SingleBar(
{
format: `🪄 Collecting by component: [${chalk.cyan('{bar}')}] {component} | {value}/{total}`,
},
cliProgress.Presets.rect,
);
bar.start(styleFiles.length, 0);
(async () => {
await generateCssinjs({
key: 'file',
beforeRender(componentName: string) {
bar.tick(1, { component: componentName });
bar.increment({ component: componentName });
},
render(Component: any) {
ReactDOMServer.renderToString(React.createElement(Component));
@ -44,8 +47,8 @@ const bar = new ProgressBar('🚀 Collecting by component: [:bar] :component (:c
);
},
});
bar.stop();
const tokenPath = `${process.cwd()}/components/version/token.json`;
fs.writeJsonSync(tokenPath, statistic, 'utf8');
console.log(chalk.green(` Collected token statistics successfully, check it in`), tokenPath);
console.log(chalk.green(`Collected token statistics successfully, check it in`), tokenPath);
})();

View File

@ -9,6 +9,7 @@ import axios from 'axios';
import cliProgress from 'cli-progress';
import checkRepo from './check-repo';
const { Notification: Notifier } = require('node-notifier');
const simpleGit = require('simple-git');
process.on('SIGINT', () => {
@ -37,9 +38,14 @@ const emojify = (status: string = '') => {
};
async function downloadArtifact(url: string, filepath: string) {
const bar = new cliProgress.SingleBar({
format: ` 下载中 [${chalk.cyan('{bar}')}] {percentage}% | 预计还剩: {eta}s | {value}/{total}`,
});
const bar = new cliProgress.SingleBar(
{
format: ` 下载中 [${chalk.cyan(
'{bar}',
)}] {percentage}% | : {eta}s | {value}/{total}`,
},
cliProgress.Presets.rect,
);
bar.start(1, 0);
const response = await axios.get(url, {
headers: {
@ -161,6 +167,12 @@ const runPrePublish = async () => {
await runScript({ event: 'test:dekko', path: '.', stdio: 'inherit' });
await runScript({ event: 'test:package-diff', path: '.', stdio: 'inherit' });
spinner.succeed(`文件检查通过,准备发布!`);
new Notifier().notify({
title: '✅ 准备发布到 npm',
message: '产物已经准备好了,快回来输入 npm 校验码了!',
sound: 'Crystal',
});
process.exit(0);
};