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
44 lines (37 loc) 路 1.03 KB
/
Copy pathmain.ts
File metadata and controls
44 lines (37 loc) 路 1.03 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
#!/usr/bin/env -S deno run -A
import usercssMeta from "usercss-meta";
import { ensureDir } from "std/fs/mod.ts";
import { walk } from "std/fs/walk.ts";
import { join } from "std/path/mod.ts";
import { REPO_ROOT } from "@/deps.ts";
const stylesheets = walk(join(REPO_ROOT, "styles"), {
includeFiles: true,
includeDirs: false,
includeSymlinks: false,
match: [/\.user.css$/],
});
// Recommended settings.
const settings = {
settings: {
updateInterval: 24,
updateOnlyEnabled: true,
patchCsp: true,
},
};
const data: Record<string, unknown>[] = [settings];
for await (const entry of stylesheets) {
const content = await Deno.readTextFile(entry.path);
const { metadata } = usercssMeta.parse(content);
data.push({
enabled: true,
name: metadata.name,
description: metadata.description,
author: metadata.author,
url: metadata.url,
updateUrl: metadata.updateURL,
usercssData: metadata,
sourceCode: content,
});
}
ensureDir("dist");
Deno.writeTextFile("dist/import.json", JSON.stringify(data));