Skip to content
Permalink
Browse files
Initial commit
  • Loading branch information
dasilv32 committed Apr 22, 2020
0 parents commit ffc50c62483fd0c6d0f53655f711e67182d40576
Show file tree
Hide file tree
Showing 38 changed files with 1,693 additions and 0 deletions.
@@ -0,0 +1,4 @@

docs/**
node_modules/**
coverage/**
@@ -0,0 +1,77 @@

{
"env": {
"es6": true,
"jasmine": true,
"node": true,
"browser": true,
"jest": true
},
"parserOptions": {
"ecmaVersion": 2018,
"noInlineConfig": true,
"reportUnusedDisableDirectives": true,
"sourceType": "module"
},
"rules": {
"arrow-body-style": "error",
"arrow-spacing": ["warn", {"before": true, "after": true}],
"brace-style": "error",
"camelcase": ["error", {"properties": "never"}],
"complexity": ["error", 5],
"eol-last": "warn",
"eqeqeq": "error",
"func-call-spacing": ["error", "never"],
"global-require": "error",
"handle-callback-err": "warn",
"indent": ["warn", "tab", {"SwitchCase": 1}],
"key-spacing": ["error", {"beforeColon": false, "afterColon": true}],
"linebreak-style": ["warn", "unix"],
"max-depth": ["error", 3],
"max-len": ["warn", { "code": 120, "tabWidth": 4 }],
"max-lines": ["warn", {"max": 150, "skipBlankLines": true, "skipComments": true}],
"max-lines-per-function": ["warn", {"max": 20, "skipBlankLines": true, "skipComments": true}],
"max-nested-callbacks": ["error", 4],
"max-params": ["error", 5],
"max-statements": ["error", 20],
"no-cond-assign": "error",
"no-dupe-args": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-empty": "warn",
"no-empty-function": "error",
"no-multiple-empty-lines": "warn",
"no-extra-parens": "error",
"no-func-assign": "error",
"no-irregular-whitespace": "error",
"no-magic-numbers": ["warn", {"ignore": [-1, 0, 1]}],
"no-multi-spaces": "warn",
"no-multi-str": "off",
"no-unexpected-multiline": "error",
"no-unreachable": "error",
"no-self-assign": "error",
"no-trailing-spaces": "warn",
"no-undef": "error",
"no-unused-vars": "warn",
"no-var": 2,
"prefer-arrow-callback": "warn",
"prefer-const": "error",
"prefer-template": "error",
"quotes": ["warn", "single"],
"semi": ["warn", "never"],
"space-before-blocks": ["error", { "functions": "always", "keywords": "always", "classes": "always" }],
"space-before-function-paren": ["error", "never"],
"strict": ["error", "global"],
"yoda": "error"
},
"overrides": [{
"files": [ "*.test.js", "*.spec.js", "*.steps.js" ],
"rules": {
"global-require": "off",
"max-lines-per-function": "off",
"max-lines": "off",
"max-statements": "off",
"no-magic-numbers": "off"
}
}]
}
@@ -0,0 +1,28 @@
#!/bin/bash

set -e

echo "POST-CHECKOUT"

prevHEAD=$1
newHEAD=$2
checkoutType=$3

[[ $checkoutType == 1 ]] && checkoutType='branch' || checkoutType='file' ;

echo " Checkout type: $checkoutType"
echo " prev HEAD: "`git name-rev --name-only $prevHEAD`
echo " new HEAD: "`git name-rev --name-only $newHEAD`

# this is a file checkout – do nothing
if [ "$3" == "0" ]; then exit; fi

BRANCH_NAME=$(git symbolic-ref --short -q HEAD)
NUM_CHECKOUTS=`git reflog --date=local | grep -o ${BRANCH_NAME} | wc -l`

#if the refs of the previous and new heads are the same
#AND the number of checkouts equals one, a new branch has been created
if [ "$1" == "$2" ] && [ ${NUM_CHECKOUTS} -eq 1 ]; then
echo " new branch '$BRANCH_NAME' created"
fi
echo
@@ -0,0 +1,7 @@
#!/bin/sh

set -e # using the options command to abort script at first error
echo
echo "POST-COMMIT"
# ./node_modules/.bin/markdownlint --ignore node_modules .
echo
@@ -0,0 +1,76 @@
#!/bin/sh

set -e # using the options command to abort script at first error
echo
echo "PRE-COMMIT"

EMAIL=$(git config user.email)

# make sure the user has registered a valid university email address
if [[ $EMAIL != *"@coventry.ac.uk" ]]; then
echo " invalid config settings"
echo " Your registered email is currently '$EMAIL'"
echo " please run the following git commands:"
echo " $ git config user.email xxx@coventry.ac.uk"
echo " $ git config user.name 'zzz'"
echo " where 'xxx' is your university username"
echo " and 'zzz' is your name as it appears on your university ID badge"
echo
exit 1
fi

# see if the user is trying to merge a branch into master
branch="$(git rev-parse --abbrev-ref HEAD)"
if [[ $2 == 'merge' ]]; then
echo "merging branch"
if [[ "$branch" == "master" ]]; then
echo " trying to merge into the 'master' branch"
echo " you should push the local branch to GitHub"
echo " and merge to master using a pull request"
echo
exit 1
fi
fi

# see if the user is trying to commit to the master branch
if [ "$branch" = "master" ]; then
read -p " You are about to commit to the master branch, are you sure? [y|n] " -n 1 -r < /dev/tty
echo
if echo $REPLY | grep -E '^[Yy]$' > /dev/null
then
exit 0 # commit will execute
fi
exit 1 # commit will not execute
fi

# is the current branch a direct child of the master branch?
# echo "checking parent branch"
# PARENT=$(git show-branch -a | grep -v `git rev-parse --abbrev-ref HEAD` | grep -v origin | sed 's/.*\[\(.*\)\].*/\1/' | grep -v -e '^$' | grep -v "^----$"
# echo "parent branch is $PARENT")

# see if the user is trying to commit to the master branch
# echo " you are trying to commit to the '$branch' branch"
# if [ "$branch" = "master" ]; then
# echo " you can't commit directly to the master branch"
# echo " create a local feature branch first"
# echo
# exit 1
# fi

# check for valid branch name:

# valid_branch_regex="^iss\d{3}\/[a-z\-]+$"

# if [[ ! $local_branch =~ $valid_branch_regex ]]
# then
# echo "invalid branch name"
# echo " format is: 'iss000/issue-name'"
# echo " replacing '000' with the issue number and 'issue-name' with the issue name"
# echo " only lower-case letters and replace spaces in the issue name with dashes"
# echo " rename your branch and try again"
# exit 1
# fi

./node_modules/.bin/eslint .

echo " commit successful..."
@@ -0,0 +1,4 @@
#!/bin/sh

set -e # using the options command to abort script at first error
echo "running the 'pre-merge-commit' script"
@@ -0,0 +1,18 @@
#!/bin/sh

echo
echo "PRE-PUSH"

protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')

if [ $protected_branch = $current_branch ]
then
read -p " You're about to push master, is that what you intended? [y|n] " -n 1 -r < /dev/tty
echo
if echo $REPLY | grep -E '^[Yy]$' > /dev/null
then
exit 0 # push will execute
fi
exit 1 # push will not execute
fi
@@ -0,0 +1,37 @@
#!/bin/sh

# With thanks to Sergio Vaccaro <sergio.vaccaro@istat.it>

set -e # using the options command to abort script at first error
echo
echo "PREPARE-COMMIT-MSG"

# Branch to protect
PROTECTED_BRANCH="master"

# Remote
REMOTE=""

# Check for merges
if [[ $2 != 'merge' ]]; then
# Not a merge
ECHO " not a merge"
exit 0
fi

# Current branch
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

# Check if in PROTECTED_BRANCH
#if [[ "$CURRENT_BRANCH" != "$PROTECTED_BRANCH" ]]; then
# # Not in PROTECTED_BRANCH: can proceed
# ECHO " not in the ${PROTECTED_BRANCH} branch"
# exit 0
#fi

echo " you are trying to merge into the ${PROTECTED_BRANCH} branch"
echo " merging branches to master must be done by creating a pull request"
echo " this merge has been cancelled however you will need to"
echo " reset the operation before continuing by running git reset --merge"
echo
exit 1
@@ -0,0 +1,31 @@

.DS_Store
node_modules/
coverage/
screenshots/*
docs/

data/
coverage/
sessions/
screenshots/
__image_snapshots_/
__diff_output__/
trace/
.node-persist/

*.db
*snap.png
*diff.png
*trace.json
*.0x

config.json
#Should probably be re-added
#Or at least provide documentation on how to populate

*.pptx
*.mp4

*.codio
*.c9
@@ -0,0 +1,42 @@
image: node:latest

stages:
- code-testing
- staging-server
- acceptance-testing

linting:
stage: code-testing
script:
- npm install
- npm run linter

dependency-checks:
stage: code-testing
script:
- npm install
- npm run dependency

unit-testing:
stage: code-testing
script:
- npm install
- npm test

code-coverage:
stage: code-testing
script:
- npm install
- npm run coverage

coverage-report:
stage: staging-server
script:
- npm install
- npm run coverage
artifacts:
paths:
- docs
expire_in: 30 days
only:
- master
@@ -0,0 +1,33 @@

{
"line-length": false,
"no-inline-html": {
"allowed_elements": [
"a", "br"
]
},
"header-increment": true,
"ul-style": {
"style": "dash"
},
"ul-start-left": true,
"no-trailing-spaces": {
"br_spaces": 0
},
"no-hard-tabs": true,
"no-reversed-links": true,
"no-multiple-blanks": true,
"no-missing-space-atx": true,
"no-multiple-space-atx": true,
"blanks-around-headers": true,
"header-start-left": true,
"no-duplicate-header": true,
"single-h1": true,
"blanks-around-fences": true,
"blanks-around-lists": true,
"no-bare-urls": true,
"no-space-in-emphasis": true,
"no-space-in-code": true,
"no-space-in-links": true,
"fenced-code-language": true
}
@@ -0,0 +1,27 @@

{
"version": "0.2.0",
"configurations": [

{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId": "${command:PickProcess}"
},
{
"type": "node",
"request": "launch",
"name": "Jest",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["--runInBand"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"protocol": "inspector",
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
}
}
]
}

0 comments on commit ffc50c6

Please sign in to comment.