feat: make hexagonal scaffolding optional via copier question#3
Open
mariushelf wants to merge 1 commit into
Open
feat: make hexagonal scaffolding optional via copier question#3mariushelf wants to merge 1 commit into
mariushelf wants to merge 1 commit into
Conversation
Add an `include_hexagonal` boolean question (default true). When false,
the generated project gets only the flat src layout (main/settings/utils)
and none of the hexagonal machinery.
The scaffolding is gated entirely at generation time:
- The domain/services/adapters directories and the example test use
Jinja conditional names (`{% if include_hexagonal %}...{% endif %}`),
so copier skips them when the answer is false.
- pyproject.toml.jinja wraps the import-linter dev dependency and the
`[tool.importlinter]` contracts in the same conditional.
- AGENTS.md.jinja and README.md.jinja drop their Architecture sections,
and AGENTS.md's lint note no longer mentions import-linter.
- .pre-commit-config.yaml and Makefile become .jinja templates: the
lint-imports pre-commit hook is omitted, and the Makefile's
`import_lint` target becomes a no-op (kept so CI's `make import_lint`
step stays valid in both modes). cicd.yaml is left untemplated to
avoid clashing with GitHub's `${{ }}` expressions.
The template's test suite is now parametrised over both answers, so the
hexagonal and flat layouts are each generated and verified end to end
(lint, test, main, pre-commit).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an
include_hexagonalcopier question (bool, defaulttrue). Whenfalse, the generated project is the original flat layout (main/settings/utils) with none of the hexagonal machinery — no layers, no example slice, no import-linter.How it's gated (all at generation time)
domain/services/adapters/dirs + example test{% if include_hexagonal %}domain{% endif %}. Copier skips empty-named paths and their subtree.[tool.importlinter]contracts{% if include_hexagonal %}inpyproject.toml.jinjalint-importspre-commit hook.pre-commit-config.yaml→.jinja, hook wrappedimport_lintMakefile→.jinja; target becomes a no-op@echoin flat mode (kept so CI'smake import_lintstays valid), and dropped from thelinttarget's depscicd.yamlis full of GitHub${{ }}that clashes with Jinja's{{ }}. Its import-linter step callsmake import_lint, which is the no-op in flat mode.Verification
tests/test_template.pyis now parametrised overinclude_hexagonal=[True, False], so each of the 6 checks runs against both a hexagonal and a flat generated project: renders the right files,pytest,python -m main,make lint,make test, andpre-commit run --all-files. All 12 pass locally.test_template_rendersadditionally asserts thedomain/dir and example test exist iffinclude_hexagonalis true.