Skip to content

Commit a6c5baa

Browse files
committed
Merge branch 'main' into feat-push-notifications-with-fcm
2 parents 5109433 + 0cf0833 commit a6c5baa

File tree

141 files changed

+5866
-141
lines changed

Some content is hidden

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

141 files changed

+5866
-141
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: "Generate README markdown table"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types:
8+
- closed
9+
jobs:
10+
readme-generator:
11+
if: github.event.pull_request.merged == true
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Prepare repository
16+
uses: actions/checkout@v2
17+
with:
18+
ref: ${{ github.event.pull_request.base.ref }}
19+
20+
- name: Prepare Node.js
21+
uses: actions/setup-node@v2
22+
with:
23+
node-version: "16"
24+
25+
- name: Prepare function
26+
run: |
27+
cd .github/workflows/markdown-table-workflow
28+
npm install
29+
30+
- name: Run function
31+
run: cd .github/workflows/markdown-table-workflow && node index.js
32+
33+
- name: Push changes
34+
run: |
35+
git config user.name github-actions
36+
git config user.email [email protected]
37+
git add README.md
38+
git commit -m "Auto: README table generation" || true
39+
git push || true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import fs from "node:fs";
2+
import path from "node:path";
3+
import { markdownTable } from "markdown-table";
4+
5+
const verboseRuntimes = {
6+
cpp: "C++",
7+
dart: "Dart",
8+
deno: "Deno",
9+
dotnet: ".NET",
10+
java: "Java",
11+
kotlin: "Kotlin",
12+
node: "Node.js",
13+
php: "PHP",
14+
python: "Python",
15+
ruby: "Ruby",
16+
swift: "Swift",
17+
};
18+
19+
const folderDenylist = [".github", ".git"];
20+
21+
const generateUniqueTemplates = (runtimes) => {
22+
let templates = [];
23+
24+
for (const runtime of runtimes) {
25+
const folders = fs
26+
.readdirSync(path.join(".", `../../../${runtime}`), {
27+
withFileTypes: true,
28+
})
29+
.filter((dirent) => dirent.isDirectory())
30+
.map((dirent) => dirent.name);
31+
32+
templates.push(...folders);
33+
}
34+
35+
return [...new Set(templates)];
36+
};
37+
38+
const generateTableRows = (templates, runtimes) => {
39+
return templates.map((template) => {
40+
const languagesSupport = runtimes.map((runtime) => {
41+
return fs.existsSync(path.join(".", `../../../${runtime}/${template}`))
42+
? `[✅](/${runtime}/${template})`
43+
: "🏗️";
44+
});
45+
46+
return [template, ...languagesSupport];
47+
});
48+
};
49+
50+
const sortRuntimesBySupport = (runtimes, uniqueTemplates) => {
51+
return runtimes.sort((a, b) => {
52+
const aTemplates = uniqueTemplates.filter((template) =>
53+
fs.existsSync(path.join(".", `../../../${a}/${template}`))
54+
);
55+
const bTemplates = uniqueTemplates.filter((template) =>
56+
fs.existsSync(path.join(".", `../../../${b}/${template}`))
57+
);
58+
59+
return bTemplates.length - aTemplates.length;
60+
});
61+
};
62+
63+
const updateReadmeFile = (readmePath, table) => {
64+
const readme = fs.readFileSync(readmePath).toString();
65+
66+
if (
67+
readme.includes("<!-- TABLE:START -->") &&
68+
readme.includes("<!-- TABLE:END -->")
69+
) {
70+
const newReadme = `${
71+
readme.split("<!-- TABLE:START -->")[0]
72+
}<!-- TABLE:START -->\n${table}\n<!-- TABLE:END -->${
73+
readme.split("<!-- TABLE:END -->")[1]
74+
}`;
75+
76+
fs.writeFileSync(readmePath, newReadme);
77+
}
78+
};
79+
80+
let runtimes = fs
81+
.readdirSync(path.join(".", "../../../"), { withFileTypes: true })
82+
.filter((dirent) => dirent.isDirectory())
83+
.map((dirent) => dirent.name)
84+
.filter((folder) => !folderDenylist.includes(folder))
85+
.sort();
86+
87+
const uniqueTemplates = generateUniqueTemplates(runtimes);
88+
runtimes = sortRuntimesBySupport(runtimes, uniqueTemplates);
89+
const tableRows = generateTableRows(uniqueTemplates, runtimes);
90+
91+
const sortedTableRows = tableRows.sort((a, b) => {
92+
const aCount = a.filter((column) => column !== "").length;
93+
const bCount = b.filter((column) => column !== "").length;
94+
95+
return aCount > bCount ? -1 : 1;
96+
});
97+
98+
const table = markdownTable([
99+
[
100+
"Template",
101+
...runtimes.map((r) => (verboseRuntimes[r] ? verboseRuntimes[r] : r)),
102+
],
103+
...sortedTableRows,
104+
]);
105+
106+
const readmePath = path.join(".", "../../../README.md");
107+
updateReadmeFile(readmePath, table);

.github/workflows/markdown-table-workflow/package-lock.json

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "markdown-table-workflow",
3+
"version": "1.0.0",
4+
"description": "",
5+
"type": "module",
6+
"main": "index.js",
7+
"scripts": {
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"keywords": [],
11+
"author": "",
12+
"license": "ISC",
13+
"dependencies": {
14+
"markdown-table": "^3.0.3"
15+
}
16+
}

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to make participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity, expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

0 commit comments

Comments
 (0)