ci(scripts): consistent variables & comments (#420)

This commit is contained in:
uncenter authored and GitHub committed 2024-01-26 22:37:57 +00:00
1 parent a974422f0a
commit 6cfb96b1e4
8 files changed
+49 -48

No files matched your search

+20 -20
View File
@@ -12,16 +12,16 @@ import { getUserstylesData } from "@/utils.ts";
export const verifyMetadata = async (
entry: WalkEntry,
content: string,
repo: string,
userstyle: string,
) => {
const assert = await assertions(repo);
const assert = await assertions(userstyle);
const file = relative(REPO_ROOT, entry.path);
const { metadata, errors: parsingErrors } = usercssMeta.parse(content, {
allowErrors: true,
});
// pretty print / annotate the parsing errors
// Pretty print / annotate the parsing errors.
parsingErrors.map((e) => {
let startLine = 0;
for (const line of content.split("\n")) {
@@ -32,17 +32,17 @@ export const verifyMetadata = async (
log(e.message, { file, startLine, content });
});
Object.entries(assert).forEach(([k, v]) => {
const defacto = metadata[k];
if (defacto !== v) {
for (const [key, value] of Object.entries(assert)) {
const defacto = metadata[key];
if (defacto !== value) {
const line = content
.split("\n")
.findIndex((line) => line.includes(k)) + 1;
.findIndex((line) => line.includes(key)) + 1;
const message = sprintf(
"Metadata %s should be %s but is %s",
color.bold(k),
color.green(v),
color.bold(key),
color.green(value),
color.red(String(defacto)),
);
@@ -52,12 +52,12 @@ export const verifyMetadata = async (
content,
}, "warning");
}
});
}
// parse the usercss variables to less global variables, e.g.
// Parse the UserCSS variables to LESS global variables, e.g.
// `@var select lightFlavor "Light Flavor" ["latte:Latte*", "frappe:Frappé", "macchiato:Macchiato", "mocha:Mocha"]`
// gets parsed as
// `lightFlavor: "latte"`
// `lightFlavor: "latte"`.
const globalVars = Object.entries(metadata.vars)
.reduce((acc, [k, v]) => {
return { ...acc, [k]: v.default };
@@ -69,7 +69,7 @@ export const verifyMetadata = async (
};
};
const assertions = async (repo: string) => {
const assertions = async (userstyle: string) => {
const prefix = "https://github.com/catppuccin/userstyles";
const { userstyles } = await getUserstylesData().catch((err) => {
@@ -79,16 +79,16 @@ const assertions = async (repo: string) => {
return {
name: `${
Array.isArray(userstyles[repo].name)
? (userstyles[repo].name as string[]).join("/")
: userstyles[repo].name
Array.isArray(userstyles[userstyle].name)
? (userstyles[userstyle].name as string[]).join("/")
: userstyles[userstyle].name
} Catppuccin`,
namespace: `github.com/catppuccin/userstyles/styles/${repo}`,
namespace: `github.com/catppuccin/userstyles/styles/${userstyle}`,
author: "Catppuccin",
license: "MIT",
preprocessor: "less",
homepageURL: `${prefix}/tree/main/styles/${repo}`,
updateURL: `${prefix}/raw/main/styles/${repo}/catppuccin.user.css`,
supportURL: `${prefix}/issues?q=is%3Aopen+is%3Aissue+label%3A${repo}`,
homepageURL: `${prefix}/tree/main/styles/${userstyle}`,
updateURL: `${prefix}/raw/main/styles/${userstyle}/catppuccin.user.css`,
supportURL: `${prefix}/issues?q=is%3Aopen+is%3Aissue+label%3A${userstyle}`,
};
};