refactor: layer variables are named layer or layerXyz (#16282)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
4df84a7d03
commit
ecfdda5fa8
401 files changed
+7338
-7418
No files matched your search
@@ -21,13 +21,13 @@ const processOutput = (stdout: string): VcsProcess.VcsProcessOutput => ({
|
||||
|
||||
const mockRun = vi.fn<VcsProcess.VcsProcess["Service"]["run"]>();
|
||||
|
||||
const supportLayer = Layer.mergeAll(
|
||||
const layerSupport = Layer.mergeAll(
|
||||
Layer.mock(VcsProcess.VcsProcess)({
|
||||
run: mockRun,
|
||||
}),
|
||||
NodeServices.layer,
|
||||
);
|
||||
const layer = Layer.mergeAll(AzureDevOpsCli.layer.pipe(Layer.provide(supportLayer)), supportLayer);
|
||||
const layer = Layer.mergeAll(AzureDevOpsCli.layer.pipe(Layer.provide(layerSupport)), layerSupport);
|
||||
|
||||
afterEach(() => {
|
||||
mockRun.mockReset();
|
||||
|
||||
@@ -27,7 +27,7 @@ const TEMPLATE_DIRECTORIES = [
|
||||
"docs/PULL_REQUEST_TEMPLATE",
|
||||
] as const;
|
||||
|
||||
const PrTemplateDetectionTestLayer = GitVcsDriver.layer.pipe(
|
||||
const layerPrTemplateDetectionTest = GitVcsDriver.layer.pipe(
|
||||
Layer.provide(
|
||||
ServerConfig.layerTest(process.cwd(), {
|
||||
prefix: "t3-pr-template-test-",
|
||||
@@ -59,7 +59,7 @@ const runWithTempDirectory = <A, E, R>(
|
||||
yield* runGit(cwd, ["config", "user.name", "Test User"]);
|
||||
return yield* test(cwd);
|
||||
}),
|
||||
).pipe(Effect.provide(PrTemplateDetectionTestLayer));
|
||||
).pipe(Effect.provide(layerPrTemplateDetectionTest));
|
||||
|
||||
const writeTemplate = (cwd: string, relativePath: string, contents: string) =>
|
||||
Effect.gen(function* () {
|
||||
|
||||
@@ -25,7 +25,7 @@ import * as SourceControlDiscovery from "./SourceControlDiscovery.ts";
|
||||
import * as SourceControlProviderRegistry from "./SourceControlProviderRegistry.ts";
|
||||
import { firstNonEmptyLine } from "./SourceControlProviderDiscovery.ts";
|
||||
|
||||
const sourceControlProviderRegistryTestLayer = (input: {
|
||||
const layerSourceControlProviderRegistryTest = (input: {
|
||||
readonly bitbucket: Partial<BitbucketApi.BitbucketApi["Service"]>;
|
||||
readonly process: Partial<VcsProcess.VcsProcess["Service"]>;
|
||||
}) =>
|
||||
@@ -530,7 +530,7 @@ it.effect("reports implemented tools separately from locally available executabl
|
||||
);
|
||||
},
|
||||
} satisfies Partial<VcsProcess.VcsProcess["Service"]>;
|
||||
const testLayer = SourceControlDiscovery.layer.pipe(
|
||||
const layerTest = SourceControlDiscovery.layer.pipe(
|
||||
Layer.provide(
|
||||
ServerConfig.layerTest(process.cwd(), {
|
||||
prefix: "t3-source-control-discovery-",
|
||||
@@ -538,7 +538,7 @@ it.effect("reports implemented tools separately from locally available executabl
|
||||
),
|
||||
Layer.provide(Layer.mock(VcsProcess.VcsProcess)(processMock)),
|
||||
Layer.provide(
|
||||
sourceControlProviderRegistryTestLayer({
|
||||
layerSourceControlProviderRegistryTest({
|
||||
process: processMock,
|
||||
bitbucket: {
|
||||
probeAuth: Effect.succeed({
|
||||
@@ -613,7 +613,7 @@ it.effect("reports implemented tools separately from locally available executabl
|
||||
const bitbucket = result.sourceControlProviders.find((item) => item.kind === "bitbucket");
|
||||
assert.ok(bitbucket);
|
||||
assert.strictEqual(bitbucket.executable, undefined);
|
||||
}).pipe(Effect.provide(testLayer));
|
||||
}).pipe(Effect.provide(layerTest));
|
||||
});
|
||||
|
||||
it.effect("probes provider authentication without exposing token details", () => {
|
||||
@@ -681,7 +681,7 @@ Logged in to gitlab.com as gitlab-user
|
||||
);
|
||||
},
|
||||
} satisfies Partial<VcsProcess.VcsProcess["Service"]>;
|
||||
const testLayer = SourceControlDiscovery.layer.pipe(
|
||||
const layerTest = SourceControlDiscovery.layer.pipe(
|
||||
Layer.provide(
|
||||
ServerConfig.layerTest(process.cwd(), {
|
||||
prefix: "t3-source-control-auth-discovery-",
|
||||
@@ -689,7 +689,7 @@ Logged in to gitlab.com as gitlab-user
|
||||
),
|
||||
Layer.provide(Layer.mock(VcsProcess.VcsProcess)(processMock)),
|
||||
Layer.provide(
|
||||
sourceControlProviderRegistryTestLayer({
|
||||
layerSourceControlProviderRegistryTest({
|
||||
process: processMock,
|
||||
bitbucket: {
|
||||
probeAuth: Effect.succeed({
|
||||
@@ -748,7 +748,7 @@ Logged in to gitlab.com as gitlab-user
|
||||
},
|
||||
],
|
||||
);
|
||||
}).pipe(Effect.provide(testLayer));
|
||||
}).pipe(Effect.provide(layerTest));
|
||||
});
|
||||
|
||||
it.effect("discovers Forgejo accounts and retains the server port", () =>
|
||||
|
||||
@@ -60,7 +60,7 @@ function makeRegistry(input: {
|
||||
}),
|
||||
} satisfies Partial<VcsDriver.VcsDriver["Service"]>;
|
||||
|
||||
const registryLayer = Layer.mock(VcsDriverRegistry.VcsDriverRegistry)({
|
||||
const layerRegistry = Layer.mock(VcsDriverRegistry.VcsDriverRegistry)({
|
||||
get: () => Effect.succeed(driver as unknown as VcsDriver.VcsDriver["Service"]),
|
||||
resolve:
|
||||
input.resolve ??
|
||||
@@ -81,7 +81,7 @@ function makeRegistry(input: {
|
||||
})),
|
||||
});
|
||||
|
||||
const processLayer = Layer.mock(VcsProcess.VcsProcess)({
|
||||
const layerProcess = Layer.mock(VcsProcess.VcsProcess)({
|
||||
run: () => Effect.succeed(processOutput("")),
|
||||
...input.process,
|
||||
});
|
||||
@@ -90,8 +90,8 @@ function makeRegistry(input: {
|
||||
Effect.provide(
|
||||
Layer.mergeAll(
|
||||
NodeServices.layer,
|
||||
registryLayer,
|
||||
processLayer,
|
||||
layerRegistry,
|
||||
layerProcess,
|
||||
Layer.mock(AzureDevOpsCli.AzureDevOpsCli)({}),
|
||||
Layer.mock(BitbucketApi.BitbucketApi)({}),
|
||||
Layer.mock(GitHubCli.GitHubCli)(input.github ?? {}),
|
||||
|
||||
@@ -54,12 +54,12 @@ function processOutput(): GitVcsDriver.ExecuteGitResult {
|
||||
};
|
||||
}
|
||||
|
||||
function makeLayer(input: {
|
||||
function layer(input: {
|
||||
readonly provider?: SourceControlProvider.SourceControlProvider["Service"];
|
||||
readonly git?: Partial<GitVcsDriver.GitVcsDriver["Service"]>;
|
||||
readonly fileSystem?: FileSystem.FileSystem;
|
||||
}) {
|
||||
const serviceLayer = SourceControlRepositoryService.layer.pipe(
|
||||
const layerService = SourceControlRepositoryService.layer.pipe(
|
||||
Layer.provide(
|
||||
Layer.mock(SourceControlProviderRegistry.SourceControlProviderRegistry)({
|
||||
resolveLink: () => undefined,
|
||||
@@ -89,11 +89,11 @@ function makeLayer(input: {
|
||||
);
|
||||
|
||||
return input.fileSystem
|
||||
? serviceLayer.pipe(
|
||||
? layerService.pipe(
|
||||
Layer.provide(Layer.succeed(FileSystem.FileSystem, input.fileSystem)),
|
||||
Layer.provideMerge(NodePath.layer),
|
||||
)
|
||||
: serviceLayer.pipe(Layer.provideMerge(NodeServices.layer));
|
||||
: layerService.pipe(Layer.provideMerge(NodeServices.layer));
|
||||
}
|
||||
|
||||
it.effect("looks up repositories through the requested provider without search", () => {
|
||||
@@ -116,7 +116,7 @@ it.effect("looks up repositories through the requested provider without search",
|
||||
|
||||
assert.deepStrictEqual(result, { provider: "github", ...CLONE_URLS });
|
||||
assert.deepStrictEqual(calls, [{ cwd: "/workspace", repository: "octocat/t3code" }]);
|
||||
}).pipe(Effect.provide(makeLayer({ provider })));
|
||||
}).pipe(Effect.provide(layer({ provider })));
|
||||
});
|
||||
|
||||
it.effect("preserves provider failures without deriving the repository message from them", () => {
|
||||
@@ -149,7 +149,7 @@ it.effect("preserves provider failures without deriving the repository message f
|
||||
"Source control repository operation lookupRepository failed for github: The source control operation could not be completed.",
|
||||
);
|
||||
assert.strictEqual(error.cause, providerCause);
|
||||
}).pipe(Effect.provide(makeLayer({ provider })));
|
||||
}).pipe(Effect.provide(layer({ provider })));
|
||||
});
|
||||
|
||||
it.effect("clones a looked-up repository into the requested destination", () =>
|
||||
@@ -184,7 +184,7 @@ it.effect("clones a looked-up repository into the requested destination", () =>
|
||||
]);
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
makeLayer({
|
||||
layer({
|
||||
git: {
|
||||
execute: (input) =>
|
||||
Effect.sync(() => {
|
||||
@@ -226,7 +226,7 @@ it.effect("reports clone progress from git's stderr and keeps its error text on
|
||||
);
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
makeLayer({
|
||||
layer({
|
||||
git: {
|
||||
execute: (input) =>
|
||||
Effect.gen(function* () {
|
||||
@@ -274,7 +274,7 @@ it.effect("strips embedded credentials from the remote URL it reports", () =>
|
||||
});
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
makeLayer({
|
||||
layer({
|
||||
git: {
|
||||
execute: (input) =>
|
||||
Effect.sync(() => {
|
||||
@@ -316,7 +316,7 @@ it.effect("discards only a directory git wrote to", () =>
|
||||
assert.include(replacedError.detail, "could not be inspected");
|
||||
// A destination that never got created is nothing to discard.
|
||||
yield* service.discardClone(path.join(parent, "missing"));
|
||||
}).pipe(Effect.provide(makeLayer({})));
|
||||
}).pipe(Effect.provide(layer({})));
|
||||
|
||||
// The partial clone is emptied but its directory (the workspace root) stays.
|
||||
assert.deepStrictEqual(yield* fs.readDirectory(partial), []);
|
||||
@@ -342,7 +342,7 @@ it.effect("redacts query tokens and userinfo containing '@' from reported URLs",
|
||||
destinationPath: path.join(parent, "b"),
|
||||
});
|
||||
assert.equal(nested.remoteUrl, "https://github.com/octocat/t3code.git");
|
||||
}).pipe(Effect.provide(makeLayer({})));
|
||||
}).pipe(Effect.provide(layer({})));
|
||||
}).pipe(Effect.provide(NodeServices.layer)),
|
||||
);
|
||||
|
||||
@@ -368,7 +368,7 @@ it.effect("preserves destination probe failures instead of treating them as miss
|
||||
assert.strictEqual(error.cause, fileSystemCause);
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
makeLayer({
|
||||
layer({
|
||||
fileSystem: FileSystem.makeNoop({
|
||||
exists: () => Effect.fail(fileSystemCause),
|
||||
makeDirectory: () => Effect.void,
|
||||
@@ -422,7 +422,7 @@ it.effect("publishes by creating the repository, adding a remote, and pushing up
|
||||
assert.deepStrictEqual(pushCalls, [{ cwd: "/workspace", remoteName: "origin" }]);
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
makeLayer({
|
||||
layer({
|
||||
provider,
|
||||
git: {
|
||||
ensureRemote: (input) =>
|
||||
@@ -464,7 +464,7 @@ it.effect("publishes to the remote name returned by ensureRemote", () => {
|
||||
assert.deepStrictEqual(pushCalls, [{ cwd: "/workspace", remoteName: "origin-1" }]);
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
makeLayer({
|
||||
layer({
|
||||
git: {
|
||||
ensureRemote: () => Effect.succeed("origin-1"),
|
||||
pushCurrentBranch: (cwd, _fallbackBranch, options) =>
|
||||
@@ -506,7 +506,7 @@ it.effect("publish succeeds with status remote_added when the local repo has no
|
||||
assert.strictEqual(pushCalls, 0);
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
makeLayer({
|
||||
layer({
|
||||
git: {
|
||||
execute: (input) =>
|
||||
input.args[0] === "rev-parse"
|
||||
|
||||
Reference in new issue
Block a user