Skip to content

Commit b9f4e5f

Browse files
committed
fix(ci): resolve Effect-TS catchAll rule violations and TS union type lint errors
1 parent 93e6a22 commit b9f4e5f

5 files changed

Lines changed: 40 additions & 26 deletions

File tree

packages/lib/src/usecases/actions/create-project.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ import { renderError } from "../errors.js"
2323
import { applyGithubForkConfig } from "../github-fork.js"
2424
import { defaultProjectsRoot } from "../menu-helpers.js"
2525
import { findSshPrivateKey } from "../path-helpers.js"
26-
import {
27-
buildSshCommand,
28-
getContainerIpIfInsideContainer
29-
} from "../projects-core.js"
26+
import { buildSshCommand, getContainerIpIfInsideContainer } from "../projects-core.js"
3027
import { resolveTemplateResourceLimits } from "../resource-limits.js"
3128
import { autoSyncState } from "../state-repo.js"
3229
import { ensureTerminalCursorVisible } from "../terminal-cursor.js"
@@ -148,7 +145,7 @@ const openSshBestEffort = (
148145

149146
const ipAddress = yield* _(
150147
getContainerIpIfInsideContainer(fs, process.cwd(), template.containerName).pipe(
151-
Effect.catchAll(() => Effect.succeed(undefined))
148+
Effect.orElse(() => Effect.succeed<string | undefined>(""))
152149
)
153150
)
154151

packages/lib/src/usecases/actions/docker-up.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ const logSshAccess = (
3838
const path = yield* _(Path.Path)
3939

4040
const isInsideContainer = yield* _(fs.exists("/.dockerenv"))
41-
let ipAddress: string | undefined = undefined
41+
let ipAddress: string | undefined
4242

4343
if (isInsideContainer) {
4444
const containerIp = yield* _(
4545
runDockerInspectContainerIp(baseDir, config.containerName).pipe(
46-
Effect.catchAll(() => Effect.succeed(""))
46+
Effect.orElse(() => Effect.succeed(""))
4747
)
4848
)
4949
if (containerIp.length > 0) {

packages/lib/src/usecases/projects-core.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { Effect, pipe } from "effect"
66

77
import type { ProjectConfig, TemplateConfig } from "../core/domain.js"
88
import { deriveRepoPathParts } from "../core/domain.js"
9-
import { runDockerInspectContainerIp } from "../shell/docker.js"
109
import { readProjectConfig } from "../shell/config.js"
10+
import { runDockerInspectContainerIp } from "../shell/docker.js"
1111
import type { ConfigDecodeError, ConfigNotFoundError } from "../shell/errors.js"
1212
import { resolveBaseDir } from "../shell/paths.js"
1313
import { findDockerGitConfigPaths } from "./docker-git-config-search.js"
@@ -89,12 +89,12 @@ export const getContainerIpIfInsideContainer = (
8989
Effect.gen(function*(_) {
9090
const isInsideContainer = yield* _(fs.exists("/.dockerenv"))
9191
if (!isInsideContainer) {
92-
return undefined
92+
return
9393
}
9494
return yield* _(
9595
runDockerInspectContainerIp(projectDir, containerName).pipe(
96-
Effect.map((ip) => (ip.length > 0 ? ip : undefined)),
97-
Effect.catchAll(() => Effect.succeed(undefined))
96+
Effect.orElse(() => Effect.succeed("")),
97+
Effect.map((ip) => (ip.length > 0 ? ip : undefined))
9898
)
9999
)
100100
})
@@ -117,7 +117,11 @@ const findProjectConfigPaths = (
117117
export const loadProjectSummary = (
118118
configPath: string,
119119
sshKey: string | null
120-
): Effect.Effect<ProjectSummary, ProjectLoadError, FileSystem.FileSystem | Path.Path | CommandExecutor.CommandExecutor> =>
120+
): Effect.Effect<
121+
ProjectSummary,
122+
ProjectLoadError,
123+
FileSystem.FileSystem | Path.Path | CommandExecutor.CommandExecutor
124+
> =>
121125
Effect.gen(function*(_) {
122126
const { config, fs, path, projectDir } = yield* _(loadProjectBase(configPath))
123127

packages/lib/src/usecases/projects-list.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ import {
2626
// EFFECT: Effect<void, PlatformError, FileSystem | Path>
2727
// INVARIANT: output is deterministic for a stable filesystem
2828
// COMPLEXITY: O(n) where n = |projects|
29+
export type ListProjectsContext = FileSystem.FileSystem | Path.Path | CommandExecutor.CommandExecutor
30+
2931
export const listProjects: Effect.Effect<
3032
void,
3133
PlatformError,
32-
FileSystem.FileSystem | Path.Path | CommandExecutor.CommandExecutor
34+
ListProjectsContext
3335
> = pipe(
3436
withProjectIndexAndSsh((index, sshKey) =>
3537
Effect.gen(function*(_) {
@@ -78,9 +80,12 @@ const emptyItems = (): ReadonlyArray<ProjectItem> => []
7880
const collectProjectValues = <A, B, E>(
7981
configPaths: ReadonlyArray<string>,
8082
sshKey: string | null,
81-
load: (configPath: string, sshKey: string | null) => Effect.Effect<A, E, FileSystem.FileSystem | Path.Path | CommandExecutor.CommandExecutor>,
83+
load: (
84+
configPath: string,
85+
sshKey: string | null
86+
) => Effect.Effect<A, E, ListProjectsContext>,
8287
toValue: (value: A) => B
83-
): Effect.Effect<ReadonlyArray<B>, never, FileSystem.FileSystem | Path.Path | CommandExecutor.CommandExecutor> =>
88+
): Effect.Effect<ReadonlyArray<B>, never, ListProjectsContext> =>
8489
Effect.gen(function*(_) {
8590
const available: Array<B> = []
8691

@@ -102,10 +107,17 @@ const collectProjectValues = <A, B, E>(
102107
})
103108

104109
const listProjectValues = <A, B, E>(
105-
load: (configPath: string, sshKey: string | null) => Effect.Effect<A, E, FileSystem.FileSystem | Path.Path | CommandExecutor.CommandExecutor>,
110+
load: (
111+
configPath: string,
112+
sshKey: string | null
113+
) => Effect.Effect<A, E, ListProjectsContext>,
106114
toValue: (value: A) => B,
107115
empty: () => ReadonlyArray<B>
108-
): Effect.Effect<ReadonlyArray<B>, PlatformError, FileSystem.FileSystem | Path.Path | CommandExecutor.CommandExecutor> =>
116+
): Effect.Effect<
117+
ReadonlyArray<B>,
118+
PlatformError,
119+
ListProjectsContext
120+
> =>
109121
pipe(
110122
withProjectIndexAndSsh((index, sshKey) => collectProjectValues(index.configPaths, sshKey, load, toValue)),
111123
Effect.map((values) => values ?? empty())
@@ -114,7 +126,7 @@ const listProjectValues = <A, B, E>(
114126
export const listProjectSummaries: Effect.Effect<
115127
ReadonlyArray<string>,
116128
PlatformError,
117-
FileSystem.FileSystem | Path.Path | CommandExecutor.CommandExecutor
129+
ListProjectsContext
118130
> = listProjectValues(loadProjectSummary, renderProjectSummary, emptySummaries)
119131

120132
// CHANGE: load docker-git projects for TUI selection
@@ -130,7 +142,7 @@ export const listProjectSummaries: Effect.Effect<
130142
export const listProjectItems: Effect.Effect<
131143
ReadonlyArray<ProjectItem>,
132144
PlatformError,
133-
FileSystem.FileSystem | Path.Path | CommandExecutor.CommandExecutor
145+
ListProjectsContext
134146
> = listProjectValues(loadProjectItem, (value) => value, emptyItems)
135147

136148
// CHANGE: list only running docker-git projects (for "Stop container" UI)
@@ -146,7 +158,7 @@ export const listProjectItems: Effect.Effect<
146158
export const listRunningProjectItems: Effect.Effect<
147159
ReadonlyArray<ProjectItem>,
148160
PlatformError | CommandFailedError,
149-
FileSystem.FileSystem | Path.Path | CommandExecutor.CommandExecutor
161+
ListProjectsContext
150162
> = pipe(
151163
Effect.all([listProjectItems, runDockerPsNames(process.cwd())]),
152164
Effect.map(([items, runningNames]) => items.filter((item) => runningNames.includes(item.containerName)))

packages/lib/src/usecases/projects-ssh.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type * as CommandExecutor from "@effect/platform/CommandExecutor"
22
import type { PlatformError } from "@effect/platform/Error"
33
import * as FileSystem from "@effect/platform/FileSystem"
4-
import * as Path from "@effect/platform/Path"
4+
import type * as Path from "@effect/platform/Path"
55
import { Duration, Effect, pipe, Schedule } from "effect"
66

77
import { runCommandExitCode, runCommandWithExitCodes } from "../shell/command-runner.js"
@@ -169,11 +169,11 @@ export const connectProjectSshWithUp = (
169169
const template = yield* _(runDockerComposeUpWithPortCheck(item.projectDir))
170170

171171
const isInsideContainer = yield* _(fs.exists("/.dockerenv"))
172-
let ipAddress: string | undefined = undefined
172+
let ipAddress: string | undefined
173173
if (isInsideContainer) {
174174
const containerIp = yield* _(
175175
runDockerInspectContainerIp(item.projectDir, template.containerName).pipe(
176-
Effect.catchAll(() => Effect.succeed(""))
176+
Effect.orElse(() => Effect.succeed(""))
177177
)
178178
)
179179
if (containerIp.length > 0) {
@@ -209,7 +209,9 @@ export const listProjectStatus: Effect.Effect<
209209
forEachProjectStatus(index.configPaths, (status) =>
210210
Effect.gen(function*(_) {
211211
const fs = yield* _(FileSystem.FileSystem)
212-
const ipAddress = yield* _(getContainerIpIfInsideContainer(fs, status.projectDir, status.config.template.containerName))
212+
const ipAddress = yield* _(
213+
getContainerIpIfInsideContainer(fs, status.projectDir, status.config.template.containerName)
214+
)
213215

214216
yield* _(Effect.log(renderProjectStatusHeader(status)))
215217
yield* _(Effect.log(`SSH access: ${buildSshCommand(status.config.template, sshKey, ipAddress)}`))
@@ -226,6 +228,5 @@ export const listProjectStatus: Effect.Effect<
226228
),
227229
onSuccess: () => Effect.void
228230
})
229-
)
230-
)
231+
))
231232
).pipe(Effect.asVoid)

0 commit comments

Comments
 (0)