Skip to content

Commit 72f3e7a

Browse files
committed
fix(app): remove duplicate workspace path logic
1 parent 5715919 commit 72f3e7a

2 files changed

Lines changed: 11 additions & 19 deletions

File tree

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,19 @@ import type { RawOptions } from "@effect-template/lib/core/command-options"
55
import {
66
type Command,
77
defaultTemplateConfig,
8-
deriveRepoPathParts,
98
type ParseError,
109
resolveRepoInput
1110
} from "@effect-template/lib/core/domain"
1211

1312
import { parseRawOptions } from "./parser-options.js"
14-
import { splitPositionalRepo } from "./parser-shared.js"
15-
16-
const resolveCloneRepoPath = (resolvedRepo: ReturnType<typeof resolveRepoInput>): string => {
17-
const baseParts = deriveRepoPathParts(resolvedRepo.repoUrl).pathParts
18-
const projectParts = resolvedRepo.workspaceSuffix ? [...baseParts, resolvedRepo.workspaceSuffix] : baseParts
19-
return projectParts.join("/")
20-
}
13+
import { resolveWorkspaceRepoPath, splitPositionalRepo } from "./parser-shared.js"
2114

2215
const applyCloneDefaults = (
2316
raw: RawOptions,
2417
rawRepoUrl: string,
2518
resolvedRepo: ReturnType<typeof resolveRepoInput>
2619
): RawOptions => {
27-
const repoPath = resolveCloneRepoPath(resolvedRepo)
20+
const repoPath = resolveWorkspaceRepoPath(resolvedRepo)
2821
const sshUser = raw.sshUser?.trim() ?? defaultTemplateConfig.sshUser
2922
const homeDir = `/home/${sshUser}`
3023
return {

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ type PositionalRepo = {
99
readonly restArgs: ReadonlyArray<string>
1010
}
1111

12+
export const resolveWorkspaceRepoPath = (
13+
resolvedRepo: ReturnType<typeof resolveRepoInput>
14+
): string => {
15+
const baseParts = deriveRepoPathParts(resolvedRepo.repoUrl).pathParts
16+
const projectParts = resolvedRepo.workspaceSuffix ? [...baseParts, resolvedRepo.workspaceSuffix] : baseParts
17+
return projectParts.join("/")
18+
}
19+
1220
export const splitPositionalRepo = (args: ReadonlyArray<string>): PositionalRepo => {
1321
const first = args[0]
1422
const positionalRepoUrl = first !== undefined && !first.startsWith("-") ? first : undefined
@@ -24,16 +32,7 @@ export const parseProjectDirWithOptions = (
2432
const { positionalRepoUrl, restArgs } = splitPositionalRepo(args)
2533
const raw = yield* _(parseRawOptions(restArgs))
2634
const rawRepoUrl = raw.repoUrl ?? positionalRepoUrl
27-
const resolvedRepo = rawRepoUrl ? resolveRepoInput(rawRepoUrl) : null
28-
const repoPath = resolvedRepo
29-
? (() => {
30-
const baseParts = deriveRepoPathParts(resolvedRepo.repoUrl).pathParts
31-
const projectParts = resolvedRepo.workspaceSuffix
32-
? [...baseParts, resolvedRepo.workspaceSuffix]
33-
: baseParts
34-
return projectParts.join("/")
35-
})()
36-
: null
35+
const repoPath = rawRepoUrl ? resolveWorkspaceRepoPath(resolveRepoInput(rawRepoUrl)) : null
3736
const projectDir = raw.projectDir ??
3837
(repoPath
3938
? `.docker-git/${repoPath}`

0 commit comments

Comments
 (0)