refactor(project create): split RunE into phase-specific files#1024
Merged
Conversation
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.
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.
Summary
cmd/project/project_create.gowas 888 lines with a single ~570-lineRunEclosure that mixed flag parsing, the interactivehuhform, 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.project_create.gocreateOptions,parseCreateFlags,applyNonInteractiveDefaults,initproject_create_form.gorunCreateForm— interactive form loopproject_create_validate.govalidateAndPreflight, advisory/incompatibility prompts,resolveVersion,filterInstallVersions,renderSecurityAdvisoriesproject_create_scaffold.goscaffoldProject+setupDeployment+setupCI, template embedsproject_create_install.goinstallAndFinalize,printCreateSummary,runComposerInstallRunEis now ~25 lines of orchestration. ThecreateOptionsstruct 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.ModePermusages 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/...— existingTestResolveVersion,TestSetupDeployment,TestSetupCI,TestValidDeploymentMethods,TestValidCISystemsstill passshopware-cli project create my-test(interactive, restart form, cancel)shopware-cli project create my-test 6.7.0.0 --no-audit --deployment=none --ci=github --docker(non-interactive)