ci(lint): validate name metadata (#402)
Co-authored-by: winston <[email protected]>
This commit is contained in:
1 parent
8da437f9f2
commit
5bb6f6db1e
14 files changed
+96
-67
No files matched your search
@@ -28,7 +28,7 @@ for await (const entry of stylesheets) {
|
||||
const content = await Deno.readTextFile(entry.path);
|
||||
|
||||
// verify the usercss metadata
|
||||
const { globalVars, isLess } = verifyMetadata(entry, content, repo);
|
||||
const { globalVars, isLess } = await verifyMetadata(entry, content, repo);
|
||||
// don't attempt to compile or lint non-less files
|
||||
if (!isLess) continue;
|
||||
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
// @deno-types="@/types/usercss-meta.d.ts";
|
||||
import usercssMeta from "usercss-meta";
|
||||
import { log } from "@/lint/logger.ts";
|
||||
import * as color from "std/fmt/colors.ts";
|
||||
import { sprintf } from "std/fmt/printf.ts";
|
||||
import type { WalkEntry } from "std/fs/walk.ts";
|
||||
import { relative } from "std/path/mod.ts";
|
||||
import { REPO_ROOT } from "@/deps.ts";
|
||||
|
||||
export const verifyMetadata = (
|
||||
import { REPO_ROOT } from "@/deps.ts";
|
||||
import { log } from "@/lint/logger.ts";
|
||||
import { getUserstylesData } from "@/utils.ts";
|
||||
|
||||
export const verifyMetadata = async (
|
||||
entry: WalkEntry,
|
||||
content: string,
|
||||
repo: string,
|
||||
) => {
|
||||
const assert = assertions(repo);
|
||||
const assert = await assertions(repo);
|
||||
const file = relative(REPO_ROOT, entry.path);
|
||||
|
||||
const { metadata, errors: parsingErrors } = usercssMeta.parse(content, {
|
||||
@@ -67,9 +69,20 @@ export const verifyMetadata = (
|
||||
};
|
||||
};
|
||||
|
||||
const assertions = (repo: string) => {
|
||||
const assertions = async (repo: string) => {
|
||||
const prefix = "https://github.com/catppuccin/userstyles";
|
||||
|
||||
const { userstyles } = await getUserstylesData().catch((err) => {
|
||||
console.error(err);
|
||||
Deno.exit(1);
|
||||
});
|
||||
|
||||
return {
|
||||
name: `${
|
||||
Array.isArray(userstyles[repo].name)
|
||||
? (userstyles[repo].name as string[]).join("/")
|
||||
: userstyles[repo].name
|
||||
} Catppuccin`,
|
||||
namespace: `github.com/catppuccin/userstyles/styles/${repo}`,
|
||||
author: "Catppuccin",
|
||||
license: "MIT",
|
||||
|
||||
Reference in new issue
Block a user