appres

package
v0.0.0-...-9196c9a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cli.Command{
	Name:  "res",
	Usage: "tools for knockout resource generator",
	Subcommands: []*cli.Command{
		{
			Name:  "gql-action",
			Usage: "gen actions from graphql",
			Flags: []cli.Flag{
				cnf,
				appcode,
				&cli.PathFlag{
					Name:    "gql",
					Usage:   "the gqlgen config path",
					Value:   "codegen/gqlgen/gqlgen.yaml",
					Aliases: []string{"g"},
				},
			},
			Action: func(ctx *cli.Context) error {
				return GenGqlActions(Config{
					KnockoutConfig: ctx.String("config"),
					GQLConfig:      ctx.String("gql"),
					AppCode:        ctx.String("app"),
				})
			},
		},
		{
			Name:  "ent",
			Usage: "gen resource from ent schema. Root schema will generate to app_res",
			Flags: []cli.Flag{
				cnf,
				appcode,
				&cli.PathFlag{
					Name:    "schema",
					Usage:   "the ent schema path",
					Value:   "codegen/entgen/schema",
					Aliases: []string{"e"},
				},
			},
			Action: func(ctx *cli.Context) error {
				return GenEntSchemaRes(Config{
					KnockoutConfig: ctx.String("config"),
					EntConfig:      ctx.String("schema"),
					AppCode:        ctx.String("app"),
				})
			},
		},
		{
			Name:  "menu",
			Usage: "gen app menu from web project.",
			Flags: []cli.Flag{
				cnf,
				appcode,
				&cli.PathFlag{
					Name:    "data",
					Usage:   "the menu data path",
					Value:   "web/src/components/layout/menu.json",
					Aliases: []string{"d"},
				},
			},
			Action: func(ctx *cli.Context) error {
				return GenAppMenu(Config{
					KnockoutConfig: ctx.String("config"),
					EntConfig:      ctx.String("schema"),
					MenuConfig:     ctx.String("data"),
					AppCode:        ctx.String("app"),
				})
			},
		},
	},
}

Functions

func GenAppMenu

func GenAppMenu(cfg Config) error

func GenEntSchemaRes

func GenEntSchemaRes(cfg Config) error

GenEntSchemaRes generate resource from ent schema

func GenGqlActions

func GenGqlActions(cfg Config) error

Types

type Config

type Config struct {
	KnockoutConfig string
	EntConfig      string
	GQLConfig      string
	MenuConfig     string
	Dialect        string
	DSN            string
	AppCode        string
	AppID          int
	PortalClient   *ent.Client
}
type MenuData struct {
	Name     string      `json:"name"`
	Icon     string      `json:"icon"`
	Path     string      `json:"path"`
	Redirect string      `json:"action"`
	Children []*MenuData `json:"children"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL