From 80538908a8d70779fbc0b345bb663a29e5cc776c Mon Sep 17 00:00:00 2001 From: Matej Kramny Date: Wed, 22 Feb 2017 03:51:23 -0800 Subject: [PATCH] update contributing.md - fix ./make.sh watch - rename .jade -> .pug --- .gitignore | 3 +- CONTRIBUTING.md | 104 ++++-------------- make.sh | 7 +- public/html/{abstract.jade => abstract.pug} | 0 public/html/{admin.jade => admin.pug} | 0 public/html/auth/{login.jade => login.pug} | 0 public/html/auth/{logout.jade => logout.pug} | 0 public/html/{dashboard.jade => dashboard.pug} | 0 public/html/{index.jade => index.pug} | 3 +- public/html/projects/{add.jade => add.pug} | 0 .../{container.jade => container.pug} | 0 ...eateTaskModal.jade => createTaskModal.pug} | 0 .../{dashboard.jade => dashboard.pug} | 0 public/html/projects/{edit.jade => edit.pug} | 0 .../environment/{add.jade => add.pug} | 0 .../environment/{list.jade => list.pug} | 0 .../projects/inventory/{add.jade => add.pug} | 0 .../inventory/{edit.jade => edit.pug} | 0 .../inventory/{list.jade => list.pug} | 0 .../html/projects/keys/{add.jade => add.pug} | 0 .../projects/keys/{list.jade => list.pug} | 0 .../repositories/{add.jade => add.pug} | 0 .../repositories/{list.jade => list.pug} | 0 .../projects/{schedule.jade => schedule.pug} | 0 .../{taskModal.jade => taskModal.pug} | 0 .../projects/templates/{add.jade => add.pug} | 0 .../templates/{list.jade => list.pug} | 0 .../html/projects/users/{add.jade => add.pug} | 0 .../projects/users/{list.jade => list.pug} | 0 public/html/{tasks.jade => tasks.pug} | 0 public/html/users/{add.jade => add.pug} | 0 public/html/users/{list.jade => list.pug} | 0 public/html/users/{user.jade => user.pug} | 0 33 files changed, 32 insertions(+), 85 deletions(-) rename public/html/{abstract.jade => abstract.pug} (100%) rename public/html/{admin.jade => admin.pug} (100%) rename public/html/auth/{login.jade => login.pug} (100%) rename public/html/auth/{logout.jade => logout.pug} (100%) rename public/html/{dashboard.jade => dashboard.pug} (100%) rename public/html/{index.jade => index.pug} (82%) rename public/html/projects/{add.jade => add.pug} (100%) rename public/html/projects/{container.jade => container.pug} (100%) rename public/html/projects/{createTaskModal.jade => createTaskModal.pug} (100%) rename public/html/projects/{dashboard.jade => dashboard.pug} (100%) rename public/html/projects/{edit.jade => edit.pug} (100%) rename public/html/projects/environment/{add.jade => add.pug} (100%) rename public/html/projects/environment/{list.jade => list.pug} (100%) rename public/html/projects/inventory/{add.jade => add.pug} (100%) rename public/html/projects/inventory/{edit.jade => edit.pug} (100%) rename public/html/projects/inventory/{list.jade => list.pug} (100%) rename public/html/projects/keys/{add.jade => add.pug} (100%) rename public/html/projects/keys/{list.jade => list.pug} (100%) rename public/html/projects/repositories/{add.jade => add.pug} (100%) rename public/html/projects/repositories/{list.jade => list.pug} (100%) rename public/html/projects/{schedule.jade => schedule.pug} (100%) rename public/html/projects/{taskModal.jade => taskModal.pug} (100%) rename public/html/projects/templates/{add.jade => add.pug} (100%) rename public/html/projects/templates/{list.jade => list.pug} (100%) rename public/html/projects/users/{add.jade => add.pug} (100%) rename public/html/projects/users/{list.jade => list.pug} (100%) rename public/html/{tasks.jade => tasks.pug} (100%) rename public/html/users/{add.jade => add.pug} (100%) rename public/html/users/{list.jade => list.pug} (100%) rename public/html/users/{user.jade => user.pug} (100%) diff --git a/.gitignore b/.gitignore index dccdcd20..8c25834b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ build/ public/js/bundle.js public/css/semaphore.css config.json -.DS_Store \ No newline at end of file +.DS_Store +node_modules \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0230d7fd..5d1608b3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,111 +6,55 @@ When creating a pull-request you should: - __gofmt and vet the code:__ Use `gofmt`, `golint`, `govet` and `goimports` to clean up your code. - __Update api documentation:__ If your pull-request adding/modifying an API request, make sure you update the swagger documentation (`api-docs.yml`) +# Installation in a development environment -# Installing dependencies +- [Install Go](https://golang.org/doc/install) +- Install MySQL / MariaDB +- Install node.js -First of all you'll need the Go Language and Node.js installed. If you dont have them installed, you can follow these steps: - -1) Create a directory called 'bin' in home that will receive the lib files from GoLang and Node.js: +1) Set up the gopath ``` -mkdir ~/bin -cd ~/bin -wget https://storage.googleapis.com/golang/go1.7.3.linux-amd64.tar.gz -wget https://nodejs.org/dist/v6.9.1/node-v6.9.1-linux-x64.tar.xz -tar xvf go1.7.3.linux-amd64.tar.gz -tar xvf node-v6.9.1-linux-x64.tar.xz -mv go golang -mv node-v6.9.1-linux-x64 node-js -ln -s ~/bin/golang/bin/go ./go -ln -s ~/bin/golang/bin/godoc ./godoc -ln -s ~/bin/golang/bin/gofmt ./gofmt -ln -s ~/bin/node-js/bin/node ./node -ln -s ~/bin/node-js/bin/npm ./npm +mkdir -p $GOPATH/src/github.com/ansible-semaphore && cd $GOPATH/src/github.com/ansible-semaphore ``` -2) Create project path and clone the repository with --recursive: +2) Clone semaphore (with submodules) ``` -mkdir ~/GoProjects/src/github.com/ansible-semaphore/ -cd ~/GoProjects/src/github.com/ansible-semaphore/ -git clone --recursive git@github.com:ansible-semaphore/semaphore.git +git clone --recursive git@github.com:ansible-semaphore/semaphore.git && cd semaphore ``` -3) Add environment variables to .profile (or .bashrc) need by go and npm (Don't forget to use source on file or reopen the terminal after): +3) Install dev dependencies ``` -PATH=/~/bin:/~/GoProjects/bin:/~/.npm-global/bin:$PATH -GOPATH=~/GoProjects -GOROOT=~/bin/golang -NPM_CONFIG_PREFIX=~/.npm-global -export PATH GOPATH GOROOT NPM_CONFIG_PREFIX -``` - -4) Clone project and Install go dependencies: - -``` -cd ~/GoProjects/src/github.com/ansible-semaphore/ -git clone --recursive https://github.com/ansible-semaphore/semaphore.git -go get github.com/jteeuwen/go-bindata/... -go get github.com/mitchellh/gox -go get github.com/cespare/reflex -go get -u ./... -``` - -5) Install node.js dependencies: - -``` -cd ~/GoProjects/src/github.com/ansible-semaphore/ -npm install -g less pug-cli nodemon +go get ./... github.com/cespare/reflex github.com/jteeuwen/go-bindata/... npm install async +npm install -g nodemon pug-cli less ``` -6) OPTIONAL: Create a MySQL Container to develop (or install and setup One): +4) Set up config, database & run migrations ``` -docker run -d --name semaphore-db -v semaphore-data:/var/lib/mysql -p 3306:3306 -e MYSQL_USER=semaphore -e MYSQL_DATABASE=semaphore -e MYSQL_PASSWORD=semaphore -e MYSQL_ROOT_PASSWORD=semaphore mysql -``` - -7) Download the 2.0.4 version into main directory and run the setup to trigger the db migration: - -``` -wget https://github.com/ansible-semaphore/semaphore/releases/download/v2.0.4/semaphore_linux_amd64 -chmod +x semaphore_linux_amd64 -./semaphore_linux_amd64 -setup -``` - -8) Created a config.json which have the Database information to start the development: - -``` -cd ~/GoProjects/src/github.com/ansible-semaphore/semaphore cat <> config.json { "mysql": { "host": "127.0.0.1:3306", - "user": "semaphore", - "pass": "semaphore", + "user": "root", + "pass": "", "name": "semaphore" }, - "session_db": "127.0.0.1:6379", - "port": ":8010" + "port": ":3000" } EOT + +echo "create database semaphore;" | mysql -uroot -p +go run cli/main.go -config ./config.json -migrate ``` -9) Start the Watch process: +Now it's ready to start.. Run `./make.sh watch` -``` -cd ~/GoProjects/src/github.com/ansible-semaphore/semaphore -./make.sh watch -``` - -10) Point your browser to localhost:8010. Enjoy. - - -# Other Informations - -For more information about GoPaths take a look at ([go wiki](https://github.com/golang/go/wiki/GOPATH), [tutorial](http://www.ryanday.net/2012/10/01/installing-go-and-gopath/), [SO question](https://stackoverflow.com/questions/21001387/how-do-i-set-the-gopath-environment-variable-on-ubuntu-what-file-must-i-edit)). - - -You will need to have a local `config.json` file because it is linked to. It should contain your local configuration. +- Watches js files in `public/js/*` and compiles into a bundle +- Watches css files in `public/css/*` and compiles into css code +- Watches pug files in `public/html/*` and compiles them into html +- Watches go files and recompiles the binary +- Open [localhost:3000](http://localhost:3000) diff --git a/make.sh b/make.sh index fb63f8a5..04267865 100755 --- a/make.sh +++ b/make.sh @@ -49,10 +49,11 @@ if [ "$1" == "watch" ]; then nodemon -w js -i bundle.js -e js bundler.js & nodemon -w css -e less --exec "lessc css/semaphore.less > css/semaphore.css" & - pug -w -P html/*.jade html/*/*.jade html/*/*/*.jade & + pug -w -P html/*.pug html/*/*.pug html/*/*/*.pug & - cd ../ - reflex -r '\.go$' -s -d none -- sh -c 'go run cli/main.go' + cd - + reflex -r '\.go$' -R '^public/vendor/' -R '^node_modules/' -s -d none -- sh -c 'go build -i -o /tmp/semaphore cli/main.go && /tmp/semaphore' + exit 0 fi diff --git a/public/html/abstract.jade b/public/html/abstract.pug similarity index 100% rename from public/html/abstract.jade rename to public/html/abstract.pug diff --git a/public/html/admin.jade b/public/html/admin.pug similarity index 100% rename from public/html/admin.jade rename to public/html/admin.pug diff --git a/public/html/auth/login.jade b/public/html/auth/login.pug similarity index 100% rename from public/html/auth/login.jade rename to public/html/auth/login.pug diff --git a/public/html/auth/logout.jade b/public/html/auth/logout.pug similarity index 100% rename from public/html/auth/logout.jade rename to public/html/auth/logout.pug diff --git a/public/html/dashboard.jade b/public/html/dashboard.pug similarity index 100% rename from public/html/dashboard.jade rename to public/html/dashboard.pug diff --git a/public/html/index.jade b/public/html/index.pug similarity index 82% rename from public/html/index.jade rename to public/html/index.pug index c6811450..2957cd67 100644 --- a/public/html/index.jade +++ b/public/html/index.pug @@ -55,6 +55,7 @@ html(lang="en" ng-app="semaphore") title Ansible-Semaphore on GitHub path(d="M0 0h250v250") path.octo-arm(d="M127.4 110c-14.6-9.2-9.4-19.5-9.4-19.5 3-7 1.5-11 1.5-11-1-6.2 3-2 3-2 4 4.7 2 11 2 11-2.2 10.4 5 14.8 9 16.2" fill="currentColor") - path.octo-body(d="M113.2 114.3s3.6 1.6 4.7.6l15-13.7c3-2.4 6-3 8.2-2.7-8-11.2-14-25 3-41 4.7-4.4 10.6-6.4 16.2-6.4.6-1.6 3.6-7.3 11.8-10.7 0 0 4.5 2.7 6.8 16.5 4.3 2.7 8.3 6 12 9.8 3.3 3.5 6.7 8 8.6 12.3 14 3 16.8 8 16.8 8-3.4 8-9.4 11-11.4 11 0 5.8-2.3 11-7.5 15.5-16.4 16-30 9-40 .2 0 3-1 7-5.2 11l-13.3 11c-1 1 .5 5.3.8 5z" fill="currentColor") + //- https://github.com/pugjs/pug/issues/2741 + //- path.octo-body(d="M113.2 114.3s3.6 1.6 4.7.6l15-13.7c3-2.4 6-3 8.2-2.7-8-11.2-14-25 3-41 4.7-4.4 10.6-6.4 16.2-6.4.6-1.6 3.6-7.3 11.8-10.7 0 0 4.5 2.7 6.8 16.5 4.3 2.7 8.3 6 12 9.8 3.3 3.5 6.7 8 8.6 12.3 14 3 16.8 8 16.8 8-3.4 8-9.4 11-11.4 11 0 5.8-2.3 11-7.5 15.5-16.4 16-30 9-40 .2 0 3-1 7-5.2 11l-13.3 11c-1 1 .5 5.3.8 5z" fill="currentColor") script(src="/public/js/bundle.js") \ No newline at end of file diff --git a/public/html/projects/add.jade b/public/html/projects/add.pug similarity index 100% rename from public/html/projects/add.jade rename to public/html/projects/add.pug diff --git a/public/html/projects/container.jade b/public/html/projects/container.pug similarity index 100% rename from public/html/projects/container.jade rename to public/html/projects/container.pug diff --git a/public/html/projects/createTaskModal.jade b/public/html/projects/createTaskModal.pug similarity index 100% rename from public/html/projects/createTaskModal.jade rename to public/html/projects/createTaskModal.pug diff --git a/public/html/projects/dashboard.jade b/public/html/projects/dashboard.pug similarity index 100% rename from public/html/projects/dashboard.jade rename to public/html/projects/dashboard.pug diff --git a/public/html/projects/edit.jade b/public/html/projects/edit.pug similarity index 100% rename from public/html/projects/edit.jade rename to public/html/projects/edit.pug diff --git a/public/html/projects/environment/add.jade b/public/html/projects/environment/add.pug similarity index 100% rename from public/html/projects/environment/add.jade rename to public/html/projects/environment/add.pug diff --git a/public/html/projects/environment/list.jade b/public/html/projects/environment/list.pug similarity index 100% rename from public/html/projects/environment/list.jade rename to public/html/projects/environment/list.pug diff --git a/public/html/projects/inventory/add.jade b/public/html/projects/inventory/add.pug similarity index 100% rename from public/html/projects/inventory/add.jade rename to public/html/projects/inventory/add.pug diff --git a/public/html/projects/inventory/edit.jade b/public/html/projects/inventory/edit.pug similarity index 100% rename from public/html/projects/inventory/edit.jade rename to public/html/projects/inventory/edit.pug diff --git a/public/html/projects/inventory/list.jade b/public/html/projects/inventory/list.pug similarity index 100% rename from public/html/projects/inventory/list.jade rename to public/html/projects/inventory/list.pug diff --git a/public/html/projects/keys/add.jade b/public/html/projects/keys/add.pug similarity index 100% rename from public/html/projects/keys/add.jade rename to public/html/projects/keys/add.pug diff --git a/public/html/projects/keys/list.jade b/public/html/projects/keys/list.pug similarity index 100% rename from public/html/projects/keys/list.jade rename to public/html/projects/keys/list.pug diff --git a/public/html/projects/repositories/add.jade b/public/html/projects/repositories/add.pug similarity index 100% rename from public/html/projects/repositories/add.jade rename to public/html/projects/repositories/add.pug diff --git a/public/html/projects/repositories/list.jade b/public/html/projects/repositories/list.pug similarity index 100% rename from public/html/projects/repositories/list.jade rename to public/html/projects/repositories/list.pug diff --git a/public/html/projects/schedule.jade b/public/html/projects/schedule.pug similarity index 100% rename from public/html/projects/schedule.jade rename to public/html/projects/schedule.pug diff --git a/public/html/projects/taskModal.jade b/public/html/projects/taskModal.pug similarity index 100% rename from public/html/projects/taskModal.jade rename to public/html/projects/taskModal.pug diff --git a/public/html/projects/templates/add.jade b/public/html/projects/templates/add.pug similarity index 100% rename from public/html/projects/templates/add.jade rename to public/html/projects/templates/add.pug diff --git a/public/html/projects/templates/list.jade b/public/html/projects/templates/list.pug similarity index 100% rename from public/html/projects/templates/list.jade rename to public/html/projects/templates/list.pug diff --git a/public/html/projects/users/add.jade b/public/html/projects/users/add.pug similarity index 100% rename from public/html/projects/users/add.jade rename to public/html/projects/users/add.pug diff --git a/public/html/projects/users/list.jade b/public/html/projects/users/list.pug similarity index 100% rename from public/html/projects/users/list.jade rename to public/html/projects/users/list.pug diff --git a/public/html/tasks.jade b/public/html/tasks.pug similarity index 100% rename from public/html/tasks.jade rename to public/html/tasks.pug diff --git a/public/html/users/add.jade b/public/html/users/add.pug similarity index 100% rename from public/html/users/add.jade rename to public/html/users/add.pug diff --git a/public/html/users/list.jade b/public/html/users/list.pug similarity index 100% rename from public/html/users/list.jade rename to public/html/users/list.pug diff --git a/public/html/users/user.jade b/public/html/users/user.pug similarity index 100% rename from public/html/users/user.jade rename to public/html/users/user.pug