diff --git a/deno.json b/deno.json index 678a75c3..7d250bf5 100644 --- a/deno.json +++ b/deno.json @@ -2,6 +2,7 @@ "imports": { "@/": "./scripts/", "@actions/core": "npm:@actions/core@1.11.1", + "@catppuccin/catppuccin/": "https://raw.githubusercontent.com/catppuccin/catppuccin/de9d2cd963059753c8fd66fbb6f807be95c6cc1e/", "@catppuccin/palette": "npm:@catppuccin/palette@^1.7.1", "@octokit/rest": "npm:@octokit/rest@^21.0.2", "@std/assert": "jsr:@std/assert@^1.0.9", @@ -11,7 +12,6 @@ "@std/path": "jsr:@std/path@^1.0.8", "@std/yaml": "jsr:@std/yaml@^1.0.5", "ajv": "npm:ajv@8.17.1", - "@catppuccin/catppuccin/": "https://raw.githubusercontent.com/catppuccin/catppuccin/703edd47016cebe4bcb5164d38e2007c0cf6f65a/", "handlebars": "npm:handlebars@4.7.8", "json-schema-to-typescript": "npm:json-schema-to-typescript@^15.0.3", "less": "npm:less@4.2.1", @@ -30,7 +30,6 @@ "ci:sync-maintainers": "deno run -A ./scripts/sync-maintainers/main.ts", "ci:update-types": "deno run -A ./scripts/types/update-types.ts", "ci:bump": "deno run -A ./scripts/bump-version/main.ts", - "lint": "deno run -A ./scripts/lint/main.ts", "lint:fix": "deno task lint --fix" }, @@ -47,8 +46,12 @@ }, "lint": { "rules": { - "tags": ["recommended"], - "include": ["verbatim-module-syntax"] + "tags": [ + "recommended" + ], + "include": [ + "verbatim-module-syntax" + ] } } } diff --git a/deno.lock b/deno.lock index 3223ab7d..c39361a5 100644 --- a/deno.lock +++ b/deno.lock @@ -12,6 +12,7 @@ "npm:@catppuccin/palette@^1.7.1": "1.7.1", "npm:@octokit/rest@^21.0.2": "21.0.2_@octokit+core@6.1.2", "npm:@types/less@*": "3.0.7", + "npm:@types/node@*": "22.5.4", "npm:ajv@8.17.1": "8.17.1", "npm:handlebars@4.7.8": "4.7.8", "npm:json-schema-to-typescript@^15.0.3": "15.0.3", @@ -244,6 +245,12 @@ "@types/lodash@4.17.13": { "integrity": "sha512-lfx+dftrEZcdBPczf9d0Qv0x+j/rfNCMuC6OcfXmO8gkfeNAY88PgKUbvG56whcN23gc27yenwF6oJZXGFpYxg==" }, + "@types/node@22.5.4": { + "integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==", + "dependencies": [ + "undici-types" + ] + }, "ajv@8.17.1": { "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dependencies": [ @@ -970,6 +977,9 @@ "uglify-js@3.19.3": { "integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==" }, + "undici-types@6.19.8": { + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" + }, "undici@5.28.4": { "integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", "dependencies": [ @@ -1006,7 +1016,7 @@ "https://github.com/openstyles/stylus/raw/8fe35a4b90d85fb911bd7aa1deab4e4733c31150/src/js/sections-util.js": "https://raw.githubusercontent.com/openstyles/stylus/8fe35a4b90d85fb911bd7aa1deab4e4733c31150/src/js/sections-util.js" }, "remote": { - "https://raw.githubusercontent.com/catppuccin/catppuccin/703edd47016cebe4bcb5164d38e2007c0cf6f65a/resources/ports.schema.json": "8282601df9f1c40a3e9f6448142e43300a37beca8e038bac289b3daef659aadc", + "https://raw.githubusercontent.com/catppuccin/catppuccin/de9d2cd963059753c8fd66fbb6f807be95c6cc1e/resources/categories.schema.json": "56966507d145608cb3dc41642a32eba0a4e18bfcf3c32e92aed6113951b74dec", "https://raw.githubusercontent.com/openstyles/stylus/8fe35a4b90d85fb911bd7aa1deab4e4733c31150/src/js/sections-util.js": "387e164ad40bc76048dccaafce6a032ac745616e7fc29f1873d7da33f5739502" }, "workspace": { diff --git a/scripts/constants.ts b/scripts/constants.ts index 83aab78f..0189475e 100644 --- a/scripts/constants.ts +++ b/scripts/constants.ts @@ -1,4 +1,4 @@ -import PORTS_SCHEMA from "@catppuccin/catppuccin/resources/ports.schema.json" with { +import CATEGORIES_SCHEMA from "@catppuccin/catppuccin/resources/categories.schema.json" with { type: "json", }; import USERSTYLES_SCHEMA from "@/userstyles.schema.json" with { @@ -15,4 +15,4 @@ if (!ROOT) throw new Error("ROOT was not located."); */ export const REPO_ROOT = path.join(ROOT, ".."); -export { PORTS_SCHEMA, USERSTYLES_SCHEMA }; +export { CATEGORIES_SCHEMA, USERSTYLES_SCHEMA }; diff --git a/scripts/generate/main.ts b/scripts/generate/main.ts index 4195a1af..a86b9fde 100755 --- a/scripts/generate/main.ts +++ b/scripts/generate/main.ts @@ -7,7 +7,7 @@ import { generateStyleReadmes } from "@/generate/readme-styles.ts"; import { writeWithPreamble } from "@/generate/utils.ts"; import { getAuthenticatedOctokit, - getPortsData, + getCategoriesData, getUserstylesData, getUserstylesTeamMembers, } from "@/utils.ts"; @@ -19,12 +19,12 @@ if (!Deno.env.get("CI")) { } const userstylesData = getUserstylesData(); -const portsData = await getPortsData(); +const categoriesData = await getCategoriesData(); /** * Generate the main README.md, listing all ports as a table of contents */ -await generateMainReadme(userstylesData.userstyles, portsData); +await generateMainReadme(userstylesData.userstyles, categoriesData); /** * Generate README.md files for each style */ diff --git a/scripts/generate/readme-repo.ts b/scripts/generate/readme-repo.ts index d1688a93..dd4b092e 100644 --- a/scripts/generate/readme-repo.ts +++ b/scripts/generate/readme-repo.ts @@ -1,4 +1,4 @@ -import type { PortsSchema, UserstylesSchema } from "@/types/mod.ts"; +import type { CategoriesSchema, UserstylesSchema } from "@/types/mod.ts"; import { REPO_ROOT } from "@/constants.ts"; import * as path from "@std/path"; @@ -14,9 +14,9 @@ type MappedPorts = { export async function generateMainReadme( userstyles: UserstylesSchema.Userstyles, - portsData: PortsSchema.PortsSchema, + categoriesData: CategoriesSchema.CategoryDefinitions, ) { - if (!portsData.categories) throw ("Ports data is missing categories"); + if (!categoriesData) throw ("Categories data is missing categories"); const categorized = Object.entries(userstyles) .reduce((acc, [slug, { categories, ...port }]) => { @@ -37,7 +37,7 @@ export async function generateMainReadme( return acc; }, {} as MappedPorts); - const portListData = portsData.categories + const portListData = categoriesData .filter((category) => categorized[category.key] !== undefined) .map((category) => { return { meta: category, ports: categorized[category.key] }; diff --git a/scripts/types/mod.ts b/scripts/types/mod.ts index b424f663..403c49ee 100644 --- a/scripts/types/mod.ts +++ b/scripts/types/mod.ts @@ -1,2 +1,2 @@ export * as UserstylesSchema from "@/types/userstyles.d.ts"; -export * as PortsSchema from "@catppuccin/catppuccin/resources/types/ports.d.ts"; +export * as CategoriesSchema from "@catppuccin/catppuccin/resources/types/categories.d.ts"; \ No newline at end of file diff --git a/scripts/userstyles.schema.json b/scripts/userstyles.schema.json index 731c1d8e..25e91546 100644 --- a/scripts/userstyles.schema.json +++ b/scripts/userstyles.schema.json @@ -14,7 +14,9 @@ "title": "Userstyle", "type": "object", "description": "The directory of the userstyle.", - "examples": ["youtube"], + "examples": [ + "youtube" + ], "additionalProperties": false, "properties": { "name": { @@ -28,11 +30,18 @@ "type": "string" }, "minItems": 2, - "examples": [["AniList", "AniChart"]] + "examples": [ + [ + "AniList", + "AniChart" + ] + ] }, { "type": "string", - "examples": ["YouTube"] + "examples": [ + "YouTube" + ] } ] }, @@ -64,14 +73,19 @@ "lavender", "text" ], - "examples": ["pink"] + "examples": [ + "pink" + ] }, "icon": { "$id": "#userstyles/userstyle/icon", "title": "Icon", "description": "The icon to use on the website. This should be the same name as the SVG file on https://simpleicons.org/. If a `.svg` suffix is present, it's taken from the local website repository resources.", "type": "string", - "examples": ["twitch", "twitch.svg"] + "examples": [ + "twitch", + "twitch.svg" + ] }, "readme": { "$id": "#userstyles/userstyle/readme", @@ -92,12 +106,17 @@ }, "minItems": 2, "examples": [ - ["https://anilist.co", "https://anichart.net"] + [ + "https://anilist.co", + "https://anichart.net" + ] ] }, { "type": "string", - "examples": ["https://github.com"] + "examples": [ + "https://github.com" + ] } ] }, @@ -128,11 +147,16 @@ "description": "An answer to the question about the userstyle." } }, - "required": ["question", "answer"] + "required": [ + "question", + "answer" + ] } } }, - "required": ["app-link"] + "required": [ + "app-link" + ] }, "current-maintainers": { "$id": "#userstyles/userstyle/current-maintainers", @@ -183,58 +207,20 @@ "description": "The GitHub profile link of the collaborator to show in the userstyle README." } }, - "required": ["url"] + "required": [ + "url" + ] } }, "categories": { "$id": "#categories", "type": "array", + "description": "The categories that fit the port the most, the first category is the primary category which the port will be listed under on the README.", "minItems": 1, "maxItems": 3, "items": { - "$ref": "#/$defs/category" + "$ref": "https://raw.githubusercontent.com/catppuccin/catppuccin/refs/heads/main/resources/categories.schema.json#/$defs/category" } - }, - "category": { - "$id": "#category", - "type": "string", - "enum": [ - "3d_modelling", - "analytics", - "application_launcher", - "artificial_intelligence", - "boot_loader", - "browser", - "browser_extension", - "cli", - "code_editor", - "desktop_environment", - "development", - "discussion_forum", - "document_viewer", - "education", - "email_client", - "entertainment", - "file_manager", - "game", - "game_development", - "health_and_fitness", - "library", - "music", - "note_taking", - "notification_daemon", - "photo_and_video", - "productivity", - "search_engine", - "self_hosted", - "social_networking", - "system", - "terminal", - "translation_tool", - "userstyle", - "wiki", - "window_manager" - ] } } } diff --git a/scripts/utils.ts b/scripts/utils.ts index 398f721e..bbbee3aa 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -1,6 +1,10 @@ -import type { PortsSchema, UserstylesSchema } from "@/types/mod.ts"; +import type { CategoriesSchema, UserstylesSchema } from "@/types/mod.ts"; import type { SetRequired } from "type-fest/source/set-required.d.ts"; -import { PORTS_SCHEMA, REPO_ROOT, USERSTYLES_SCHEMA } from "@/constants.ts"; +import { + CATEGORIES_SCHEMA, + REPO_ROOT, + USERSTYLES_SCHEMA, +} from "@/constants.ts"; import * as yaml from "@std/yaml"; import * as path from "@std/path"; @@ -19,23 +23,26 @@ export function validateYaml( content: string, schema: Schema, file: string, + options?: Ajv.Options, ): T { - const ajv = new Ajv.default(); + const ajv = new Ajv.default(options); const validate = ajv.compile(schema); const data = yaml.parse(content); if (!validate(data)) { log.error( - validate.errors!.map((err) => - sprintf( - "%s %s%s", - err.instancePath.slice(1).replaceAll("/", "."), - err.message, - err.params.allowedValues - ? ` (${JSON.stringify(err.params.allowedValues, undefined)})` - : "", + validate + .errors!.map((err) => + sprintf( + "%s %s%s", + err.instancePath.slice(1).replaceAll("/", "."), + err.message, + err.params.allowedValues + ? ` (${JSON.stringify(err.params.allowedValues, undefined)})` + : "", + ) ) - ).join(" and "), + .join(" and "), { file, }, @@ -60,6 +67,7 @@ export function getUserstylesData(): Userstyles { content, USERSTYLES_SCHEMA, "scripts/userstyles.yml", + { schemas: [CATEGORIES_SCHEMA] }, ); for (const field of ["userstyles", "collaborators"] as const) { @@ -76,15 +84,14 @@ export function getUserstylesData(): Userstyles { if (err instanceof Error && err.name === "SyntaxError") { const groups = /(?.*) at line (?\d+), column (?\d+):[\S\s]*/ - .exec(err.message)?.groups; - log.error( - groups!.message, - { - file: "scripts/userstyles.yml", - startLine: Number(groups!.line), - content: content, - }, - ); + .exec( + err.message, + )?.groups; + log.error(groups!.message, { + file: "scripts/userstyles.yml", + startLine: Number(groups!.line), + content: content, + }); } else { throw err; } @@ -97,15 +104,17 @@ export function getUserstylesData(): Userstyles { * Utility function that calls {@link validateYaml} on the ports.yml file. * Fails when data.userstyles is undefined. */ -export async function getPortsData(): Promise { +export async function getCategoriesData(): Promise< + CategoriesSchema.CategoryDefinitions +> { const content = await fetch( - "https://raw.githubusercontent.com/catppuccin/catppuccin/main/resources/ports.yml", + "https://raw.githubusercontent.com/catppuccin/catppuccin/de9d2cd963059753c8fd66fbb6f807be95c6cc1e/resources/categories.yml", ).then((res) => res.text()); - const data = validateYaml( + const data = validateYaml( content, - PORTS_SCHEMA, - "ports.yml", + CATEGORIES_SCHEMA, + "categories.yml", ); return data; @@ -160,12 +169,11 @@ export async function getUserstylesTeamMembers( octokit: Octokit, team: UserstylesTeam, ): Promise { - const members = await octokit.teams - .listMembersInOrg({ - org: "catppuccin", - team_slug: team, - per_page: 100, - }); + const members = await octokit.teams.listMembersInOrg({ + org: "catppuccin", + team_slug: team, + per_page: 100, + }); return members.data.map(({ login }) => login.toLowerCase()); }