refactor(scripts): cleanup & enforce code style (#1388)
This commit is contained in:
1 parent
7db9b234c1
commit
5d74d700a2
23 files changed
+290
-270
No files matched your search
@@ -1,20 +1,21 @@
|
||||
import { join } from "@std/path";
|
||||
import type { PortsSchema, UserstylesSchema } from "@/types/mod.ts";
|
||||
import { REPO_ROOT } from "@/constants.ts";
|
||||
|
||||
import * as path from "@std/path";
|
||||
import Handlebars from "handlebars";
|
||||
|
||||
import { REPO_ROOT } from "@/deps.ts";
|
||||
import { PortsSchema, UserStylesSchema } from "@/types/mod.ts";
|
||||
import { updateFile, updateReadme } from "@/generate/utils.ts";
|
||||
import { updateReadme } from "@/generate/utils.ts";
|
||||
|
||||
type MappedPorts = {
|
||||
[k: string]: (
|
||||
UserStylesSchema.Userstyle & { path: string }
|
||||
UserstylesSchema.Userstyle & { path: string }
|
||||
)[];
|
||||
};
|
||||
|
||||
export const generateMainReadme = async (
|
||||
userstyles: UserStylesSchema.Userstyles,
|
||||
export async function generateMainReadme(
|
||||
userstyles: UserstylesSchema.Userstyles,
|
||||
portsData: PortsSchema.PortsSchema,
|
||||
) => {
|
||||
) {
|
||||
if (!portsData.categories) throw ("Ports data is missing categories");
|
||||
|
||||
const categorized = Object.entries(userstyles)
|
||||
@@ -23,7 +24,11 @@ export const generateMainReadme = async (
|
||||
// only care about the first (primary) category in the categories array
|
||||
acc[categories[0]] ??= [];
|
||||
|
||||
acc[categories[0]].push({ path: `styles/${slug}`, categories, ...port });
|
||||
acc[categories[0]].push({
|
||||
path: `styles/${slug}`,
|
||||
categories,
|
||||
...port,
|
||||
});
|
||||
|
||||
// Sort by name, first array entry if necessary
|
||||
acc[categories[0]].sort((a, b) =>
|
||||
@@ -53,7 +58,13 @@ export const generateMainReadme = async (
|
||||
emoji: meta.emoji,
|
||||
name: meta.name,
|
||||
ports: ports.map(
|
||||
({ name, path, "current-maintainers": currentMaintainers }) => {
|
||||
(
|
||||
{
|
||||
name,
|
||||
path,
|
||||
"current-maintainers": currentMaintainers,
|
||||
},
|
||||
) => {
|
||||
return {
|
||||
name: [name].flat(),
|
||||
maintained: currentMaintainers.length > 0,
|
||||
@@ -65,14 +76,13 @@ export const generateMainReadme = async (
|
||||
}),
|
||||
});
|
||||
|
||||
const readmePath = join(REPO_ROOT, "README.md");
|
||||
await updateFile(
|
||||
const readmePath = path.join(REPO_ROOT, "README.md");
|
||||
await Deno.writeTextFile(
|
||||
readmePath,
|
||||
updateReadme({
|
||||
readme: Deno.readTextFileSync(readmePath),
|
||||
section: "userstyles",
|
||||
newContent: portContent,
|
||||
}),
|
||||
false,
|
||||
).catch((e) => console.error(e));
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user