refactor(source-control): Azure DevOps lives in @t3tools/source-control-azure-devops (#17592)
Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
f6e45028ef
commit
d01febb509
30 files changed
+169
-47
No files matched your search
@@ -1,448 +0,0 @@
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { assert, it, afterEach, describe, expect, vi } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as PlatformError from "effect/PlatformError";
|
||||
import { ChildProcessSpawner } from "effect/process";
|
||||
import { VcsProcessExitError, VcsProcessSpawnError } from "@t3tools/contracts";
|
||||
|
||||
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";
|
||||
|
||||
const processOutput = (stdout: string): VcsProcess.VcsProcessOutput => ({
|
||||
exitCode: ChildProcessSpawner.ExitCode(0),
|
||||
stdout,
|
||||
stderr: "",
|
||||
stdoutTruncated: false,
|
||||
stderrTruncated: false,
|
||||
});
|
||||
|
||||
const mockRun = vi.fn<VcsProcess.VcsProcess["Service"]["run"]>();
|
||||
|
||||
const layerSupport = Layer.mergeAll(
|
||||
Layer.mock(VcsProcess.VcsProcess)({
|
||||
run: mockRun,
|
||||
}),
|
||||
NodeServices.layer,
|
||||
);
|
||||
const layer = Layer.mergeAll(AzureDevOpsCli.layer.pipe(Layer.provide(layerSupport)), layerSupport);
|
||||
|
||||
afterEach(() => {
|
||||
mockRun.mockReset();
|
||||
});
|
||||
|
||||
describe("AzureDevOpsCli.layer", () => {
|
||||
it.effect("parses pull request view output", () =>
|
||||
Effect.gen(function* () {
|
||||
mockRun.mockReturnValueOnce(
|
||||
Effect.succeed(
|
||||
processOutput(
|
||||
JSON.stringify({
|
||||
pullRequestId: 42,
|
||||
title: "Add Azure provider",
|
||||
sourceRefName: "refs/heads/feature/source-control",
|
||||
targetRefName: "refs/heads/main",
|
||||
status: "active",
|
||||
creationDate: "2026-01-02T00:00:00.000Z",
|
||||
closedDate: null,
|
||||
_links: {
|
||||
web: {
|
||||
href: "https://dev.azure.com/acme/project/_git/repo/pullrequest/42",
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const az = yield* AzureDevOpsCli.AzureDevOpsCli;
|
||||
const result = yield* az.getPullRequest({
|
||||
cwd: "/repo",
|
||||
reference: "#42",
|
||||
});
|
||||
|
||||
assert.strictEqual(result.number, 42);
|
||||
assert.strictEqual(result.title, "Add Azure provider");
|
||||
assert.strictEqual(result.url, "https://dev.azure.com/acme/project/_git/repo/pullrequest/42");
|
||||
assert.strictEqual(result.baseRefName, "main");
|
||||
assert.strictEqual(result.headRefName, "feature/source-control");
|
||||
assert.strictEqual(result.state, "open");
|
||||
assert.deepStrictEqual(result.updatedAt._tag, Option.some(1)._tag);
|
||||
assert.deepStrictEqual(mockRun.mock.calls.at(-1)?.[0], {
|
||||
operation: "AzureDevOpsCli.execute",
|
||||
command: "az",
|
||||
args: [
|
||||
"repos",
|
||||
"pr",
|
||||
"show",
|
||||
"--detect",
|
||||
"true",
|
||||
"--id",
|
||||
"42",
|
||||
"--only-show-errors",
|
||||
"--output",
|
||||
"json",
|
||||
],
|
||||
cwd: "/repo",
|
||||
timeoutMs: 30_000,
|
||||
});
|
||||
}).pipe(Effect.provide(layer)),
|
||||
);
|
||||
|
||||
it.effect("builds a web URL when Azure returns only the pull request REST URL", () =>
|
||||
Effect.gen(function* () {
|
||||
mockRun.mockReturnValueOnce(
|
||||
Effect.succeed(
|
||||
processOutput(
|
||||
JSON.stringify({
|
||||
pullRequestId: 863,
|
||||
title: "Fix Azure link",
|
||||
url: "https://dev.azure.com/saplyai/a8fe4088-ad76-4eda-aaaa-e3329713a097/_apis/git/repositories/16108a25-93a3-4eff-b77d-85e894ee0fe4/pullRequests/863",
|
||||
repository: {
|
||||
name: "CV-engine",
|
||||
project: {
|
||||
name: "CV-engine",
|
||||
},
|
||||
},
|
||||
sourceRefName: "refs/heads/feature/azure-pr-link",
|
||||
targetRefName: "refs/heads/main",
|
||||
status: "active",
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const az = yield* AzureDevOpsCli.AzureDevOpsCli;
|
||||
const result = yield* az.getPullRequest({
|
||||
cwd: "/repo",
|
||||
reference: "863",
|
||||
});
|
||||
|
||||
assert.strictEqual(
|
||||
result.url,
|
||||
"https://dev.azure.com/saplyai/CV-engine/_git/CV-engine/pullrequest/863",
|
||||
);
|
||||
}).pipe(Effect.provide(layer)),
|
||||
);
|
||||
|
||||
it.effect("lists pull requests with Azure status and source branch arguments", () =>
|
||||
Effect.gen(function* () {
|
||||
mockRun.mockReturnValueOnce(
|
||||
Effect.succeed(
|
||||
processOutput(
|
||||
JSON.stringify([
|
||||
{
|
||||
pullRequestId: 7,
|
||||
title: "Merged work",
|
||||
sourceRefName: "refs/heads/feature/merged",
|
||||
targetRefName: "refs/heads/main",
|
||||
status: "completed",
|
||||
closedDate: "2026-01-03T00:00:00.000Z",
|
||||
_links: {
|
||||
web: {
|
||||
href: "https://dev.azure.com/acme/project/_git/repo/pullrequest/7",
|
||||
},
|
||||
},
|
||||
},
|
||||
]),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const az = yield* AzureDevOpsCli.AzureDevOpsCli;
|
||||
const result = yield* az.listPullRequests({
|
||||
cwd: "/repo",
|
||||
headSelector: "origin:feature/merged",
|
||||
state: "merged",
|
||||
limit: 10,
|
||||
});
|
||||
|
||||
assert.strictEqual(result[0]?.state, "merged");
|
||||
assert.strictEqual(result[0]?.mergedAt, "2026-01-03T00:00:00.000Z");
|
||||
assert.strictEqual(result[0]?.closedAt, null);
|
||||
expect(mockRun).toHaveBeenCalledWith({
|
||||
operation: "AzureDevOpsCli.execute",
|
||||
command: "az",
|
||||
args: [
|
||||
"repos",
|
||||
"pr",
|
||||
"list",
|
||||
"--detect",
|
||||
"true",
|
||||
"--source-branch",
|
||||
"feature/merged",
|
||||
"--status",
|
||||
"completed",
|
||||
"--top",
|
||||
"10",
|
||||
"--only-show-errors",
|
||||
"--output",
|
||||
"json",
|
||||
],
|
||||
cwd: "/repo",
|
||||
timeoutMs: 30_000,
|
||||
});
|
||||
}).pipe(Effect.provide(layer)),
|
||||
);
|
||||
|
||||
it.effect("reads repository clone URLs", () =>
|
||||
Effect.gen(function* () {
|
||||
mockRun.mockReturnValueOnce(
|
||||
Effect.succeed(
|
||||
processOutput(
|
||||
JSON.stringify({
|
||||
name: "repo",
|
||||
webUrl: "https://dev.azure.com/acme/project/_git/repo",
|
||||
remoteUrl: "https://dev.azure.com/acme/project/_git/repo",
|
||||
sshUrl: "[email protected]:v3/acme/project/repo",
|
||||
project: {
|
||||
name: "project",
|
||||
},
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const az = yield* AzureDevOpsCli.AzureDevOpsCli;
|
||||
const result = yield* az.getRepositoryCloneUrls({
|
||||
cwd: "/repo",
|
||||
repository: "repo",
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(result, {
|
||||
nameWithOwner: "project/repo",
|
||||
url: "https://dev.azure.com/acme/project/_git/repo",
|
||||
sshUrl: "[email protected]:v3/acme/project/repo",
|
||||
});
|
||||
}).pipe(Effect.provide(layer)),
|
||||
);
|
||||
|
||||
it.effect("creates repositories through Azure Repos", () =>
|
||||
Effect.gen(function* () {
|
||||
mockRun.mockReturnValueOnce(
|
||||
Effect.succeed(
|
||||
processOutput(
|
||||
JSON.stringify({
|
||||
name: "repo",
|
||||
webUrl: "https://dev.azure.com/acme/project/_git/repo",
|
||||
remoteUrl: "https://dev.azure.com/acme/project/_git/repo",
|
||||
sshUrl: "[email protected]:v3/acme/project/repo",
|
||||
project: {
|
||||
name: "project",
|
||||
},
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const az = yield* AzureDevOpsCli.AzureDevOpsCli;
|
||||
const result = yield* az.createRepository({
|
||||
cwd: "/repo",
|
||||
repository: "project/repo",
|
||||
visibility: "private",
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(result, {
|
||||
nameWithOwner: "project/repo",
|
||||
url: "https://dev.azure.com/acme/project/_git/repo",
|
||||
sshUrl: "[email protected]:v3/acme/project/repo",
|
||||
});
|
||||
expect(mockRun).toHaveBeenCalledWith({
|
||||
operation: "AzureDevOpsCli.execute",
|
||||
command: "az",
|
||||
args: [
|
||||
"repos",
|
||||
"create",
|
||||
"--detect",
|
||||
"true",
|
||||
"--name",
|
||||
"repo",
|
||||
"--project",
|
||||
"project",
|
||||
"--only-show-errors",
|
||||
"--output",
|
||||
"json",
|
||||
],
|
||||
cwd: "/repo",
|
||||
timeoutMs: 30_000,
|
||||
});
|
||||
}).pipe(Effect.provide(layer)),
|
||||
);
|
||||
|
||||
it.effect("creates pull requests using the body file as the Azure description", () =>
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const bodyFile = `/tmp/t3code-azure-devops-cli-.md`;
|
||||
yield* fileSystem.writeFileString(bodyFile, "Generated body");
|
||||
mockRun.mockReturnValueOnce(Effect.succeed(processOutput("{}")));
|
||||
|
||||
const az = yield* AzureDevOpsCli.AzureDevOpsCli;
|
||||
yield* az.createPullRequest({
|
||||
cwd: "/repo",
|
||||
baseBranch: "main",
|
||||
headSelector: "feature/provider",
|
||||
title: "Provider PR",
|
||||
bodyFile,
|
||||
});
|
||||
|
||||
expect(mockRun).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
command: "az",
|
||||
cwd: "/repo",
|
||||
args: expect.arrayContaining(["--description", `@${bodyFile}`]),
|
||||
}),
|
||||
);
|
||||
expect(mockRun.mock.calls[0]?.[0].args).not.toContain("--output");
|
||||
}).pipe(Effect.provide(layer)),
|
||||
);
|
||||
|
||||
it.effect("does not force JSON output on checkout side-effect commands", () =>
|
||||
Effect.gen(function* () {
|
||||
mockRun.mockReturnValueOnce(Effect.succeed(processOutput("")));
|
||||
|
||||
const az = yield* AzureDevOpsCli.AzureDevOpsCli;
|
||||
yield* az.checkoutPullRequest({
|
||||
cwd: "/repo",
|
||||
reference: "42",
|
||||
});
|
||||
|
||||
expect(mockRun).toHaveBeenCalledWith({
|
||||
operation: "AzureDevOpsCli.execute",
|
||||
command: "az",
|
||||
args: [
|
||||
"repos",
|
||||
"pr",
|
||||
"checkout",
|
||||
"--only-show-errors",
|
||||
"--detect",
|
||||
"true",
|
||||
"--id",
|
||||
"42",
|
||||
"--remote-name",
|
||||
"origin",
|
||||
],
|
||||
cwd: "/repo",
|
||||
timeoutMs: 30_000,
|
||||
});
|
||||
}).pipe(Effect.provide(layer)),
|
||||
);
|
||||
|
||||
it.effect("forwards explicit output limits to the process boundary", () =>
|
||||
Effect.gen(function* () {
|
||||
mockRun.mockReturnValueOnce(Effect.succeed(processOutput("")));
|
||||
|
||||
const az = yield* AzureDevOpsCli.AzureDevOpsCli;
|
||||
yield* az.execute({
|
||||
cwd: "/repo",
|
||||
args: ["repos", "pr", "list"],
|
||||
maxOutputBytes: 16 * 1024 * 1024,
|
||||
});
|
||||
|
||||
expect(mockRun).toHaveBeenCalledWith({
|
||||
operation: "AzureDevOpsCli.execute",
|
||||
command: "az",
|
||||
args: ["repos", "pr", "list"],
|
||||
cwd: "/repo",
|
||||
timeoutMs: 30_000,
|
||||
maxOutputBytes: 16 * 1024 * 1024,
|
||||
});
|
||||
}).pipe(Effect.provide(layer)),
|
||||
);
|
||||
|
||||
it.effect("preserves VCS causes without copying upstream details into messages", () =>
|
||||
Effect.gen(function* () {
|
||||
const cause = new VcsProcessExitError({
|
||||
operation: "AzureDevOpsCli.execute",
|
||||
command: "az repos list --organization sensitive-upstream-detail",
|
||||
cwd: "/repo",
|
||||
exitCode: 1,
|
||||
detail: "sensitive-upstream-detail",
|
||||
});
|
||||
mockRun.mockReturnValueOnce(Effect.fail(cause));
|
||||
|
||||
const az = yield* AzureDevOpsCli.AzureDevOpsCli;
|
||||
const error = yield* az.execute({ cwd: "/repo", args: ["repos", "list"] }).pipe(Effect.flip);
|
||||
|
||||
assert.instanceOf(error, AzureDevOpsCli.AzureDevOpsCommandFailedError);
|
||||
assert.strictEqual(error.operation, "execute");
|
||||
assert.strictEqual(error.command, "az");
|
||||
assert.strictEqual(error.cwd, "/repo");
|
||||
assert.strictEqual(error.argumentCount, 2);
|
||||
assert.strictEqual(error.detail, "Azure DevOps CLI command failed.");
|
||||
assert.strictEqual(error.cause, cause);
|
||||
assert.equal(error.message.includes("sensitive-upstream-detail"), false);
|
||||
}).pipe(Effect.provide(layer)),
|
||||
);
|
||||
|
||||
it.effect("does not report a missing working directory as a missing Azure CLI", () =>
|
||||
Effect.gen(function* () {
|
||||
const cwd = "/missing/repo";
|
||||
const platformCause = PlatformError.systemError({
|
||||
_tag: "NotFound",
|
||||
module: "ChildProcess",
|
||||
method: "spawn",
|
||||
syscall: "chdir",
|
||||
pathOrDescriptor: cwd,
|
||||
});
|
||||
const cause = new VcsProcessSpawnError({
|
||||
operation: "AzureDevOpsCli.execute",
|
||||
command: "az",
|
||||
cwd,
|
||||
argumentCount: 2,
|
||||
cause: platformCause,
|
||||
});
|
||||
mockRun.mockReturnValueOnce(Effect.fail(cause));
|
||||
|
||||
const az = yield* AzureDevOpsCli.AzureDevOpsCli;
|
||||
const error = yield* az.execute({ cwd, args: ["repos", "list"] }).pipe(Effect.flip);
|
||||
|
||||
assert.instanceOf(error, AzureDevOpsCli.AzureDevOpsCommandFailedError);
|
||||
assert.strictEqual(error.cwd, cwd);
|
||||
assert.strictEqual(error.cause, cause);
|
||||
}).pipe(Effect.provide(layer)),
|
||||
);
|
||||
|
||||
it.effect("keeps invalid pull request output diagnostics structured", () =>
|
||||
Effect.gen(function* () {
|
||||
mockRun.mockReturnValueOnce(Effect.succeed(processOutput("not-json")));
|
||||
|
||||
const az = yield* AzureDevOpsCli.AzureDevOpsCli;
|
||||
const error = yield* az.getPullRequest({ cwd: "/repo", reference: "42" }).pipe(Effect.flip);
|
||||
|
||||
assert.instanceOf(error, AzureDevOpsCli.AzureDevOpsPullRequestDecodeError);
|
||||
assert.strictEqual(error.operation, "getPullRequest");
|
||||
assert.strictEqual(error.command, "az");
|
||||
assert.strictEqual(error.cwd, "/repo");
|
||||
assert.strictEqual(error.outputLength, 8);
|
||||
assert.strictEqual(error.detail, "Azure DevOps CLI returned invalid pull request JSON.");
|
||||
assert.exists(error.cause);
|
||||
assert.strictEqual(
|
||||
error.message,
|
||||
"Azure DevOps CLI failed in getPullRequest: Azure DevOps CLI returned invalid pull request JSON.",
|
||||
);
|
||||
}).pipe(Effect.provide(layer)),
|
||||
);
|
||||
|
||||
it.effect("preserves rate-limit failures as a distinct error", () =>
|
||||
Effect.gen(function* () {
|
||||
const cause = new VcsProcessExitError({
|
||||
operation: "AzureDevOpsCli.execute",
|
||||
command: "az",
|
||||
cwd: "/repo",
|
||||
argumentCount: 2,
|
||||
exitCode: 1,
|
||||
detail: "API rate limit exceeded.",
|
||||
failureKind: "rate-limited",
|
||||
});
|
||||
mockRun.mockReturnValueOnce(Effect.fail(cause));
|
||||
|
||||
const az = yield* AzureDevOpsCli.AzureDevOpsCli;
|
||||
const error = yield* az.execute({ cwd: "/repo", args: ["repos", "list"] }).pipe(Effect.flip);
|
||||
|
||||
assert.instanceOf(error, AzureDevOpsCli.AzureDevOpsCliRateLimitError);
|
||||
assert.strictEqual(error.cause, cause);
|
||||
}).pipe(Effect.provide(layer)),
|
||||
);
|
||||
});
|
||||
@@ -1,554 +0,0 @@
|
||||
import * as Context from "effect/Context";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as PlatformError from "effect/PlatformError";
|
||||
import * as Result from "effect/Result";
|
||||
import * as Schema from "effect/Schema";
|
||||
import {
|
||||
NonNegativeInt,
|
||||
TrimmedNonEmptyString,
|
||||
type SourceControlRepositoryVisibility,
|
||||
type VcsError,
|
||||
} from "@t3tools/contracts";
|
||||
|
||||
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
import {
|
||||
decodeAzureDevOpsPullRequestJson,
|
||||
decodeAzureDevOpsPullRequestListJson,
|
||||
type NormalizedAzureDevOpsPullRequestRecord,
|
||||
} from "./azureDevOpsPullRequests.ts";
|
||||
import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
|
||||
|
||||
const DEFAULT_TIMEOUT_MS = 30_000;
|
||||
|
||||
const azureDevOpsCommandErrorFields = {
|
||||
operation: Schema.Literal("execute"),
|
||||
command: Schema.Literal("az"),
|
||||
cwd: Schema.String,
|
||||
argumentCount: NonNegativeInt,
|
||||
cause: Schema.Defect(),
|
||||
};
|
||||
|
||||
export class AzureDevOpsCliUnavailableError extends Schema.TaggedError<AzureDevOpsCliUnavailableError>()(
|
||||
"AzureDevOpsCliUnavailableError",
|
||||
azureDevOpsCommandErrorFields,
|
||||
) {
|
||||
get detail(): string {
|
||||
return "Azure CLI (`az`) with the Azure DevOps extension is required but not available on PATH.";
|
||||
}
|
||||
|
||||
override get message(): string {
|
||||
return `Azure DevOps CLI failed in ${this.operation}: ${this.detail}`;
|
||||
}
|
||||
}
|
||||
|
||||
export class AzureDevOpsCliAuthenticationError extends Schema.TaggedError<AzureDevOpsCliAuthenticationError>()(
|
||||
"AzureDevOpsCliAuthenticationError",
|
||||
azureDevOpsCommandErrorFields,
|
||||
) {
|
||||
get detail(): string {
|
||||
return "Azure DevOps CLI is not authenticated. Run `az devops login` and retry.";
|
||||
}
|
||||
|
||||
override get message(): string {
|
||||
return `Azure DevOps CLI failed in ${this.operation}: ${this.detail}`;
|
||||
}
|
||||
}
|
||||
|
||||
export class AzureDevOpsCliRateLimitError extends Schema.TaggedError<AzureDevOpsCliRateLimitError>()(
|
||||
"AzureDevOpsCliRateLimitError",
|
||||
azureDevOpsCommandErrorFields,
|
||||
) {
|
||||
get detail(): string {
|
||||
return "Azure DevOps API rate limit exceeded.";
|
||||
}
|
||||
|
||||
override get message(): string {
|
||||
return `Azure DevOps CLI failed in ${this.operation}: ${this.detail}`;
|
||||
}
|
||||
}
|
||||
|
||||
export class AzureDevOpsPullRequestNotFoundError extends Schema.TaggedError<AzureDevOpsPullRequestNotFoundError>()(
|
||||
"AzureDevOpsPullRequestNotFoundError",
|
||||
azureDevOpsCommandErrorFields,
|
||||
) {
|
||||
get detail(): string {
|
||||
return "Pull request not found. Check the PR number or URL and try again.";
|
||||
}
|
||||
|
||||
override get message(): string {
|
||||
return `Azure DevOps CLI failed in ${this.operation}: ${this.detail}`;
|
||||
}
|
||||
}
|
||||
|
||||
export class AzureDevOpsCommandFailedError extends Schema.TaggedError<AzureDevOpsCommandFailedError>()(
|
||||
"AzureDevOpsCommandFailedError",
|
||||
azureDevOpsCommandErrorFields,
|
||||
) {
|
||||
get detail(): string {
|
||||
return "Azure DevOps CLI command failed.";
|
||||
}
|
||||
|
||||
override get message(): string {
|
||||
return `Azure DevOps CLI failed in ${this.operation}: ${this.detail}`;
|
||||
}
|
||||
|
||||
static fromVcsError(
|
||||
context: {
|
||||
readonly operation: "execute";
|
||||
readonly command: "az";
|
||||
readonly cwd: string;
|
||||
readonly argumentCount: number;
|
||||
},
|
||||
cause: VcsError,
|
||||
): AzureDevOpsCliError {
|
||||
const fields = { ...context, cause };
|
||||
|
||||
if (
|
||||
cause._tag === "VcsProcessSpawnError" &&
|
||||
cause.cause instanceof PlatformError.PlatformError &&
|
||||
cause.cause.reason._tag === "NotFound" &&
|
||||
cause.cause.reason.pathOrDescriptor !== context.cwd &&
|
||||
cause.cause.reason.syscall !== "chdir"
|
||||
) {
|
||||
return new AzureDevOpsCliUnavailableError(fields);
|
||||
}
|
||||
|
||||
if (cause._tag === "VcsProcessExitError") {
|
||||
if (cause.failureKind === "authentication") {
|
||||
return new AzureDevOpsCliAuthenticationError(fields);
|
||||
}
|
||||
if (cause.failureKind === "rate-limited") {
|
||||
return new AzureDevOpsCliRateLimitError(fields);
|
||||
}
|
||||
if (cause.failureKind === "not-found") {
|
||||
return new AzureDevOpsPullRequestNotFoundError(fields);
|
||||
}
|
||||
}
|
||||
|
||||
return new AzureDevOpsCommandFailedError(fields);
|
||||
}
|
||||
}
|
||||
|
||||
const azureDevOpsDecodeErrorFields = {
|
||||
command: Schema.Literal("az"),
|
||||
cwd: Schema.String,
|
||||
outputLength: NonNegativeInt,
|
||||
cause: Schema.Defect(),
|
||||
};
|
||||
|
||||
export class AzureDevOpsPullRequestListDecodeError extends Schema.TaggedError<AzureDevOpsPullRequestListDecodeError>()(
|
||||
"AzureDevOpsPullRequestListDecodeError",
|
||||
{
|
||||
operation: Schema.Literal("listPullRequests"),
|
||||
...azureDevOpsDecodeErrorFields,
|
||||
},
|
||||
) {
|
||||
get detail(): string {
|
||||
return "Azure DevOps CLI returned invalid PR list JSON.";
|
||||
}
|
||||
|
||||
override get message(): string {
|
||||
return `Azure DevOps CLI failed in ${this.operation}: ${this.detail}`;
|
||||
}
|
||||
}
|
||||
|
||||
export class AzureDevOpsPullRequestDecodeError extends Schema.TaggedError<AzureDevOpsPullRequestDecodeError>()(
|
||||
"AzureDevOpsPullRequestDecodeError",
|
||||
{
|
||||
operation: Schema.Literal("getPullRequest"),
|
||||
...azureDevOpsDecodeErrorFields,
|
||||
},
|
||||
) {
|
||||
get detail(): string {
|
||||
return "Azure DevOps CLI returned invalid pull request JSON.";
|
||||
}
|
||||
|
||||
override get message(): string {
|
||||
return `Azure DevOps CLI failed in ${this.operation}: ${this.detail}`;
|
||||
}
|
||||
}
|
||||
|
||||
const AzureDevOpsRepositoryDecodeOperation = Schema.Literals([
|
||||
"getRepositoryCloneUrls",
|
||||
"getDefaultBranch",
|
||||
"createRepository",
|
||||
]);
|
||||
|
||||
export class AzureDevOpsRepositoryDecodeError extends Schema.TaggedError<AzureDevOpsRepositoryDecodeError>()(
|
||||
"AzureDevOpsRepositoryDecodeError",
|
||||
{
|
||||
operation: AzureDevOpsRepositoryDecodeOperation,
|
||||
...azureDevOpsDecodeErrorFields,
|
||||
},
|
||||
) {
|
||||
get detail(): string {
|
||||
return "Azure DevOps CLI returned invalid repository JSON.";
|
||||
}
|
||||
|
||||
override get message(): string {
|
||||
return `Azure DevOps CLI failed in ${this.operation}: ${this.detail}`;
|
||||
}
|
||||
}
|
||||
|
||||
export const AzureDevOpsCliError = Schema.Union([
|
||||
AzureDevOpsCliUnavailableError,
|
||||
AzureDevOpsCliAuthenticationError,
|
||||
AzureDevOpsCliRateLimitError,
|
||||
AzureDevOpsPullRequestNotFoundError,
|
||||
AzureDevOpsCommandFailedError,
|
||||
AzureDevOpsPullRequestListDecodeError,
|
||||
AzureDevOpsPullRequestDecodeError,
|
||||
AzureDevOpsRepositoryDecodeError,
|
||||
]);
|
||||
export type AzureDevOpsCliError = typeof AzureDevOpsCliError.Type;
|
||||
|
||||
export interface AzureDevOpsRepositoryCloneUrls {
|
||||
readonly nameWithOwner: string;
|
||||
readonly url: string;
|
||||
readonly sshUrl: string;
|
||||
}
|
||||
|
||||
export class AzureDevOpsCli extends Context.Service<
|
||||
AzureDevOpsCli,
|
||||
{
|
||||
readonly execute: (input: {
|
||||
readonly cwd: string;
|
||||
readonly args: ReadonlyArray<string>;
|
||||
readonly timeoutMs?: number;
|
||||
readonly maxOutputBytes?: number;
|
||||
}) => Effect.Effect<VcsProcess.VcsProcessOutput, AzureDevOpsCliError>;
|
||||
|
||||
readonly listPullRequests: (input: {
|
||||
readonly cwd: string;
|
||||
readonly headSelector: string;
|
||||
readonly source?: SourceControlProvider.SourceControlRefSelector;
|
||||
readonly state: "open" | "closed" | "merged" | "all";
|
||||
readonly limit?: number;
|
||||
}) => Effect.Effect<ReadonlyArray<NormalizedAzureDevOpsPullRequestRecord>, AzureDevOpsCliError>;
|
||||
|
||||
readonly getPullRequest: (input: {
|
||||
readonly cwd: string;
|
||||
readonly reference: string;
|
||||
}) => Effect.Effect<NormalizedAzureDevOpsPullRequestRecord, AzureDevOpsCliError>;
|
||||
|
||||
readonly getRepositoryCloneUrls: (input: {
|
||||
readonly cwd: string;
|
||||
readonly repository: string;
|
||||
}) => Effect.Effect<AzureDevOpsRepositoryCloneUrls, AzureDevOpsCliError>;
|
||||
|
||||
readonly createRepository: (input: {
|
||||
readonly cwd: string;
|
||||
readonly repository: string;
|
||||
readonly visibility: SourceControlRepositoryVisibility;
|
||||
}) => Effect.Effect<AzureDevOpsRepositoryCloneUrls, AzureDevOpsCliError>;
|
||||
|
||||
readonly createPullRequest: (input: {
|
||||
readonly cwd: string;
|
||||
readonly baseBranch: string;
|
||||
readonly headSelector: string;
|
||||
readonly source?: SourceControlProvider.SourceControlRefSelector;
|
||||
readonly target?: SourceControlProvider.SourceControlRefSelector;
|
||||
readonly title: string;
|
||||
readonly bodyFile: string;
|
||||
}) => Effect.Effect<void, AzureDevOpsCliError>;
|
||||
|
||||
readonly getDefaultBranch: (input: {
|
||||
readonly cwd: string;
|
||||
}) => Effect.Effect<string | null, AzureDevOpsCliError>;
|
||||
|
||||
readonly checkoutPullRequest: (input: {
|
||||
readonly cwd: string;
|
||||
readonly reference: string;
|
||||
readonly remoteName?: string;
|
||||
}) => Effect.Effect<void, AzureDevOpsCliError>;
|
||||
}
|
||||
>()("t3/sourceControl/AzureDevOpsCli") {}
|
||||
|
||||
function normalizeChangeRequestId(reference: string): string {
|
||||
const trimmed = reference.trim().replace(/^#/, "");
|
||||
const urlMatch = /(?:pullrequest|pull-request|pull|_pulls?)\/(\d+)(?:\D.*)?$/i.exec(trimmed);
|
||||
return urlMatch?.[1] ?? trimmed;
|
||||
}
|
||||
|
||||
function toAzureStatus(state: "open" | "closed" | "merged" | "all"): string {
|
||||
switch (state) {
|
||||
case "open":
|
||||
return "active";
|
||||
case "closed":
|
||||
return "abandoned";
|
||||
case "merged":
|
||||
return "completed";
|
||||
case "all":
|
||||
return "all";
|
||||
}
|
||||
}
|
||||
|
||||
const RawAzureDevOpsRepositorySchema = Schema.Struct({
|
||||
name: TrimmedNonEmptyString,
|
||||
webUrl: TrimmedNonEmptyString,
|
||||
remoteUrl: TrimmedNonEmptyString,
|
||||
sshUrl: TrimmedNonEmptyString,
|
||||
project: Schema.optional(
|
||||
Schema.Struct({
|
||||
name: TrimmedNonEmptyString,
|
||||
}),
|
||||
),
|
||||
defaultBranch: Schema.optional(Schema.NullOr(Schema.String)),
|
||||
});
|
||||
|
||||
function normalizeDefaultBranch(value: string | null | undefined): string | null {
|
||||
const trimmed = value?.trim().replace(/^refs\/heads\//, "") ?? "";
|
||||
return trimmed.length > 0 ? trimmed : null;
|
||||
}
|
||||
|
||||
function normalizeRepositoryCloneUrls(
|
||||
raw: Schema.Schema.Type<typeof RawAzureDevOpsRepositorySchema>,
|
||||
): AzureDevOpsRepositoryCloneUrls {
|
||||
const projectName = raw.project?.name.trim();
|
||||
return {
|
||||
nameWithOwner: projectName ? `${projectName}/${raw.name}` : raw.name,
|
||||
url: raw.remoteUrl,
|
||||
sshUrl: raw.sshUrl,
|
||||
};
|
||||
}
|
||||
|
||||
function parseRepositorySpecifier(repository: string): {
|
||||
readonly project: string | null;
|
||||
readonly name: string;
|
||||
} {
|
||||
const parts: Array<string> = [];
|
||||
for (const part of repository.split("/")) {
|
||||
const trimmed = part.trim();
|
||||
if (trimmed.length > 0) {
|
||||
parts.push(trimmed);
|
||||
}
|
||||
}
|
||||
return {
|
||||
project: parts.length > 1 ? (parts.at(-2) ?? null) : null,
|
||||
name: parts.at(-1) ?? repository.trim(),
|
||||
};
|
||||
}
|
||||
|
||||
function decodeAzureDevOpsJson<S extends Schema.Top>(
|
||||
raw: string,
|
||||
schema: S,
|
||||
operation: typeof AzureDevOpsRepositoryDecodeOperation.Type,
|
||||
cwd: string,
|
||||
): Effect.Effect<S["Type"], AzureDevOpsRepositoryDecodeError, S["DecodingServices"]> {
|
||||
return Schema.decodeEffect(Schema.fromJsonString(schema))(raw).pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new AzureDevOpsRepositoryDecodeError({
|
||||
operation,
|
||||
command: "az",
|
||||
cwd,
|
||||
outputLength: raw.length,
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/** @public Service construction is part of the canonical Effect module API. */
|
||||
export const make = Effect.gen(function* () {
|
||||
const process = yield* VcsProcess.VcsProcess;
|
||||
|
||||
const execute: AzureDevOpsCli["Service"]["execute"] = (input) =>
|
||||
process
|
||||
.run({
|
||||
operation: "AzureDevOpsCli.execute",
|
||||
command: "az",
|
||||
args: input.args,
|
||||
cwd: input.cwd,
|
||||
timeoutMs: input.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
||||
...(input.maxOutputBytes === undefined ? {} : { maxOutputBytes: input.maxOutputBytes }),
|
||||
})
|
||||
.pipe(
|
||||
Effect.mapError((error) =>
|
||||
AzureDevOpsCommandFailedError.fromVcsError(
|
||||
{
|
||||
operation: "execute",
|
||||
command: "az",
|
||||
cwd: input.cwd,
|
||||
argumentCount: input.args.length,
|
||||
},
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const executeJson = (input: Parameters<AzureDevOpsCli["Service"]["execute"]>[0]) =>
|
||||
execute({
|
||||
...input,
|
||||
args: [...input.args, "--only-show-errors", "--output", "json"],
|
||||
});
|
||||
|
||||
return AzureDevOpsCli.of({
|
||||
execute,
|
||||
listPullRequests: (input) =>
|
||||
executeJson({
|
||||
cwd: input.cwd,
|
||||
args: [
|
||||
"repos",
|
||||
"pr",
|
||||
"list",
|
||||
"--detect",
|
||||
"true",
|
||||
"--source-branch",
|
||||
SourceControlProvider.sourceBranch(input),
|
||||
"--status",
|
||||
toAzureStatus(input.state),
|
||||
"--top",
|
||||
String(input.limit ?? 20),
|
||||
],
|
||||
}).pipe(
|
||||
Effect.map((result) => result.stdout.trim()),
|
||||
Effect.flatMap((raw) =>
|
||||
raw.length === 0
|
||||
? Effect.succeed([])
|
||||
: Effect.sync(() => decodeAzureDevOpsPullRequestListJson(raw)).pipe(
|
||||
Effect.flatMap((decoded) => {
|
||||
if (!Result.isSuccess(decoded)) {
|
||||
return Effect.fail(
|
||||
new AzureDevOpsPullRequestListDecodeError({
|
||||
operation: "listPullRequests",
|
||||
command: "az",
|
||||
cwd: input.cwd,
|
||||
outputLength: raw.length,
|
||||
cause: decoded.failure,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return Effect.succeed(decoded.success);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
getPullRequest: (input) =>
|
||||
executeJson({
|
||||
cwd: input.cwd,
|
||||
args: [
|
||||
"repos",
|
||||
"pr",
|
||||
"show",
|
||||
"--detect",
|
||||
"true",
|
||||
"--id",
|
||||
normalizeChangeRequestId(input.reference),
|
||||
],
|
||||
}).pipe(
|
||||
Effect.map((result) => result.stdout.trim()),
|
||||
Effect.flatMap((raw) =>
|
||||
Effect.sync(() => decodeAzureDevOpsPullRequestJson(raw)).pipe(
|
||||
Effect.flatMap((decoded) => {
|
||||
if (!Result.isSuccess(decoded)) {
|
||||
return Effect.fail(
|
||||
new AzureDevOpsPullRequestDecodeError({
|
||||
operation: "getPullRequest",
|
||||
command: "az",
|
||||
cwd: input.cwd,
|
||||
outputLength: raw.length,
|
||||
cause: decoded.failure,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return Effect.succeed(decoded.success);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
getRepositoryCloneUrls: (input) =>
|
||||
executeJson({
|
||||
cwd: input.cwd,
|
||||
args: ["repos", "show", "--detect", "true", "--repository", input.repository],
|
||||
}).pipe(
|
||||
Effect.map((result) => result.stdout.trim()),
|
||||
Effect.flatMap((raw) =>
|
||||
decodeAzureDevOpsJson(
|
||||
raw,
|
||||
RawAzureDevOpsRepositorySchema,
|
||||
"getRepositoryCloneUrls",
|
||||
input.cwd,
|
||||
),
|
||||
),
|
||||
Effect.map(normalizeRepositoryCloneUrls),
|
||||
),
|
||||
createRepository: (input) => {
|
||||
const repository = parseRepositorySpecifier(input.repository);
|
||||
// Azure Repos access is governed by project/organization permissions.
|
||||
// `az repos create` does not expose a per-repository visibility flag, so
|
||||
// the generic source-control visibility input is intentionally not
|
||||
// translated into CLI args for this provider.
|
||||
return executeJson({
|
||||
cwd: input.cwd,
|
||||
args: [
|
||||
"repos",
|
||||
"create",
|
||||
"--detect",
|
||||
"true",
|
||||
"--name",
|
||||
repository.name,
|
||||
...(repository.project ? ["--project", repository.project] : []),
|
||||
],
|
||||
}).pipe(
|
||||
Effect.map((result) => result.stdout.trim()),
|
||||
Effect.flatMap((raw) =>
|
||||
decodeAzureDevOpsJson(raw, RawAzureDevOpsRepositorySchema, "createRepository", input.cwd),
|
||||
),
|
||||
Effect.map(normalizeRepositoryCloneUrls),
|
||||
);
|
||||
},
|
||||
createPullRequest: (input) =>
|
||||
execute({
|
||||
cwd: input.cwd,
|
||||
args: [
|
||||
"repos",
|
||||
"pr",
|
||||
"create",
|
||||
"--only-show-errors",
|
||||
"--detect",
|
||||
"true",
|
||||
"--target-branch",
|
||||
input.target?.refName ?? input.baseBranch,
|
||||
"--source-branch",
|
||||
SourceControlProvider.sourceBranch(input),
|
||||
"--title",
|
||||
input.title,
|
||||
"--description",
|
||||
`@${input.bodyFile}`,
|
||||
],
|
||||
}).pipe(Effect.asVoid),
|
||||
getDefaultBranch: (input) =>
|
||||
executeJson({
|
||||
cwd: input.cwd,
|
||||
args: ["repos", "show", "--detect", "true"],
|
||||
}).pipe(
|
||||
Effect.map((result) => result.stdout.trim()),
|
||||
Effect.flatMap((raw) =>
|
||||
decodeAzureDevOpsJson(raw, RawAzureDevOpsRepositorySchema, "getDefaultBranch", input.cwd),
|
||||
),
|
||||
Effect.map((repo) => normalizeDefaultBranch(repo.defaultBranch)),
|
||||
),
|
||||
checkoutPullRequest: (input) =>
|
||||
execute({
|
||||
cwd: input.cwd,
|
||||
args: [
|
||||
"repos",
|
||||
"pr",
|
||||
"checkout",
|
||||
"--only-show-errors",
|
||||
"--detect",
|
||||
"true",
|
||||
"--id",
|
||||
normalizeChangeRequestId(input.reference),
|
||||
"--remote-name",
|
||||
input.remoteName ?? "origin",
|
||||
],
|
||||
}).pipe(Effect.asVoid),
|
||||
});
|
||||
});
|
||||
|
||||
export const layer = Layer.effect(AzureDevOpsCli, make);
|
||||
@@ -1,120 +0,0 @@
|
||||
import { assert, it } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
|
||||
import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";
|
||||
import * as AzureDevOpsSourceControlProvider from "./AzureDevOpsSourceControlProvider.ts";
|
||||
|
||||
function makeProvider(azure: Partial<AzureDevOpsCli.AzureDevOpsCli["Service"]>) {
|
||||
return AzureDevOpsSourceControlProvider.make.pipe(
|
||||
Effect.provide(Layer.mock(AzureDevOpsCli.AzureDevOpsCli)(azure)),
|
||||
);
|
||||
}
|
||||
|
||||
it.effect("maps Azure DevOps PR summaries into provider-neutral change requests", () =>
|
||||
Effect.gen(function* () {
|
||||
const provider = yield* makeProvider({
|
||||
getPullRequest: () =>
|
||||
Effect.succeed({
|
||||
number: 42,
|
||||
title: "Add Azure provider",
|
||||
url: "https://dev.azure.com/acme/project/_git/repo/pullrequest/42",
|
||||
baseRefName: "main",
|
||||
headRefName: "feature/source-control",
|
||||
state: "closed",
|
||||
closedAt: "2026-08-23T10:00:00Z",
|
||||
updatedAt: Option.none(),
|
||||
}),
|
||||
});
|
||||
|
||||
const changeRequest = yield* provider.getChangeRequest({
|
||||
cwd: "/repo",
|
||||
reference: "42",
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(changeRequest, {
|
||||
provider: "azure-devops",
|
||||
number: 42,
|
||||
title: "Add Azure provider",
|
||||
url: "https://dev.azure.com/acme/project/_git/repo/pullrequest/42",
|
||||
baseRefName: "main",
|
||||
headRefName: "feature/source-control",
|
||||
state: "closed",
|
||||
closedAt: "2026-08-23T10:00:00Z",
|
||||
mergedAt: null,
|
||||
updatedAt: Option.none(),
|
||||
isCrossRepository: false,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("adds change-request context while retaining Azure CLI causes", () =>
|
||||
Effect.gen(function* () {
|
||||
const cause = new AzureDevOpsCli.AzureDevOpsCommandFailedError({
|
||||
operation: "execute",
|
||||
command: "az",
|
||||
cwd: "/repo",
|
||||
argumentCount: 2,
|
||||
cause: new Error("raw upstream detail that should remain in the cause"),
|
||||
});
|
||||
const provider = yield* makeProvider({
|
||||
checkoutPullRequest: () => Effect.fail(cause),
|
||||
});
|
||||
|
||||
const error = yield* provider
|
||||
.checkoutChangeRequest({ cwd: "/repo", reference: "#42" })
|
||||
.pipe(Effect.flip);
|
||||
|
||||
assert.deepStrictEqual(
|
||||
{
|
||||
provider: error.provider,
|
||||
operation: error.operation,
|
||||
command: error.command,
|
||||
cwd: error.cwd,
|
||||
reference: error.reference,
|
||||
detail: error.detail,
|
||||
},
|
||||
{
|
||||
provider: "azure-devops",
|
||||
operation: "checkoutChangeRequest",
|
||||
command: "az",
|
||||
cwd: "/repo",
|
||||
reference: "#42",
|
||||
detail: "Azure DevOps CLI command failed.",
|
||||
},
|
||||
);
|
||||
assert.strictEqual(error.cause, cause);
|
||||
assert.equal(error.message.includes("raw upstream detail"), false);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("creates Azure DevOps PRs through provider-neutral input names", () =>
|
||||
Effect.gen(function* () {
|
||||
let createInput:
|
||||
| Parameters<AzureDevOpsCli.AzureDevOpsCli["Service"]["createPullRequest"]>[0]
|
||||
| null = null;
|
||||
const provider = yield* makeProvider({
|
||||
createPullRequest: (input) => {
|
||||
createInput = input;
|
||||
return Effect.void;
|
||||
},
|
||||
});
|
||||
|
||||
yield* provider.createChangeRequest({
|
||||
cwd: "/repo",
|
||||
baseRefName: "main",
|
||||
headSelector: "feature/provider",
|
||||
title: "Provider PR",
|
||||
bodyFile: "/tmp/body.md",
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(createInput, {
|
||||
cwd: "/repo",
|
||||
baseBranch: "main",
|
||||
headSelector: "feature/provider",
|
||||
title: "Provider PR",
|
||||
bodyFile: "/tmp/body.md",
|
||||
});
|
||||
}),
|
||||
);
|
||||
@@ -1,236 +0,0 @@
|
||||
import * as Effect from "effect/Effect";
|
||||
import { SourceControlProviderError, type ChangeRequest } from "@t3tools/contracts";
|
||||
|
||||
import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";
|
||||
import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
|
||||
import {
|
||||
combinedAuthOutput,
|
||||
firstSafeAuthLine,
|
||||
providerAuth,
|
||||
type SourceControlAuthProbeInput,
|
||||
type SourceControlCliDiscoverySpec,
|
||||
} from "@t3tools/source-control-core/server/discovery";
|
||||
|
||||
function parseAzureAuth(input: SourceControlAuthProbeInput) {
|
||||
const account = input.stdout.trim().split(/\r?\n/)[0]?.trim();
|
||||
|
||||
if (input.exitCode !== 0) {
|
||||
return providerAuth({
|
||||
status: "unauthenticated",
|
||||
detail:
|
||||
firstSafeAuthLine(combinedAuthOutput(input)) ?? "Run `az login` to authenticate Azure CLI.",
|
||||
});
|
||||
}
|
||||
|
||||
if (account !== undefined && account.length > 0) {
|
||||
return providerAuth({
|
||||
status: "authenticated",
|
||||
account,
|
||||
host: "dev.azure.com",
|
||||
});
|
||||
}
|
||||
|
||||
return providerAuth({
|
||||
status: "unknown",
|
||||
host: "dev.azure.com",
|
||||
detail: "Azure CLI account status could not be parsed.",
|
||||
});
|
||||
}
|
||||
|
||||
export const discovery = {
|
||||
type: "cli",
|
||||
kind: "azure-devops",
|
||||
label: "Azure DevOps",
|
||||
executable: "az",
|
||||
versionArgs: ["--version"],
|
||||
authArgs: ["account", "show", "--query", "user.name", "-o", "tsv"],
|
||||
// `az` boots a fresh Python interpreter on every invocation, so even `az --version`
|
||||
// takes ~6s on Windows and overruns the default budget, leaving the provider reported
|
||||
// as missing on machines where it is installed. `gh` and `glab` answer in ~0.3s.
|
||||
probeTimeoutMs: 20_000,
|
||||
parseAuth: parseAzureAuth,
|
||||
installHint:
|
||||
"Install the Azure command-line tools (`az`), then enable Azure DevOps support with `az extension add --name azure-devops`.",
|
||||
} satisfies SourceControlCliDiscoverySpec;
|
||||
|
||||
function toChangeRequest(summary: {
|
||||
readonly number: number;
|
||||
readonly title: string;
|
||||
readonly url: string;
|
||||
readonly baseRefName: string;
|
||||
readonly headRefName: string;
|
||||
readonly state: "open" | "closed" | "merged";
|
||||
readonly isDraft?: boolean;
|
||||
readonly closedAt?: string | null;
|
||||
readonly mergedAt?: string | null;
|
||||
readonly updatedAt: ChangeRequest["updatedAt"];
|
||||
}): ChangeRequest {
|
||||
return {
|
||||
provider: "azure-devops",
|
||||
number: summary.number,
|
||||
title: summary.title,
|
||||
url: summary.url,
|
||||
baseRefName: summary.baseRefName,
|
||||
headRefName: summary.headRefName,
|
||||
state: summary.state,
|
||||
...(summary.isDraft === true ? { isDraft: true } : {}),
|
||||
closedAt: summary.closedAt ?? null,
|
||||
mergedAt: summary.mergedAt ?? null,
|
||||
updatedAt: summary.updatedAt,
|
||||
isCrossRepository: false,
|
||||
};
|
||||
}
|
||||
|
||||
export const make = Effect.gen(function* () {
|
||||
const azure = yield* AzureDevOpsCli.AzureDevOpsCli;
|
||||
|
||||
return SourceControlProvider.SourceControlProvider.of({
|
||||
kind: "azure-devops",
|
||||
listChangeRequests: (input) => {
|
||||
const source = SourceControlProvider.sourceControlRefFromInput(input);
|
||||
return azure
|
||||
.listPullRequests({
|
||||
cwd: input.cwd,
|
||||
headSelector: input.headSelector,
|
||||
...(source !== undefined ? { source } : {}),
|
||||
state: input.state,
|
||||
...(input.limit !== undefined ? { limit: input.limit } : {}),
|
||||
})
|
||||
.pipe(
|
||||
Effect.map((items) => items.map(toChangeRequest)),
|
||||
Effect.mapError(
|
||||
(error) =>
|
||||
new SourceControlProviderError({
|
||||
provider: "azure-devops",
|
||||
operation: "listChangeRequests",
|
||||
command: error.command,
|
||||
cwd: input.cwd,
|
||||
reference: SourceControlProvider.transportSafeSourceControlErrorValue(
|
||||
input.headSelector,
|
||||
),
|
||||
detail: error.detail,
|
||||
cause: error,
|
||||
}),
|
||||
),
|
||||
);
|
||||
},
|
||||
getChangeRequest: (input) =>
|
||||
azure.getPullRequest(input).pipe(
|
||||
Effect.map(toChangeRequest),
|
||||
Effect.mapError(
|
||||
(error) =>
|
||||
new SourceControlProviderError({
|
||||
provider: "azure-devops",
|
||||
operation: "getChangeRequest",
|
||||
command: error.command,
|
||||
cwd: input.cwd,
|
||||
reference: SourceControlProvider.transportSafeSourceControlErrorValue(
|
||||
input.reference,
|
||||
),
|
||||
detail: error.detail,
|
||||
cause: error,
|
||||
}),
|
||||
),
|
||||
),
|
||||
createChangeRequest: (input) => {
|
||||
const source = SourceControlProvider.sourceControlRefFromInput(input);
|
||||
return azure
|
||||
.createPullRequest({
|
||||
cwd: input.cwd,
|
||||
baseBranch: input.baseRefName,
|
||||
headSelector: input.headSelector,
|
||||
...(source !== undefined ? { source } : {}),
|
||||
...(input.target !== undefined ? { target: input.target } : {}),
|
||||
title: input.title,
|
||||
bodyFile: input.bodyFile,
|
||||
})
|
||||
.pipe(
|
||||
Effect.mapError(
|
||||
(error) =>
|
||||
new SourceControlProviderError({
|
||||
provider: "azure-devops",
|
||||
operation: "createChangeRequest",
|
||||
command: error.command,
|
||||
cwd: input.cwd,
|
||||
reference: SourceControlProvider.transportSafeSourceControlErrorValue(
|
||||
input.headSelector,
|
||||
),
|
||||
detail: error.detail,
|
||||
cause: error,
|
||||
}),
|
||||
),
|
||||
);
|
||||
},
|
||||
getRepositoryCloneUrls: (input) =>
|
||||
azure.getRepositoryCloneUrls(input).pipe(
|
||||
Effect.mapError(
|
||||
(error) =>
|
||||
new SourceControlProviderError({
|
||||
provider: "azure-devops",
|
||||
operation: "getRepositoryCloneUrls",
|
||||
command: error.command,
|
||||
cwd: input.cwd,
|
||||
repository: SourceControlProvider.transportSafeSourceControlErrorValue(
|
||||
input.repository,
|
||||
),
|
||||
detail: error.detail,
|
||||
cause: error,
|
||||
}),
|
||||
),
|
||||
),
|
||||
createRepository: (input) =>
|
||||
azure.createRepository(input).pipe(
|
||||
Effect.mapError(
|
||||
(error) =>
|
||||
new SourceControlProviderError({
|
||||
provider: "azure-devops",
|
||||
operation: "createRepository",
|
||||
command: error.command,
|
||||
cwd: input.cwd,
|
||||
repository: SourceControlProvider.transportSafeSourceControlErrorValue(
|
||||
input.repository,
|
||||
),
|
||||
detail: error.detail,
|
||||
cause: error,
|
||||
}),
|
||||
),
|
||||
),
|
||||
getDefaultBranch: (input) =>
|
||||
azure.getDefaultBranch({ cwd: input.cwd }).pipe(
|
||||
Effect.mapError(
|
||||
(error) =>
|
||||
new SourceControlProviderError({
|
||||
provider: "azure-devops",
|
||||
operation: "getDefaultBranch",
|
||||
command: error.command,
|
||||
cwd: input.cwd,
|
||||
detail: error.detail,
|
||||
cause: error,
|
||||
}),
|
||||
),
|
||||
),
|
||||
checkoutChangeRequest: (input) =>
|
||||
azure
|
||||
.checkoutPullRequest({
|
||||
cwd: input.cwd,
|
||||
reference: input.reference,
|
||||
...(input.context !== undefined ? { remoteName: input.context.remoteName } : {}),
|
||||
})
|
||||
.pipe(
|
||||
Effect.mapError(
|
||||
(error) =>
|
||||
new SourceControlProviderError({
|
||||
provider: "azure-devops",
|
||||
operation: "checkoutChangeRequest",
|
||||
command: error.command,
|
||||
cwd: input.cwd,
|
||||
reference: SourceControlProvider.transportSafeSourceControlErrorValue(
|
||||
input.reference,
|
||||
),
|
||||
detail: error.detail,
|
||||
cause: error,
|
||||
}),
|
||||
),
|
||||
),
|
||||
});
|
||||
});
|
||||
@@ -16,7 +16,8 @@ import * as ServerConfig from "../config.ts";
|
||||
import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";
|
||||
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
|
||||
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";
|
||||
import * as AzureDevOpsCli from "@t3tools/source-control-azure-devops/server/AzureDevOpsCli";
|
||||
import * as AzureDevOpsPullRequestCli from "@t3tools/source-control-azure-devops/server/AzureDevOpsPullRequestCli";
|
||||
import * as BitbucketApi from "./BitbucketApi.ts";
|
||||
import * as GitHubApi from "./GitHubApi.ts";
|
||||
import * as GitLabCli from "./GitLabCli.ts";
|
||||
@@ -39,6 +40,7 @@ const layerSourceControlProviderRegistryTest = (input: {
|
||||
prefix: "t3-source-control-registry-test-",
|
||||
}).pipe(Layer.provide(NodeServices.layer)),
|
||||
Layer.mock(AzureDevOpsCli.AzureDevOpsCli)({}),
|
||||
Layer.mock(AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli)({}),
|
||||
Layer.mock(BitbucketApi.BitbucketApi)(input.bitbucket),
|
||||
ServerSettings.ServerSettingsService.layerTest(),
|
||||
Layer.mock(GitHubApi.GitHubApi)({}),
|
||||
|
||||
@@ -13,7 +13,8 @@ import * as ServerConfig from "../config.ts";
|
||||
import type * as VcsDriver from "../vcs/VcsDriver.ts";
|
||||
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
|
||||
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";
|
||||
import * as AzureDevOpsCli from "@t3tools/source-control-azure-devops/server/AzureDevOpsCli";
|
||||
import * as AzureDevOpsPullRequestCli from "@t3tools/source-control-azure-devops/server/AzureDevOpsPullRequestCli";
|
||||
import * as BitbucketApi from "./BitbucketApi.ts";
|
||||
import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";
|
||||
import * as GitHubApi from "./GitHubApi.ts";
|
||||
@@ -103,6 +104,7 @@ function makeRegistry(input: {
|
||||
),
|
||||
),
|
||||
Layer.mock(AzureDevOpsCli.AzureDevOpsCli)({}),
|
||||
Layer.mock(AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli)({}),
|
||||
Layer.mock(BitbucketApi.BitbucketApi)({}),
|
||||
ServerSettings.ServerSettingsService.layerTest(),
|
||||
Layer.mock(GitHubApi.GitHubApi)({
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
import type { SourceControlProviderKind } from "@t3tools/contracts";
|
||||
import { detectSourceControlProviderFromRemoteUrl } from "@t3tools/shared/sourceControl";
|
||||
|
||||
import * as AzureDevOpsSourceControlProvider from "./AzureDevOpsSourceControlProvider.ts";
|
||||
import * as BitbucketSourceControlProvider from "./BitbucketSourceControlProvider.ts";
|
||||
import * as GitHubSourceControlProvider from "./GitHubSourceControlProvider.ts";
|
||||
import * as GitLabSourceControlProvider from "./GitLabSourceControlProvider.ts";
|
||||
@@ -310,7 +309,6 @@ export const make = Effect.gen(function* () {
|
||||
const gitlab = yield* GitLabSourceControlProvider.make;
|
||||
const bitbucket = yield* BitbucketSourceControlProvider.make;
|
||||
const bitbucketDiscovery = yield* BitbucketSourceControlProvider.makeDiscovery;
|
||||
const azureDevOps = yield* AzureDevOpsSourceControlProvider.make;
|
||||
const drivers = yield* Effect.forEach(BuiltInDrivers.BUILT_IN_SOURCE_CONTROL_DRIVERS, (driver) =>
|
||||
driver.make.pipe(
|
||||
Effect.map((instance): SourceControlProviderRegistration => ({
|
||||
@@ -320,7 +318,9 @@ export const make = Effect.gen(function* () {
|
||||
})),
|
||||
),
|
||||
);
|
||||
return yield* makeWithProviders([
|
||||
// Discovery lists hosts in this order, so it is kept while hosts move into packages.
|
||||
const order = ["github", "gitlab", "azure-devops", "bitbucket", "forgejo"];
|
||||
const registrations: ReadonlyArray<SourceControlProviderRegistration> = [
|
||||
{
|
||||
kind: "github",
|
||||
provider: github,
|
||||
@@ -331,18 +331,16 @@ export const make = Effect.gen(function* () {
|
||||
provider: gitlab,
|
||||
discovery: GitLabSourceControlProvider.discovery,
|
||||
},
|
||||
{
|
||||
kind: "azure-devops",
|
||||
provider: azureDevOps,
|
||||
discovery: AzureDevOpsSourceControlProvider.discovery,
|
||||
},
|
||||
{
|
||||
kind: "bitbucket",
|
||||
provider: bitbucket,
|
||||
discovery: bitbucketDiscovery,
|
||||
},
|
||||
...drivers,
|
||||
]);
|
||||
];
|
||||
return yield* makeWithProviders(
|
||||
registrations.toSorted((left, right) => order.indexOf(left.kind) - order.indexOf(right.kind)),
|
||||
);
|
||||
});
|
||||
|
||||
export const layer = Layer.effect(SourceControlProviderRegistry, make);
|
||||
@@ -1,222 +0,0 @@
|
||||
import * as Cause from "effect/Cause";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Exit from "effect/Exit";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Result from "effect/Result";
|
||||
import * as Schema from "effect/Schema";
|
||||
import { PositiveInt, TrimmedNonEmptyString } from "@t3tools/contracts";
|
||||
import { decodeJsonResult } from "@t3tools/shared/schemaJson";
|
||||
|
||||
export interface NormalizedAzureDevOpsPullRequestRecord {
|
||||
readonly number: number;
|
||||
readonly title: string;
|
||||
readonly url: string;
|
||||
readonly baseRefName: string;
|
||||
readonly headRefName: string;
|
||||
readonly state: "open" | "closed" | "merged";
|
||||
readonly isDraft?: boolean;
|
||||
readonly closedAt?: string | null;
|
||||
readonly mergedAt?: string | null;
|
||||
readonly updatedAt: Option.Option<DateTime.Utc>;
|
||||
}
|
||||
|
||||
const AzureDevOpsPullRequestSchema = Schema.Struct({
|
||||
pullRequestId: PositiveInt,
|
||||
title: TrimmedNonEmptyString,
|
||||
url: Schema.optional(Schema.String),
|
||||
repository: Schema.optional(
|
||||
Schema.Struct({
|
||||
name: Schema.optional(Schema.String),
|
||||
webUrl: Schema.optional(Schema.String),
|
||||
project: Schema.optional(
|
||||
Schema.Struct({
|
||||
name: Schema.optional(Schema.String),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
),
|
||||
sourceRefName: TrimmedNonEmptyString,
|
||||
targetRefName: TrimmedNonEmptyString,
|
||||
status: Schema.String,
|
||||
isDraft: Schema.optional(Schema.Boolean),
|
||||
creationDate: Schema.optional(Schema.OptionFromNullOr(Schema.DateTimeUtcFromString)),
|
||||
closedDate: Schema.optional(Schema.OptionFromNullOr(Schema.DateTimeUtcFromString)),
|
||||
_links: Schema.optional(
|
||||
Schema.Struct({
|
||||
web: Schema.optional(
|
||||
Schema.Struct({
|
||||
href: Schema.String,
|
||||
}),
|
||||
),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
function trimOptionalString(value: string | null | undefined): string | null {
|
||||
const trimmed = value?.trim() ?? "";
|
||||
return trimmed.length > 0 ? trimmed : null;
|
||||
}
|
||||
|
||||
function normalizeRefName(refName: string): string {
|
||||
return refName.trim().replace(/^refs\/heads\//, "");
|
||||
}
|
||||
|
||||
function normalizeAzureDevOpsPullRequestState(status: string): "open" | "closed" | "merged" {
|
||||
switch (status.trim().toLowerCase()) {
|
||||
case "completed":
|
||||
return "merged";
|
||||
case "abandoned":
|
||||
return "closed";
|
||||
default:
|
||||
return "open";
|
||||
}
|
||||
}
|
||||
|
||||
function encodeAzureDevOpsPathSegment(segment: string): string {
|
||||
return encodeURIComponent(segment);
|
||||
}
|
||||
|
||||
/**
|
||||
* The organization root a REST url belongs to, which is where a browser url has to be hung when
|
||||
* Azure answered with neither a web link nor a repository url. Read from what Azure returned
|
||||
* rather than from the local remote, whose shape varies.
|
||||
*/
|
||||
function azureDevOpsOrganizationBaseFromRestApiUrl(
|
||||
value: string | null | undefined,
|
||||
): string | null {
|
||||
const rawUrl = trimOptionalString(value);
|
||||
if (!rawUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = new URL(rawUrl);
|
||||
const hostname = url.hostname.toLowerCase();
|
||||
const pathSegments = url.pathname.split("/").filter((segment) => segment.length > 0);
|
||||
const isAzureRestUrl = pathSegments.some((segment) => segment.toLowerCase() === "_apis");
|
||||
if (!isAzureRestUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (hostname === "dev.azure.com") {
|
||||
const organization = pathSegments[0];
|
||||
return organization ? `${url.origin}/${organization}` : null;
|
||||
}
|
||||
|
||||
if (hostname.endsWith(".visualstudio.com")) {
|
||||
return url.origin;
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Where a pull request lives in a browser. Azure answers with a web link when asked for one and
|
||||
* otherwise leaves it to be assembled, so all three routes are tried in the order they can be
|
||||
* trusted. Takes plain fields so both the source control provider and the pull requests page
|
||||
* can share it.
|
||||
*/
|
||||
export function azureDevOpsPullRequestWebUrl(input: {
|
||||
readonly pullRequestId: number;
|
||||
readonly webLink?: string | null | undefined;
|
||||
readonly repositoryWebUrl?: string | null | undefined;
|
||||
readonly restApiUrl?: string | null | undefined;
|
||||
readonly projectName?: string | null | undefined;
|
||||
readonly repositoryName?: string | null | undefined;
|
||||
}): string {
|
||||
const webLink = trimOptionalString(input.webLink);
|
||||
if (webLink) {
|
||||
return webLink;
|
||||
}
|
||||
|
||||
const repositoryWebUrl = trimOptionalString(input.repositoryWebUrl);
|
||||
if (repositoryWebUrl) {
|
||||
return `${repositoryWebUrl.replace(/\/+$/, "")}/pullrequest/${input.pullRequestId}`;
|
||||
}
|
||||
|
||||
const organizationBase = azureDevOpsOrganizationBaseFromRestApiUrl(input.restApiUrl);
|
||||
const projectName = trimOptionalString(input.projectName);
|
||||
const repositoryName = trimOptionalString(input.repositoryName);
|
||||
if (organizationBase && projectName && repositoryName) {
|
||||
const encodedProjectName = encodeAzureDevOpsPathSegment(projectName);
|
||||
const encodedRepositoryName = encodeAzureDevOpsPathSegment(repositoryName);
|
||||
return `${organizationBase}/${encodedProjectName}/_git/${encodedRepositoryName}/pullrequest/${input.pullRequestId}`;
|
||||
}
|
||||
|
||||
return trimOptionalString(input.restApiUrl) ?? "";
|
||||
}
|
||||
|
||||
function normalizeAzureDevOpsPullRequestUrl(
|
||||
raw: Schema.Schema.Type<typeof AzureDevOpsPullRequestSchema>,
|
||||
): string {
|
||||
return azureDevOpsPullRequestWebUrl({
|
||||
pullRequestId: raw.pullRequestId,
|
||||
webLink: raw._links?.web?.href,
|
||||
repositoryWebUrl: raw.repository?.webUrl,
|
||||
restApiUrl: raw.url,
|
||||
projectName: raw.repository?.project?.name,
|
||||
repositoryName: raw.repository?.name,
|
||||
});
|
||||
}
|
||||
|
||||
function normalizeAzureDevOpsPullRequestRecord(
|
||||
raw: Schema.Schema.Type<typeof AzureDevOpsPullRequestSchema>,
|
||||
): NormalizedAzureDevOpsPullRequestRecord {
|
||||
const state = normalizeAzureDevOpsPullRequestState(raw.status);
|
||||
const terminalAt = Option.match(raw.closedDate ?? Option.none(), {
|
||||
onNone: () => null,
|
||||
onSome: DateTime.formatIso,
|
||||
});
|
||||
return {
|
||||
number: raw.pullRequestId,
|
||||
title: raw.title,
|
||||
url: normalizeAzureDevOpsPullRequestUrl(raw),
|
||||
baseRefName: normalizeRefName(raw.targetRefName),
|
||||
headRefName: normalizeRefName(raw.sourceRefName),
|
||||
state,
|
||||
...(raw.isDraft === true ? { isDraft: true } : {}),
|
||||
closedAt: state === "closed" ? terminalAt : null,
|
||||
mergedAt: state === "merged" ? terminalAt : null,
|
||||
updatedAt: (raw.closedDate ?? Option.none()).pipe(
|
||||
Option.orElse(() => raw.creationDate ?? Option.none()),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
const decodeAzureDevOpsPullRequestList = decodeJsonResult(Schema.Array(Schema.Unknown));
|
||||
const decodeAzureDevOpsPullRequest = decodeJsonResult(AzureDevOpsPullRequestSchema);
|
||||
const decodeAzureDevOpsPullRequestEntry = Schema.decodeUnknownExit(AzureDevOpsPullRequestSchema);
|
||||
|
||||
export function decodeAzureDevOpsPullRequestListJson(
|
||||
raw: string,
|
||||
): Result.Result<
|
||||
ReadonlyArray<NormalizedAzureDevOpsPullRequestRecord>,
|
||||
Cause.Cause<Schema.SchemaError>
|
||||
> {
|
||||
const result = decodeAzureDevOpsPullRequestList(raw);
|
||||
if (Result.isSuccess(result)) {
|
||||
const pullRequests: NormalizedAzureDevOpsPullRequestRecord[] = [];
|
||||
for (const entry of result.success) {
|
||||
const decodedEntry = decodeAzureDevOpsPullRequestEntry(entry);
|
||||
if (Exit.isFailure(decodedEntry)) {
|
||||
continue;
|
||||
}
|
||||
pullRequests.push(normalizeAzureDevOpsPullRequestRecord(decodedEntry.value));
|
||||
}
|
||||
return Result.succeed(pullRequests);
|
||||
}
|
||||
return Result.fail(result.failure);
|
||||
}
|
||||
|
||||
export function decodeAzureDevOpsPullRequestJson(
|
||||
raw: string,
|
||||
): Result.Result<NormalizedAzureDevOpsPullRequestRecord, Cause.Cause<Schema.SchemaError>> {
|
||||
const result = decodeAzureDevOpsPullRequest(raw);
|
||||
if (Result.isSuccess(result)) {
|
||||
return Result.succeed(normalizeAzureDevOpsPullRequestRecord(result.success));
|
||||
}
|
||||
return Result.fail(result.failure);
|
||||
}
|
||||
@@ -7,14 +7,28 @@
|
||||
*
|
||||
* @module sourceControl/builtInDrivers
|
||||
*/
|
||||
import * as AzureDevOpsCli from "@t3tools/source-control-azure-devops/server/AzureDevOpsCli";
|
||||
import * as AzureDevOpsPullRequestCli from "@t3tools/source-control-azure-devops/server/AzureDevOpsPullRequestCli";
|
||||
import * as AzureDevOpsDriver from "@t3tools/source-control-azure-devops/server/driver";
|
||||
import * as ForgejoCli from "@t3tools/source-control-forgejo/server/ForgejoCli";
|
||||
import * as ForgejoDriver from "@t3tools/source-control-forgejo/server/driver";
|
||||
import type { SourceControlDriver } from "@t3tools/source-control-core/server/driver";
|
||||
import * as Layer from "effect/Layer";
|
||||
|
||||
import * as ServerSourceControlHost from "./ServerSourceControlHost.ts";
|
||||
|
||||
/** Ordered as the hosts appear in discovery, after the ones still built in the server. */
|
||||
export const BUILT_IN_SOURCE_CONTROL_DRIVERS = [ForgejoDriver.driver] as const;
|
||||
const drivers = [AzureDevOpsDriver.driver, ForgejoDriver.driver];
|
||||
|
||||
/** Every service a built-in driver's `make` needs; the server's layers must provide them all. */
|
||||
export type BuiltInSourceControlDriversEnv =
|
||||
(typeof drivers)[number] extends SourceControlDriver<infer R> ? R : never;
|
||||
|
||||
export const BUILT_IN_SOURCE_CONTROL_DRIVERS: ReadonlyArray<
|
||||
SourceControlDriver<BuiltInSourceControlDriversEnv>
|
||||
> = drivers;
|
||||
|
||||
/** The services the built-in drivers' packages own, plus the host port they all run against. */
|
||||
export const layer = ForgejoCli.layer.pipe(Layer.provideMerge(ServerSourceControlHost.layer));
|
||||
export const layer = Layer.mergeAll(
|
||||
AzureDevOpsPullRequestCli.layer.pipe(Layer.provideMerge(AzureDevOpsCli.layer)),
|
||||
ForgejoCli.layer,
|
||||
).pipe(Layer.provideMerge(ServerSourceControlHost.layer));
|
||||
Reference in new issue
Block a user