Skip to content

Commit d8d9651

Browse files
Fix Rie validation
1 parent 5e46ce2 commit d8d9651

File tree

3 files changed

+42
-27
lines changed

3 files changed

+42
-27
lines changed

code/check.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ import { ContributorSchema as ContributorFunction } from "../contributors/_schem
88
import z from "zod";
99

1010
const TEAM_DIR = path.resolve(process.cwd(), "contributors");
11-
const PROJECTS_FILE = path.resolve(process.cwd(), "contributors/_schema/projects.ts");
12-
const SCHEMA_FILE = path.resolve(process.cwd(), "contributors/_schema/index.ts");
11+
const PROJECTS_FILE = path.resolve(
12+
process.cwd(),
13+
"contributors/_schema/projects.ts"
14+
);
15+
const SCHEMA_FILE = path.resolve(
16+
process.cwd(),
17+
"contributors/_schema/index.ts"
18+
);
1319

1420
// Global abort controller to manage running validations
1521
let currentValidationController: AbortController | null = null;
@@ -21,9 +27,9 @@ interface ValidationResult {
2127
}
2228

2329
class InvalidRoleError extends Error {
24-
constructor(projectName: string, filePath: string) {
30+
constructor(roleName: string, projectName: string, filePath: string) {
2531
super(
26-
`Invalid role in project "${projectName}" for file ./${path.relative(
32+
`Invalid role ${roleName} in project "${projectName}" for file ./${path.relative(
2733
process.cwd(),
2834
filePath
2935
)}.`
@@ -43,7 +49,7 @@ class InvalidProjectError extends Error {
4349
}
4450

4551
// @ts-expect-error This is fucked up because it's type of image in Astro
46-
const Contributor = ContributorFunction({ image: z.string})
52+
const Contributor = ContributorFunction({ image: z.string });
4753

4854
function formatValidationError(error: any, filePath: string): string {
4955
if (error.code === "unrecognized_keys") {
@@ -57,7 +63,11 @@ function formatValidationError(error: any, filePath: string): string {
5763
const path = error.path.join(".");
5864
if (path.includes("roles.")) {
5965
const projectName = path.split(".")[1];
60-
throw new InvalidRoleError(projectName, filePath);
66+
const roleName = error.unionErrors
67+
// TODO: figure out zod typings
68+
.flatMap((e: any) => e.issues)
69+
.find((issue: any) => issue.code == "invalid_enum_value")?.received;
70+
throw new InvalidRoleError(roleName, projectName, filePath);
6171
}
6272
}
6373

@@ -149,8 +159,13 @@ function validateAllTeamFiles(signal?: AbortSignal) {
149159
return results;
150160
}
151161

152-
function printResults(results: ValidationResult[]): void {
153-
console.clear();
162+
function printResults(
163+
results: ValidationResult[],
164+
isWatchMode: boolean = false
165+
): void {
166+
if (isWatchMode) {
167+
console.clear();
168+
}
154169
const hasErrors = results.some((r) => r.errors.length > 0);
155170

156171
if (hasErrors) {
@@ -200,7 +215,9 @@ async function runValidation(isWatchMode: boolean = false) {
200215
const signal = currentValidationController.signal;
201216

202217
try {
203-
console.clear();
218+
if (isWatchMode) {
219+
console.clear();
220+
}
204221
console.log("Running validation...");
205222

206223
// Needs to wait or it's not clear anything is happening

contributors/_schema/projects.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ export const PROJECTS = [
88
"Volume 0 Issue 1",
99
"Fandom Cookies",
1010
"FujoCoded",
11+
"Learn@",
1112
] as const;
12-
export type Project = typeof PROJECTS[number];
13+
export type Project = (typeof PROJECTS)[number];
1314

1415
export const VOLUME_0_ISSUE_1_ROLES = [
1516
"Technical Writer",
@@ -25,15 +26,9 @@ export const VOLUME_0_ISSUE_1_ROLES = [
2526
"Data Collection & Entry",
2627
];
2728

28-
export const WEBSITES_ROLES = [
29-
"fujoweb.dev",
30-
"fujocoded.com",
31-
];
29+
export const WEBSITES_ROLES = ["fujoweb.dev", "fujocoded.com"];
3230

33-
export const FUJOCODED_ROLES = [
34-
"HimeOps",
35-
"FujoCoded",
36-
];
31+
export const FUJOCODED_ROLES = ["HimeOps", "FujoCoded"];
3732

3833
export const FANDOM_COOKIES_ROLES = [
3934
"Artist",
@@ -48,16 +43,19 @@ export const FANDOM_COOKIES_ROLES = [
4843
"Art Direction",
4944
"Cookie Catcher Design",
5045
"Promo Campaign Assistance",
51-
"Feedback",
46+
"Feedback",
5247
];
5348

54-
export const PROJECT_ROLES : Record<Project, string[]> = {
49+
export const LEARN_AT_ROLES = ["Writers Coordinator", "Article Writer"];
50+
51+
export const PROJECT_ROLES: Record<Project, string[]> = {
5552
"Volume 0 Issue 1": VOLUME_0_ISSUE_1_ROLES,
5653
"Volume 0 Kickstarter": [],
5754
"Volume 0": [],
58-
"Websites": WEBSITES_ROLES,
55+
Websites: WEBSITES_ROLES,
5956
"Fandom Cookies": FANDOM_COOKIES_ROLES,
60-
"FujoCoded": FUJOCODED_ROLES,
57+
FujoCoded: FUJOCODED_ROLES,
58+
"Learn@": LEARN_AT_ROLES,
6159
};
6260

6361
export default PROJECTS;

contributors/rie.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: Rie
22
avatar: "./avatars/rie.png"
3-
type:
3+
type:
44
- community
55
- contractor
66
roles:
77
Learn@:
8-
- role: Writers Coordinator
9-
details: Style Guide
10-
- role: Writing Article
11-
details: Article
8+
- role: Writers Coordinator
9+
details: Style Guide Author & Process Coordinator
10+
- role: Article Writer
11+
details: Introduction to NodeJS
1212
contacts:
1313
- https://notavodkashot.carrd.co/

0 commit comments

Comments
 (0)