From 5ddc5235fe69ee80c3d2c5f8fdab3f4a232d8f54 Mon Sep 17 00:00:00 2001 From: KyleBanks Date: Thu, 23 Mar 2017 22:23:42 -0400 Subject: [PATCH] Move generated assets to seperate package --- .travis.yml | 2 +- Makefile | 8 ++++---- server/assets/assets.go | 10 ++++++++++ server/{ => assets}/bindata_assetfs.go | 22 +++++++++++----------- server/server.go | 3 ++- 5 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 server/assets/assets.go rename server/{ => assets}/bindata_assetfs.go (99%) diff --git a/.travis.yml b/.travis.yml index f044bb2..80d074e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,5 +7,5 @@ before_install: # Note: Need to ignore all cmd/goggles files because gallium will not work on the linix travis instances. script: - - rm -rf cmd/goggles/ + - rm -rf server/assets - $HOME/gopath/bin/goveralls -service=travis-ci diff --git a/Makefile b/Makefile index 7cecc46..47137fe 100644 --- a/Makefile +++ b/Makefile @@ -32,8 +32,8 @@ assets: npm install ; \ gulp - @go-bindata-assetfs -ignore=node_modules -pkg server static/... ; \ - mv bindata_assetfs.go server/ + @go-bindata-assetfs -ignore=node_modules -pkg assets static/... ; \ + mv bindata_assetfs.go server/assets/ .PHONY: assets # Cleans any built artifacts. @@ -61,7 +61,7 @@ build.app: | clean assets # binaries for the browser application. release: | sanity build.app @cd $(BIN) ; \ - zip -r -y goggles.$(VERSION).zip $(APP_NAME) + zip -r -y goggles.osx.app.$(VERSION).zip $(APP_NAME) @gox -osarch="$(strip $(RELEASE_PLATFORMS))" \ -output "bin/{{.Dir}}_$(VERSION)_{{.OS}}_{{.Arch}}" $(INSTALL_PKG) @@ -82,7 +82,7 @@ sanity: @go list ./... | grep -v vendor/ | xargs go vet @echo "---------------- LINT ----------------" - @go list ./... | grep -v vendor/ | xargs golint + @go list ./... | grep -v -e vendor/ -e server/assets | xargs golint @echo "---------------- FMT ----------------" @go list ./... | grep -v vendor/ | xargs go fmt diff --git a/server/assets/assets.go b/server/assets/assets.go new file mode 100644 index 0000000..1fa1f75 --- /dev/null +++ b/server/assets/assets.go @@ -0,0 +1,10 @@ +package assets + +import ( + "github.com/elazarl/go-bindata-assetfs" +) + +// FS returns the assets FileSystem. +func FS() *assetfs.AssetFS { + return assetFS() +} diff --git a/server/bindata_assetfs.go b/server/assets/bindata_assetfs.go similarity index 99% rename from server/bindata_assetfs.go rename to server/assets/bindata_assetfs.go index 1b83123..d2d0fac 100644 --- a/server/bindata_assetfs.go +++ b/server/assets/bindata_assetfs.go @@ -26,7 +26,7 @@ // static/package.json // DO NOT EDIT! -package server +package assets import ( "github.com/elazarl/go-bindata-assetfs" @@ -147,7 +147,7 @@ func staticCssColorsCss() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/css/colors.css", size: 989, mode: os.FileMode(420), modTime: time.Unix(1490321498, 0)} + info := bindataFileInfo{name: "static/css/colors.css", size: 989, mode: os.FileMode(420), modTime: time.Unix(1490322232, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -227,7 +227,7 @@ func staticCssMainCss() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/css/main.css", size: 3303, mode: os.FileMode(420), modTime: time.Unix(1490321498, 0)} + info := bindataFileInfo{name: "static/css/main.css", size: 3303, mode: os.FileMode(420), modTime: time.Unix(1490322233, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -367,7 +367,7 @@ func staticJsApiJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/js/api.js", size: 2752, mode: os.FileMode(420), modTime: time.Unix(1490321498, 0)} + info := bindataFileInfo{name: "static/js/api.js", size: 2752, mode: os.FileMode(420), modTime: time.Unix(1490322233, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -427,7 +427,7 @@ func staticJsLoaderJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/js/loader.js", size: 1318, mode: os.FileMode(420), modTime: time.Unix(1490321498, 0)} + info := bindataFileInfo{name: "static/js/loader.js", size: 1318, mode: os.FileMode(420), modTime: time.Unix(1490322233, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -447,7 +447,7 @@ func staticJsPkgDetailsJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/js/pkg-details.js", size: 7099, mode: os.FileMode(420), modTime: time.Unix(1490321498, 0)} + info := bindataFileInfo{name: "static/js/pkg-details.js", size: 7099, mode: os.FileMode(420), modTime: time.Unix(1490322233, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -467,7 +467,7 @@ func staticJsPkgListJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/js/pkg-list.js", size: 3650, mode: os.FileMode(420), modTime: time.Unix(1490321498, 0)} + info := bindataFileInfo{name: "static/js/pkg-list.js", size: 3650, mode: os.FileMode(420), modTime: time.Unix(1490322233, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -487,7 +487,7 @@ func staticJsPreferencesJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/js/preferences.js", size: 1010, mode: os.FileMode(420), modTime: time.Unix(1490321498, 0)} + info := bindataFileInfo{name: "static/js/preferences.js", size: 1010, mode: os.FileMode(420), modTime: time.Unix(1490322233, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -507,7 +507,7 @@ func staticJsStateJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/js/state.js", size: 714, mode: os.FileMode(420), modTime: time.Unix(1490321498, 0)} + info := bindataFileInfo{name: "static/js/state.js", size: 714, mode: os.FileMode(420), modTime: time.Unix(1490322233, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -527,7 +527,7 @@ func staticJsTemplateJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/js/template.js", size: 747, mode: os.FileMode(420), modTime: time.Unix(1490321498, 0)} + info := bindataFileInfo{name: "static/js/template.js", size: 747, mode: os.FileMode(420), modTime: time.Unix(1490322233, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -547,7 +547,7 @@ func staticJsToastJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/js/toast.js", size: 480, mode: os.FileMode(420), modTime: time.Unix(1490321498, 0)} + info := bindataFileInfo{name: "static/js/toast.js", size: 480, mode: os.FileMode(420), modTime: time.Unix(1490322233, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/server/server.go b/server/server.go index b34db05..b58823d 100644 --- a/server/server.go +++ b/server/server.go @@ -4,13 +4,14 @@ import ( "net/http" "github.com/KyleBanks/goggles/server/api" + "github.com/KyleBanks/goggles/server/assets" ) // New prepares and returns an HTTP ServeMux bound to the Goggles API and // static assets. func New(p api.Provider) *http.ServeMux { mux := http.NewServeMux() - fs := http.FileServer(assetFS()) + fs := http.FileServer(assets.FS()) mux.Handle("/", http.StripPrefix("/static/", fs)) api.Bind(p, mux)