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
39 lines (32 loc) 路 1.07 KB
/
Copy pathmain.ts
File metadata and controls
39 lines (32 loc) 路 1.07 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
import usercssMeta from "usercss-meta";
import { ensureDir } from "@std/fs";
import { calcStyleDigest } from "https://github.com/openstyles/stylus/raw/8fe35a4b90d85fb911bd7aa1deab4e4733c31150/src/js/sections-util.js";
import { getUserstylesFiles } from "@/utils.ts";
// Recommended settings.
const settings = {
settings: {
updateInterval: 24,
updateOnlyEnabled: true,
patchCsp: true,
"editor.linter": "",
},
};
const data: Record<string, unknown>[] = [settings];
for (const file of getUserstylesFiles()) {
const content = await Deno.readTextFile(file);
const { metadata } = usercssMeta.parse(content);
const userstyle = {
enabled: true,
name: metadata.name,
description: metadata.description,
author: metadata.author,
url: metadata.url,
updateUrl: metadata.updateURL,
usercssData: metadata,
sourceCode: content,
} as Record<string, unknown>;
userstyle.originalDigest = await calcStyleDigest(userstyle);
data.push(userstyle);
}
await ensureDir("dist");
await Deno.writeTextFile("dist/import.json", JSON.stringify(data));