Skip to content

Commit

Permalink
chore: release v0.5.1 (#554)
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jin-gou authored Jan 18, 2023
2 parents 95d427b + 97bcf75 commit e3dfeba
Show file tree
Hide file tree
Showing 31 changed files with 1,247 additions and 231 deletions.
32 changes: 31 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,34 @@ jobs:
run: go test -race -covermode=atomic -coverprofile=coverage.txt ./...

- name: Codecov
run: bash <(curl -s https://codecov.io/bash)
run: bash <(curl -s https://codecov.io/bash)

lint-and-ut-windows:
strategy:
matrix:
version: [ 1.18, 1.19 ]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.version }}

- uses: actions/cache@v3
with:
path: $HOME/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Lint
run: |
go vet -stdmethods=false $(go list ./...)
go install mvdan.cc/[email protected]
test -z "$(gofumpt -l -extra .)"
- name: Unit Test
run: go test -race -covermode=atomic -coverprofile=coverage.txt ./...
#
# - name: Codecov
# run: bash <(curl -s https://codecov.io/bash)
2 changes: 2 additions & 0 deletions cmd/hz/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func Init() *cli.App {
outDirFlag := cli.StringFlag{Name: "out_dir", Usage: "Specify the project path.", Destination: &globalArgs.OutDir}
handlerDirFlag := cli.StringFlag{Name: "handler_dir", Usage: "Specify the handler path.", Destination: &globalArgs.HandlerDir}
modelDirFlag := cli.StringFlag{Name: "model_dir", Usage: "Specify the model path.", Destination: &globalArgs.ModelDir}
baseDomainFlag := cli.StringFlag{Name: "base_domain", Usage: "Specify the request domain.", Destination: &globalArgs.BaseDomain}
clientDirFlag := cli.StringFlag{Name: "client_dir", Usage: "Specify the client path. If not specified, IDL generated path is used for 'client' command; no client code is generated for 'new' command", Destination: &globalArgs.ClientDir}

optPkgFlag := cli.StringSliceFlag{Name: "option_package", Aliases: []string{"P"}, Usage: "Specify the package path. ({include_path}={import_path})"}
Expand Down Expand Up @@ -262,6 +263,7 @@ func Init() *cli.App {
Flags: []cli.Flag{
&idlFlag,
&moduleFlag,
&baseDomainFlag,
&modelDirFlag,
&clientDirFlag,

Expand Down
1 change: 1 addition & 0 deletions cmd/hz/config/argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Argument struct {
ModelDir string // model path
RouterDir string // router path
ClientDir string // client path
BaseDomain string // request domain

IdlType string // idl type
IdlPaths []string // master idl path
Expand Down
20 changes: 13 additions & 7 deletions cmd/hz/generator/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type ClientMethod struct {

type ClientFile struct {
FilePath string
PackageName string
ServiceName string
BaseDomain string
Imports map[string]*model.Model
Expand All @@ -49,17 +50,22 @@ func (pkgGen *HttpPackageGenerator) genClient(pkg *HttpPackage, clientDir string
if err != nil {
return err
}
if !isExist {
err := pkgGen.TemplateGenerator.Generate(nil, hertzClientTplName, hertzClientPath, false)
if err != nil {
return err
}
baseDomain := s.BaseDomain
if len(pkgGen.BaseDomain) != 0 {
baseDomain = pkgGen.BaseDomain
}
client := ClientFile{
FilePath: filepath.Join(cliDir, util.ToSnakeCase(s.Name)+".go"),
PackageName: util.ToSnakeCase(s.Name),
ServiceName: util.ToCamelCase(s.Name),
ClientMethods: s.ClientMethods,
BaseDomain: s.BaseDomain,
BaseDomain: baseDomain,
}
if !isExist {
err := pkgGen.TemplateGenerator.Generate(client, hertzClientTplName, hertzClientPath, false)
if err != nil {
return err
}
}
client.Imports = make(map[string]*model.Model, len(client.ClientMethods))
for _, m := range client.ClientMethods {
Expand All @@ -72,7 +78,7 @@ func (pkgGen *HttpPackageGenerator) genClient(pkg *HttpPackage, clientDir string
client.Imports[mm.PackageName] = mm
}
}
err = pkgGen.TemplateGenerator.Generate(client, serviceClientName, client.FilePath, false)
err = pkgGen.TemplateGenerator.Generate(client, idlClientName, client.FilePath, false)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit e3dfeba

Please sign in to comment.