History

[codex] Migrate server source control Effect services (#3186)

Julius Marminge committed 4 months ago

Commit d9e95391 parent 7118e4342 files · +1336 −1338Browse files

Showing the changes to apps/server/src/sourceControl/AzureDevOpsSourceControlProvider.ts (1 of 42 files). Show all

Unified · Split

apps/server/src/sourceControl/AzureDevOpsSourceControlProvider.ts+15−11
@@ -4,7 +4,13 @@ import { SourceControlProviderError, type ChangeRequest } from "@t3tools/contrac · 3 unmodified lines
4 4
5import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";5import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";
6import * as SourceControlProvider from "./SourceControlProvider.ts";6import * as SourceControlProvider from "./SourceControlProvider.ts";
7import * as SourceControlProviderDiscovery from "./SourceControlProviderDiscovery.ts";7import {
8 combinedAuthOutput,
9 firstSafeAuthLine,
10 providerAuth,
11 type SourceControlAuthProbeInput,
12 type SourceControlCliDiscoverySpec,
13} from "./SourceControlProviderDiscovery.ts";
8 14
9function providerError(15function providerError(
10 operation: string,16 operation: string,
@@ -18,28 +24,26 @@ function providerError( · 7 unmodified lines
18 });24 });
19}25}
20 26
21function parseAzureAuth(input: SourceControlProviderDiscovery.SourceControlAuthProbeInput) {27function parseAzureAuth(input: SourceControlAuthProbeInput) {
22 const account = input.stdout.trim().split(/\r?\n/)[0]?.trim();28 const account = input.stdout.trim().split(/\r?\n/)[0]?.trim();
23 29
24 if (input.exitCode !== 0) {30 if (input.exitCode !== 0) {
25 return SourceControlProviderDiscovery.providerAuth({31 return providerAuth({
26 status: "unauthenticated",32 status: "unauthenticated",
27 detail:33 detail:
28 SourceControlProviderDiscovery.firstSafeAuthLine(34 firstSafeAuthLine(combinedAuthOutput(input)) ?? "Run `az login` to authenticate Azure CLI.",
29 SourceControlProviderDiscovery.combinedAuthOutput(input),
30 ) ?? "Run `az login` to authenticate Azure CLI.",
31 });35 });
32 }36 }
33 37
34 if (account !== undefined && account.length > 0) {38 if (account !== undefined && account.length > 0) {
35 return SourceControlProviderDiscovery.providerAuth({39 return providerAuth({
36 status: "authenticated",40 status: "authenticated",
37 account,41 account,
38 host: "dev.azure.com",42 host: "dev.azure.com",
39 });43 });
40 }44 }
41 45
42 return SourceControlProviderDiscovery.providerAuth({46 return providerAuth({
43 status: "unknown",47 status: "unknown",
44 host: "dev.azure.com",48 host: "dev.azure.com",
45 detail: "Azure CLI account status could not be parsed.",49 detail: "Azure CLI account status could not be parsed.",
@@ -56,7 +60,7 @@ export const discovery = { · 10 unmodified lines
56 parseAuth: parseAzureAuth,60 parseAuth: parseAzureAuth,
57 installHint:61 installHint:
58 "Install the Azure command-line tools (`az`), then enable Azure DevOps support with `az extension add --name azure-devops`.",62 "Install the Azure command-line tools (`az`), then enable Azure DevOps support with `az extension add --name azure-devops`.",
59} satisfies SourceControlProviderDiscovery.SourceControlCliDiscoverySpec;63} satisfies SourceControlCliDiscoverySpec;
60 64
61function toChangeRequest(summary: {65function toChangeRequest(summary: {
62 readonly number: number;66 readonly number: number;
@@ -80,7 +84,7 @@ function toChangeRequest(summary: { · 17 unmodified lines
80 };84 };
81}85}
82 86
83export const make = Effect.fn("makeAzureDevOpsSourceControlProvider")(function* () {87export const make = Effect.gen(function* () {
84 const azure = yield* AzureDevOpsCli.AzureDevOpsCli;88 const azure = yield* AzureDevOpsCli.AzureDevOpsCli;
85 89
86 return SourceControlProvider.SourceControlProvider.of({90 return SourceControlProvider.SourceControlProvider.of({
@@ -142,4 +146,4 @@ export const make = Effect.fn("makeAzureDevOpsSourceControlProvider")(function* · 55 unmodified lines
142 });146 });
143});147});
144 148
145export const layer = Layer.effect(SourceControlProvider.SourceControlProvider, make());149export const layer = Layer.effect(SourceControlProvider.SourceControlProvider, make);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t