build: refactor & use handlebars for generate templating (#343)
This commit is contained in:
1 parent
b1f864c1c8
commit
f48eba6354
23 files changed
+681
-408
No files matched your search
@@ -1,28 +1,21 @@
|
||||
#!/usr/bin/env -S deno run --allow-read --allow-net --allow-env
|
||||
#!/usr/bin/env -S deno run -A
|
||||
|
||||
import * as assert from "std/assert/mod.ts";
|
||||
import * as path from "std/path/mod.ts";
|
||||
import { parse as parseYaml } from "std/yaml/mod.ts";
|
||||
import Ajv from "ajv";
|
||||
import { Octokit } from "@octokit/rest";
|
||||
|
||||
import { REPO_ROOT, schema } from "@/deps.ts";
|
||||
import { Userstyle, UserstylesSchema } from "@/types.d.ts";
|
||||
import { REPO_ROOT, userStylesSchema } from "@/deps.ts";
|
||||
import type { UserStylesSchema } from "../types/mod.d.ts";
|
||||
import { validateYaml } from "@/utils.ts";
|
||||
import { UserstylesSchema } from "@/types/userstyles.d.ts";
|
||||
|
||||
const octokit = new Octokit({ auth: Deno.env.get("GITHUB_TOKEN") });
|
||||
const team = { org: "catppuccin", team_slug: "userstyles-maintainers" };
|
||||
|
||||
const ajv = new Ajv.default();
|
||||
const validate = ajv.compile<UserstylesSchema>(schema);
|
||||
|
||||
const userstylesYaml = Deno.readTextFileSync(
|
||||
path.join(REPO_ROOT, "scripts/userstyles.yml"),
|
||||
const userstylesData = await validateYaml<UserstylesSchema>(
|
||||
Deno.readTextFileSync(path.join(REPO_ROOT, "scripts/userstyles.yml")),
|
||||
userStylesSchema,
|
||||
);
|
||||
const userstylesData = parseYaml(userstylesYaml);
|
||||
if (!validate(userstylesData)) {
|
||||
console.error(validate.errors);
|
||||
Deno.exit(1);
|
||||
}
|
||||
if (userstylesData.userstyles === undefined) {
|
||||
Deno.exit(1);
|
||||
}
|
||||
@@ -30,7 +23,9 @@ if (userstylesData.userstyles === undefined) {
|
||||
// lowercase usernames of all the "current-maintainers" in the file
|
||||
const maintainers = [
|
||||
...new Set(
|
||||
Object.values(userstylesData.userstyles).flatMap((style: Userstyle) =>
|
||||
Object.values(userstylesData.userstyles).flatMap((
|
||||
style: UserStylesSchema.Userstyle,
|
||||
) =>
|
||||
style.readme["current-maintainers"].map((m) => {
|
||||
const username = m.url.split("github.com/")?.pop();
|
||||
// check that they follow github.com/username pattern
|
||||
|
||||
Reference in new issue
Block a user