Skip to content

fix: refactor project output layout into shared projectlayout domain typ - #449

Merged
cdsap merged 1 commit into
mainfrom
issue/448-hermes-refactor-project-output-layout-into-a1
Sep 6, 2026
Merged

fix: refactor project output layout into shared projectlayout domain typ#449
cdsap merged 1 commit into
mainfrom
issue/448-hermes-refactor-project-output-layout-into-a1

Conversation

@cdsap

@cdsap cdsap commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Summary

Problem

Filesystem layout rules for Language (KTS, GROOVY, BOTH) are duplicated across cli/src/main/kotlin/io/github/cdsap/projectgenerator/cli/GenerateProjectRequest.kt (resolveProjectRootPath) and project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/ProjectGenerator.kt (getProjectLanguageAttributes). The CLI picks a root path and the generator expands it into LanguageAttributes, but both encode the same policy with no single source of truth.

Why this matters

This is domain policy, not CLI or I/O detail. If one side changes (for example how --output-dir interacts with Language.BOTH) without the other, the CLI can report one location while files are written elsewhere. Tests are split across GenerateProjectsCliTest and ProjectGeneratorTest, so regressions are easy to miss.

Proposed change

Add ProjectLayout in project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/model/ with two pure functions: defaultRootPath(outputDir, language, projectName) (replacing resolveProjectRootPath) and languageAttributes(rootPath, language) (replacing getProjectLanguageAttributes). Update GenerateProjectRequest.resolve and ProjectGenerator.write() to delegate to it. Add focused unit tests in project-generator for all language/output-dir combinations.

Notes

In clean-architecture terms, output layout is a domain policy consumed by the CLI adapter and the generation use case. Centralizing it in model/ keeps infrastructure (Clikt, File writers) separate from the rule of where each language variant lives on disk, and gives library callers the same layout contract the CLI uses.

Fixes #448

Changes

  • cli/src/main/kotlin/io/github/cdsap/projectgenerator/cli/GenerateProjectRequest.kt
  • cli/src/test/kotlin/io/github/cdsap/projectgenerator/cli/GenerateProjectsCliTest.kt
  • project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/ProjectGenerator.kt
  • project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/model/ProjectLayout.kt
  • project-generator/src/test/kotlin/io/github/cdsap/projectgenerator/model/ProjectLayoutTest.kt

Verification

  • ./gradlew :project-generator:unitTest
  • ./gradlew :cli:test
  • ./gradlew ktlintCheck

@cdsap
cdsap merged commit d1e1bc6 into main Sep 6, 2026
14 checks passed
@cdsap
cdsap deleted the issue/448-hermes-refactor-project-output-layout-into-a1 branch September 6, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor project output layout into shared ProjectLayout domain type

1 participant