forked from catppuccin/userstyles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathports.ts
More file actions
51 lines (44 loc) 路 1.2 KB
/
Copy pathports.ts
File metadata and controls
51 lines (44 loc) 路 1.2 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
// deno-lint-ignore-file no-explicit-any
import fs from "fs";
import path from "path";
import YAML from "yaml";
export type Collaborator = string;
export type PortEntry = {
slug: string;
name: string;
link: string;
categories: string[];
icon?: string;
color: string;
note?: string;
currentMaintainers?: Collaborator[];
pastMaintainers?: Collaborator[];
supports?: Record<string, { name: string; link: string }>;
};
const file = fs.readFileSync(
path.resolve("../scripts/userstyles.yml"),
"utf-8",
);
const parsed = YAML.parse(file) as {
collaborators: Collaborator[];
userstyles: Record<string, any>;
};
// TODO: Use proper types from scripts lib once possible.
// Normalize keys (camelCase)
function normalizePort(slug: string, data: any): PortEntry {
return {
slug,
name: data.name,
link: data.link,
categories: data.categories ?? [],
icon: data.icon,
color: data.color,
note: data.note,
currentMaintainers: data["current-maintainers"] ?? [],
pastMaintainers: data["past-maintainers"] ?? [],
supports: data.supports,
};
}
export const ports: PortEntry[] = Object.entries(parsed.userstyles).map(
([slug, data]) => normalizePort(slug, data),
);