pull/10/head
Hunter Long 2018-06-28 17:01:43 -07:00
parent 473419fefb
commit ca53f6c9cd
8 changed files with 68 additions and 40 deletions

2
.env
View File

@ -2,7 +2,7 @@
## Database Information #
###########################
DB_CONNECTION=postgres
DB_HOST=localhost
DB_HOST=0.0.0.0
DB_PORT=5432
DB_USER=root
DB_PASS=password123

View File

@ -65,9 +65,9 @@ before_script:
- go get github.com/GeertJohan/go.rice
- go get github.com/GeertJohan/go.rice/rice
- go get
- go install
script:
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then /bin/bash -c .travis/compile.sh; fi
- go test -v -covermode=count -coverprofile=coverage.out && $GOPATH/bin/goveralls -coverprofile=coverage.out -service=travis -repotoken $COVERALLS
after_success:

View File

@ -3,28 +3,6 @@
APP="statup"
REPO="hunterlong/statup"
# COMPILE BOOTSTRAP
rm -rf bootstrap
git clone https://github.com/twbs/bootstrap.git
cd bootstrap
npm install
rm -f scss/_variables.scss
cp ../html/scss/_variables.scss scss/_variables.scss
npm run dist
mv dist/css/bootstrap.min.css ../html/css/bootstrap.min.css
cd ../
rm -rf bootstrap
# RENDERING CSS
#gem install sass
sass html/scss/base.scss html/css/base.css
# MIGRATION SQL FILE FOR CURRENT VERSION
printf "UPDATE core SET version='$VERSION';\n" >> sql/upgrade.sql
# COMPILE SRC INTO BIN
rice embed-go
# BUILD STATUP GOLANG BINS
mkdir build
xgo -go 1.10.x --targets=darwin/amd64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./

25
.travis/compile.sh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
# COMPILE BOOTSTRAP
rm -rf bootstrap
git clone https://github.com/twbs/bootstrap.git
cd bootstrap
npm install
rm -f scss/_variables.scss
cp ../html/scss/_variables.scss scss/_variables.scss
npm run dist
mv dist/css/bootstrap.min.css ../html/css/bootstrap.min.css
cd ../
rm -rf bootstrap
# RENDERING CSS
gem install sass
sass html/scss/base.scss html/css/base.css
# MIGRATION SQL FILE FOR CURRENT VERSION
printf "UPDATE core SET version='$VERSION';\n" >> sql/upgrade.sql
# COMPILE SRC INTO BIN
rice embed-go
go install

View File

@ -8,18 +8,17 @@ RUN wget https://github.com/hunterlong/statup/releases/download/$VERSION/statup-
chmod +x statup && \
mv statup /usr/local/bin/statup
#COPY build/statup /usr/local/bin/statup
#RUN chmod +x /usr/local/bin/statup
RUN wget https://assets.statup.io/sass && \
chmod +x sass && \
mv sass /usr/local/bin/sass
ENV IS_DOCKER=true
ENV SASS=/usr/local/bin/sass
ENV CMD_FILE=/usr/bin/cmd
ENV USE_ASSETS=true
RUN printf "#!/usr/bin/env sh\n\$1\n" > $CMD_FILE && \
chmod +x $CMD_FILE
ENV USE_ASSETS=true
WORKDIR /app
VOLUME /app

10
cli.go
View File

@ -17,9 +17,13 @@ func CatchCLI(args []string) {
case "sass":
CompileSASS()
case "export":
var err error
fmt.Printf("Statup v%v Exporting Static 'index.html' page...\n", VERSION)
RenderBoxes()
configs, _ = LoadConfig()
configs, err = LoadConfig()
if err != nil {
logger(3, "config.yml file not found")
}
setupMode = true
mainProcess()
time.Sleep(10 * time.Second)
@ -32,12 +36,10 @@ func CatchCLI(args []string) {
fmt.Println("Sorry updating isn't available yet!")
case "run":
fmt.Println("Running 1 time and saving to database...")
var err error
configs, err = LoadConfig()
if err != nil {
fmt.Println("config.yml file not found")
os.Exit(1)
logger(3, "config.yml file not found")
}
err = DbConnection(configs.Connection)
if err != nil {

27
main.go
View File

@ -16,6 +16,7 @@ import (
plg "plugin"
"strconv"
"strings"
"github.com/fatih/color"
)
var (
@ -94,12 +95,34 @@ func DownloadFile(filepath string, url string) error {
}
func init() {
LoadDotEnvs()
}
func LoadDotEnvs() {
err := godotenv.Load()
if err != nil {
fmt.Println("Error loading .env file")
}
}
func logger(level int, err interface{}) {
switch level {
case 3:
color.Red("ERROR: %v\n", err)
os.Exit(2)
case 2:
color.Yellow("WARNING: %v\n", err)
case 1:
color.Blue("INFO: %v\n", err)
case 0:
color.White("%v\n", err)
}
}
func main() {
if len(os.Args) >= 2 {
CatchCLI(os.Args)
@ -113,7 +136,7 @@ func main() {
configs, err = LoadConfig()
if err != nil {
fmt.Println("config.yml file not found - starting in setup mode")
logger(1, "config.yml file not found - starting in setup mode")
setupMode = true
RunHTTPServer()
}
@ -134,7 +157,7 @@ func mainProcess() {
RunDatabaseUpgrades()
core, err = SelectCore()
if err != nil {
fmt.Println("Core database was not found, Statup is not setup yet.")
logger(1, "Core database was not found, Statup is not setup yet.")
RunHTTPServer()
}

View File

@ -4,13 +4,14 @@ import (
"github.com/stretchr/testify/assert"
"os"
"testing"
"time"
"github.com/rendon/testcli"
)
func TestInit(t *testing.T) {
RenderBoxes()
os.Remove("./statup.db")
Router()
LoadDotEnvs()
}
func TestMySQLMakeConfig(t *testing.T) {
@ -236,9 +237,9 @@ func TestService_LimitedHits(t *testing.T) {
assert.Equal(t, 23, len(hits))
}
func Test(t *testing.T) {
var err error
configs, err = LoadConfig()
assert.Nil(t, err)
time.Sleep(2 * time.Second)
func TestLitecoinWalletsCommand(t *testing.T) {
c := testcli.Command("statup", "version")
c.Run()
t.Log(c.Stdout())
assert.True(t, c.StdoutContains("0 | Address: LS1QwoS72uYBHfCVmyD1oT75BAsh2iCqgP"))
}