Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

GitService.ts

45 lines1.1 KB

1/**
2 * GitService - Service for Git command execution.
3 *
4 * Uses Effect `ServiceMap.Service` for dependency injection and exposes typed
5 * domain errors for Git command execution.
6 *
7 * @module GitService
8 */
9import { ServiceMap } from "effect";
10import type { Effect } from "effect";
11​
12import type { GitCommandError } from "../Errors.ts";
13​
14export interface ExecuteGitInput {
15 readonly operation: string;
16 readonly cwd: string;
17 readonly args: ReadonlyArray<string>;
18 readonly env?: NodeJS.ProcessEnv;
19 readonly allowNonZeroExit?: boolean;
20 readonly timeoutMs?: number;
21 readonly maxOutputBytes?: number;
23​
24export interface ExecuteGitResult {
25 readonly code: number;
26 readonly stdout: string;
27 readonly stderr: string;
29​
30/**
31 * GitServiceShape - Service API for Git command execution.
32 */
33export interface GitServiceShape {
34 /**
35 * Execute a Git command.
36 */
37 readonly execute: (input: ExecuteGitInput) => Effect.Effect<ExecuteGitResult, GitCommandError>;
39​
40/**
41 * GitService - Service for Git command execution.
42 */
43export class GitService extends ServiceMap.Service<GitService, GitServiceShape>()(
44 "t3/git/Services/GitService",
45) {}