ci(lint): init (#318)

* ci(lint): init

This finishes what #132 started, supersedes #317 (thanks for the stylelint setup!)

* ci(lint): add stylelint

Co-authored-by: uncenter <[email protected]>
This commit is contained in:
winstonanduncenter authored and GitHub committed 2023-11-16 22:45:25 +01:00
1 parent 6496c51291
commit ff8da1e094
13 files changed
+1484 -73

No files matched your search

-6
View File
@@ -1,6 +0,0 @@
import schema from "../userstyles.schema.json" assert { type: "json" };
import portsSchema from "catppuccin-repo/resources/ports.schema.json" assert {
type: "json",
};
export { portsSchema, schema };
@@ -1,9 +1,10 @@
#!/usr/bin/env -S deno run --allow-env --allow-read --allow-write --allow-net
import * as path from "std/path/mod.ts";
import { parse as parseYaml } from "std/yaml/mod.ts";
import Ajv from "ajv";
import { portsSchema, schema } from "./deps.ts";
import { portsSchema, REPO_ROOT, schema } from "@/deps.ts";
import {
ApplicationLink,
@@ -15,10 +16,9 @@ import {
Usage,
Userstyle,
Userstyles,
} from "./types.d.ts";
} from "@/types.d.ts";
const ROOT = new URL(".", import.meta.url).pathname;
const REPO_ROOT = path.join(ROOT, "../..");
const ISSUE_PREFIX = "lbl:";
type Metadata = {
@@ -41,7 +41,7 @@ const validate = ajv.compile<Metadata>(schema);
const validatePorts = ajv.compile<PortMetadata>(portsSchema);
const userstylesYaml = Deno.readTextFileSync(
path.join(ROOT, "../userstyles.yml"),
path.join(REPO_ROOT, "src/userstyles.yml"),
);
const userstylesData = parseYaml(userstylesYaml);
if (!validate(userstylesData)) {
-78
View File
@@ -1,78 +0,0 @@
#!/usr/bin/env -S deno run --allow-read --allow-net --allow-env
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";
import { schema } from "./deps.ts";
import { Userstyle, UserstylesSchema } from "./types.d.ts";
const octokit = new Octokit({ auth: Deno.env.get("GITHUB_TOKEN") });
const team = { org: "catppuccin", team_slug: "userstyles-maintainers" };
const ROOT = new URL(".", import.meta.url).pathname;
const ajv = new Ajv.default();
const validate = ajv.compile<UserstylesSchema>(schema);
const userstylesYaml = Deno.readTextFileSync(
path.join(ROOT, "../userstyles.yml"),
);
const userstylesData = parseYaml(userstylesYaml);
if (!validate(userstylesData)) {
console.error(validate.errors);
Deno.exit(1);
}
if (userstylesData.userstyles === undefined) {
Deno.exit(1);
}
// lowercase usernames of all the "current-maintainers" in the file
const maintainers = [
...new Set(
Object.values(userstylesData.userstyles).flatMap((style: Userstyle) =>
style.readme["current-maintainers"].map((m) => {
const username = m.url.split("github.com/")?.pop();
// check that they follow github.com/username pattern
assert.assertExists(username);
return username.toLowerCase();
})
),
),
];
// lowercase usernames of all maintainers in the current GH team
const teamMembers = await octokit.teams
.listMembersInOrg({
...team,
per_page: 100,
})
.then((res) => res.data.map((m) => m.login.toLowerCase()));
const syncMaintainers = async () => {
if (!maintainers) return;
if (assert.equal(maintainers, teamMembers)) {
console.log("Maintainers are in sync");
return;
}
const toAdd = maintainers.filter((m) => !teamMembers.includes(m));
const toRemove = teamMembers.filter((m) => !maintainers.includes(m));
for (const m of toAdd) {
await octokit.teams.addOrUpdateMembershipForUserInOrg({
...team,
username: m,
});
}
for (const m of toRemove) {
await octokit.teams.removeMembershipForUserInOrg({
...team,
username: m,
});
}
};
await syncMaintainers();
-2
View File
@@ -1,2 +0,0 @@
export * from "../types/userstyles.d.ts";
export type { Categories as PortCategories } from "catppuccin-repo/resources/generate/types.d.ts";