refactor(scripts): pull in separate categories.schema.json (#1658)

This commit is contained in:
Hammy authored and GitHub committed 2025-03-20 08:39:11 -04:00
1 parent ef1a2be3c2
commit ac0f3f6677
8 files changed
+106 -99

No files matched your search

+3 -3
View File
@@ -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
*/
+4 -4
View File
@@ -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] };