/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { writeFile, copyFile, stat, mkdir } from "node:fs/promises";
import { join } from "node:path";
// eslint-disable-next-line import/no-extraneous-dependencies -- Since this is a dev script, there are no production dependencies.
import { parse } from "yaml";
import type { Resume } from "./interfaces/resume.js";
const htmlBeginning = `
Naomi Carrigan`;
const htmlEnd = `
`;
const request = await fetch(
"https://data.nhcarrigan.com/resume.yml",
);
if (!request.ok) {
// eslint-disable-next-line no-console -- error logging.
console.error(
`Failed to fetch resume.yaml: ${request.status.toString()} ${request.statusText}`,
);
process.exit(1);
}
const result = await request.text();
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- parse does not accept a generic.
const yaml = (await parse(
result,
)) as Resume;
const currentEmployment = yaml.employment.
filter((item) => {
return item.end_date === "Present";
}).
sort((a, b) => {
return (
new Date(`5${b.start_date}`).getTime()
- new Date(`5${a.start_date}`).getTime()
);
});
const currentVolunteer = yaml.volunteer.
filter((item) => {
return item.end_date === "Present";
}).
sort((a, b) => {
return (
new Date(`5${b.start_date}`).getTime()
- new Date(`5${a.start_date}`).getTime()
);
});
const pastEmployment = yaml.employment.
filter((item) => {
return item.end_date !== "Present";
}).
sort((a, b) => {
return (
new Date(`5${b.end_date}`).getTime()
- new Date(`5${a.end_date}`).getTime()
);
});
const pastVolunteer = yaml.volunteer.
filter((item) => {
return item.end_date !== "Present";
}).
sort((a, b) => {
return (
new Date(`5${b.end_date}`).getTime()
- new Date(`5${a.end_date}`).getTime()
);
});
yaml.employment = [ ...currentEmployment, ...pastEmployment ];
yaml.volunteer = [ ...currentVolunteer, ...pastVolunteer ];
yaml.certifications.sort((a, b) => {
return new Date(`5${b.date}`).getTime() - new Date(`5${a.date}`).getTime();
});
yaml.education.sort((a, b) => {
return (
new Date(`5${b.end_date}`).getTime() - new Date(`5${a.end_date}`).getTime()
);
});
yaml.projects.sort((a, b) => {
return new Date(`5${b.date}`).getTime() - new Date(`5${a.date}`).getTime();
});
yaml.publications.sort((a, b) => {
return new Date(b.date).getTime() - new Date(a.date).getTime();
});
const heading = `