From 96bed0abdc0bd173bd784f078bf042a51e22d698 Mon Sep 17 00:00:00 2001 From: Suraj B M Date: Thu, 25 Sep 2025 22:51:05 +0530 Subject: [PATCH] feat: change project config file name to envy.toml --- cmd/create.go | 8 ++++---- cmd/list.go | 20 ++++++++++---------- cmd/pin.go | 16 ++++++++-------- cmd/utils/other.go | 8 ++++---- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cmd/create.go b/cmd/create.go index 20645cb..3a4aafc 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -22,7 +22,7 @@ var createCmd = &cobra.Command{ return } - _, err = os.Stat(path.Join(cwd, ".envy")) + _, err = os.Stat(path.Join(cwd, "envy.toml")) // file exists, create environment if err == nil { @@ -34,7 +34,7 @@ var createCmd = &cobra.Command{ project := envy.Get("envy.project").(string) if project == "" { - utils.ErrPrint("Project name is empty. .envy file might have been modified.") + utils.ErrPrint("Project name is empty. envy.toml file might have been modified.") return } @@ -125,11 +125,11 @@ var createCmd = &cobra.Command{ env := utils.Environment{Name: environment, ProjectID: proj.ID, Data: utils.ParseEnv(string(envFile))} utils.DB.Create(&env) - filePath := path.Join(cwd, ".envy") + filePath := path.Join(cwd, "envy.toml") err = os.WriteFile(filePath, []byte(fmt.Sprintf("[envy]\nproject = \"%s\"\nenv = \"%s\"\n", project, environment)), 0644) if err != nil { - log.Println("Error creating .envy file:", err) + log.Println("Error creating envy.toml file:", err) return } diff --git a/cmd/list.go b/cmd/list.go index bbbeec8..7e9eb0f 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -14,7 +14,7 @@ var listCmd = &cobra.Command{ Short: "List all the environments in the current project", Run: func(cmd *cobra.Command, args []string) { envy, err := utils.GetEnvy() - if err != nil { + if err != nil { utils.ErrPrint(err.Error()) return } @@ -22,33 +22,33 @@ var listCmd = &cobra.Command{ project := envy.Get("envy.project").(string) pinned := envy.Get("envy.env").(string) - if project == "" { - utils.ErrPrint("Project name is empty. .envy file might have been modified.") + if project == "" { + utils.ErrPrint("Project name is empty. envy.toml file might have been modified.") return } - if pinned == "" { - utils.ErrPrint("Pinned environment is empty. .envy file might have been modified.") + if pinned == "" { + utils.ErrPrint("Pinned environment is empty. envy.toml file might have been modified.") return } dbProject, err := utils.GetProject(project) - if err != nil { + if err != nil { utils.ErrPrint(err.Error()) return } envs, err := utils.GetEnvironments(dbProject.ID) - if err != nil { + if err != nil { utils.ErrPrint(err.Error()) return } pinStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#0FF")) - for _, en := range envs { - if en.Name == pinned { + for _, en := range envs { + if en.Name == pinned { fmt.Println(" * " + en.Name + pinStyle.Render(" [pinned]")) - } else { + } else { fmt.Println(" * " + en.Name) } } diff --git a/cmd/pin.go b/cmd/pin.go index 691accc..2c53aaf 100644 --- a/cmd/pin.go +++ b/cmd/pin.go @@ -17,10 +17,10 @@ import ( // pinCmd represents the pin command var pinCmd = &cobra.Command{ Use: "pin", - Short: "Pin an environment to the .envy file", + Short: "Pin an environment to the envy.toml file", Run: func(cmd *cobra.Command, args []string) { var env = "" - if len(args) > 0 { + if len(args) > 0 { env = args[0] } @@ -32,10 +32,10 @@ var pinCmd = &cobra.Command{ dbProject, err := utils.GetProject(project) utils.StopIfErr(err) - if env != "" { + if env != "" { _, err := utils.GetEnvironment(dbProject.ID, env) utils.StopIfErr(err) - } else { + } else { envs, err := utils.GetEnvironments(dbProject.ID) utils.StopIfErr(err) @@ -44,9 +44,9 @@ var pinCmd = &cobra.Command{ huh.NewSelect[string](). Title("Select environment"). Description("Select an environment to pin"). - OptionsFunc(func () []huh.Option[string] { + OptionsFunc(func() []huh.Option[string] { var options []huh.Option[string] - for _, en := range envs { + for _, en := range envs { options = append(options, huh.NewOption(en.Name, en.Name)) } return options @@ -57,7 +57,7 @@ var pinCmd = &cobra.Command{ err = form.Run() utils.StopIfErr(err) - if env == "" { + if env == "" { return } } @@ -68,7 +68,7 @@ var pinCmd = &cobra.Command{ cwd, err := os.Getwd() utils.StopIfErr(err) - os.WriteFile(path.Join(cwd, ".envy"), data, 0744) + os.WriteFile(path.Join(cwd, "envy.toml"), data, 0744) fmt.Println("Pinned", env, "to the project.") }, diff --git a/cmd/utils/other.go b/cmd/utils/other.go index ad5134f..d89a9b4 100644 --- a/cmd/utils/other.go +++ b/cmd/utils/other.go @@ -25,20 +25,20 @@ func GetEnvy() (*toml.Tree, error) { return nil, errors.New("Not able to fetch working directory: " + err.Error()) } - _, err = os.Stat(path.Join(cwd, ".envy")) + _, err = os.Stat(path.Join(cwd, "envy.toml")) // file exists if err == nil { - envyFile, err := toml.LoadFile(path.Join(cwd, ".envy")) + envyFile, err := toml.LoadFile(path.Join(cwd, "envy.toml")) if err != nil { - return nil, errors.New("Error occured while reading .envy file:" + err.Error()) + return nil, errors.New("Error occured while reading envy.toml file:" + err.Error()) } return envyFile, nil } // file does not exist if os.IsNotExist(err) { - return nil, errors.New(".envy file doesn't exist in the current directory") + return nil, errors.New("envy.toml file doesn't exist in the current directory") } else { return nil, errors.New("Some error occured:" + err.Error()) }