Skip to content
← Public packages

@kody/kody-factory

Forkable multi-project software factory: signals, priority queue, project UI, sweep job. Agent runners and Sentry reach it by events.

FollowFork

Files

enable-project.ts

32 lines · 903 B · TypeScript
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 }
}