✨ set status to readme
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "hula-emojis-monorepo",
|
||||
"version": "1.0.0",
|
||||
"packageManager": "pnpm@9.15.4",
|
||||
"packageManager": "pnpm@10.0.0",
|
||||
"description": "The monorepo of Hula Emojis",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -7,6 +7,15 @@
|
||||
|
||||
HuLa 表情包数据。
|
||||
|
||||
## 数据概览
|
||||
|
||||
| 表情包 | 系列数 | 表情数 | GIF表情数 | 文本表情数 |
|
||||
| :---------- | --: | ---: | -----: | ----: |
|
||||
| 总计 | 27 | 2991 | 278 | 108 |
|
||||
| Bilibili表情包 | 4 | 363 | 0 | 52 |
|
||||
| 米游社表情包 | 14 | 2433 | 197 | 0 |
|
||||
| 知乎表情包 | 9 | 195 | 81 | 56 |
|
||||
|
||||
## 使用
|
||||
|
||||
```shell
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"main": "dist/data.json",
|
||||
"types": "hula-emojis.d.ts",
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@9.15.4",
|
||||
"packageManager": "pnpm@10.0.0",
|
||||
"scripts": {
|
||||
"status": "tsx scripts/status.mts",
|
||||
"build": "tsx scripts/update.mts && tsx scripts/build.mts && tsx scripts/status.mts"
|
||||
@@ -28,6 +28,7 @@
|
||||
"app-root-path": "^3.1.0",
|
||||
"axios": "^1.7.9",
|
||||
"fs-extra": "^11.3.0",
|
||||
"markdown-table-ts": "^1.0.3",
|
||||
"ora": "^8.1.1",
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "^5.7.3"
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
/**
|
||||
* @file scripts/status.mts
|
||||
* @description 查看数据概况
|
||||
* @since 1.2.1
|
||||
* @since 1.2.6
|
||||
*/
|
||||
|
||||
import fs from "fs-extra";
|
||||
import { Align, getMarkdownTable } from "markdown-table-ts";
|
||||
import { getRelativePath } from "../utils/getRelativePath.mjs";
|
||||
import type { HulaEmojiData } from "../hula-emojis.js";
|
||||
import ora from "ora";
|
||||
|
||||
const spinner = ora("正在读取数据...").start();
|
||||
// 数据处理
|
||||
const spinnerData = ora("正在读取数据...").start();
|
||||
const start = Date.now();
|
||||
const dataDir = getRelativePath("data");
|
||||
const files = fs.readdirSync(dataDir);
|
||||
@@ -22,7 +24,7 @@ type EmojiStatData = {
|
||||
};
|
||||
const res: EmojiStatData[] = [];
|
||||
for (const file of files) {
|
||||
spinner.start(`正在处理文件: ${file}`);
|
||||
spinnerData.start(`正在处理文件: ${file}`);
|
||||
const rawData: HulaEmojiData = await fs.readJson(getRelativePath("data", file));
|
||||
const seriesCount = rawData.series.length;
|
||||
const emojiFlat = rawData.series.flatMap((item) => item.emojis);
|
||||
@@ -37,17 +39,42 @@ for (const file of files) {
|
||||
textEmojisCount,
|
||||
});
|
||||
}
|
||||
spinner.succeed("数据处理完成");
|
||||
spinner.start("正在输出数据...");
|
||||
console.table(res, ["name", "seriesCount", "emojisCount", "gifEmojisCount", "textEmojisCount"]);
|
||||
const cost = Date.now() - start;
|
||||
spinnerData.succeed("数据处理完成");
|
||||
// 更新README
|
||||
const spinnerReadme = ora("正在更新README.md...").start();
|
||||
const readmePath = getRelativePath("README.md");
|
||||
const readme = fs.readFileSync(readmePath, "utf-8").split("\n");
|
||||
const overViewIndex = readme.findIndex((item) => item.startsWith("## 数据概览"));
|
||||
const useIndex = readme.findIndex((item) => item.startsWith("## 使用"));
|
||||
const totalSeries = res.reduce((acc, cur) => acc + cur.seriesCount, 0);
|
||||
const totalEmojis = res.reduce((acc, cur) => acc + cur.emojisCount, 0);
|
||||
const totalGifEmojis = res.reduce((acc, cur) => acc + cur.gifEmojisCount, 0);
|
||||
const totalTextEmojis = res.reduce((acc, cur) => acc + cur.textEmojisCount, 0);
|
||||
spinner.info(`总系列数: ${totalSeries}`);
|
||||
spinner.info(`总表情数: ${totalEmojis}`);
|
||||
spinner.info(`总GIF表情数: ${totalGifEmojis}`);
|
||||
spinner.info(`总文本表情数: ${totalTextEmojis}`);
|
||||
spinner.info(`耗时: ${cost}ms`);
|
||||
spinner.stop();
|
||||
const table = getMarkdownTable({
|
||||
table: {
|
||||
head: ["表情包", "系列数", "表情数", "GIF表情数", "文本表情数"],
|
||||
body: [
|
||||
[
|
||||
"总计",
|
||||
totalSeries.toString(),
|
||||
totalEmojis.toString(),
|
||||
totalGifEmojis.toString(),
|
||||
totalTextEmojis.toString(),
|
||||
],
|
||||
...res.map((item) => [
|
||||
item.name,
|
||||
item.seriesCount.toString(),
|
||||
item.emojisCount.toString(),
|
||||
item.gifEmojisCount.toString(),
|
||||
item.textEmojisCount.toString(),
|
||||
]),
|
||||
],
|
||||
},
|
||||
alignment: [Align.Left, Align.Right, Align.Right, Align.Right, Align.Right],
|
||||
});
|
||||
readme.splice(overViewIndex + 2, useIndex - overViewIndex - 3, ...table.split("\n"));
|
||||
fs.writeFileSync(readmePath, readme.join("\n"));
|
||||
console.table(res, ["name", "seriesCount", "emojisCount", "gifEmojisCount", "textEmojisCount"]);
|
||||
const cost = Date.now() - start;
|
||||
spinnerReadme.info(`耗时: ${cost}ms`);
|
||||
spinnerReadme.stop();
|
||||
|
||||
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
@@ -114,6 +114,9 @@ importers:
|
||||
fs-extra:
|
||||
specifier: ^11.3.0
|
||||
version: 11.3.0
|
||||
markdown-table-ts:
|
||||
specifier: ^1.0.3
|
||||
version: 1.0.3
|
||||
ora:
|
||||
specifier: ^8.1.1
|
||||
version: 8.1.1
|
||||
@@ -2442,6 +2445,9 @@ packages:
|
||||
resolution: {integrity: sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
markdown-table-ts@1.0.3:
|
||||
resolution: {integrity: sha512-lYrp7FXmBqpmGmsEF92WnSukdgYvLm15FPIODZOx9+3nobkxJxjBYcszqZf5VqTjBtISPSNC7zjU9o3zwpL6AQ==}
|
||||
|
||||
mathml-tag-names@2.1.3:
|
||||
resolution: {integrity: sha512-APMBEanjybaPzUrfqU0IMU5I0AswKMH7k8OTLs0vvV4KZpExkTkY87nR/zpbuTPj+gARop7aGUbl11pnDfW6xg==}
|
||||
|
||||
@@ -6208,6 +6214,8 @@ snapshots:
|
||||
|
||||
map-obj@4.3.0: {}
|
||||
|
||||
markdown-table-ts@1.0.3: {}
|
||||
|
||||
mathml-tag-names@2.1.3: {}
|
||||
|
||||
mdn-data@2.12.2: {}
|
||||
|
||||
Reference in New Issue
Block a user