refactor(scripts): cleanup & enforce code style (#1388)
This commit is contained in:
1 parent
7db9b234c1
commit
5d74d700a2
23 files changed
+290
-270
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { REPO_ROOT } from "@/constants.ts";
|
||||
|
||||
import * as path from "@std/path";
|
||||
import usercssMeta from "usercss-meta";
|
||||
import { ensureDir, walk } from "@std/fs";
|
||||
|
||||
const stylesheets = walk(path.join(REPO_ROOT, "styles"), {
|
||||
includeFiles: true,
|
||||
includeDirs: false,
|
||||
includeSymlinks: false,
|
||||
match: [/\.user.css$/],
|
||||
});
|
||||
|
||||
// Recommended settings.
|
||||
const settings = {
|
||||
settings: {
|
||||
updateInterval: 24,
|
||||
updateOnlyEnabled: true,
|
||||
patchCsp: true,
|
||||
"editor.linter": "",
|
||||
},
|
||||
};
|
||||
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
await ensureDir("dist");
|
||||
Deno.writeTextFile("dist/import.json", JSON.stringify(data));
|
||||
Reference in new issue
Block a user