Skip to content

Commit

Permalink
Upgrade v1.12.1 (#197)
Browse files Browse the repository at this point in the history
* Update README

* fix: path error in Windows (#192)

* feat: remove promptui (#194)

* feat: remove promptui

* fix: lint

* fix: lint

* Update README (#195)

---------

Co-authored-by: 耗子 <[email protected]>
  • Loading branch information
hwbrzzl and devhaozi committed Jun 19, 2023
1 parent 64cca18 commit 1a85319
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 30 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Example [https://github.com/goravel/example](https://github.com/goravel/example)

## Contributors

This project exists thanks to all the people who contribute.
This project exists thanks to all the people who contribute, to participate in the contribution, please see [Contribution](https://goravel.dev/prologue/contributions.html).

<a href="https://github.com/hwbrzzl" target="_blank"><img src="https://avatars.githubusercontent.com/u/24771476?v=4" width="48" height="48"></a>
<a href="https://github.com/DevHaoZi" target="_blank"><img src="https://avatars.githubusercontent.com/u/115467771?v=4" width="48" height="48"></a>
Expand Down
2 changes: 1 addition & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Laravel!

## 贡献者

这个项目的存在要归功于所有做出贡献的人。
这个项目的存在要归功于所有做出贡献的人,参与贡献请查看[贡献指南](https://goravel.dev/zh/prologue/contributions.html)

<a href="https://github.com/hwbrzzl" target="_blank"><img src="https://avatars.githubusercontent.com/u/24771476?v=4" width="48" height="48"></a>
<a href="https://github.com/DevHaoZi" target="_blank"><img src="https://avatars.githubusercontent.com/u/115467771?v=4" width="48" height="48"></a>
Expand Down
11 changes: 6 additions & 5 deletions console/console/key_generate_command.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package console

import (
"fmt"
"os"
"strings"

"github.com/gookit/color"
"github.com/manifoldco/promptui"

"github.com/goravel/framework/contracts/config"
"github.com/goravel/framework/contracts/console"
Expand Down Expand Up @@ -46,15 +46,16 @@ func (receiver *KeyGenerateCommand) Handle(ctx console.Context) error {
color.Yellowln("**************************************")
color.Yellowln("* Application In Production! *")
color.Yellowln("**************************************")
prompt := promptui.Prompt{
Label: color.New(color.Green).Sprintf("Do you really wish to run this command?(yes/no)") + "[" + color.New(color.Yellow).Sprintf("no") + "]",
}
result, err := prompt.Run()
color.Println(color.New(color.Green).Sprintf("Do you really wish to run this command? (yes/no) ") + "[" + color.New(color.Yellow).Sprintf("no") + "]" + ":")

var result string
_, err := fmt.Scanln(&result)
if err != nil {
color.Redln(err.Error())

return nil
}

if result != "yes" {
color.Yellowln("Command Canceled")

Expand Down
55 changes: 55 additions & 0 deletions console/console/key_generate_command_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package console

import (
"os"
"testing"

"github.com/stretchr/testify/assert"

configmock "github.com/goravel/framework/contracts/config/mocks"
consolemocks "github.com/goravel/framework/contracts/console/mocks"
"github.com/goravel/framework/support/file"
)

func TestKeyGenerateCommand(t *testing.T) {
mockConfig := &configmock.Config{}
mockConfig.On("GetString", "app.env").Return("local").Twice()
mockConfig.On("GetString", "app.key").Return("12345").Once()

keyGenerateCommand := NewKeyGenerateCommand(mockConfig)
mockContext := &consolemocks.Context{}

assert.False(t, file.Exists(".env"))

assert.Nil(t, keyGenerateCommand.Handle(mockContext))

err := file.Create(".env", "APP_KEY=12345\n")
assert.Nil(t, err)

assert.Nil(t, keyGenerateCommand.Handle(mockContext))
assert.True(t, file.Exists(".env"))
env, err := os.ReadFile(".env")
assert.Nil(t, err)
assert.True(t, len(env) > 10)

mockConfig.On("GetString", "app.env").Return("production").Once()

reader, writer, err := os.Pipe()
assert.Nil(t, err)
originalStdin := os.Stdin
defer func() { os.Stdin = originalStdin }()
os.Stdin = reader
go func() {
defer writer.Close()
_, err = writer.Write([]byte("no\n"))
assert.Nil(t, err)
}()

assert.Nil(t, keyGenerateCommand.Handle(mockContext))
env, err = os.ReadFile(".env")
assert.Nil(t, err)
assert.True(t, len(env) > 10)
assert.True(t, file.Remove(".env"))

mockConfig.AssertExpectations(t)
}
10 changes: 5 additions & 5 deletions foundation/console/package_make_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ func NewPackageMakeCommand() *PackageMakeCommand {
return &PackageMakeCommand{}
}

//Signature The name and signature of the console command.
// Signature The name and signature of the console command.
func (receiver *PackageMakeCommand) Signature() string {
return "make:package"
}

//Description The console command description.
// Description The console command description.
func (receiver *PackageMakeCommand) Description() string {
return "Create a package template"
}

//Extend The console command extend.
// Extend The console command extend.
func (receiver *PackageMakeCommand) Extend() command.Extend {
return command.Extend{
Category: "make",
Expand All @@ -42,7 +42,7 @@ func (receiver *PackageMakeCommand) Extend() command.Extend {
}
}

//Handle Execute the console command.
// Handle Execute the console command.
func (receiver *PackageMakeCommand) Handle(ctx console.Context) error {
pkg := ctx.Argument(0)
if pkg == "" {
Expand Down Expand Up @@ -76,7 +76,7 @@ func (receiver *PackageMakeCommand) Handle(ctx console.Context) error {
}
}

color.Green.Printf("Package created successfully: /%s\n", root)
color.Green.Printf("Package created successfully: %s\n", root)

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion foundation/console/vendor_publish_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (receiver *VendorPublishCommand) Handle(ctx console.Context) error {
color.Greenp("Copied Directory ")
color.Yellowf("[%s]", sourceFile)
color.Greenp(" To ")
color.Yellowf("/%s\n", targetFile)
color.Yellowf("%s\n", targetFile)
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/hashicorp/go-multierror v1.1.1
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible
github.com/manifoldco/promptui v0.9.0
github.com/opentracing/opentracing-go v1.2.0
github.com/ory/dockertest/v3 v3.10.0
github.com/patrickmn/go-cache v2.1.0+incompatible
Expand Down Expand Up @@ -65,7 +64,6 @@ require (
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down
10 changes: 0 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,8 @@ github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM=
github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI=
github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04=
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
github.com/cilium/ebpf v0.7.0/go.mod h1:/oI2+1shJiTGAMgl6/RgJr36Eo1jzrRcAWbcXO2usCA=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
Expand Down Expand Up @@ -427,8 +421,6 @@ github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA=
github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg=
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
Expand Down Expand Up @@ -753,7 +745,6 @@ golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down Expand Up @@ -809,7 +800,6 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
2 changes: 1 addition & 1 deletion support/constant.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package support

const Version string = "v1.12.0"
const Version string = "v1.12.1"

const (
EnvRuntime = "runtime"
Expand Down
4 changes: 0 additions & 4 deletions support/path/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import (
"github.com/goravel/framework/facades"
)

const (
AppPath = "/app"
)

func App(paths ...string) string {
finalPath := ""
if len(paths) >= 1 {
Expand Down

0 comments on commit 1a85319

Please sign in to comment.