Commit e4501fd9 authored by Moises Sacal's avatar Moises Sacal
Browse files

Merge branch 'development_process_improvements' into 'master'

Development process improvements

See merge request !1
parents cfa9f075 3ef3fa91
......@@ -44,3 +44,4 @@ e2e/*.map
Thumbs.db
test/angular
sailsWorkingDir
......@@ -76,56 +76,15 @@ For more information on testing your hook go to : https://sailsjs.com/documentat
## Development in redbox-portal
There are several ways to code against the redbox-portal. One of it is to link the code via `npm link`
A docker-compose.yml file is present in support/development and is setup to run the full ReDBox stack and install the hook. To run the stack there is a ReDBox Sails Hook Run Utility in the root of the project
*npm link this hook*
```bash
cd /into/where/hook/is/
npm link
```
npm link into redbox-portal
```bash
cd /into/redbox-portal/
npm link sails-hook-redbox-gitlab
```
## Vagrant/Docker
Using docker while running redbox-portal is a posibility
In the `docker-compose.yml` file in redbox-portal verify that the service has the volume.
```yml
- "/opt/hooks:/opt/hooks"
```
For Vagrant to place the code inside of the same machine/docker. You can share it via the VagrantFile using sync_folder
```yml
config.vm.synced_folder "/Users/moises/source/qcif/sails-hook-redbox-template", "/opt/hooks/sails-hook-redbox-template", id: "template"
```
Now inside the docker instance of redbox-portal link the hook and your redbox-portal
```bash
docker exec -it redbox-portal_redboxportal_1 /bin/bash
Usage
```
run npm link in the hook folder
```bash
cd /opt/hooks/sails-hook-redbox-template
npm link
ReDBox Sails Hook Run Utility
Usage: ./runForDev.sh [-a|--(no-)angular] [-h|--help]
-a,--angular,--no-angular: Angular mode. Will ensure permissions are set correctly on the Sails working directory so that changes can be applied (off by default)
-h,--help: Prints help
```
now link this alias in your redbox-portal
```bash
cd /opt/redbox-portal
npm link sails-hook-redbox-template
```
Note: The first time the stack runs it may take some time as yarn initialises the hook within ReDBox Portal. All subsequent runs should be faster
......@@ -21,10 +21,11 @@ module.exports = function (sails) {
}
},
configure: function () {
sails.services['TemplateService'] = TemplateService;
sails.config = _.merge(sails.config, recordTypeConfig);
sails.config = _.merge(sails.config, workflowConfig);
sails.config['form']['forms'] = _.merge(sails.config['form']['forms'], {'template-1.0-draft': recordFormConfig});
//TODO: Temporarily commenting this out as it's not initialising correctly
// sails.services['TemplateService'] = TemplateService;
// sails.config = _.merge(sails.config, recordTypeConfig);
// sails.config = _.merge(sails.config, workflowConfig);
// sails.config['form']['forms'] = _.merge(sails.config['form']['forms'], {'template-1.0-draft': recordFormConfig});
}
}
};
{
"name": "@uts-ersearch/sails-hook-redbox-template",
"name": "@uts-eresearch/sails-hook-redbox-template",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
......
......@@ -8,7 +8,8 @@
"hookName": "template"
},
"scripts": {
"test": "NODE_ENV=test node_modules/.bin/mocha"
"test": "NODE_ENV=test node_modules/.bin/mocha",
"runDev": "docker-compose -f support/development/docker-compose.yml up"
},
"repository": {
"type": "git",
......
#!/bin/bash
# version="0.1"
#
# This is an optional arguments-only example of Argbash potential
#
# ARG_OPTIONAL_BOOLEAN([angular],[a],[Angular mode. Will ensure permissions are set correctly on the Sails working directory so that changes can be applied],[])
# ARG_HELP([ReDBox Sails Hook Run Utility])
# ARGBASH_GO()
# needed because of Argbash --> m4_ignore([
### START OF CODE GENERATED BY Argbash v2.6.1 one line above ###
# Argbash is a bash code generator used to get arguments parsing right.
# Argbash is FREE SOFTWARE, see https://argbash.io for more info
# Generated online by https://argbash.io/generate
die()
{
local _ret=$2
test -n "$_ret" || _ret=1
test "$_PRINT_HELP" = yes && print_help >&2
echo "$1" >&2
exit ${_ret}
}
begins_with_short_option()
{
local first_option all_short_options
all_short_options='ah'
first_option="${1:0:1}"
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
}
# THE DEFAULTS INITIALIZATION - OPTIONALS
_arg_angular="off"
print_help ()
{
printf '%s\n' "ReDBox Sails Hook Run Utility"
printf 'Usage: %s [-a|--(no-)angular] [-h|--help]\n' "$0"
printf '\t%s\n' "-a,--angular,--no-angular: Angular mode. Will ensure permissions are set correctly on the Sails working directory so that changes can be applied (off by default)"
printf '\t%s\n' "-h,--help: Prints help"
}
parse_commandline ()
{
while test $# -gt 0
do
_key="$1"
case "$_key" in
-a|--no-angular|--angular)
_arg_angular="on"
test "${1:0:5}" = "--no-" && _arg_angular="off"
;;
-a*)
_arg_angular="on"
_next="${_key##-a}"
if test -n "$_next" -a "$_next" != "$_key"
then
begins_with_short_option "$_next" && shift && set -- "-a" "-${_next}" "$@" || die "The short option '$_key' can't be decomposed to ${_key:0:2} and -${_key:2}, because ${_key:0:2} doesn't accept value and '-${_key:2:1}' doesn't correspond to a short option."
fi
;;
-h|--help)
print_help
exit 0
;;
-h*)
print_help
exit 0
;;
*)
_PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1
;;
esac
shift
done
}
parse_commandline "$@"
# OTHER STUFF GENERATED BY Argbash
### END OF CODE GENERATED BY Argbash (sortof) ### ])
# [ <-- needed because of Argbash
echo "Value of --angular: $_arg_angular"
if [ $_arg_angular == "on" ]; then
if [ ! -d "sailsWorkingDir" ]; then
mkdir sailsWorkingDir;
fi
# Starts the docker-container with a watcher to ensure the files are editable for the vagrant user
docker-compose -f support/development/docker-compose.yml up | source support/development/monitorSailsWorkingDir.sh sailsWorkingDir
else
docker-compose -f support/development/docker-compose.yml up;
fi
# ] <-- needed because of Argbash
\ No newline at end of file
version: '3.1'
networks:
main:
services:
redboxportal:
image: qcifengineering/redbox-portal:latest
ports:
- "1500:1500"
volumes:
- "../../:/opt/sailshook"
- "../../sailsWorkingDir/tmp:/opt/redbox-portal/.tmp"
expose:
- "1500"
environment:
- NODE_ENV=docker
- PORT=1500
- sails_record__baseUrl_redbox=http://redbox:9000/redbox
- sails_record__baseUrl_mint=http://203.101.226.160/mint
networks:
main:
aliases:
- rbportal
entrypoint: /bin/bash -c "source /opt/sailshook/support/development/linkHook.sh"
mongodb:
image: mvertes/alpine-mongo:latest
networks:
main:
aliases:
- mongodb
ports:
- "27017:27017"
redbox:
image: qcifengineering/redbox:2.x
expose:
- "9000"
environment:
- RB_API_KEY=c8e844fc-8550-497f-b970-7900ec8741ca
networks:
main:
aliases:
- redbox
ports:
- "9000:9000"
#! /bin/bash
cd /opt/sailshook;
yarn link;
cd /opt/redbox-portal;
if [ ! -d "node_modules/@uts-eresearch/sails-hook-redbox-template" ]; then
yarn add "file:/opt/sailshook";
fi
yarn link "@uts-eresearch/sails-hook-redbox-template";
node app.js
\ No newline at end of file
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
# events happen, the script waits one second after the change - if
# more changes happen, the timeout is extended by a second again.
#
# Installation:
# chmod a+rx onchange.sh
# sudo cp onchange.sh /usr/local/bin
#
# Example use - rsync local changes to the remote server:
#
# onchange.sh rsync -avt . host:/remote/dir
#
# Released to Public Domain. Use it as you like.
#
EVENTS="CREATE,CLOSE_WRITE,DELETE,MODIFY,MOVED_FROM,MOVED_TO"
inotifywait -e "$EVENTS" -m -r --format '%:e %f' $1 | (
WAITING="";
while true; do
LINE="";
read -t 1 LINE;
if test -z "$LINE"; then
if test ! -z "$WAITING"; then
echo "CHANGE";
WAITING="";
fi;
else
WAITING=1;
fi;
done) | (
while true; do
read TMP;
sudo chown -R vagrant:vagrant $1
done
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment