forked from AlistGo/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathecosystem.ts
More file actions
56 lines (47 loc) · 1.45 KB
/
ecosystem.ts
File metadata and controls
56 lines (47 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import * as types from "./types";
import _all from "../ecosystem.json";
import fs from "fs";
const all = _all as types.All;
const official = all["official"];
const community = all["community"];
const github = async (args: types.Github) => {
const { repo } = args;
const resp: types.GithubRepo = await (
await fetch(`https://api.github.com/repos/${repo}`)
).json();
const topics = resp.topics
?.map((topic) => `<Badge text="${topic}" type="tip" /> `)
.join(" ");
return `### [${resp.name}](https://github.com/${repo}) *(${resp.updated_at})*
${topics}
 
${resp.description}`;
};
const fns = {
github,
};
const main = async () => {
const path = "docs/guide/ecosystem.md";
// write official
let content = "## Official\n";
const officialContent = await Promise.all(
official.map((item) => fns[item.type](item))
);
content += officialContent.join("\n");
fs.appendFileSync(path, content);
// write community
content = `
## Community
::: warning
Community repo may be outdated and crash, and no warranty of availability and security is made here.
:::
`;
const communityContent = await Promise.all(
community.map((item) => fns[item.type](item))
);
content += communityContent.join("\n");
fs.appendFileSync(path, content);
// copy to zh
fs.copyFileSync(path, "docs/zh/guide/ecosystem.md");
};
main();