feat(generate): Prepare general generate command
This commit is contained in:
parent
1af6aa52fb
commit
b1f168286f
@ -20,16 +20,32 @@ var generateCmd = &cobra.Command{
|
||||
Use: "generate",
|
||||
Short: "Generate all the files (API, DB, ...)",
|
||||
Long: `Generate will automatically create all the files of the Project.
|
||||
You can also generate files for each 'modules' by using the command bellows`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("generate called")
|
||||
},
|
||||
You can also generate files for each 'module' by using the command bellows`,
|
||||
Run: runGenerate,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(generateCmd)
|
||||
}
|
||||
|
||||
// runGenerate will launch sub generate function for the current project.
|
||||
func runGenerate(cmd *cobra.Command, args []string) {
|
||||
runGenerateAPI(cmd, args)
|
||||
runGenerateDocker(cmd, args)
|
||||
runGenerateHelm(cmd, args)
|
||||
runGenerateLauncher(cmd, args)
|
||||
|
||||
// Load config to check if we need to generat DB
|
||||
_, config, err := loadProjectAndConfig()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if config.Features.DatabaseModels.Enabled {
|
||||
runGenerateDB(cmd, args)
|
||||
}
|
||||
}
|
||||
|
||||
func loadProjectAndConfig() (string, *models.Config, error) {
|
||||
|
||||
log.Debugf("Checking dependencies")
|
||||
|
@ -5,8 +5,6 @@ Copyright © 2022 Matthieu Derasse <git@derasse.fr>
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -14,11 +12,13 @@ import (
|
||||
var apiCmd = &cobra.Command{
|
||||
Use: "api",
|
||||
Short: "Generate Go-Swagger Files and Controllers",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("api called")
|
||||
},
|
||||
Run: runGenerateAPI,
|
||||
}
|
||||
|
||||
func init() {
|
||||
generateCmd.AddCommand(apiCmd)
|
||||
}
|
||||
|
||||
// runGenerateAPI will generate api files such as controllers, server, unit test, ... for the current project.
|
||||
func runGenerateAPI(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
|
@ -5,8 +5,6 @@ Copyright © 2022 Matthieu Derasse <git@derasse.fr>
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -14,11 +12,13 @@ import (
|
||||
var dbCmd = &cobra.Command{
|
||||
Use: "db",
|
||||
Short: "Generate Database Struct from pkg/dbmodels/schema.yaml",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("db called")
|
||||
},
|
||||
Run: runGenerateDB,
|
||||
}
|
||||
|
||||
func init() {
|
||||
generateCmd.AddCommand(dbCmd)
|
||||
}
|
||||
|
||||
// runGenerateDB will generate database models, db connector, ... for the current project.
|
||||
func runGenerateDB(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
|
@ -15,15 +15,15 @@ import (
|
||||
var dockerCmd = &cobra.Command{
|
||||
Use: "docker",
|
||||
Short: "Generate Dockerfile & co for API, Crons and Workers",
|
||||
Run: runGenerateDockerAction,
|
||||
Run: runGenerateDocker,
|
||||
}
|
||||
|
||||
func init() {
|
||||
generateCmd.AddCommand(dockerCmd)
|
||||
}
|
||||
|
||||
// runGenerateDockerAction will generate the Dockerfile & co for the current project.
|
||||
func runGenerateDockerAction(cmd *cobra.Command, args []string) {
|
||||
// runGenerateDocker will generate the Dockerfile & co for the current project.
|
||||
func runGenerateDocker(cmd *cobra.Command, args []string) {
|
||||
log.Debugf("Starting command GenerateDocker")
|
||||
|
||||
currentPath, config, err := loadProjectAndConfig()
|
||||
|
@ -5,8 +5,6 @@ Copyright © 2022 Matthieu Derasse <git@derasse.fr>
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -14,11 +12,13 @@ import (
|
||||
var helmCmd = &cobra.Command{
|
||||
Use: "helm",
|
||||
Short: "Generate Kubernetes Helm chart for API & Workers",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("helm called")
|
||||
},
|
||||
Run: runGenerateHelm,
|
||||
}
|
||||
|
||||
func init() {
|
||||
generateCmd.AddCommand(helmCmd)
|
||||
}
|
||||
|
||||
// runGenerateHekm will generate k8s helm chart for the current project.
|
||||
func runGenerateHelm(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
|
@ -15,15 +15,15 @@ import (
|
||||
var launcherCmd = &cobra.Command{
|
||||
Use: "launcher",
|
||||
Short: "Generate Launcher entrypoint bash script",
|
||||
Run: runGenerateLauncherAction,
|
||||
Run: runGenerateLauncher,
|
||||
}
|
||||
|
||||
func init() {
|
||||
generateCmd.AddCommand(launcherCmd)
|
||||
}
|
||||
|
||||
// runGenerateLauncherAction will generate the entrypoint for the current project.
|
||||
func runGenerateLauncherAction(cmd *cobra.Command, args []string) {
|
||||
// runGenerateLauncher will generate the entrypoint for the current project.
|
||||
func runGenerateLauncher(cmd *cobra.Command, args []string) {
|
||||
log.Debugf("Starting command GenerateLauncher")
|
||||
|
||||
currentPath, config, err := loadProjectAndConfig()
|
||||
|
@ -15,15 +15,15 @@ import (
|
||||
var makefileCmd = &cobra.Command{
|
||||
Use: "makefile",
|
||||
Short: "Generate Makefile",
|
||||
Run: runGenerateMakefileAction,
|
||||
Run: runGenerateMakefile,
|
||||
}
|
||||
|
||||
func init() {
|
||||
generateCmd.AddCommand(makefileCmd)
|
||||
}
|
||||
|
||||
// runGenerateMakefileAction will generate the Makefile for the current project.
|
||||
func runGenerateMakefileAction(cmd *cobra.Command, args []string) {
|
||||
// runGenerateMakefile will generate the Makefile for the current project.
|
||||
func runGenerateMakefile(cmd *cobra.Command, args []string) {
|
||||
log.Debugf("Starting command GenerateMakefile")
|
||||
|
||||
currentPath, config, err := loadProjectAndConfig()
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
var readmeCmd = &cobra.Command{
|
||||
Use: "readme",
|
||||
Short: "Generate Readme",
|
||||
Run: runGenerateReadmeAction,
|
||||
Run: runGenerateReadme,
|
||||
}
|
||||
|
||||
func init() {
|
||||
@ -23,7 +23,7 @@ func init() {
|
||||
}
|
||||
|
||||
// runGenerateReadmeAction will generate the Readme for the current project.
|
||||
func runGenerateReadmeAction(cmd *cobra.Command, args []string) {
|
||||
func runGenerateReadme(cmd *cobra.Command, args []string) {
|
||||
log.Debugf("Starting command GenerateReadme")
|
||||
currentPath, config, err := loadProjectAndConfig()
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user