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