mirror of
https://github.com/silicoflare/envy.git
synced 2026-05-26 19:57:59 +05:30
feat: change project config file name to envy.toml
This commit is contained in:
@@ -22,7 +22,7 @@ var createCmd = &cobra.Command{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = os.Stat(path.Join(cwd, ".envy"))
|
_, err = os.Stat(path.Join(cwd, "envy.toml"))
|
||||||
|
|
||||||
// file exists, create environment
|
// file exists, create environment
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -34,7 +34,7 @@ var createCmd = &cobra.Command{
|
|||||||
|
|
||||||
project := envy.Get("envy.project").(string)
|
project := envy.Get("envy.project").(string)
|
||||||
if project == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,11 +125,11 @@ var createCmd = &cobra.Command{
|
|||||||
env := utils.Environment{Name: environment, ProjectID: proj.ID, Data: utils.ParseEnv(string(envFile))}
|
env := utils.Environment{Name: environment, ProjectID: proj.ID, Data: utils.ParseEnv(string(envFile))}
|
||||||
utils.DB.Create(&env)
|
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)
|
err = os.WriteFile(filePath, []byte(fmt.Sprintf("[envy]\nproject = \"%s\"\nenv = \"%s\"\n", project, environment)), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error creating .envy file:", err)
|
log.Println("Error creating envy.toml file:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ var listCmd = &cobra.Command{
|
|||||||
pinned := envy.Get("envy.env").(string)
|
pinned := envy.Get("envy.env").(string)
|
||||||
|
|
||||||
if project == "" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if pinned == "" {
|
if pinned == "" {
|
||||||
utils.ErrPrint("Pinned environment is empty. .envy file might have been modified.")
|
utils.ErrPrint("Pinned environment is empty. envy.toml file might have been modified.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
// pinCmd represents the pin command
|
// pinCmd represents the pin command
|
||||||
var pinCmd = &cobra.Command{
|
var pinCmd = &cobra.Command{
|
||||||
Use: "pin",
|
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) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var env = ""
|
var env = ""
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
@@ -68,7 +68,7 @@ var pinCmd = &cobra.Command{
|
|||||||
|
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
utils.StopIfErr(err)
|
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.")
|
fmt.Println("Pinned", env, "to the project.")
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -25,20 +25,20 @@ func GetEnvy() (*toml.Tree, error) {
|
|||||||
return nil, errors.New("Not able to fetch working directory: " + err.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
|
// file exists
|
||||||
if err == nil {
|
if err == nil {
|
||||||
envyFile, err := toml.LoadFile(path.Join(cwd, ".envy"))
|
envyFile, err := toml.LoadFile(path.Join(cwd, "envy.toml"))
|
||||||
if err != nil {
|
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
|
return envyFile, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// file does not exist
|
// file does not exist
|
||||||
if os.IsNotExist(err) {
|
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 {
|
} else {
|
||||||
return nil, errors.New("Some error occured:" + err.Error())
|
return nil, errors.New("Some error occured:" + err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user