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

builtInDrivers.ts

55 lines3.0 KB

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 */
10import * as AzureDevOpsCli from "@t3tools/source-control-azure-devops/server/AzureDevOpsCli";
11import * as AzureDevOpsPullRequestCli from "@t3tools/source-control-azure-devops/server/AzureDevOpsPullRequestCli";
12import * as AzureDevOpsDriver from "@t3tools/source-control-azure-devops/server/driver";
13import * as BitbucketApi from "@t3tools/source-control-bitbucket/server/BitbucketApi";
14import * as BitbucketPullRequestApi from "@t3tools/source-control-bitbucket/server/BitbucketPullRequestApi";
15import * as BitbucketDriver from "@t3tools/source-control-bitbucket/server/driver";
16import * as ForgejoCli from "@t3tools/source-control-forgejo/server/ForgejoCli";
17import * as ForgejoDriver from "@t3tools/source-control-forgejo/server/driver";
18import * as GitHubApi from "@t3tools/source-control-github/server/GitHubApi";
19import * as GitHubPullRequestApi from "@t3tools/source-control-github/server/GitHubPullRequestApi";
20import * as GitHubDriver from "@t3tools/source-control-github/server/driver";
21import * as GitLabCli from "@t3tools/source-control-gitlab/server/GitLabCli";
22import * as GitLabPullRequestCli from "@t3tools/source-control-gitlab/server/GitLabPullRequestCli";
23import * as GitLabDriver from "@t3tools/source-control-gitlab/server/driver";
24import type { SourceControlDriver } from "@t3tools/source-control-core/server/driver";
25import * as Layer from "effect/Layer";
26​
27import * as ServerSourceControlHost from "./ServerSourceControlHost.ts";
28​
29const drivers = [
30 GitHubDriver.driver,
31 GitLabDriver.driver,
32 AzureDevOpsDriver.driver,
33 BitbucketDriver.driver,
34 ForgejoDriver.driver,
35];
36​
37/** Every service a built-in driver's `make` needs; the server's layers must provide them all. */
38export type BuiltInSourceControlDriversEnv =
39 (typeof drivers)[number] extends SourceControlDriver<infer R> ? R : never;
40​
41/** Ordered as the hosts appear in discovery. */
42export const BUILT_IN_SOURCE_CONTROL_DRIVERS: ReadonlyArray<
43 SourceControlDriver<BuiltInSourceControlDriversEnv>
44> = drivers;
45​
46/** The services the built-in drivers' packages own, plus the host port they all run against. */
47export const layer = Layer.mergeAll(
48 // `GitHubApi.layerWithDependencies` carries the quota reserve and rate-limit pause every GitHub
49 // reader shares, so the server builds it once, here.
50 GitHubPullRequestApi.layer.pipe(Layer.provideMerge(GitHubApi.layerWithDependencies)),
51 AzureDevOpsPullRequestCli.layer.pipe(Layer.provideMerge(AzureDevOpsCli.layer)),
52 BitbucketPullRequestApi.layer.pipe(Layer.provideMerge(BitbucketApi.layer)),
53 ForgejoCli.layer,
54 GitLabPullRequestCli.layer.pipe(Layer.provideMerge(GitLabCli.layer)),
55).pipe(Layer.provideMerge(ServerSourceControlHost.layer));