Skip to content

Commit

Permalink
Release/1.2.1 (#678)
Browse files Browse the repository at this point in the history
Co-authored-by: shuai <lishuailing@sifou.com>
Co-authored-by: kelvinkuo <kelvinkuo224@gmail.com>
Co-authored-by: hgaol <dhangao@hotmail.com>
Co-authored-by: sy-records <52o@qq52o.cn>
  • Loading branch information
5 people authored Dec 14, 2023
1 parent a00f660 commit 82fdfc7
Show file tree
Hide file tree
Showing 83 changed files with 2,248 additions and 1,022 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: build clean ui

VERSION=1.2.0
VERSION=1.2.1
BIN=answer
DIR_SRC=./cmd/answer
DOCKER_CMD=docker
Expand Down
38 changes: 37 additions & 1 deletion cmd/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ var (
// This config is used to upgrade the database from a specific version manually.
// If you want to upgrade the database to version 1.1.0, you can use `answer upgrade -f v1.1.0`.
upgradeVersion string
// The fields that need to be set to the default value
configFields []string
)

func init() {
Expand All @@ -60,7 +62,9 @@ func init() {

upgradeCmd.Flags().StringVarP(&upgradeVersion, "from", "f", "", "upgrade from specific version, eg: -f v1.1.0")

for _, cmd := range []*cobra.Command{initCmd, checkCmd, runCmd, dumpCmd, upgradeCmd, buildCmd, pluginCmd} {
configCmd.Flags().StringSliceVarP(&configFields, "with", "w", []string{}, "the fields that need to be set to the default value, eg: -w allow_password_login")

for _, cmd := range []*cobra.Command{initCmd, checkCmd, runCmd, dumpCmd, upgradeCmd, buildCmd, pluginCmd, configCmd} {
rootCmd.AddCommand(cmd)
}
}
Expand Down Expand Up @@ -231,6 +235,38 @@ To run answer, use:
})
},
}

// configCmd set some config to default value
configCmd = &cobra.Command{
Use: "config",
Short: "set some config to default value",
Long: `set some config to default value`,
Run: func(_ *cobra.Command, _ []string) {
cli.FormatAllPath(dataDirPath)

c, err := conf.ReadConfig(cli.GetConfigFilePath())
if err != nil {
fmt.Println("read config failed: ", err.Error())
return
}

field := &cli.ConfigField{}
for _, f := range configFields {
switch f {
case "allow_password_login":
field.AllowPasswordLogin = true
default:
fmt.Printf("field %s not support\n", f)
}
}
err = cli.SetDefaultConfig(c.Data.Database, c.Data.Cache, field)
if err != nil {
fmt.Println("set default config failed: ", err.Error())
} else {
fmt.Println("set default config successfully")
}
},
}
)

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down
3 changes: 3 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ var (
Revision = "-"
// Time is the build time of the project
Time = "-"
// GoVersion is the go version of the project
GoVersion = "1.19"
// log level
logLevel = os.Getenv("LOG_LEVEL")
// log path
Expand Down Expand Up @@ -75,6 +77,7 @@ func runApp() {
}
constant.Version = Version
constant.Revision = Revision
constant.GoVersion = GoVersion
schema.AppStartTime = time.Now()
fmt.Println("answer Version:", constant.Version, " Revision:", constant.Revision)

Expand Down
4 changes: 2 additions & 2 deletions cmd/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 19 additions & 9 deletions docs/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 19 additions & 9 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6871,12 +6871,13 @@
"object_id"
],
"properties": {
"bookmark": {
"type": "boolean"
},
"group_id": {
"description": "user collection group TagID",
"type": "string"
},
"object_id": {
"description": "object TagID",
"type": "string"
}
}
Expand All @@ -6885,13 +6886,7 @@
"type": "object",
"properties": {
"object_collection_count": {
"type": "string"
},
"object_id": {
"type": "string"
},
"switch": {
"type": "boolean"
"type": "integer"
}
}
},
Expand Down Expand Up @@ -8755,6 +8750,9 @@
"site_users": {
"$ref": "#/definitions/schema.SiteUsersResp"
},
"site_write": {
"$ref": "#/definitions/schema.SiteWriteResp"
},
"theme": {
"$ref": "#/definitions/schema.SiteThemeResp"
},
Expand Down Expand Up @@ -8846,6 +8844,9 @@
"allow_new_registrations": {
"type": "boolean"
},
"allow_password_login": {
"type": "boolean"
},
"login_required": {
"type": "boolean"
}
Expand All @@ -8866,6 +8867,9 @@
"allow_new_registrations": {
"type": "boolean"
},
"allow_password_login": {
"type": "boolean"
},
"login_required": {
"type": "boolean"
}
Expand Down Expand Up @@ -9028,6 +9032,9 @@
"items": {
"type": "string"
}
},
"restrict_answer": {
"type": "boolean"
}
}
},
Expand All @@ -9048,6 +9055,9 @@
"items": {
"type": "string"
}
},
"restrict_answer": {
"type": "boolean"
}
}
},
Expand Down
20 changes: 13 additions & 7 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,11 @@ definitions:
type: object
schema.CollectionSwitchReq:
properties:
bookmark:
type: boolean
group_id:
description: user collection group TagID
type: string
object_id:
description: object TagID
type: string
required:
- group_id
Expand All @@ -370,11 +370,7 @@ definitions:
schema.CollectionSwitchResp:
properties:
object_collection_count:
type: string
object_id:
type: string
switch:
type: boolean
type: integer
type: object
schema.ConfigField:
properties:
Expand Down Expand Up @@ -1677,6 +1673,8 @@ definitions:
$ref: '#/definitions/schema.SiteSeoResp'
site_users:
$ref: '#/definitions/schema.SiteUsersResp'
site_write:
$ref: '#/definitions/schema.SiteWriteResp'
theme:
$ref: '#/definitions/schema.SiteThemeResp'
version:
Expand Down Expand Up @@ -1738,6 +1736,8 @@ definitions:
type: boolean
allow_new_registrations:
type: boolean
allow_password_login:
type: boolean
login_required:
type: boolean
type: object
Expand All @@ -1751,6 +1751,8 @@ definitions:
type: boolean
allow_new_registrations:
type: boolean
allow_password_login:
type: boolean
login_required:
type: boolean
type: object
Expand Down Expand Up @@ -1861,6 +1863,8 @@ definitions:
items:
type: string
type: array
restrict_answer:
type: boolean
type: object
schema.SiteWriteResp:
properties:
Expand All @@ -1874,6 +1878,8 @@ definitions:
items:
type: string
type: array
restrict_answer:
type: boolean
type: object
schema.TagItem:
properties:
Expand Down
Loading

0 comments on commit 82fdfc7

Please sign in to comment.