Skip to content

Commit fc0c3a6

Browse files
authored
Merge branch 'master' into master
2 parents 5d476aa + 1fca398 commit fc0c3a6

79 files changed

Lines changed: 977 additions & 339 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/pull_request_template.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
- [ ] 菜谱包含`必备原料和工具`, `计算`, `操作`三部分内容。
1515
- [ ] 菜品的`原材料用量`是无歧义且准确的。对于可以自行发挥的量给出了建议的范围。
1616
- [ ] 菜品的`制作步骤`是无歧义,准确且完整的。对于每一个步骤的开始和结束都有明确的标准。
17-
- [ ] 我已更新 Readme 对本次修改的菜谱的引用链接。
1817
- [ ] 我没有破坏模板的一二级标题格式。
1918
- [ ] 我没有删除模板中必需的内容。
2019
- [ ] 我已删除干净所有的复制出来的模板的注释。

.github/readme-generate.js

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
const { readdir, writeFile, stat } = require('fs/promises');
2+
3+
const ignorePaths = ['.git', 'README.md', 'node_modules', 'CONTRIBUTING.md', '.github'];
4+
5+
const categories = {
6+
'home-cooking': {
7+
title: '家常菜',
8+
template: '',
9+
},
10+
breakfast: {
11+
title: '早餐',
12+
template: '',
13+
},
14+
staple: {
15+
title: '主食',
16+
template: '',
17+
},
18+
'semi-finished': {
19+
title: '半成品加工',
20+
template: '',
21+
},
22+
soup: {
23+
title: '汤与粥',
24+
template: '',
25+
},
26+
drink: {
27+
title: '饮料',
28+
template: '',
29+
},
30+
condiment: {
31+
title: '酱料和其它材料',
32+
template: '',
33+
},
34+
dessert: {
35+
title: '甜品',
36+
template: '',
37+
},
38+
};
39+
40+
let README_TEMPLATE = `# 程序员做饭指南
41+
42+
[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/Anduin2017/HowToCook/Continuous%20Integration/master)](https://github.com/Anduin2017/HowToCook/actions/workflows/ci.yml)
43+
[![License](https://img.shields.io/github/license/Anduin2017/HowToCook)](./LICENSE)
44+
[![GitHub contributors](https://img.shields.io/github/contributors/Anduin2017/HowToCook)](https://github.com/Anduin2017/HowToCook/graphs/contributors)
45+
46+
最近在家隔离,出不了门。只能宅在家做饭了。作为程序员,我偶尔在网上找找菜谱和做法。但是这些菜谱往往写法千奇百怪,经常中间莫名出来一些材料。对于习惯了形式语言的程序员来说极其不友好。
47+
48+
所以,我计划自己搜寻菜谱和并结合实际做菜的经验,准备用更清晰精准的描述来整理常见菜的做法,以方便程序员在家做饭。
49+
50+
同样,我希望它是一个由社区驱动和维护的开源项目,使更多人能够一起做一个有趣的仓库。所以非常欢迎大家贡献它~
51+
52+
## 如何贡献
53+
54+
针对发现的问题,直接修改并提交 Pull request 即可。
55+
56+
在写新菜谱时,请复制并修改已有的菜谱模板: [示例菜](https://github.com/Anduin2017/HowToCook/blob/master/dishes/template/%E7%A4%BA%E4%BE%8B%E8%8F%9C/%E7%A4%BA%E4%BE%8B%E8%8F%9C.md?plain=1)。
57+
在提交 Pull Request 前更新一下 README.md 里的引用。
58+
59+
## 做菜之前
60+
61+
{{before}}
62+
## 菜谱
63+
{{main}}
64+
## 进阶知识学习
65+
66+
如果你已经做了许多上面的菜,对于厨艺已经入门,并且想学习更加高深的烹饪技巧,请继续阅读下面的内容:
67+
68+
{{after}}`;
69+
70+
async function main() {
71+
try {
72+
let BEFORE = (MAIN = AFTER = '');
73+
const markdownObj = await getAllMarkdown('.');
74+
for (const markdown of markdownObj) {
75+
if (markdown.path.includes('tips/advanced')) {
76+
AFTER += inlineTemplate(markdown.file, markdown.path, true);
77+
continue;
78+
}
79+
if (markdown.path.includes('tips')) {
80+
BEFORE += inlineTemplate(markdown.file, markdown.path, true);
81+
continue;
82+
}
83+
84+
for (const category of Object.keys(categories)) {
85+
if (markdown.path.includes(category)) {
86+
let currentCategoryStr = categories[category].template;
87+
currentCategoryStr += inlineTemplate(markdown.file, markdown.path);
88+
categories[category].template = currentCategoryStr;
89+
}
90+
}
91+
}
92+
93+
for (const category of Object.values(categories)) {
94+
MAIN += categoryTemplate(category.title, category.template);
95+
}
96+
97+
await writeFile(
98+
'./README.md',
99+
README_TEMPLATE.replace('{{before}}', BEFORE)
100+
.replace('{{main}}', MAIN)
101+
.replace('{{after}}', AFTER),
102+
);
103+
} catch (error) {
104+
console.error(error);
105+
}
106+
}
107+
108+
async function getAllMarkdown(path) {
109+
const paths = [];
110+
const files = await readdir(path);
111+
// chinese alphabetic order
112+
files.sort((a, b) => a.localeCompare(b, 'zh-CN'));
113+
114+
// mtime order
115+
// files.sort(async (a, b) => {
116+
// const aStat = await stat(`${path}/${a}`);
117+
// const bStat = await stat(`${path}/${b}`);
118+
// return aStat.mtime - bStat.mtime;
119+
// });
120+
for (const file of files) {
121+
const filePath = `${path}/${file}`;
122+
if (ignorePaths.includes(file)) continue;
123+
const fileStat = await stat(filePath);
124+
if (fileStat.isFile() && file.endsWith('.md')) {
125+
paths.push({ path, file });
126+
} else if (fileStat.isDirectory()) {
127+
const subFiles = await getAllMarkdown(filePath);
128+
paths.push(...subFiles);
129+
}
130+
}
131+
return paths;
132+
}
133+
134+
function inlineTemplate(file, path) {
135+
return `* [${file.replace('.md', '')}](${path}/${file})\n`;
136+
}
137+
138+
function categoryTemplate(title, inlineStr) {
139+
return `\n### ${title}\n\n${inlineStr}`;
140+
}
141+
142+
main();

.github/stale.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Configuration for probot-stale - https://github.com/probot/stale
2+
# Number of days of inactivity before an issue becomes stale
3+
daysUntilStale: 30
4+
# Number of days of inactivity before a stale issue is closed
5+
daysUntilClose: 7
6+
# Issues with these labels will never be considered stale
7+
exemptLabels:
8+
- "Type: Bug"
9+
# Label to use when marking an issue as stale
10+
staleLabel: "Resolution: Stale"
11+
issues:
12+
# Comment to post when marking an issue as stale.
13+
markComment: >
14+
This issue has been automatically marked as stale.
15+
**If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open.
16+
We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!
17+
# Comment to post when closing a stale issue.
18+
closeComment: >
19+
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!
20+
pulls:
21+
# Comment to post when marking a pull request as stale.
22+
markComment: >
23+
This pull request has been automatically marked as stale.
24+
**If this pull request is still relevant, please leave any comment** (for example, "bump"), and we'll keep it open.
25+
We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.
26+
# Comment to post when closing a stale pull request.
27+
closeComment: >
28+
Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Readme Generate
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
- '*/*'
8+
- '**'
9+
pull_request:
10+
branches:
11+
- '*'
12+
- '*/*'
13+
- '**'
14+
workflow_dispatch:
15+
16+
jobs:
17+
readme-gen:
18+
runs-on: ubuntu-latest
19+
# if: github.repository_owner == 'Anduin2017'
20+
steps:
21+
- uses: actions/checkout@v2
22+
- run: node ./.github/readme-generate.js
23+
- uses: stefanzweifel/git-auto-commit-action@v4
24+
with:
25+
commit_message: "[ci skip] Automatic generate readme"
26+
file_pattern: ":/*.md"
27+
commit_user_name: github-actions[bot]
28+
commit_user_email: github-actions[bot]@users.noreply.github.com
29+
commit_author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

.github/workflows/textlint.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
name: Textlint
22

33
on:
4-
schedule:
5-
- cron: '0 */6 * * *'
4+
push:
5+
branches:
6+
- '*'
7+
- '*/*'
8+
- '**'
9+
pull_request:
10+
branches:
11+
- '*'
12+
- '*/*'
13+
- '**'
614
workflow_dispatch:
715

816
jobs:

CONTRIBUTING.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,3 @@
9595
- 确保分类正确,不和已有的菜名重复
9696
- 确保签入的内容都符合 CC0 协议。尤其注意图片是否有水印!
9797
- 确保他没有签入任何个人身份信息、EUII、Email 地址、GitHub 用户名
98-

0 commit comments

Comments
 (0)