Skip to content

Commit

Permalink
Use npm instead of submodule. Split public to web/public & web/resources
Browse files Browse the repository at this point in the history
Fix build under Windows

Remove htmls from pug directory

Move package.json to web directory

Remove OS type checking from test

Fix builder.js codestyle

Remove Taskfile_windows.yml
  • Loading branch information
fiftin committed Mar 13, 2018
1 parent 3a6173f commit 7263101
Show file tree
Hide file tree
Showing 91 changed files with 234 additions and 111 deletions.
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
gin-bin
build/
public/js/bundle.js
public/css/semaphore.css
web/public/js/bundle.js
web/public/css/*.*
web/public/html/**/*.*
web/public/fonts/*.*
config.json
.DS_Store
node_modules
node_modules/

.idea/
caddyfile
Expand All @@ -14,3 +16,4 @@ bin/
util/version.go
/vendor/
/coverage.out
!.gitkeep
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

49 changes: 24 additions & 25 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ tasks:
all:
desc: Install, Compile, Test and Build Semaphore for local architecture
cmds:
- deps
- compile
- test
- build:local
- task: deps
- task: compile
- task: test
- task: build:local

deps:
desc: Install all dependencies
Expand All @@ -28,24 +28,22 @@ tasks:

deps:fe:
desc: Installs npm requirements for front end from package.json
dir: public
dir: web
cmds:
- git submodule update --init --recursive
- npm i -g less pug-cli
- npm i async
- npm install

deps:tools:
desc: Installs tools needed
dir: public
dir: web
cmds:
- npm install -g nodemon
- go get -u github.com/golang/dep/cmd/dep
- go get github.com/cespare/reflex
- go get github.com/cespare/reflex || true
- go get -u github.com/gobuffalo/packr/...
- go get github.com/mitchellh/gox
- go get -u github.com/haya14busa/goverage


compile:
desc: Generates compiled frontend and backend resources (must be in this order)
cmds:
Expand All @@ -54,25 +52,26 @@ tasks:

compile:fe:
desc: Runs less, pug and node
dir: public
dir: web
sources:
- css/semaphore.less
- html/*.pug
- html/**/*.pug
- resources/css/semaphore.less
- resources/html/*.pug
- resources/html/**/*.pug
generates:
- css/semaphore.css
- html/*.html
- html/**/*.html
- js/bundle.json
- public/css/semaphore.css
- public/html/*.html
- public/html/**/*.html
- bundle.json
cmds:
- lessc css/semaphore.less > css/semaphore.css
- pug $(find ./html/ -name "*.pug")
- node ./bundler.js
- lessc resources/less/semaphore.less > public/css/semaphore.css
- pug resources/pug --out public/html
- cp node_modules/font-awesome/fonts/* public/fonts
- node bundler.js

compile:be:
desc: Runs Packr for static assets
sources:
- public/*
- web/public/*
- db/migrations/*
generates:
- db/db-packr.go
Expand All @@ -94,17 +93,17 @@ tasks:

watch:
desc: Watch fe and be file changes and rebuild
dir: public
dir: web/resources
cmds:
- task: watch:fe
- task: watch:be

watch:be:
cmds:
- reflex -r '\.go$' -R '^public/vendor/' -R '^node_modules/' -s -d none -- sh -c 'go build -i -o /tmp/semaphore_bin cli/main.go && /tmp/semaphore_bin -config $(pwd)/config.json'
- reflex -r '\.go$' -R '^node_modules/' -s -d none -- sh -c 'go build -i -o /tmp/semaphore_bin cli/main.go && /tmp/semaphore_bin -config $(pwd)/config.json'

watch:fe:
dir: public
dir: web/resources
cmds:
- nodemon -w js -i bundle.js -e js bundler.js &
- nodemon -w css -e less --exec "lessc css/semaphore.less > css/semaphore.css" &
Expand Down
2 changes: 1 addition & 1 deletion api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/russross/blackfriday"
)

var publicAssets = packr.NewBox("../public")
var publicAssets = packr.NewBox("../web/public")

// Declare all routes
func Route() mulekick.Router {
Expand Down
10 changes: 8 additions & 2 deletions api/tasks/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (


func TestCheckTmpDir(t *testing.T) {

//It should be able to create a random dir in /tmp
dirName := os.TempDir()+ "/" + randString(rand.Intn(10 - 4) + 4)
err := checkTmpDir(dirName)
Expand All @@ -27,6 +26,14 @@ func TestCheckTmpDir(t *testing.T) {
if err != nil {
t.Fatal(err)
}

if stat, err:= os.Stat(dirName); err != nil {
t.Fatal(err)
} else if stat.Mode() != os.FileMode(int(0550)) {
// File System is not support 0550 mode, skip this test
return
}

err = checkTmpDir(dirName+"/noway")
if err == nil {
t.Fatal("You should not be able to write in this folder, causing an error")
Expand All @@ -35,7 +42,6 @@ func TestCheckTmpDir(t *testing.T) {
if err != nil {
t.Log(err)
}

}


Expand Down
25 changes: 0 additions & 25 deletions public/bundle.json

This file was deleted.

35 changes: 0 additions & 35 deletions public/bundler.js

This file was deleted.

1 change: 0 additions & 1 deletion public/css/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion public/html/.gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions public/require_config.js

This file was deleted.

1 change: 0 additions & 1 deletion public/vendor
Submodule vendor deleted from 31cbac
24 changes: 24 additions & 0 deletions web/bundle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[
"node_modules/angular/angular.min",
"node_modules/angular-couch-potato/dist/angular-couch-potato",
"node_modules/@uirouter/angularjs/release/angular-ui-router",
"node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls",
"node_modules/angular-loading-bar/build/loading-bar",
"node_modules/moment/min/moment.min",
"node_modules/sweetalert/dist/sweetalert.min",
"node_modules/angular-ui-ace/src/ui-ace",
"node_modules/ace-builds/src-min-noconflict/ace",
"node_modules/ace-builds/src-min-noconflict/mode-json",
"node_modules/ace-builds/src-min-noconflict/mode-yaml",
"node_modules/ace-builds/src-min-noconflict/mode-ini",
"node_modules/angularjs-scroll-glue/src/scrollglue",
"public/js/app",
"public/js/routes/router",
"public/js/routes/auth",
"public/js/routes/project",

"public/js/factories/project",

"node_modules/requirejs/require",
"require_config"
]
27 changes: 27 additions & 0 deletions web/bundler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var fs = require('fs'),
bundle = require('./bundle.json'),
out = fs.createWriteStream('./public/js/bundle.js');

bundle.forEach(function(file) {
var o = {};
if (typeof file === 'object') {
o = file;
file = o.src;
}

file = file + '.js';

var contents = fs.readFileSync(file);

out.write('\n/* BUNDLED FILE: ' + file + ' */\n');

if (o.pre) {
out.write(o.pre + '\n');
}

out.write(contents + '\n');

if (o.post) {
out.write(o.post + '\n');
}
});
Loading

0 comments on commit 7263101

Please sign in to comment.