Skip to content

refactor(project create): split RunE into phase-specific files#1024

Merged
Soner (shyim) merged 2 commits into
nextfrom
refactor/project-create-decompose
May 18, 2026
Merged

refactor(project create): split RunE into phase-specific files#1024
Soner (shyim) merged 2 commits into
nextfrom
refactor/project-create-decompose

Conversation

@shyim

Copy link
Copy Markdown
Member

Summary

cmd/project/project_create.go was 888 lines with a single ~570-line RunE closure that mixed flag parsing, the interactive huh form, validation, file scaffolding, composer install, and summary rendering. This PR splits it into one orchestrator plus four phase files in the same package — no behavior changes.

File Lines Responsibility
project_create.go 171 Cobra command, createOptions, parseCreateFlags, applyNonInteractiveDefaults, init
project_create_form.go 286 runCreateForm — interactive form loop
project_create_validate.go 236 validateAndPreflight, advisory/incompatibility prompts, resolveVersion, filterInstallVersions, renderSecurityAdvisories
project_create_scaffold.go 159 scaffoldProject + setupDeployment + setupCI, template embeds
project_create_install.go 175 installAndFinalize, printCreateSummary, runComposerInstall

RunE is now ~25 lines of orchestration. The createOptions struct carries state across phases instead of 10+ local vars in a closure.

This is a pure restructuring: same files written, same prompts shown, same flag semantics. os.ModePerm usages in the scaffolding code are preserved as-is and tracked separately in #1020.

Addresses item #3 in the post-merge review of next (CODE_IMPROVEMENTS.md).

Test plan

  • go build ./...
  • go vet ./cmd/project/...
  • go test ./cmd/project/... — existing TestResolveVersion, TestSetupDeployment, TestSetupCI, TestValidDeploymentMethods, TestValidCISystems still pass
  • Manual: shopware-cli project create my-test (interactive, restart form, cancel)
  • Manual: shopware-cli project create my-test 6.7.0.0 --no-audit --deployment=none --ci=github --docker (non-interactive)
  • Manual: confirm security-advisory prompt still appears for an affected version

project_create.go was 888 lines with a ~570-line RunE closure mixing
flag parsing, interactive form, validation, scaffolding, composer
install, and summary rendering. Split into one orchestrator plus four
phase files in the same package:

- project_create.go        — cobra command + RunE orchestrator,
                             createOptions, parseCreateFlags,
                             applyNonInteractiveDefaults, init
- project_create_form.go   — runCreateForm (interactive huh form loop)
- project_create_validate.go — validateAndPreflight, security advisory
                               and incompatibility prompts, version
                               resolution helpers
- project_create_scaffold.go — scaffoldProject + setupDeployment +
                               setupCI, embeds
- project_create_install.go  — installAndFinalize, printCreateSummary,
                               runComposerInstall

No behavior change. Existing TestResolveVersion / TestSetupDeployment /
TestSetupCI / TestValidDeploymentMethods / TestValidCISystems still
pass against the new layout.

Refs CODE_IMPROVEMENTS item #3.
The form has many conditional groups (one per optional question),
which matches existing precedent in updateStoreInfo and
BuildAssetsForExtensions. Splitting the form definition across
helpers just to satisfy the linter would scatter the WithHideFunc
closures and hurt readability.
@shyim Soner (shyim) merged commit d749b0e into next May 18, 2026
2 checks passed
@shyim Soner (shyim) deleted the refactor/project-create-decompose branch May 18, 2026 03:30
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.

1 participant