44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
// Task keys look like "PEP-42": project key + per-project sequence number.
|
|
const KEY_RE = /^([A-Z][A-Z0-9]{1,9})-(\d+)$/;
|
|
|
|
export interface TaskKey {
|
|
projectKey: string;
|
|
number: number;
|
|
}
|
|
|
|
export function formatTaskKey(projectKey: string, number: number): string {
|
|
return `${projectKey}-${number}`;
|
|
}
|
|
|
|
/** Parses "PEP-42", "pep-42" or a bare "42" (resolved against `defaultProjectKey`). */
|
|
export function parseTaskKey(input: string, defaultProjectKey?: string): TaskKey | null {
|
|
const s = input.trim().toUpperCase().replace(/^#/, "");
|
|
const m = KEY_RE.exec(s);
|
|
if (m) return { projectKey: m[1]!, number: Number(m[2]) };
|
|
if (/^\d+$/.test(s) && defaultProjectKey) return { projectKey: defaultProjectKey, number: Number(s) };
|
|
return null;
|
|
}
|
|
|
|
/** Contents of `.peppa/project.json`, written into every project repo at init. */
|
|
export interface PeppaProjectFile {
|
|
slug: string;
|
|
key: string;
|
|
name: string;
|
|
peppaUrl: string;
|
|
/** CI commands (PEP-57); a missing command = the step is skipped. `install` runs first. */
|
|
checks?: Partial<Record<CheckName | "install", string>>;
|
|
/** Deployment (PEP-57): compose file with Traefik labels, service, port, health path. */
|
|
deploy?: {
|
|
compose?: string;
|
|
service?: string;
|
|
port?: number;
|
|
health?: string;
|
|
migrate?: string;
|
|
hosts?: Partial<Record<"preview" | "staging" | "prod", string>>;
|
|
};
|
|
}
|
|
|
|
/** CI checks of a project, in the order the workflow runs them. */
|
|
export const CHECK_NAMES = ["lint", "typecheck", "test", "build"] as const;
|
|
export type CheckName = (typeof CHECK_NAMES)[number];
|