auto-init local app commands#267
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an auto-init guard that detects missing/incomplete local .hx app config for commands that require it, optionally runs interactive initialization, and then continues the original command. It also refactors init-app execution to support error-returning execution and updates config tests to behave correctly on Windows home directory resolution.
Changes:
- Add
cmd/autoinitwithEnsure()invoked from the root persistent pre-run hook to auto-initialize local app config when required. - Refactor
initappto exposeRunInitAppE(error-returning) and keepRunInitAppas a printing wrapper. - Update auto-update config tests to set both
HOMEandUSERPROFILEfor Windows compatibility.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/config/config_autoupdate_test.go | Adds a helper to set HOME + USERPROFILE for cross-platform global-config tests. |
| cmd/root.go | Hooks auto-init guard into root command execution via PersistentPreRunE. |
| cmd/initapp/initapp.go | Introduces RunInitAppE and updates init flow to return errors instead of printing+returning early. |
| cmd/autoinit/autoinit.go | New auto-init guard: detects missing/incomplete local config, optionally runs init, revalidates. |
| cmd/autoinit/autoinit_test.go | New unit tests covering config completeness detection, command matching, and auto-init behaviors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request introduces an autoinit package to handle missing local app configurations, integrates it into the CLI's global pre-run logic, and adds performance timing recording to env pull and env push operations. Additionally, concurrency has been implemented for environment operations to improve performance. The reviewer correctly identified that several references to the renamed cfg variable in cmd/env/pull/pull.go need to be updated to ensure the code uses the local configuration instance rather than the package name.
I am having trouble creating individual review comments. Click here to see my feedback.
cmd/env/pull/pull.go (158)
Update reference to the renamed cfg variable to avoid shadowing issues.
secretValue, _, err = secret.LoadSecret(cfg.OrganizationId, *cfg.ProjectId)
cmd/env/pull/pull.go (166)
Update reference to the renamed cfg variable to avoid shadowing issues.
pulledEnvs, err := service.getAllEnvsAndDecryptIntoFiles(orgId, appId, projectId, secretValue, cfg, forceFlag, recorder)
cmd/env/pull/pull.go (176)
Update reference to the renamed cfg variable to avoid shadowing issues.
if err = service.saveDecryptedEnvIntoFile(orgId, "default", appId, secretValue, cfg, forceFlag, nil, recorder); err != nil {
cmd/env/pull/pull.go (189)
Update reference to the renamed cfg variable to avoid shadowing issues.
if err = service.saveDecryptedEnvIntoFile(orgId, envName, appId, secretValue, cfg, forceFlag, nil, recorder); err != nil {
|
Response to Gemini review: I’m not applying the |
Summary
.hxconfig.USERPROFILE.Validation
go test ./cmd/autoinitgo test ./...with isolated temporaryHOME/USERPROFILE