diff --git a/cmd/cloud.go b/cmd/cloud.go index 2921b78e..8f6dc9dc 100644 --- a/cmd/cloud.go +++ b/cmd/cloud.go @@ -262,7 +262,7 @@ Examples: force = true } // check to see if we have any env vars that are not in the project - envFile, projectData = envutil.ProcessEnvFiles(ctx, logger, dir, theproject, projectData, apiUrl, token, force) + envFile, projectData = envutil.ProcessEnvFiles(ctx, logger, dir, theproject, projectData, apiUrl, token, force, false) if tui.HasTTY { _, localIssues, remoteIssues, err := buildAgentTree(keys, state, context) diff --git a/cmd/dev.go b/cmd/dev.go index 3400e6d1..06af5e4b 100644 --- a/cmd/dev.go +++ b/cmd/dev.go @@ -70,7 +70,7 @@ Examples: var envfile *deployer.EnvFile - envfile, project = envutil.ProcessEnvFiles(ctx, log, dir, theproject.Project, project, theproject.APIURL, apiKey, false) + envfile, project = envutil.ProcessEnvFiles(ctx, log, dir, theproject.Project, project, theproject.APIURL, apiKey, false, true) if envfile == nil { // we don't have an env file so we need to create one since this likely means you have cloned a new project diff --git a/cmd/project.go b/cmd/project.go index 7ce649e1..806b9131 100644 --- a/cmd/project.go +++ b/cmd/project.go @@ -329,15 +329,15 @@ Examples: fmt.Println(tui.Text("• ") + tui.Command(" project import") + tui.Text(" - Import this project to your organization")) fmt.Println(tui.Text("• ") + tui.Command(" deploy") + tui.Text(" - Deploy this project")) fmt.Println() - + continueAnyway := tui.Ask(logger, "Are you sure you want to create a new project here?", false) - + if !continueAnyway { fmt.Println() tui.ShowSuccess("No worries! Use one of the commands above to work with your existing project.") os.Exit(0) } - + fmt.Println() tui.ShowWarning("Continuing with new project creation...") fmt.Println() @@ -899,7 +899,7 @@ Examples: if !tui.HasTTY { force = true } - _, _ = envutil.ProcessEnvFiles(ctx, logger, context.Dir, context.Project, nil, context.APIURL, context.Token, force) + _, _ = envutil.ProcessEnvFiles(ctx, logger, context.Dir, context.Project, nil, context.APIURL, context.Token, force, false) }, } diff --git a/internal/envutil/envutil.go b/internal/envutil/envutil.go index ca54a127..062b04f1 100644 --- a/internal/envutil/envutil.go +++ b/internal/envutil/envutil.go @@ -31,8 +31,23 @@ var looksLikeSecret = regexp.MustCompile(`(?i)(^|_|-)(APIKEY|API_KEY|PRIVATE_KEY var isAgentuityEnv = regexp.MustCompile(`(?i)AGENTUITY_`) // ProcessEnvFiles handles .env and template env processing -func ProcessEnvFiles(ctx context.Context, logger logger.Logger, dir string, theproject *project.Project, projectData *project.ProjectData, apiUrl, token string, force bool) (*deployer.EnvFile, *project.ProjectData) { +func ProcessEnvFiles(ctx context.Context, logger logger.Logger, dir string, theproject *project.Project, projectData *project.ProjectData, apiUrl, token string, force bool, isLocalDev bool) (*deployer.EnvFile, *project.ProjectData) { envfilename := filepath.Join(dir, ".env") + if isLocalDev { + f := filepath.Join(dir, ".env.development") + if util.Exists(f) { + envfilename = f + } else { + // create it but don't load it -- this is required because uv expects a .env.development file to exist from the template + // but since its gitignore it won't get checked in and might not exist when you clone a project + of, err := os.Create(f) + if err != nil { + errsystem.New(errsystem.ErrInvalidConfiguration, err, errsystem.WithContextMessage("Failed to create .env.development file")).ShowErrorAndExit() + } + defer of.Close() + of.WriteString("# This file is used to store development environment variables\n") + } + } var envFile *deployer.EnvFile if (tui.HasTTY || force) && util.Exists(envfilename) { // attempt to see if we have any template files