because I got bored of customising my CV for every job
1import { execSync } from "node:child_process";
2import { resolve } from "node:path";
3
4const root = resolve(import.meta.dirname, "..");
5
6type Step = {
7 name: string;
8 command: string;
9};
10
11const steps: Step[] = [
12 { name: "Install dependencies", command: "pnpm install --frozen-lockfile" },
13 { name: "Generate Prisma client", command: "pnpm prisma:generate" },
14 { name: "Lint", command: "pnpm lint" },
15 { name: "Typecheck", command: "pnpm typecheck" },
16 { name: "Build", command: "pnpm build" },
17];
18
19const run = (step: Step): boolean => {
20 console.log(`\n==> ${step.name}`);
21 try {
22 execSync(step.command, { cwd: root, stdio: "inherit" });
23 console.log(`==> ${step.name} passed`);
24 return true;
25 } catch {
26 console.error(`==> ${step.name} FAILED`);
27 return false;
28 }
29};
30
31const selectedStep = process.argv[2];
32
33const stepsToRun = selectedStep
34 ? steps.filter((s) => s.name.toLowerCase().includes(selectedStep.toLowerCase()))
35 : steps;
36
37if (stepsToRun.length === 0) {
38 console.error(
39 `No step matching "${selectedStep}". Available: ${steps.map((s) => s.name).join(", ")}`,
40 );
41 process.exit(1);
42}
43
44console.log(
45 `Running ${stepsToRun.length} step(s): ${stepsToRun.map((s) => s.name).join(" -> ")}`,
46);
47
48const failed = stepsToRun.find((step) => !run(step));
49
50if (failed) {
51 console.error(`\nPipeline failed at: ${failed.name}`);
52 process.exit(1);
53}
54
55console.log("\nPipeline passed");