From a5a3bf30bfde652ba1f84bdb4cee10a0b5a3213c Mon Sep 17 00:00:00 2001 From: Denis Gukov Date: Tue, 24 Nov 2020 00:24:27 +0500 Subject: [PATCH 1/2] ci: return golang image to 1.13 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 23f61d225..5535eb47c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,7 +9,7 @@ aliases: # git clone -b $CIRCLE_BRANCH https://github.com/ansible-semaphore/semaphore.git ./ - &golang-image - image: circleci/golang:1.15.5 + image: circleci/golang:1.13 - &working-dir /go/src/github.com/ansible-semaphore/semaphore From 060f4d93ebca9c63aac5bb018329d8ae66ae4b07 Mon Sep 17 00:00:00 2001 From: Denis Gukov Date: Tue, 24 Nov 2020 01:57:03 +0500 Subject: [PATCH 2/2] fix(be): loading static content --- .gitignore | 2 +- Taskfile.yml | 1 + api/router.go | 26 ++++++++++++++------------ web2/.gitignore | 23 ----------------------- 4 files changed, 16 insertions(+), 36 deletions(-) delete mode 100644 web2/.gitignore diff --git a/.gitignore b/.gitignore index 3c5405969..750b8834d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,8 @@ web/public/js/bundle.js web/public/css/*.* web/public/html/**/*.* web/public/fonts/*.* -web2/dist web2/.nyc_output +web2/dist/**/* config.json .DS_Store node_modules/ diff --git a/Taskfile.yml b/Taskfile.yml index 81d88f4fc..e97b8eee9 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -127,6 +127,7 @@ tasks: - db/db-packr.go - api/api-packr.go cmds: + - mkdir -p web2/dist - go run util/version_gen/generator.go {{ if .TAG }}{{ .TAG }}{{ else }}{{ if .SEMAPHORE_VERSION }}{{ .SEMAPHORE_VERSION }}{{ else }}{{ .BRANCH }}-{{ .SHA }}-{{ .TIMESTAMP }}{{ if .DIRTY }}-dirty{{ end }}{{ end }}{{end}} - packr vars: diff --git a/api/router.go b/api/router.go index a42bc52de..da051d154 100644 --- a/api/router.go +++ b/api/router.go @@ -16,15 +16,8 @@ import ( "github.com/russross/blackfriday" ) -var publicAssets packr.Box - -func getPublicAssetsPath() string { - if util.Config != nil && util.Config.OldFrontend { - return "../web/public" - } - - return "../web2/dist" -} +var publicAssets = packr.NewBox("../web/public") +var publicAssets2 = packr.NewBox("../web2/dist") //JSONMiddleware ensures that all the routes respond with Json, this is added by default to all routes func JSONMiddleware(next http.Handler) http.Handler { @@ -58,8 +51,6 @@ func notFoundHandler(w http.ResponseWriter, r *http.Request) { // Route declares all routes func Route() *mux.Router { - publicAssets = packr.NewBox(getPublicAssetsPath()) - r := mux.NewRouter().StrictSlash(true) r.NotFoundHandler = http.HandlerFunc(servePublic) @@ -271,7 +262,18 @@ func servePublic(w http.ResponseWriter, r *http.Request) { split := strings.Split(path, ".") suffix := split[len(split)-1] - res, err := publicAssets.MustBytes(path) + fmt.Println("path") + fmt.Println(path) + + var res []byte + var err error + + if util.Config.OldFrontend { + res, err = publicAssets.MustBytes(path) + } else { + res, err = publicAssets2.MustBytes(path) + } + if err != nil { notFoundHandler(w, r) return diff --git a/web2/.gitignore b/web2/.gitignore deleted file mode 100644 index 403adbc1e..000000000 --- a/web2/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -.DS_Store -node_modules -/dist - - -# local env files -.env.local -.env.*.local - -# Log files -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# Editor directories and files -.idea -.vscode -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw?