| 1 | /** |
| 2 | * The source control drivers this build ships with. Both registries, repository operations and |
| 3 | * pull requests, iterate this list; a host with no driver here shows up as unsupported. |
| 4 | * |
| 5 | * Adding a host means writing its `@t3tools/source-control-<host>` package, adding its driver |
| 6 | * here, and providing its services' layers in `layer` below. |
| 7 | * |
| 8 | * @module sourceControl/builtInDrivers |
| 9 | */ |
| 10 | import * as AzureDevOpsCli from "@t3tools/source-control-azure-devops/server/AzureDevOpsCli"; |
| 11 | import * as AzureDevOpsPullRequestCli from "@t3tools/source-control-azure-devops/server/AzureDevOpsPullRequestCli"; |
| 12 | import * as AzureDevOpsDriver from "@t3tools/source-control-azure-devops/server/driver"; |
| 13 | import * as BitbucketApi from "@t3tools/source-control-bitbucket/server/BitbucketApi"; |
| 14 | import * as BitbucketPullRequestApi from "@t3tools/source-control-bitbucket/server/BitbucketPullRequestApi"; |
| 15 | import * as BitbucketDriver from "@t3tools/source-control-bitbucket/server/driver"; |
| 16 | import * as ForgejoCli from "@t3tools/source-control-forgejo/server/ForgejoCli"; |
| 17 | import * as ForgejoDriver from "@t3tools/source-control-forgejo/server/driver"; |
| 18 | import * as GitCafeApi from "@t3tools/source-control-gitcafe/server/GitCafeApi"; |
| 19 | import * as GitCafeCredentials from "@t3tools/source-control-gitcafe/server/GitCafeCredentials"; |
| 20 | import * as GitCafeDriver from "@t3tools/source-control-gitcafe/server/driver"; |
| 21 | import * as GitHubApi from "@t3tools/source-control-github/server/GitHubApi"; |
| 22 | import * as GitHubPullRequestApi from "@t3tools/source-control-github/server/GitHubPullRequestApi"; |
| 23 | import * as GitHubDriver from "@t3tools/source-control-github/server/driver"; |
| 24 | import * as GitLabCli from "@t3tools/source-control-gitlab/server/GitLabCli"; |
| 25 | import * as GitLabPullRequestCli from "@t3tools/source-control-gitlab/server/GitLabPullRequestCli"; |
| 26 | import * as GitLabDriver from "@t3tools/source-control-gitlab/server/driver"; |
| 27 | import type { SourceControlDriver } from "@t3tools/source-control-core/server/driver"; |
| 28 | import * as Layer from "effect/Layer"; |
| 29 | |
| 30 | import * as ServerSourceControlHost from "./ServerSourceControlHost.ts"; |
| 31 | |
| 32 | const drivers = [ |
| 33 | GitHubDriver.driver, |
| 34 | GitLabDriver.driver, |
| 35 | AzureDevOpsDriver.driver, |
| 36 | BitbucketDriver.driver, |
| 37 | ForgejoDriver.driver, |
| 38 | GitCafeDriver.driver, |
| 39 | ]; |
| 40 | |
| 41 | /** Every service a built-in driver's `make` needs; the server's layers must provide them all. */ |
| 42 | export type BuiltInSourceControlDriversEnv = |
| 43 | (typeof drivers)[number] extends SourceControlDriver<infer R> ? R : never; |
| 44 | |
| 45 | /** Ordered as the hosts appear in discovery. */ |
| 46 | export const BUILT_IN_SOURCE_CONTROL_DRIVERS: ReadonlyArray< |
| 47 | SourceControlDriver<BuiltInSourceControlDriversEnv> |
| 48 | > = drivers; |
| 49 | |
| 50 | /** The services the built-in drivers' packages own, plus the host port they all run against. */ |
| 51 | export const layer = Layer.mergeAll( |
| 52 | // `GitHubApi.layerWithDependencies` carries the quota reserve and rate-limit pause every GitHub |
| 53 | // reader shares, so the server builds it once, here. |
| 54 | GitHubPullRequestApi.layer.pipe(Layer.provideMerge(GitHubApi.layerWithDependencies)), |
| 55 | AzureDevOpsPullRequestCli.layer.pipe(Layer.provideMerge(AzureDevOpsCli.layer)), |
| 56 | BitbucketPullRequestApi.layer.pipe(Layer.provideMerge(BitbucketApi.layer)), |
| 57 | ForgejoCli.layer, |
| 58 | GitCafeApi.layer.pipe(Layer.provideMerge(GitCafeCredentials.layer)), |
| 59 | GitLabPullRequestCli.layer.pipe(Layer.provideMerge(GitLabCli.layer)), |
| 60 | ).pipe(Layer.provideMerge(ServerSourceControlHost.layer)); |