Skip to content
Permalink
Browse files

use go modules to version tools

  • Loading branch information...
cbrake committed Nov 6, 2018
1 parent 492519c commit 595187d49e15e14cbc60f35e1a8865cfa6c3510c
Showing with 45 additions and 7 deletions.
  1. +32 −7 envsetup.sh
  2. +2 −0 go.mod
  3. +2 −0 go.sum
  4. +9 −0 tools.go
@@ -1,35 +1,60 @@
RECOMMENDED_ELM_VERSION=0.19.0

app_check_elm() {
if ! elm --version >/dev/null 2>&1; then
echo "Please install elm >= 0.19"
echo "https://guide.elm-lang.org/install.html"
return 1
fi

version=$(elm --version)
if [ "$version" != "$RECOMMENDED_ELM_VERSION" ]; then
echo "found elm $version, recommend elm version $RECOMMENDED_ELM_VERSION"
echo "not sure what will happen otherwise"
fi

return 0
}

app_setup() {
go get -u github.com/benbjohnson/genesis/...
go mod download
go install github.com/benbjohnson/genesis/... || return 1
app_check_elm || return 1
return 0
}

app_build_frontend() {
(cd frontend && elm make src/Main.elm --output=public/elm.js) || return 1
(cd frontend && cp index.html public/) || return 1
return 0
}

app_build_assets() {
mkdir -p assets/frontend
genesis -C frontend/public -pkg frontend index.html elm.js >assets/frontend/assets.go
mkdir -p assets/frontend || return 1
genesis -C frontend/public -pkg frontend index.html elm.js >assets/frontend/assets.go || return 1
return 0
}

app_build_dependencies() {
app_build_frontend || return 1
app_build_assets || return 1
return 0
}

app_build() {
app_build_dependencies
app_build_dependencies || return 1
go build -o siot-portal cmd/portal/main.go || return 1
return 0
}

app_deploy() {
app_build_dependencies
gcloud app deploy cmd/portal
app_build_dependencies || return 1
gcloud app deploy cmd/portal || return 1
return 0
}

app_run() {
app_build_dependencies
app_build_dependencies || return 1
go run cmd/portal/main.go || return 1
return 0
}
2 go.mod
@@ -1 +1,3 @@
module github.com/simpleiot/simpleiot

require github.com/benbjohnson/genesis v0.2.1
2 go.sum
@@ -0,0 +1,2 @@
github.com/benbjohnson/genesis v0.2.1 h1:a3Q3egZj+hD+OqIMXCrPP+3DQwFg2W/4WVJMsxT9jvM=
github.com/benbjohnson/genesis v0.2.1/go.mod h1:8ATnWEh6jLjo/pORjjfvkkxauC+XaSIvVfEXMI0Cv9M=
@@ -0,0 +1,9 @@
// +build tools

package simpleiot

import (
// genesis is used to generate static assets
// to embed in binary
_ "github.com/benbjohnson/genesis/cmd/genesis"
)

0 comments on commit 595187d

Please sign in to comment.
You can’t perform that action at this time.