[codex] Migrate server source control Effect services (#3186)
Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
7118e43d16
commit
d9e9539862
42 files changed
+1326
-1328
No files matched your search
@@ -4,7 +4,13 @@ import { SourceControlProviderError, type ChangeRequest } from "@t3tools/contrac
|
||||
|
||||
import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";
|
||||
import * as SourceControlProvider from "./SourceControlProvider.ts";
|
||||
import * as SourceControlProviderDiscovery from "./SourceControlProviderDiscovery.ts";
|
||||
import {
|
||||
combinedAuthOutput,
|
||||
firstSafeAuthLine,
|
||||
providerAuth,
|
||||
type SourceControlAuthProbeInput,
|
||||
type SourceControlCliDiscoverySpec,
|
||||
} from "./SourceControlProviderDiscovery.ts";
|
||||
|
||||
function providerError(
|
||||
operation: string,
|
||||
@@ -18,28 +24,26 @@ function providerError(
|
||||
});
|
||||
}
|
||||
|
||||
function parseAzureAuth(input: SourceControlProviderDiscovery.SourceControlAuthProbeInput) {
|
||||
function parseAzureAuth(input: SourceControlAuthProbeInput) {
|
||||
const account = input.stdout.trim().split(/\r?\n/)[0]?.trim();
|
||||
|
||||
if (input.exitCode !== 0) {
|
||||
return SourceControlProviderDiscovery.providerAuth({
|
||||
return providerAuth({
|
||||
status: "unauthenticated",
|
||||
detail:
|
||||
SourceControlProviderDiscovery.firstSafeAuthLine(
|
||||
SourceControlProviderDiscovery.combinedAuthOutput(input),
|
||||
) ?? "Run `az login` to authenticate Azure CLI.",
|
||||
firstSafeAuthLine(combinedAuthOutput(input)) ?? "Run `az login` to authenticate Azure CLI.",
|
||||
});
|
||||
}
|
||||
|
||||
if (account !== undefined && account.length > 0) {
|
||||
return SourceControlProviderDiscovery.providerAuth({
|
||||
return providerAuth({
|
||||
status: "authenticated",
|
||||
account,
|
||||
host: "dev.azure.com",
|
||||
});
|
||||
}
|
||||
|
||||
return SourceControlProviderDiscovery.providerAuth({
|
||||
return providerAuth({
|
||||
status: "unknown",
|
||||
host: "dev.azure.com",
|
||||
detail: "Azure CLI account status could not be parsed.",
|
||||
@@ -56,7 +60,7 @@ export const discovery = {
|
||||
parseAuth: parseAzureAuth,
|
||||
installHint:
|
||||
"Install the Azure command-line tools (`az`), then enable Azure DevOps support with `az extension add --name azure-devops`.",
|
||||
} satisfies SourceControlProviderDiscovery.SourceControlCliDiscoverySpec;
|
||||
} satisfies SourceControlCliDiscoverySpec;
|
||||
|
||||
function toChangeRequest(summary: {
|
||||
readonly number: number;
|
||||
@@ -80,7 +84,7 @@ function toChangeRequest(summary: {
|
||||
};
|
||||
}
|
||||
|
||||
export const make = Effect.fn("makeAzureDevOpsSourceControlProvider")(function* () {
|
||||
export const make = Effect.gen(function* () {
|
||||
const azure = yield* AzureDevOpsCli.AzureDevOpsCli;
|
||||
|
||||
return SourceControlProvider.SourceControlProvider.of({
|
||||
@@ -142,4 +146,4 @@ export const make = Effect.fn("makeAzureDevOpsSourceControlProvider")(function*
|
||||
});
|
||||
});
|
||||
|
||||
export const layer = Layer.effect(SourceControlProvider.SourceControlProvider, make());
|
||||
export const layer = Layer.effect(SourceControlProvider.SourceControlProvider, make);
|
||||
Reference in new issue
Block a user