Skip to content

Commit f712aef

Browse files
committed
Renamed commands to their new names. Fixed checking of jq version in check command
1 parent b09210d commit f712aef

File tree

8 files changed

+179
-42
lines changed

8 files changed

+179
-42
lines changed

cmd/apply.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package cmd
2+
3+
import (
4+
"github.com/commitdev/zero/configs"
5+
"github.com/spf13/cobra"
6+
)
7+
8+
var applyConfigPath string
9+
10+
func init() {
11+
applyCmd.PersistentFlags().StringVarP(&applyConfigPath, "config", "c", configs.CommitYml, "config path")
12+
13+
rootCmd.AddCommand(applyCmd)
14+
}
15+
16+
var applyCmd = &cobra.Command{
17+
Use: "apply",
18+
Short: "Execute modules to create projects, infrastructure, etc.",
19+
Run: func(cmd *cobra.Command, args []string) {
20+
21+
},
22+
}

cmd/check.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ func getSemver(req requirement, out []byte) (*semver.Version, error) {
7373
fmt.Sprintf("Try running %s %s locally and checking it works.", req.command, strings.Join(req.args, " ")),
7474
}
7575
}
76+
77+
// Default patch version number to 0 if it doesn't exist
78+
if v[3] == "" {
79+
v[3] = "0"
80+
}
81+
7682
versionString := fmt.Sprintf("%s.%s.%s", v[1], v[2], v[3])
7783
version, err := semver.NewVersion(versionString)
7884
if err != nil {
@@ -125,7 +131,7 @@ var checkCmd = &cobra.Command{
125131
name: "jq\t\t",
126132
command: "jq",
127133
args: []string{"--version"},
128-
regexStr: `jq-(0|[1-9]\d*)\.(0|[1-9]\d*)-(0|[1-9]\d*)`,
134+
regexStr: `jq-(0|[1-9]\d*)\.(0|[1-9]\d*)\-?(0|[1-9]\d*)?`,
129135
minVersion: "1.5.0",
130136
docsURL: "https://stedolan.github.io/jq/download/",
131137
},

cmd/create.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
package cmd
22

33
import (
4+
"github.com/commitdev/zero/configs"
45
"github.com/commitdev/zero/internal/config"
5-
"github.com/commitdev/zero/internal/context"
6-
"github.com/commitdev/zero/pkg/util/exit"
6+
"github.com/commitdev/zero/internal/generate"
77
"github.com/spf13/cobra"
88
)
99

10+
var createConfigPath string
11+
1012
func init() {
13+
createCmd.PersistentFlags().StringVarP(&createConfigPath, "config", "c", configs.CommitYml, "config path")
14+
1115
rootCmd.AddCommand(createCmd)
1216
}
1317

1418
var createCmd = &cobra.Command{
1519
Use: "create",
16-
Short: "Create new project with provided name.",
20+
Short: "Create directories and render templates based on included modules.",
1721
Run: func(cmd *cobra.Command, args []string) {
18-
if len(args) < 1 {
19-
exit.Fatal("Project name cannot be empty!")
20-
}
2122

22-
projectName := args[0]
23-
context.Create(projectName, "./")
23+
cfg := config.LoadGeneratorConfig(createConfigPath)
2424

25-
config.CreateExample(projectName)
25+
generate.GenerateModules(cfg)
2626
},
2727
}

cmd/generate.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

cmd/init.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package cmd
2+
3+
import (
4+
"github.com/commitdev/zero/internal/config"
5+
"github.com/commitdev/zero/internal/context"
6+
"github.com/commitdev/zero/pkg/util/exit"
7+
"github.com/spf13/cobra"
8+
)
9+
10+
func init() {
11+
rootCmd.AddCommand(initCmd)
12+
}
13+
14+
var initCmd = &cobra.Command{
15+
Use: "init",
16+
Short: "Create new project with provided name and initialize configuration based on user input.",
17+
Run: func(cmd *cobra.Command, args []string) {
18+
if len(args) < 1 {
19+
exit.Fatal("Project name cannot be empty!")
20+
}
21+
22+
projectName := args[0]
23+
context.Create(projectName, "./")
24+
25+
config.CreateExample(projectName)
26+
},
27+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"testing"
55
)
66

7-
func TestCreateWorks(t *testing.T) {
7+
func TestInitWorks(t *testing.T) {
88
// @TODO : Figure out a way to test this
99
// tmpdir, err := ioutil.TempDir("", "commit0-")
1010
// if err != nil {

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ go 1.12
55
require (
66
github.com/aws/aws-sdk-go v1.25.33
77
github.com/commitdev/commit0 v0.0.0-20200515235753-f146c26933bd
8-
github.com/chzyer/logex v1.1.10 // indirect
9-
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
10-
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect
118
github.com/coreos/go-semver v0.2.0
9+
github.com/gobuffalo/packr/v2 v2.8.0 // indirect
1210
github.com/google/uuid v1.1.1
1311
github.com/gorilla/handlers v1.4.2
1412
github.com/gorilla/mux v1.7.3
@@ -17,6 +15,6 @@ require (
1715
github.com/kyokomi/emoji v2.1.0+incompatible
1816
github.com/logrusorgru/aurora v0.0.0-20191017060258-dc85c304c434
1917
github.com/manifoldco/promptui v0.3.0
20-
github.com/spf13/cobra v0.0.5
18+
github.com/spf13/cobra v0.0.6
2119
gopkg.in/yaml.v2 v2.2.5
2220
)

0 commit comments

Comments
 (0)