This repository has been archived by the owner on Apr 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions-webrh
executable file
·109 lines (98 loc) · 3.74 KB
/
functions-webrh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
############
# WEBRH HELPER FUNCTIONS
# General: repositories must live in the same parent folder
#
# dependencies:
# -- USER variable; from bash_profile
# a string containing the user name
# -- REPOS array; from bash_profile
# an array of valid project repositories
# -- REPO_HOME variable; from bash_profile
# the path where all the repos exist together
# -- Repo shortcut alias'; from functions-dev
# cds to the top of a specific repo
# -- getMaster function required; from bash_profile
# returns repo-specific master branch
# -- sandbox function required; from bash_profile
# returns sandbox path
# -- getRepo function required; from functions-dev
# returns name of current repository
############
test -f functions-dev && . $_
function cprh2drupal {
webrh && echoCmd cp -rfv dist ../webdrupal/html/sites/all/libraries/webrh/dist
}
# Syncs the webrh directory with webdrupal and pushes up to selected sandbox
# to run on a box other than yours, set USER variable equal to the name of that box
function pksync {
repo=$(getRepo)
start=$(pwd)
if [[ $repo == "webrh" || $repo == "webrh-alt" ]]; then
echo "Syncing $repo with $USER" && echoCmd grunt && echoCmd bower link && webdrupal && echoCmd echo "Move to $(pwd)" && bower link webrh && echoCmd grunt build && echoCmd echo "rsync webdrupal to $USER" && echo "$USER" | make rsync2sandbox
# Alternate command for when bower isn't working in webdrupal
#echo "Syncing $repo with $USER" && grunt && webdrupal && grunt build && cprh2drupal && webdrupal && echoCmd echo "Move to $(pwd)" && echoCmd echo "rsync webdrupal to $USER" && echo "$USER" | make rsync2sandbox
else
echo "This command must be run in the webrh directory."
fi
cd $start
}
# Runs an import of patterns
# to run on a box other than yours, set USER variable equal to the name of that box
function pkimport {
start=$(pwd)
all=--all
#[ $# -eq 0 ] && patterns="--all" || patterns="$*"
echo "Importing patterns to $USER" && ssh $(sandbox) "cd ${DRUPAL_LOC} && drush pbi ${*:-$all} && drush cc all"
cd $start
}
# Runs an import of patterns
# to run on a box other than yours, set USER variable equal to the name of that box
function pkchanged {
start=$(pwd)
all=--changed
#[ $# -eq 0 ] && patterns="--all" || patterns="$*"
echo "Importing patterns to $USER" && ssh $(sandbox) "cd ${DRUPAL_LOC} && drush pbi ${*:-$all} && drush cc all"
cd $start
}
# Runs a remove and then an import of patterns
# to run on a box other than yours, set USER variable equal to the name of that box
function pkbuild {
start=$(pwd)
#[ $# -eq 0 ] && patterns="--all" || patterns="$*"
echo "Remove and then import patterns to $USER" && ssh $(sandbox) "cd ${DRUPAL_LOC} && drush pbi-remove ${*:-$all} && drush pbi ${*:-$all} && drush cc all"
cd $start
}
function pkfull {
buildbox ${USER:1} && pksync ${USER:1} && pkimport ${USER:1}
}
function testupdate {
repo=$(getRepo)
pattern_count=$#
fail=0
success=0
if [[ $repo == "webrh" || $repo == "webrh-alt" ]]; then
#if no patterns were provided, throw error
if [ $pattern_count -eq 0 ]; then
echo "No test names were provided to update. Please provide tests names in this format:\n\t$ testupdate promo_band standard_text_band cta"
return;
fi
# iterate over list of patterns to update tests for
for pattern in $@; do
grunt test:$pattern:update
# if the update fails, run it one more time
if [ $? -ne 0 ]; then
let "fail++"
grunt test:$pattern:update
if [ $? -ne 0 ]; then
let "success++"
fi
else
let "success++"
fi
done
echoCmd echo "${success} successful update(s) | ${fail} failed update(s)"
else
echo "This command must be run in the webrh directory."
fi
}