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