forked from catppuccin/userstyles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
executable file
路68 lines (63 loc) 路 1.99 KB
/
Copy pathmain.ts
File metadata and controls
executable file
路68 lines (63 loc) 路 1.99 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
57
58
59
60
61
62
63
64
65
66
67
68
import * as path from "@std/path";
import { REPO_ROOT } from "@/constants.ts";
import { syncIssueLabels } from "@/generate/labels.ts";
import { generateMainReadme } from "@/generate/readme-repo.ts";
import { generateStyleReadmes } from "@/generate/readme-styles.ts";
import { writeWithPreamble } from "@/generate/utils.ts";
import {
getAuthenticatedOctokit,
getPortsData,
getUserstylesData,
getUserstylesTeamMembers,
} from "@/utils.ts";
const userstylesData = getUserstylesData();
const portsData = await getPortsData();
/**
* Generate the main README.md, listing all ports as a table of contents
*/
await generateMainReadme(userstylesData.userstyles, portsData);
/**
* Generate README.md files for each style
*/
generateStyleReadmes(userstylesData.userstyles);
/**
* Keep
* - `.github/issue-labeler.yml`
* - `.github/labels.yml`
* - `.github/pr-labeler.yml`
* in sync with the userstyle metadata.
*/
await syncIssueLabels(userstylesData.userstyles);
/**
* Keep `.github/CODEOWNERS` in sync with the userstyle metadata.
*/
function maintainersCodeOwners() {
return Object.entries(userstylesData.userstyles!)
.filter(([_, { "current-maintainers": currentMaintainers }]) =>
currentMaintainers.length > 0
)
.map(([slug, { "current-maintainers": currentMaintainers }]) => {
const codeOwners = currentMaintainers
.map((maintainer) => `@${maintainer.url.split("/").pop()}`)
.join(" ");
return `/styles/${slug} ${codeOwners}`;
})
.join("\n");
}
async function userstylesStaffCodeOwners() {
const paths = ["/.github/", "/scripts/", "/template/"];
const octokit = getAuthenticatedOctokit();
const staffMembers = await getUserstylesTeamMembers(
octokit,
"userstyles-staff",
);
return paths.map((path) =>
`${path} ${staffMembers.map((member) => "@" + member).join(" ")}`
).join(
"\n",
);
}
await writeWithPreamble(
path.join(REPO_ROOT, ".github/CODEOWNERS"),
`${maintainersCodeOwners()}\n\n${await userstylesStaffCodeOwners()}`,
);