Skip to content

Commit 458146a

Browse files
committed
feat(jzero): Optimize code and simplify flag
1 parent 23f6307 commit 458146a

28 files changed

Lines changed: 272 additions & 405 deletions

README-EN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# jzero
22

3+
**Free your hands and have more time to play games**
4+
35
[![Build Status](https://img.shields.io/github/actions/workflow/status/jzero-io/jzero/ci.yaml?branch=main&label=jzero-ci&logo=github&style=flat-square)](https://github.com/jzero-io/jzero/actions?query=workflow%3Ajzero-ci)
46
[![GitHub release](https://img.shields.io/github/release/jzero-io/jzero.svg?style=flat-square)](https://github.com/jzero-io/jzero/releases/latest)
57
[![GitHub package version](https://img.shields.io/github/v/release/jzero-io/jzero?include_prereleases&sort=semver&label=Docker%20Image%20version)](https://github.com/jzero-io/jzero/pkgs/container/jzero)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
通过模板创建项目,并基于 proto/api/sql 文件生成 Server/Client/Model 代码。
2929

3030
具备以下特点:
31-
* 基于 [go-zero](https://go-zero.dev) 框架但不局限于 go-zero 框架, 理论上可以基于模板特性接入任意框架
31+
* 基于 [go-zero](https://go-zero.dev) 框架但不局限于 go-zero 框架, 基于模板特性支持任意框架
3232
* 优化 go-zero 框架已有痛点, 并扩展新的特性, 完全兼容 go-zero 框架
33-
* 基于配置文件, 通过极简指令生成代码
33+
* 基于配置文件, 通过极简指令生成代码, MCP 模式下使用友好
3434
* 基于 git 仅对改动文件部分生成代码, 极大提升大型项目代码生成效率
35-
* 维护常用开发模板, 一键生成符合企业级代码规范的项目
35+
* 内置不同场景模板, 一键生成符合企业级代码规范的项目
3636
* 所有配套工具链跨平台使用, 支持 windows/mac/linux
3737

3838
更多详情请参阅:https://docs.jzero.io
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
syntax: v1
2-
31
gen:
42
hooks:
53
after:
64
- jzero gen swagger
7-
- jzero format
5+
- jzero format
6+
7+
style: {{.Style}}

cmd/jzero/.template/frame/api/app/internal/svc/service_context.go.tpl renamed to cmd/jzero/.template/frame/api/app/internal/svc/{{FormatStyle .Style "service_context"}}.go.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package svc
22

33
import (
4-
configurator "github.com/zeromicro/go-zero/core/configcenter"
4+
configurator "github.com/zeromicro/go-zero/core/configcenter"
55

66
"{{ .Module }}/internal/config"
77
"{{ .Module }}/internal/custom"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
syntax: v1
2-
31
gen:
42
hooks:
53
after:
6-
- jzero gen swagger
4+
- jzero gen swagger
5+
6+
style: {{.Style}}

cmd/jzero/.template/frame/gateway/app/internal/svc/service_context.go.tpl renamed to cmd/jzero/.template/frame/gateway/app/internal/svc/{{FormatStyle .Style "service_context"}}.go.tpl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
package svc
22

33
import (
4+
configurator "github.com/zeromicro/go-zero/core/configcenter"
5+
46
"{{ .Module }}/internal/config"
57
"{{ .Module }}/internal/custom"
6-
7-
configurator "github.com/zeromicro/go-zero/core/configcenter"
88
)
99

1010
type ServiceContext struct {
1111
Config configurator.Configurator[config.Config]
12-
1312
Custom *custom.Custom
1413
}
1514

1615
func NewServiceContext(cc configurator.Configurator[config.Config]) *ServiceContext {
17-
sc := &ServiceContext{
16+
sc := &ServiceContext{
1817
Config: cc,
1918
Custom: custom.New(cc),
2019
}
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
syntax: v1
2-
31
gen:
4-
# add custom gen flags
5-
6-
# add custom gen zrpcclient flags
7-
zrpcclient:
2+
style: {{.Style}}

cmd/jzero/.template/frame/rpc/app/internal/svc/service_context.go.tpl renamed to cmd/jzero/.template/frame/rpc/app/internal/svc/{{FormatStyle .Style "service_context"}}.go.tpl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
package svc
22

33
import (
4+
configurator "github.com/zeromicro/go-zero/core/configcenter"
5+
46
"{{ .Module }}/internal/config"
57
"{{ .Module }}/internal/custom"
6-
7-
configurator "github.com/zeromicro/go-zero/core/configcenter"
88
)
99

1010
type ServiceContext struct {
1111
Config configurator.Configurator[config.Config]
12-
1312
Custom *custom.Custom
1413
}
1514

1615
func NewServiceContext(cc configurator.Configurator[config.Config]) *ServiceContext {
17-
sc := &ServiceContext{
16+
sc := &ServiceContext{
1817
Config: cc,
1918
Custom: custom.New(),
2019
}

cmd/jzero/.template/go-zero/api/handler.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Code generated by goctl. Templates Edited by jzero. DO NOT EDIT.
2+
13
package {{.PkgName}}
24

35
import (

cmd/jzero/internal/command/gen/gen.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ func GetCommand() *cobra.Command {
152152
genCmd.PersistentFlags().StringSliceP("desc", "", []string{}, "set desc path")
153153
genCmd.PersistentFlags().StringSliceP("desc-ignore", "", []string{}, "set desc ignore path")
154154

155-
genCmd.Flags().BoolP("change-logic-types", "", false, "if api file or proto change, e.g. Request or Response type, change logic file content types but not file")
156-
genCmd.Flags().BoolP("regen-api-handler", "", false, "")
157-
genCmd.Flags().BoolP("rpc-style-patch", "", false, "")
158155
genCmd.Flags().BoolP("git-change", "", false, "set is git change, if changes then generate code")
159156
genCmd.Flags().BoolP("route2code", "", false, "is generate route2code")
160157
genCmd.Flags().BoolP("rpc-client", "", false, "is generate rpc client code by goctl")

0 commit comments

Comments
 (0)