import { setProjectEnabled, setRepoEnabled } from '../projects/config.ts' /** * Disable a project and/or a repo on that project (safe default: no delete). * * @param input - projectId and optional repoRef * @returns Updated project * * @example * import disableProject from 'kody:@kody/kody-factory/disable-project' * await disableProject({ projectId: 'mediarss', dryRun: true }) */ export default async function disableProject(input: { projectId: string repoRef?: string dryRun?: boolean }) { if (!input?.projectId) throw new Error('disable-project: projectId is required') if (input.dryRun) { return { projectId: input.projectId, repoRef: input.repoRef ?? null, wouldDisable: true, persisted: false, dryRun: true, } } const project = input.repoRef ? await setRepoEnabled(input.projectId, input.repoRef, false) : await setProjectEnabled(input.projectId, false) return { project, persisted: true, dryRun: false } }