| 1 | /** |
| 2 | * The server's implementation of `SourceControlHost.SourceControlHost`, the only server surface |
| 3 | * source control provider packages may use. |
| 4 | * |
| 5 | * @module sourceControl/ServerSourceControlHost |
| 6 | */ |
| 7 | import * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost"; |
| 8 | import * as Effect from "effect/Effect"; |
| 9 | import * as Layer from "effect/Layer"; |
| 10 | |
| 11 | import * as ServerSettings from "../serverSettings.ts"; |
| 12 | import * as GitVcsDriver from "../vcs/GitVcsDriver.ts"; |
| 13 | import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts"; |
| 14 | import * as VcsProcess from "../vcs/VcsProcess.ts"; |
| 15 | |
| 16 | export const layer = Layer.effect( |
| 17 | SourceControlHost.SourceControlHost, |
| 18 | Effect.gen(function* () { |
| 19 | const serverSettings = yield* ServerSettings.ServerSettingsService; |
| 20 | const process = yield* VcsProcess.VcsProcess; |
| 21 | const git = yield* GitVcsDriver.GitVcsDriver; |
| 22 | const vcsRegistry = yield* VcsDriverRegistry.VcsDriverRegistry; |
| 23 | return SourceControlHost.SourceControlHost.of({ |
| 24 | settings: { get: serverSettings.getSettings }, |
| 25 | process: { run: process.run }, |
| 26 | git: { |
| 27 | execute: git.execute, |
| 28 | resolveCommit: git.resolveCommit, |
| 29 | remotes: (cwd) => |
| 30 | vcsRegistry.resolve({ cwd }).pipe(Effect.map((handle) => handle.driver.listRemotes(cwd))), |
| 31 | readConfigValue: git.readConfigValue, |
| 32 | resolvePrimaryRemoteName: git.resolvePrimaryRemoteName, |
| 33 | ensureRemote: git.ensureRemote, |
| 34 | listLocalBranchNames: git.listLocalBranchNames, |
| 35 | fetchRemoteBranch: git.fetchRemoteBranch, |
| 36 | fetchRemoteTrackingBranch: git.fetchRemoteTrackingBranch, |
| 37 | setBranchUpstream: git.setBranchUpstream, |
| 38 | switchRef: git.switchRef, |
| 39 | }, |
| 40 | }); |
| 41 | }), |
| 42 | ); |