diff --git a/.drone.yml b/.drone.yml index 5a4752b..c5d1183 100644 --- a/.drone.yml +++ b/.drone.yml @@ -28,7 +28,7 @@ pipeline: commands: - cd frontend/ - yarn build - deps: + build: image: golang:1.10 pull: true environment: @@ -36,6 +36,8 @@ pipeline: commands: - go get -u github.com/golang/dep/cmd/dep - dep ensure + - go get -u github.com/gobuffalo/packr/... + - packr -z test: image: golang:1.10 pull: true @@ -56,6 +58,13 @@ pipeline: - xgo -out gitea-github-migrator -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" --targets=windows/*,darwin/*,linux/* . when: event: [ tag ] + clean: + image: golang:1.10 + pull: true + environment: + GOPATH: /go + commands: + - packr clean gitea: image: plugins/gitea-release:latest pull: true diff --git a/.gitignore b/.gitignore index 7560965..81ca976 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +*-packr.go # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 .glide/ diff --git a/Gopkg.lock b/Gopkg.lock index 26c9dcb..34e918e 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -35,6 +35,12 @@ revision = "d459835d2b077e44f7c9b453505ee29881d5d12d" version = "v1.2" +[[projects]] + name = "github.com/gobuffalo/packr" + packages = ["."] + revision = "bd47f2894846e32edcf9aa37290fef76c327883f" + version = "v1.11.1" + [[projects]] name = "github.com/golang/protobuf" packages = ["proto"] @@ -65,6 +71,12 @@ revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39" version = "v0.0.3" +[[projects]] + name = "github.com/pkg/errors" + packages = ["."] + revision = "645ef00459ed84a119197bfb8d8205042c6df63d" + version = "v0.8.0" + [[projects]] name = "github.com/ugorji/go" packages = ["codec"] @@ -131,6 +143,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "2884c43b72546db916785490241c84920a25e0f43df532f9b3a551a678e3cc42" + inputs-digest = "4a75dbc846a83d2e7c1a0d840da062e06835663a2a4a60225d41ee22a89db840" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 81c5650..175e8b2 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -51,3 +51,7 @@ [[constraint]] branch = "master" name = "github.com/jinzhu/configor" + +[[constraint]] + name = "github.com/gobuffalo/packr" + version = "1.11.1" diff --git a/api/fs.go b/api/fs.go new file mode 100644 index 0000000..ff7b5e4 --- /dev/null +++ b/api/fs.go @@ -0,0 +1,18 @@ +package api + +import ( + "strings" + + "github.com/gobuffalo/packr" +) + +type BundledFS struct { + packr.Box +} + +func (fs *BundledFS) Exists(prefix string, filepath string) bool { + if p := strings.TrimPrefix(filepath, prefix); len(p) < len(filepath) { + return fs.Has(p) + } + return false +} diff --git a/api/router.go b/api/router.go index 23ee7f1..4dbb1bb 100644 --- a/api/router.go +++ b/api/router.go @@ -22,12 +22,15 @@ import ( "git.jonasfranz.software/JonasFranzDEV/gitea-github-migrator/api/auth" "github.com/gin-gonic/contrib/static" "github.com/gin-gonic/gin" + "github.com/gobuffalo/packr" ) func InitRoutes() *gin.Engine { r := gin.Default() auth.InitOAuthConfig() - r.Use(static.Serve("/", static.LocalFile("./frontend", true))) + + box := packr.NewBox("../frontend/dist/") + r.Use(static.Serve("/", &BundledFS{box})) api := r.Group("/api") { au := api.Group("/auth") diff --git a/frontend/index.html b/frontend/index.html deleted file mode 100644 index b876827..0000000 --- a/frontend/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - -
- -