forked from catppuccin/userstyles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlabels.ts
More file actions
76 lines (69 loc) 路 2.17 KB
/
Copy pathlabels.ts
File metadata and controls
76 lines (69 loc) 路 2.17 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
69
70
71
72
73
74
75
76
import { join } from "std/path/mod.ts";
import { REPO_ROOT } from "@/deps.ts";
import { updateFile } from "@/generate/utils.ts";
import { UserStylesSchema } from "@/types/mod.ts";
import { stringify } from "std/yaml/stringify.ts";
import palette from "https://raw.githubusercontent.com/catppuccin/palette/v0.2.0/palette-porcelain.json" with {
type: "json",
};
/**
* Macchiato color definitions as hex values.
*/
const macchiatoHex = Object.entries(palette.macchiato)
.reduce((acc, [k, v]) => {
acc[k] = `#${v.hex}`;
return acc;
}, {} as Record<keyof typeof palette.macchiato, string>);
const toIssueLabel = (slug: string | number) => `lbl:${slug}`;
export const syncIssueLabels = async (
userstyles: UserStylesSchema.Userstyles,
) => {
updateFile(
join(REPO_ROOT, ".github/issue-labeler.yml"),
stringify(
Object.entries(userstyles)
.reduce((acc, [key]) => {
acc[key.toString()] = [`(${toIssueLabel(key)})`];
return acc;
}, {} as Record<string, string[]>),
),
);
const userstyleIssueContent = Deno.readTextFileSync(join(
REPO_ROOT,
"scripts/generate/templates/userstyle-issue.yml",
));
Deno.writeTextFileSync(
join(REPO_ROOT, ".github/ISSUE_TEMPLATE/userstyle.yml"),
userstyleIssueContent.replace(
`"$LABELS"`,
`${
Object.entries(userstyles)
.map(([key]) => `"${toIssueLabel(key)}"`)
.join(", ")
}`,
),
);
// .github/pr-labeler.yml
updateFile(
join(REPO_ROOT, ".github/pr-labeler.yml"),
stringify(
Object.entries(userstyles)
.reduce((acc, [key]) => {
acc[`${key}`] = `styles/${key}/**/*`;
return acc;
}, {} as Record<string, string>),
),
);
// .github/labels.yml
const syncLabelsContent = Object.entries(userstyles)
.map(([slug, style]) => {
return {
name: slug,
description: [style.name].flat().join(", "),
color: style.color ? macchiatoHex[style.color] : macchiatoHex.blue,
};
});
const syncLabels = join(REPO_ROOT, ".github/labels.yml");
// deno-lint-ignore no-explicit-any
await updateFile(syncLabels, stringify(syncLabelsContent as any));
};