LinkinStars commented on code in PR #785:
URL: https://github.com/apache/incubator-answer/pull/785#discussion_r1502331492
##########
script/build_plugin.sh:
##########
@@ -16,28 +16,29 @@
# specific language governing permissions and limitations
# under the License.
-set -e
Review Comment:
We need to exit the script when it encounters a problem, rather than
continuing on.
##########
script/build_plugin.sh:
##########
@@ -16,28 +16,29 @@
# specific language governing permissions and limitations
# under the License.
-set -e
-echo "begin build plugin"
-plugin_file=./script/plugin_list
-if [ ! -f "$plugin_file" ]; then
+cmd="./answer build"
+
+echo "Check, if file plugin_list exist"
+sleep 1
Review Comment:
We probably don't need to sleep here to stop for a while.
##########
internal/cli/build.go:
##########
@@ -312,17 +312,17 @@ func generateIndexTsContent(folders []string) string {
return builder.String()
}
-// buildUI run pnpm install and pnpm build commands to build ui
+// buildUI run yarn and yarn react-app-rewired build commands to build ui
func buildUI(b *buildingMaterial) (err error) {
localUIBuildDir := filepath.Join(b.tmpDir,
"vendor/github.com/apache/incubator-answer/ui")
- pnpmInstallCmd := b.newExecCmd("pnpm", "pre-install")
+ pnpmInstallCmd := b.newExecCmd("yarn", "pre-install")
pnpmInstallCmd.Dir = localUIBuildDir
if err = pnpmInstallCmd.Run(); err != nil {
return err
}
- pnpmBuildCmd := b.newExecCmd("pnpm", "build")
+ pnpmBuildCmd := b.newExecCmd("yarn", "react-app-rewired", "build")
Review Comment:
Currently, `pnpm` is the official and more recommended usage. We should use
`pnpm` instead of `yarn`.
##########
internal/service/question_service.go:
##########
@@ -187,15 +187,6 @@ func (qs *QuestionService) AddQuestionCheckTags(ctx
context.Context, Tags []*ent
return []string{}, nil
}
func (qs *QuestionService) CheckAddQuestion(ctx context.Context, req
*schema.QuestionAdd) (errorlist any, err error) {
- if len(req.Tags) == 0 {
- errorlist := make([]*validator.FormErrorField, 0)
- errorlist = append(errorlist, &validator.FormErrorField{
- ErrorField: "tags",
- ErrorMsg: translator.Tr(handler.GetLangByCtx(ctx),
reason.TagNotFound),
- })
- err = errors.BadRequest(reason.RecommendTagEnter)
- return errorlist, err
- }
Review Comment:
Questions cannot be posted without a tag.
##########
script/plugin_list:
##########
@@ -1 +1,11 @@
-github.com/apache/incubator-answer-plugins/connector-basic@latest
\ No newline at end of file
+github.com/apache/incubator-answer-plugins/cache-redis@latest
+github.com/apache/incubator-answer-plugins/connector-basic@latest
+github.com/apache/incubator-answer-plugins/connector-github@latest
+github.com/apache/incubator-answer-plugins/connector-google@latest
+github.com/apache/incubator-answer-plugins/editor-chart@latest
+github.com/apache/incubator-answer-plugins/editor-formula@latest
+github.com/apache/incubator-answer-plugins/search-algolia@latest
+github.com/apache/incubator-answer-plugins/search-elasticsearch@latest
+github.com/apache/incubator-answer-plugins/search-meilisearch@latest
+github.com/apache/incubator-answer-plugins/storage-aliyunoss@latest
+github.com/apache/incubator-answer-plugins/storage-s3@latest
Review Comment:
The default version will not contain all the plugins.
##########
script/build_plugin.sh:
##########
@@ -16,28 +16,29 @@
# specific language governing permissions and limitations
# under the License.
-set -e
-echo "begin build plugin"
-plugin_file=./script/plugin_list
-if [ ! -f "$plugin_file" ]; then
+cmd="./answer build"
+
+echo "Check, if file plugin_list exist"
+sleep 1
+if ! [ -f "plugin_list" ]; then
echo "plugin_list is not exist"
exit 0
fi
-echo "plugin_list exist"
-cmd="./answer build "
-for repo in `cat $plugin_file`
-do
- echo ${repo}
- cmd=$cmd" --with "${repo}
+echo "Begin build plugin..."
+sleep 1
Review Comment:
We probably don't need to sleep here to stop for a while.
##########
pkg/checker/username.go:
##########
@@ -22,7 +22,7 @@ package checker
import "regexp"
var (
- usernameReg = regexp.MustCompile(`^[a-z0-9._-]{4,30}$`)
+ usernameReg = regexp.MustCompile(`^[A-Za-z0-9._-]{1,32}$`)
Review Comment:
Our current rule is correct and doesn't require a change in length or
uppercase.
##########
script/build_plugin.sh:
##########
@@ -16,28 +16,29 @@
# specific language governing permissions and limitations
# under the License.
-set -e
-echo "begin build plugin"
-plugin_file=./script/plugin_list
-if [ ! -f "$plugin_file" ]; then
+cmd="./answer build"
+
+echo "Check, if file plugin_list exist"
+sleep 1
+if ! [ -f "plugin_list" ]; then
echo "plugin_list is not exist"
exit 0
fi
-echo "plugin_list exist"
-cmd="./answer build "
-for repo in `cat $plugin_file`
-do
- echo ${repo}
- cmd=$cmd" --with "${repo}
+echo "Begin build plugin..."
+sleep 1
+for repo in $(cat plugin_list); do
+ cmd+=" --with ${repo}"
done
-echo "cmd is "$cmd
Review Comment:
We need the logs to know if the final executed command contains the list of
plugins we need.
##########
internal/install/install_req.go:
##########
@@ -96,13 +96,13 @@ type InitEnvironmentResp struct {
// InitBaseInfoReq init base info request
type InitBaseInfoReq struct {
- Language string `validate:"required,gt=0,lte=30" json:"lang"`
- SiteName string `validate:"required,sanitizer,gt=0,lte=30"
json:"site_name"`
+ Language string `validate:"required,gt=0,lte=32" json:"lang"`
+ SiteName string `validate:"required,sanitizer,gt=0,lte=32"
json:"site_name"`
SiteURL string `validate:"required,gt=0,lte=512,url"
json:"site_url"`
- ContactEmail string `validate:"required,email,gt=0,lte=500"
json:"contact_email"`
- AdminName string `validate:"required,gt=3,lte=30" json:"name"`
- AdminPassword string `validate:"required,gte=8,lte=32" json:"password"`
- AdminEmail string `validate:"required,email,gt=0,lte=500"
json:"email"`
+ ContactEmail string `validate:"required,email,gt=0,lte=512"
json:"contact_email"`
+ AdminName string `validate:"required,gt=2,lte=64" json:"name"`
+ AdminPassword string `validate:"required,gte=4,lte=128" json:"password"`
+ AdminEmail string `validate:"required,email,gt=0,lte=512"
json:"email"`
Review Comment:
There is no problem setting the length of this section. The password length
should be 8-32.
##########
internal/install/install_main.go:
##########
@@ -49,8 +73,13 @@ func Run(configPath string) {
if len(port) == 0 {
port = "80"
}
- fmt.Printf("[SUCCESS] answer installation service will run at:
http://localhost:%s/install/ \n", port)
- if err = installServer.Run(":" + port); err != nil {
- panic(err)
+
+ localIP := getLocalIP()
+
+ if installByEnv, err := TryToInstallByEnv(); !installByEnv {
+ fmt.Printf("[SUCCESS] Answer installation service will run at:
http://%s:%s/install/ \n", localIP, port)
+ if err = installServer.Run(":" + port); err != nil {
+ panic(err)
+ }
Review Comment:
The `TryToInstallByEnv` function should not be called again for installation
here.
##########
internal/service/question_service.go:
##########
@@ -242,15 +233,6 @@ func (qs *QuestionService) HasNewTag(ctx context.Context,
tags []*schema.TagItem
// AddQuestion add question
func (qs *QuestionService) AddQuestion(ctx context.Context, req
*schema.QuestionAdd) (questionInfo any, err error) {
- if len(req.Tags) == 0 {
- errorlist := make([]*validator.FormErrorField, 0)
- errorlist = append(errorlist, &validator.FormErrorField{
- ErrorField: "tags",
- ErrorMsg: translator.Tr(handler.GetLangByCtx(ctx),
reason.TagNotFound),
- })
- err = errors.BadRequest(reason.RecommendTagEnter)
- return errorlist, err
- }
Review Comment:
Questions cannot be posted without a tag.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]