Skip to content

Commit c4436d6

Browse files
committed
fix(lint): satisfy complexity/max-lines rules
1 parent 785c3f5 commit c4436d6

7 files changed

Lines changed: 186 additions & 132 deletions

File tree

packages/app/src/docker-git/cli/parser-scrap.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,17 @@ export const parseScrap = (args: ReadonlyArray<string>): Either.Either<Command,
5353
const rest = args.slice(1)
5454

5555
return Match.value(action).pipe(
56-
Match.when("export", () =>
57-
Either.map(parseProjectDirWithOptions(rest), ({ projectDir, raw }) =>
58-
makeScrapExportCommand(
59-
projectDir,
60-
raw.archivePath?.trim() && raw.archivePath.trim().length > 0
61-
? raw.archivePath.trim()
62-
: defaultArchivePath
63-
))),
56+
Match.when(
57+
"export",
58+
() =>
59+
Either.map(parseProjectDirWithOptions(rest), ({ projectDir, raw }) =>
60+
makeScrapExportCommand(
61+
projectDir,
62+
raw.archivePath?.trim() && raw.archivePath.trim().length > 0
63+
? raw.archivePath.trim()
64+
: defaultArchivePath
65+
))
66+
),
6467
Match.when("import", () =>
6568
Either.flatMap(parseProjectDirWithOptions(rest), ({ projectDir, raw }) => {
6669
const archivePath = raw.archivePath?.trim()

packages/app/src/docker-git/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import type { AppError } from "@effect-template/lib/usecases/errors"
1212
import { renderError } from "@effect-template/lib/usecases/errors"
1313
import { downAllDockerGitProjects, listProjectStatus } from "@effect-template/lib/usecases/projects"
14+
import { exportScrap, importScrap } from "@effect-template/lib/usecases/scrap"
1415
import {
1516
stateCommit,
1617
stateInit,
@@ -25,7 +26,6 @@ import {
2526
listTerminalSessions,
2627
tailTerminalLogs
2728
} from "@effect-template/lib/usecases/terminal-sessions"
28-
import { exportScrap, importScrap } from "@effect-template/lib/usecases/scrap"
2929
import { Effect, Match, pipe } from "effect"
3030
import { readCommand } from "./cli/read-command.js"
3131
import { attachTmux, listTmuxPanes } from "./tmux.js"

packages/lib/src/core/templates-entrypoint/nested-docker-git.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { TemplateConfig } from "../domain.js"
22

3-
const entrypointDockerGitBootstrapTemplate = String.raw`# Bootstrap ~/.docker-git for nested docker-git usage inside this container.
3+
const entrypointDockerGitBootstrapTemplate = String
4+
.raw`# Bootstrap ~/.docker-git for nested docker-git usage inside this container.
45
DOCKER_GIT_HOME="/home/__SSH_USER__/.docker-git"
56
DOCKER_GIT_AUTH_DIR="$DOCKER_GIT_HOME/.orch/auth/codex"
67
DOCKER_GIT_ENV_DIR="$DOCKER_GIT_HOME/.orch/env"

packages/lib/src/core/templates/dockerfile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ const renderDockerfileBun = (config: TemplateConfig): string =>
9393
renderDockerfileBunPrelude(config),
9494
config.enableMcpPlaywright
9595
? dockerfilePlaywrightMcpBlock
96-
.replaceAll("\\${", "${")
97-
.replaceAll("__SERVICE_NAME__", config.serviceName)
96+
.replaceAll("\\${", "${")
97+
.replaceAll("__SERVICE_NAME__", config.serviceName)
9898
: "",
9999
renderDockerfileBunProfile()
100100
]

packages/lib/src/usecases/errors.ts

Lines changed: 43 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { PlatformError } from "@effect/platform/Error"
2+
import { Match } from "effect"
23
import { type ParseError } from "../core/domain.js"
34
import { formatParseError } from "../core/parse-errors.js"
45
import type {
@@ -51,65 +52,48 @@ const renderDockerAccessHeadline = (issue: DockerAccessError["issue"]): string =
5152
? "Cannot access Docker daemon socket: permission denied."
5253
: "Cannot connect to Docker daemon."
5354

54-
const renderPrimaryError = (error: NonParseError): string | null => {
55-
if (error._tag === "FileExistsError") {
56-
return `File already exists: ${error.path} (use --force to overwrite)`
57-
}
58-
59-
if (error._tag === "DockerCommandError") {
60-
return [
61-
`docker compose failed with exit code ${error.exitCode}`,
62-
"Hint: ensure Docker daemon is running and current user can access /var/run/docker.sock (for example via the docker group)."
63-
].join("\n")
64-
}
65-
66-
if (error._tag === "DockerAccessError") {
67-
return [
68-
renderDockerAccessHeadline(error.issue),
69-
"Hint: ensure Docker daemon is running and current user can access the docker socket.",
70-
"Hint: if you use rootless Docker, set DOCKER_HOST to your user socket (for example unix:///run/user/$UID/docker.sock).",
71-
`Details: ${error.details}`
72-
].join("\n")
73-
}
74-
75-
if (error._tag === "CloneFailedError") {
76-
return `Clone failed for ${error.repoUrl} (${error.repoRef}) into ${error.targetDir}`
77-
}
78-
79-
if (error._tag === "PortProbeError") {
80-
return `SSH port check failed for ${error.port}: ${error.message}`
81-
}
82-
83-
if (error._tag === "CommandFailedError") {
84-
return `${error.command} failed with exit code ${error.exitCode}`
85-
}
86-
87-
if (error._tag === "ScrapArchiveNotFoundError") {
88-
return `Scrap archive not found: ${error.path} (run docker-git scrap export first)`
89-
}
90-
91-
if (error._tag === "ScrapTargetDirUnsupportedError") {
92-
return [
93-
`Cannot use scrap with targetDir ${error.targetDir}.`,
94-
`Reason: ${error.reason}`,
95-
`Hint: scrap currently supports workspaces under /home/${error.sshUser}/... only.`
96-
].join("\n")
97-
}
98-
99-
if (error._tag === "ScrapWipeRefusedError") {
100-
return [
101-
`Refusing to wipe workspace for scrap import (targetDir ${error.targetDir}).`,
102-
`Reason: ${error.reason}`,
103-
"Hint: re-run with --no-wipe, or set a narrower --target-dir when creating the project."
104-
].join("\n")
105-
}
106-
107-
if (error._tag === "AuthError") {
108-
return error.message
109-
}
110-
111-
return null
112-
}
55+
const renderPrimaryError = (error: NonParseError): string | null =>
56+
Match.value(error).pipe(
57+
Match.when({ _tag: "FileExistsError" }, ({ path }) => `File already exists: ${path} (use --force to overwrite)`),
58+
Match.when({ _tag: "DockerCommandError" }, ({ exitCode }) =>
59+
[
60+
`docker compose failed with exit code ${exitCode}`,
61+
"Hint: ensure Docker daemon is running and current user can access /var/run/docker.sock (for example via the docker group)."
62+
].join("\n")),
63+
Match.when({ _tag: "DockerAccessError" }, ({ details, issue }) =>
64+
[
65+
renderDockerAccessHeadline(issue),
66+
"Hint: ensure Docker daemon is running and current user can access the docker socket.",
67+
"Hint: if you use rootless Docker, set DOCKER_HOST to your user socket (for example unix:///run/user/$UID/docker.sock).",
68+
`Details: ${details}`
69+
].join("\n")),
70+
Match.when({ _tag: "CloneFailedError" }, ({ repoRef, repoUrl, targetDir }) =>
71+
`Clone failed for ${repoUrl} (${repoRef}) into ${targetDir}`),
72+
Match.when({ _tag: "PortProbeError" }, ({ message, port }) =>
73+
`SSH port check failed for ${port}: ${message}`),
74+
Match.when(
75+
{ _tag: "CommandFailedError" },
76+
({ command, exitCode }) => `${command} failed with exit code ${exitCode}`
77+
),
78+
Match.when(
79+
{ _tag: "ScrapArchiveNotFoundError" },
80+
({ path }) => `Scrap archive not found: ${path} (run docker-git scrap export first)`
81+
),
82+
Match.when({ _tag: "ScrapTargetDirUnsupportedError" }, ({ reason, sshUser, targetDir }) =>
83+
[
84+
`Cannot use scrap with targetDir ${targetDir}.`,
85+
`Reason: ${reason}`,
86+
`Hint: scrap currently supports workspaces under /home/${sshUser}/... only.`
87+
].join("\n")),
88+
Match.when({ _tag: "ScrapWipeRefusedError" }, ({ reason, targetDir }) =>
89+
[
90+
`Refusing to wipe workspace for scrap import (targetDir ${targetDir}).`,
91+
`Reason: ${reason}`,
92+
"Hint: re-run with --no-wipe, or set a narrower --target-dir when creating the project."
93+
].join("\n")),
94+
Match.when({ _tag: "AuthError" }, ({ message }) => message),
95+
Match.orElse(() => null)
96+
)
11397

11498
const renderConfigError = (error: NonParseError): string | null => {
11599
if (error._tag === "ConfigNotFoundError") {

0 commit comments

Comments
 (0)