refactor(scripts): pull in separate categories.schema.json (#1658)
This commit is contained in:
1 parent
ef1a2be3c2
commit
ac0f3f6677
8 files changed
+106
-99
No files matched your search
@@ -2,6 +2,7 @@
|
|||||||
"imports": {
|
"imports": {
|
||||||
"@/": "./scripts/",
|
"@/": "./scripts/",
|
||||||
"@actions/core": "npm:@actions/[email protected]",
|
"@actions/core": "npm:@actions/[email protected]",
|
||||||
|
"@catppuccin/catppuccin/": "https://raw.githubusercontent.com/catppuccin/catppuccin/de9d2cd963059753c8fd66fbb6f807be95c6cc1e/",
|
||||||
"@catppuccin/palette": "npm:@catppuccin/palette@^1.7.1",
|
"@catppuccin/palette": "npm:@catppuccin/palette@^1.7.1",
|
||||||
"@octokit/rest": "npm:@octokit/rest@^21.0.2",
|
"@octokit/rest": "npm:@octokit/rest@^21.0.2",
|
||||||
"@std/assert": "jsr:@std/assert@^1.0.9",
|
"@std/assert": "jsr:@std/assert@^1.0.9",
|
||||||
@@ -11,7 +12,6 @@
|
|||||||
"@std/path": "jsr:@std/path@^1.0.8",
|
"@std/path": "jsr:@std/path@^1.0.8",
|
||||||
"@std/yaml": "jsr:@std/yaml@^1.0.5",
|
"@std/yaml": "jsr:@std/yaml@^1.0.5",
|
||||||
"ajv": "npm:[email protected]",
|
"ajv": "npm:[email protected]",
|
||||||
"@catppuccin/catppuccin/": "https://raw.githubusercontent.com/catppuccin/catppuccin/703edd47016cebe4bcb5164d38e2007c0cf6f65a/",
|
|
||||||
"handlebars": "npm:[email protected]",
|
"handlebars": "npm:[email protected]",
|
||||||
"json-schema-to-typescript": "npm:json-schema-to-typescript@^15.0.3",
|
"json-schema-to-typescript": "npm:json-schema-to-typescript@^15.0.3",
|
||||||
"less": "npm:[email protected]",
|
"less": "npm:[email protected]",
|
||||||
@@ -30,7 +30,6 @@
|
|||||||
"ci:sync-maintainers": "deno run -A ./scripts/sync-maintainers/main.ts",
|
"ci:sync-maintainers": "deno run -A ./scripts/sync-maintainers/main.ts",
|
||||||
"ci:update-types": "deno run -A ./scripts/types/update-types.ts",
|
"ci:update-types": "deno run -A ./scripts/types/update-types.ts",
|
||||||
"ci:bump": "deno run -A ./scripts/bump-version/main.ts",
|
"ci:bump": "deno run -A ./scripts/bump-version/main.ts",
|
||||||
|
|
||||||
"lint": "deno run -A ./scripts/lint/main.ts",
|
"lint": "deno run -A ./scripts/lint/main.ts",
|
||||||
"lint:fix": "deno task lint --fix"
|
"lint:fix": "deno task lint --fix"
|
||||||
},
|
},
|
||||||
@@ -47,8 +46,12 @@
|
|||||||
},
|
},
|
||||||
"lint": {
|
"lint": {
|
||||||
"rules": {
|
"rules": {
|
||||||
"tags": ["recommended"],
|
"tags": [
|
||||||
"include": ["verbatim-module-syntax"]
|
"recommended"
|
||||||
|
],
|
||||||
|
"include": [
|
||||||
|
"verbatim-module-syntax"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
"npm:@catppuccin/palette@^1.7.1": "1.7.1",
|
"npm:@catppuccin/palette@^1.7.1": "1.7.1",
|
||||||
"npm:@octokit/rest@^21.0.2": "21.0.2_@[email protected]",
|
"npm:@octokit/rest@^21.0.2": "21.0.2_@[email protected]",
|
||||||
"npm:@types/less@*": "3.0.7",
|
"npm:@types/less@*": "3.0.7",
|
||||||
|
"npm:@types/node@*": "22.5.4",
|
||||||
"npm:[email protected]": "8.17.1",
|
"npm:[email protected]": "8.17.1",
|
||||||
"npm:[email protected]": "4.7.8",
|
"npm:[email protected]": "4.7.8",
|
||||||
"npm:json-schema-to-typescript@^15.0.3": "15.0.3",
|
"npm:json-schema-to-typescript@^15.0.3": "15.0.3",
|
||||||
@@ -244,6 +245,12 @@
|
|||||||
"@types/[email protected]": {
|
"@types/[email protected]": {
|
||||||
"integrity": "sha512-lfx+dftrEZcdBPczf9d0Qv0x+j/rfNCMuC6OcfXmO8gkfeNAY88PgKUbvG56whcN23gc27yenwF6oJZXGFpYxg=="
|
"integrity": "sha512-lfx+dftrEZcdBPczf9d0Qv0x+j/rfNCMuC6OcfXmO8gkfeNAY88PgKUbvG56whcN23gc27yenwF6oJZXGFpYxg=="
|
||||||
},
|
},
|
||||||
|
"@types/[email protected]": {
|
||||||
|
"integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==",
|
||||||
|
"dependencies": [
|
||||||
|
"undici-types"
|
||||||
|
]
|
||||||
|
},
|
||||||
"[email protected]": {
|
"[email protected]": {
|
||||||
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
|
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
@@ -970,6 +977,9 @@
|
|||||||
"[email protected]": {
|
"[email protected]": {
|
||||||
"integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ=="
|
"integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ=="
|
||||||
},
|
},
|
||||||
|
"[email protected]": {
|
||||||
|
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw=="
|
||||||
|
},
|
||||||
"[email protected]": {
|
"[email protected]": {
|
||||||
"integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==",
|
"integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==",
|
||||||
"dependencies": [
|
"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"
|
"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": {
|
"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"
|
"https://raw.githubusercontent.com/openstyles/stylus/8fe35a4b90d85fb911bd7aa1deab4e4733c31150/src/js/sections-util.js": "387e164ad40bc76048dccaafce6a032ac745616e7fc29f1873d7da33f5739502"
|
||||||
},
|
},
|
||||||
"workspace": {
|
"workspace": {
|
||||||
|
|||||||
@@ -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",
|
type: "json",
|
||||||
};
|
};
|
||||||
import USERSTYLES_SCHEMA from "@/userstyles.schema.json" with {
|
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 const REPO_ROOT = path.join(ROOT, "..");
|
||||||
|
|
||||||
export { PORTS_SCHEMA, USERSTYLES_SCHEMA };
|
export { CATEGORIES_SCHEMA, USERSTYLES_SCHEMA };
|
||||||
@@ -7,7 +7,7 @@ import { generateStyleReadmes } from "@/generate/readme-styles.ts";
|
|||||||
import { writeWithPreamble } from "@/generate/utils.ts";
|
import { writeWithPreamble } from "@/generate/utils.ts";
|
||||||
import {
|
import {
|
||||||
getAuthenticatedOctokit,
|
getAuthenticatedOctokit,
|
||||||
getPortsData,
|
getCategoriesData,
|
||||||
getUserstylesData,
|
getUserstylesData,
|
||||||
getUserstylesTeamMembers,
|
getUserstylesTeamMembers,
|
||||||
} from "@/utils.ts";
|
} from "@/utils.ts";
|
||||||
@@ -19,12 +19,12 @@ if (!Deno.env.get("CI")) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const userstylesData = getUserstylesData();
|
const userstylesData = getUserstylesData();
|
||||||
const portsData = await getPortsData();
|
const categoriesData = await getCategoriesData();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the main README.md, listing all ports as a table of contents
|
* 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
|
* Generate README.md files for each style
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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 { REPO_ROOT } from "@/constants.ts";
|
||||||
|
|
||||||
import * as path from "@std/path";
|
import * as path from "@std/path";
|
||||||
@@ -14,9 +14,9 @@ type MappedPorts = {
|
|||||||
|
|
||||||
export async function generateMainReadme(
|
export async function generateMainReadme(
|
||||||
userstyles: UserstylesSchema.Userstyles,
|
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)
|
const categorized = Object.entries(userstyles)
|
||||||
.reduce((acc, [slug, { categories, ...port }]) => {
|
.reduce((acc, [slug, { categories, ...port }]) => {
|
||||||
@@ -37,7 +37,7 @@ export async function generateMainReadme(
|
|||||||
return acc;
|
return acc;
|
||||||
}, {} as MappedPorts);
|
}, {} as MappedPorts);
|
||||||
|
|
||||||
const portListData = portsData.categories
|
const portListData = categoriesData
|
||||||
.filter((category) => categorized[category.key] !== undefined)
|
.filter((category) => categorized[category.key] !== undefined)
|
||||||
.map((category) => {
|
.map((category) => {
|
||||||
return { meta: category, ports: categorized[category.key] };
|
return { meta: category, ports: categorized[category.key] };
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
export * as UserstylesSchema from "@/types/userstyles.d.ts";
|
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";
|
||||||
@@ -14,7 +14,9 @@
|
|||||||
"title": "Userstyle",
|
"title": "Userstyle",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "The directory of the userstyle.",
|
"description": "The directory of the userstyle.",
|
||||||
"examples": ["youtube"],
|
"examples": [
|
||||||
|
"youtube"
|
||||||
|
],
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": {
|
"name": {
|
||||||
@@ -28,11 +30,18 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"minItems": 2,
|
"minItems": 2,
|
||||||
"examples": [["AniList", "AniChart"]]
|
"examples": [
|
||||||
|
[
|
||||||
|
"AniList",
|
||||||
|
"AniChart"
|
||||||
|
]
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"examples": ["YouTube"]
|
"examples": [
|
||||||
|
"YouTube"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -64,14 +73,19 @@
|
|||||||
"lavender",
|
"lavender",
|
||||||
"text"
|
"text"
|
||||||
],
|
],
|
||||||
"examples": ["pink"]
|
"examples": [
|
||||||
|
"pink"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"icon": {
|
"icon": {
|
||||||
"$id": "#userstyles/userstyle/icon",
|
"$id": "#userstyles/userstyle/icon",
|
||||||
"title": "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.",
|
"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",
|
"type": "string",
|
||||||
"examples": ["twitch", "twitch.svg"]
|
"examples": [
|
||||||
|
"twitch",
|
||||||
|
"twitch.svg"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"readme": {
|
"readme": {
|
||||||
"$id": "#userstyles/userstyle/readme",
|
"$id": "#userstyles/userstyle/readme",
|
||||||
@@ -92,12 +106,17 @@
|
|||||||
},
|
},
|
||||||
"minItems": 2,
|
"minItems": 2,
|
||||||
"examples": [
|
"examples": [
|
||||||
["https://anilist.co", "https://anichart.net"]
|
[
|
||||||
|
"https://anilist.co",
|
||||||
|
"https://anichart.net"
|
||||||
|
]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"examples": ["https://github.com"]
|
"examples": [
|
||||||
|
"https://github.com"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -128,11 +147,16 @@
|
|||||||
"description": "An answer to the question about the userstyle."
|
"description": "An answer to the question about the userstyle."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["question", "answer"]
|
"required": [
|
||||||
|
"question",
|
||||||
|
"answer"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["app-link"]
|
"required": [
|
||||||
|
"app-link"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"current-maintainers": {
|
"current-maintainers": {
|
||||||
"$id": "#userstyles/userstyle/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."
|
"description": "The GitHub profile link of the collaborator to show in the userstyle README."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["url"]
|
"required": [
|
||||||
|
"url"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"categories": {
|
"categories": {
|
||||||
"$id": "#categories",
|
"$id": "#categories",
|
||||||
"type": "array",
|
"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,
|
"minItems": 1,
|
||||||
"maxItems": 3,
|
"maxItems": 3,
|
||||||
"items": {
|
"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"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+40
-32
@@ -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 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 yaml from "@std/yaml";
|
||||||
import * as path from "@std/path";
|
import * as path from "@std/path";
|
||||||
@@ -19,23 +23,26 @@ export function validateYaml<T>(
|
|||||||
content: string,
|
content: string,
|
||||||
schema: Schema,
|
schema: Schema,
|
||||||
file: string,
|
file: string,
|
||||||
|
options?: Ajv.Options,
|
||||||
): T {
|
): T {
|
||||||
const ajv = new Ajv.default();
|
const ajv = new Ajv.default(options);
|
||||||
const validate = ajv.compile<T>(schema);
|
const validate = ajv.compile<T>(schema);
|
||||||
const data = yaml.parse(content);
|
const data = yaml.parse(content);
|
||||||
|
|
||||||
if (!validate(data)) {
|
if (!validate(data)) {
|
||||||
log.error(
|
log.error(
|
||||||
validate.errors!.map((err) =>
|
validate
|
||||||
sprintf(
|
.errors!.map((err) =>
|
||||||
"%s %s%s",
|
sprintf(
|
||||||
err.instancePath.slice(1).replaceAll("/", "."),
|
"%s %s%s",
|
||||||
err.message,
|
err.instancePath.slice(1).replaceAll("/", "."),
|
||||||
err.params.allowedValues
|
err.message,
|
||||||
? ` (${JSON.stringify(err.params.allowedValues, undefined)})`
|
err.params.allowedValues
|
||||||
: "",
|
? ` (${JSON.stringify(err.params.allowedValues, undefined)})`
|
||||||
|
: "",
|
||||||
|
)
|
||||||
)
|
)
|
||||||
).join(" and "),
|
.join(" and "),
|
||||||
{
|
{
|
||||||
file,
|
file,
|
||||||
},
|
},
|
||||||
@@ -60,6 +67,7 @@ export function getUserstylesData(): Userstyles {
|
|||||||
content,
|
content,
|
||||||
USERSTYLES_SCHEMA,
|
USERSTYLES_SCHEMA,
|
||||||
"scripts/userstyles.yml",
|
"scripts/userstyles.yml",
|
||||||
|
{ schemas: [CATEGORIES_SCHEMA] },
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const field of ["userstyles", "collaborators"] as const) {
|
for (const field of ["userstyles", "collaborators"] as const) {
|
||||||
@@ -76,15 +84,14 @@ export function getUserstylesData(): Userstyles {
|
|||||||
if (err instanceof Error && err.name === "SyntaxError") {
|
if (err instanceof Error && err.name === "SyntaxError") {
|
||||||
const groups =
|
const groups =
|
||||||
/(?<message>.*) at line (?<line>\d+), column (?<column>\d+):[\S\s]*/
|
/(?<message>.*) at line (?<line>\d+), column (?<column>\d+):[\S\s]*/
|
||||||
.exec(err.message)?.groups;
|
.exec(
|
||||||
log.error(
|
err.message,
|
||||||
groups!.message,
|
)?.groups;
|
||||||
{
|
log.error(groups!.message, {
|
||||||
file: "scripts/userstyles.yml",
|
file: "scripts/userstyles.yml",
|
||||||
startLine: Number(groups!.line),
|
startLine: Number(groups!.line),
|
||||||
content: content,
|
content: content,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
@@ -97,15 +104,17 @@ export function getUserstylesData(): Userstyles {
|
|||||||
* Utility function that calls {@link validateYaml} on the ports.yml file.
|
* Utility function that calls {@link validateYaml} on the ports.yml file.
|
||||||
* Fails when data.userstyles is undefined.
|
* Fails when data.userstyles is undefined.
|
||||||
*/
|
*/
|
||||||
export async function getPortsData(): Promise<PortsSchema.PortsSchema> {
|
export async function getCategoriesData(): Promise<
|
||||||
|
CategoriesSchema.CategoryDefinitions
|
||||||
|
> {
|
||||||
const content = await fetch(
|
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());
|
).then((res) => res.text());
|
||||||
|
|
||||||
const data = validateYaml<PortsSchema.PortsSchema>(
|
const data = validateYaml<CategoriesSchema.CategoryDefinitions>(
|
||||||
content,
|
content,
|
||||||
PORTS_SCHEMA,
|
CATEGORIES_SCHEMA,
|
||||||
"ports.yml",
|
"categories.yml",
|
||||||
);
|
);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
@@ -160,12 +169,11 @@ export async function getUserstylesTeamMembers(
|
|||||||
octokit: Octokit,
|
octokit: Octokit,
|
||||||
team: UserstylesTeam,
|
team: UserstylesTeam,
|
||||||
): Promise<string[]> {
|
): Promise<string[]> {
|
||||||
const members = await octokit.teams
|
const members = await octokit.teams.listMembersInOrg({
|
||||||
.listMembersInOrg({
|
org: "catppuccin",
|
||||||
org: "catppuccin",
|
team_slug: team,
|
||||||
team_slug: team,
|
per_page: 100,
|
||||||
per_page: 100,
|
});
|
||||||
});
|
|
||||||
return members.data.map(({ login }) => login.toLowerCase());
|
return members.data.map(({ login }) => login.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user