Showing the changes to apps/server/src/sourceControl/AzureDevOpsSourceControlProvider.ts (1 of 42 files). Show all
Unified · Split
| @@ -4,7 +4,13 @@ import { SourceControlProviderError, type ChangeRequest } from "@t3tools/contrac · 3 unmodified lines | |||
| 4 | 4 | ||
| 5 | import * as AzureDevOpsCli from "./AzureDevOpsCli.ts"; | 5 | import * as AzureDevOpsCli from "./AzureDevOpsCli.ts"; |
| 6 | import * as SourceControlProvider from "./SourceControlProvider.ts"; | 6 | import * as SourceControlProvider from "./SourceControlProvider.ts"; |
| 7 | import * as SourceControlProviderDiscovery from "./SourceControlProviderDiscovery.ts"; | 7 | import { |
| 8 | combinedAuthOutput, | ||
| 9 | firstSafeAuthLine, | ||
| 10 | providerAuth, | ||
| 11 | type SourceControlAuthProbeInput, | ||
| 12 | type SourceControlCliDiscoverySpec, | ||
| 13 | } from "./SourceControlProviderDiscovery.ts"; | ||
| 8 | 14 | ||
| 9 | function providerError( | 15 | function providerError( |
| 10 | operation: string, | 16 | operation: string, |
| @@ -18,28 +24,26 @@ function providerError( · 7 unmodified lines | |||
| 18 | }); | 24 | }); |
| 19 | } | 25 | } |
| 20 | 26 | ||
| 21 | function parseAzureAuth(input: SourceControlProviderDiscovery.SourceControlAuthProbeInput) { | 27 | function 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 | ||
| 61 | function toChangeRequest(summary: { | 65 | function 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 | ||
| 83 | export const make = Effect.fn("makeAzureDevOpsSourceControlProvider")(function* () { | 87 | export 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 | ||
| 145 | export const layer = Layer.effect(SourceControlProvider.SourceControlProvider, make()); | 149 | export const layer = Layer.effect(SourceControlProvider.SourceControlProvider, make); |