Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)

},
}
Expand Down
17 changes: 16 additions & 1 deletion internal/envutil/envutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading