Skip to content

Commit a12624f

Browse files
ci: 添加 README 文档同步到 pub.dev 官网和 site 文档 (#887)
* ci: 添加 README 同步脚本并在工作流中执行 * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 1670f41 commit a12624f

7 files changed

Lines changed: 106 additions & 20 deletions

File tree

.github/workflows/autofix.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,7 @@ jobs:
3939
working-directory: ./tdesign-component/example
4040
run: flutter build apk -t ./lib/main.dart --release
4141

42+
- name: Sync README files
43+
run: node scripts/sync-readme.mjs
44+
4245
- uses: autofix-ci/action@v1

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ English | [简体中文](./README_zh_CN.md)
3737

3838
<img width="200" src="https://tdesign.tencent.com/flutter/assets/qrcode/td_apk_qrcode_0_2_7.png" />
3939

40-
Download link: [https://oteam-tdesign-1258344706.cos.ap-guangzhou.tencentcos.cn/flutter/tdesign-flutter-0.2.7-314.apk](https://oteam-tdesign-1258344706.cos.ap-guangzhou.tencentcos.cn/flutter/tdesign-flutter-0.2.7-314.apk)
40+
Download link: [tdesign-flutter-0.2.7-314.apk](https://oteam-tdesign-1258344706.cos.ap-guangzhou.tencentcos.cn/flutter/tdesign-flutter-0.2.7-314.apk)
4141

4242
**iOS**: Run the project to preview
4343

@@ -245,14 +245,14 @@ For more usage examples, refer to [example/lib/page/](https://github.com/Tencent
245245

246246
TDesign provides component libraries for other platforms and frameworks:
247247

248-
| Platform | Repository |
249-
|----------|------------|
250-
| Vue 2.x | [tdesign-vue](https://github.com/Tencent/tdesign-vue) |
251-
| Vue 3.x | [tdesign-vue-next](https://github.com/Tencent/tdesign-vue-next) |
252-
| React | [tdesign-react](https://github.com/Tencent/tdesign-react) |
253-
| Vue 3.x Mobile | [tdesign-mobile-vue](https://github.com/Tencent/tdesign-mobile-vue) |
254-
| React Mobile | [tdesign-mobile-react](https://github.com/Tencent/tdesign-mobile-react) |
255-
| WeChat Miniprogram | [tdesign-miniprogram](https://github.com/Tencent/tdesign-miniprogram) |
248+
| Platform | Repository |
249+
| ------------------ | ----------------------------------------------------------------------- |
250+
| Vue 2.x | [tdesign-vue](https://github.com/Tencent/tdesign-vue) |
251+
| Vue 3.x | [tdesign-vue-next](https://github.com/Tencent/tdesign-vue-next) |
252+
| React | [tdesign-react](https://github.com/Tencent/tdesign-react) |
253+
| Vue 3.x Mobile | [tdesign-mobile-vue](https://github.com/Tencent/tdesign-mobile-vue) |
254+
| React Mobile | [tdesign-mobile-react](https://github.com/Tencent/tdesign-mobile-react) |
255+
| WeChat Miniprogram | [tdesign-miniprogram](https://github.com/Tencent/tdesign-miniprogram) |
256256

257257
## 🤝 Contributing
258258

README_zh_CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838
<img width="200" src="https://tdesign.tencent.com/flutter/assets/qrcode/td_apk_qrcode_0_2_7.png" />
3939

40+
下载链接:[tdesign-flutter-0.2.7-314.apk](https://oteam-tdesign-1258344706.cos.ap-guangzhou.tencentcos.cn/flutter/tdesign-flutter-0.2.7-314.apk)
41+
4042
**iOS**:运行项目预览
4143

4244
[https://github.com/Tencent/tdesign-flutter/tree/main/tdesign-component](https://github.com/Tencent/tdesign-flutter/tree/main/tdesign-component)

scripts/sync-readme.mjs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { readFileSync, writeFileSync, existsSync } from 'fs';
2+
import { dirname } from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
const __dirname = dirname(fileURLToPath(import.meta.url));
6+
const rootDir = `${__dirname}/..`;
7+
8+
// ============================================================
9+
// 同步配置
10+
// ============================================================
11+
// source: 被监听的源文件
12+
// targets: 同步目标列表
13+
// - path: 目标文件路径
14+
// - transform: 可选,内容转换函数名
15+
// ============================================================
16+
17+
const transforms = {
18+
// 移除语言切换链接: [English](./README.md) | 简体中文
19+
removeLangLink: (content) => {
20+
return content.replace(/\[English\]\(\.\/README\.md\) \| \n?/g, '');
21+
},
22+
};
23+
24+
const syncConfig = [
25+
{
26+
source: 'README.md',
27+
targets: [
28+
{ path: 'tdesign-component/README.md' },
29+
],
30+
},
31+
{
32+
source: 'README_zh_CN.md',
33+
targets: [
34+
{ path: 'tdesign-component/README_zh_CN.md' },
35+
{ path: 'tdesign-site/site/docs/getting-started.md', transform: 'removeLangLink' },
36+
],
37+
},
38+
];
39+
40+
// ============================================================
41+
// 同步逻辑
42+
// ============================================================
43+
44+
function sync() {
45+
for (const { source, targets } of syncConfig) {
46+
const sourcePath = `${rootDir}/${source}`;
47+
48+
if (!existsSync(sourcePath)) {
49+
console.log(`[Skip] Source not found: ${source}`);
50+
continue;
51+
}
52+
53+
const sourceContent = readFileSync(sourcePath, 'utf-8');
54+
console.log(`[Read] ${source}`);
55+
56+
for (const { path, transform } of targets) {
57+
let content = sourceContent;
58+
59+
if (transform) {
60+
const transformFn = transforms[transform];
61+
if (transformFn) {
62+
content = transformFn(content);
63+
console.log(` [Transform: ${transform}]`);
64+
} else {
65+
console.log(` [Warn] Unknown transform: ${transform}`);
66+
}
67+
}
68+
69+
writeFileSync(`${rootDir}/${path}`, content, 'utf-8');
70+
console.log(` [Sync] -> ${path}`);
71+
}
72+
}
73+
74+
console.log('\nDone!');
75+
}
76+
77+
sync();

tdesign-component/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ English | [简体中文](./README_zh_CN.md)
3737

3838
<img width="200" src="https://tdesign.tencent.com/flutter/assets/qrcode/td_apk_qrcode_0_2_7.png" />
3939

40-
Download link: [https://oteam-tdesign-1258344706.cos.ap-guangzhou.tencentcos.cn/flutter/tdesign-flutter-0.2.7-314.apk](https://oteam-tdesign-1258344706.cos.ap-guangzhou.tencentcos.cn/flutter/tdesign-flutter-0.2.7-314.apk)
40+
Download link: [tdesign-flutter-0.2.7-314.apk](https://oteam-tdesign-1258344706.cos.ap-guangzhou.tencentcos.cn/flutter/tdesign-flutter-0.2.7-314.apk)
4141

4242
**iOS**: Run the project to preview
4343

@@ -245,14 +245,14 @@ For more usage examples, refer to [example/lib/page/](https://github.com/Tencent
245245

246246
TDesign provides component libraries for other platforms and frameworks:
247247

248-
| Platform | Repository |
249-
|----------|------------|
250-
| Vue 2.x | [tdesign-vue](https://github.com/Tencent/tdesign-vue) |
251-
| Vue 3.x | [tdesign-vue-next](https://github.com/Tencent/tdesign-vue-next) |
252-
| React | [tdesign-react](https://github.com/Tencent/tdesign-react) |
253-
| Vue 3.x Mobile | [tdesign-mobile-vue](https://github.com/Tencent/tdesign-mobile-vue) |
254-
| React Mobile | [tdesign-mobile-react](https://github.com/Tencent/tdesign-mobile-react) |
255-
| WeChat Miniprogram | [tdesign-miniprogram](https://github.com/Tencent/tdesign-miniprogram) |
248+
| Platform | Repository |
249+
| ------------------ | ----------------------------------------------------------------------- |
250+
| Vue 2.x | [tdesign-vue](https://github.com/Tencent/tdesign-vue) |
251+
| Vue 3.x | [tdesign-vue-next](https://github.com/Tencent/tdesign-vue-next) |
252+
| React | [tdesign-react](https://github.com/Tencent/tdesign-react) |
253+
| Vue 3.x Mobile | [tdesign-mobile-vue](https://github.com/Tencent/tdesign-mobile-vue) |
254+
| React Mobile | [tdesign-mobile-react](https://github.com/Tencent/tdesign-mobile-react) |
255+
| WeChat Miniprogram | [tdesign-miniprogram](https://github.com/Tencent/tdesign-miniprogram) |
256256

257257
## 🤝 Contributing
258258

tdesign-component/README_zh_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
<img width="200" src="https://tdesign.tencent.com/flutter/assets/qrcode/td_apk_qrcode_0_2_7.png" />
3939

40-
下载链接:[https://oteam-tdesign-1258344706.cos.ap-guangzhou.tencentcos.cn/flutter/tdesign-flutter-0.2.7-314.apk](https://oteam-tdesign-1258344706.cos.ap-guangzhou.tencentcos.cn/flutter/tdesign-flutter-0.2.7-314.apk)
40+
下载链接:[tdesign-flutter-0.2.7-314.apk](https://oteam-tdesign-1258344706.cos.ap-guangzhou.tencentcos.cn/flutter/tdesign-flutter-0.2.7-314.apk)
4141

4242
**iOS**:运行项目预览
4343

tdesign-site/site/docs/getting-started.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
</a>
2020
</p>
2121

22+
23+
2224
**TDesign Flutter** 是基于腾讯设计体系的跨平台 UI 组件库,使用 Flutter 框架开发,可快速构建美观、一致的移动端/Web 应用,提供丰富的预制组件和主题定制能力,支持 iOS、Android、Web 多端运行。
2325

2426
## 🎉 特性
@@ -33,7 +35,9 @@
3335

3436
**Android**:扫描二维码下载预览应用
3537

36-
<img width="200" src="https://tdesign.tencent.com//flutter/assets/qrcode/td_apk_qrcode_0_2_7.png" />
38+
<img width="200" src="https://tdesign.tencent.com/flutter/assets/qrcode/td_apk_qrcode_0_2_7.png" />
39+
40+
下载链接:[tdesign-flutter-0.2.7-314.apk](https://oteam-tdesign-1258344706.cos.ap-guangzhou.tencentcos.cn/flutter/tdesign-flutter-0.2.7-314.apk)
3741

3842
**iOS**:运行项目预览
3943

0 commit comments

Comments
 (0)