ci(lint): catch yaml errors (#659)

This commit is contained in:
uncenter authored and GitHub committed 2024-03-13 16:32:45 -04:00
1 parent 7a351386d8
commit 7139901985
3 files changed
+73 -28

No files matched your search

+8 -1
View File
@@ -10,6 +10,7 @@ import { checkForMissingFiles } from "@/lint/file-checker.ts";
import { log } from "@/lint/logger.ts";
import { verifyMetadata } from "@/lint/metadata.ts";
import { lint } from "@/lint/stylelint.ts";
import { getUserstylesData } from "@/utils.ts";
const flags = parseFlags(Deno.args, { boolean: ["fix"] });
const subDir = flags._[0]?.toString() ?? "";
@@ -19,6 +20,7 @@ const stylesheets = walk(join(REPO_ROOT, "styles", subDir), {
includeSymlinks: false,
match: [/\.user.css$/],
});
const { userstyles } = getUserstylesData();
let failed = false;
@@ -29,7 +31,12 @@ for await (const entry of stylesheets) {
const content = await Deno.readTextFile(entry.path);
// Verify the UserCSS metadata.
const { globalVars, isLess } = await verifyMetadata(entry, content, dir);
const { globalVars, isLess } = await verifyMetadata(
entry,
content,
dir,
userstyles,
);
// Don't attempt to compile or lint non-LESS files.
if (!isLess) continue;
+5 -8
View File
@@ -7,14 +7,16 @@ import { join, relative } from "std/path/mod.ts";
import { REPO_ROOT } from "@/deps.ts";
import { log } from "@/lint/logger.ts";
import { formatListOfItems, getUserstylesData } from "@/utils.ts";
import { formatListOfItems } from "@/utils.ts";
import type { Userstyles } from "@/types/userstyles.d.ts";
export const verifyMetadata = async (
entry: WalkEntry,
content: string,
userstyle: string,
userstyles: Userstyles,
) => {
const assert = await assertions(userstyle);
const assert = assertions(userstyle, userstyles);
const file = relative(REPO_ROOT, entry.path);
const { metadata, errors: parsingErrors } = usercssMeta.parse(content, {
@@ -116,14 +118,9 @@ export const verifyMetadata = async (
};
};
const assertions = async (userstyle: string) => {
const assertions = (userstyle: string, userstyles: Userstyles) => {
const prefix = "https://github.com/catppuccin/userstyles";
const { userstyles } = await getUserstylesData().catch((err) => {
console.error(err);
Deno.exit(1);
});
if (!userstyles[userstyle]) {
log("Metadata section for this userstyle has not been added", {
file: "scripts/userstyles.yml",