Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

Commit 99c578c

Browse files
committed
Merge branch 'master' of https://github.com/wplib/box-scripts
2 parents cf55b30 + 0ee61d7 commit 99c578c

23 files changed

+797
-140
lines changed

guest/cli/box

Lines changed: 59 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,70 @@
66
source /vagrant/scripts/guest/cli/includes/functions
77
source /vagrant/scripts/guest/cli/includes/constants
88

9-
if [ "$1" == "" ]; then
10-
export WPLIB_BOX_COMMAND="help"
11-
else
12-
export WPLIB_BOX_COMMAND="$1"
13-
fi
14-
15-
command_file="${WPLIB_BOX_COMMANDS_DIR}/${WPLIB_BOX_COMMAND}"
9+
#
10+
#
11+
#if [[ "$1" != "set-user-name" && "$1" != "set-user-email" ]];then
12+
#
13+
# verify_user_config || error=1
14+
#
15+
#fi
1616

17-
if [ "${WPLIB_BOX_COMMAND}" == "help" ]; then
18-
source "${command_file}"
19-
echo
20-
exit
21-
fi
17+
if [ "" == "${error}" ];then
2218

23-
if [ -f "${command_file}" ]; then
24-
command_type="bash"
25-
else
26-
if [ -f "${command_file}.php" ]; then
27-
command_type="php"
19+
if [ "$1" == "" ]; then
20+
export WPLIB_BOX_COMMAND="help"
2821
else
29-
echo
30-
echo -e "\tCommand not found: $1"
22+
export WPLIB_BOX_COMMAND="$1"
23+
fi
24+
25+
command_file="${WPLIB_BOX_COMMANDS_DIR}/${WPLIB_BOX_COMMAND}"
26+
27+
if [ "${WPLIB_BOX_COMMAND}" == "help" ]; then
28+
source "${command_file}"
29+
check_updates_available "$*"
3130
echo
3231
exit
3332
fi
33+
34+
if [ -f "${command_file}" ]; then
35+
command_type="bash"
36+
else
37+
if [ -f "${command_file}.php" ]; then
38+
command_type="php"
39+
else
40+
echo
41+
echo -e "\tCommand not found: $1"
42+
echo
43+
exit
44+
fi
45+
fi
46+
47+
echo_if_not_quiet "$*" "*Running $1..."
48+
initial_dir=$(pwd)
49+
error=0
50+
case "${command_type}" in
51+
"bash")
52+
source "${command_file}" "$2" "$3" "$4" "$5"
53+
error=$?
54+
;;
55+
"php")
56+
57+
/usr/bin/php7.0 "${WPLIB_BOX_INCLUDES_DIR}/run-command.php" --args "${WPLIB_BOX_COMMAND}" "$2" "$3" "$4" "$5"
58+
error=$?
59+
;;
60+
esac
61+
cd "${initial_dir}"
62+
63+
fi
64+
65+
if [[ $error -eq 0 ]]; then
66+
echo_if_not_quiet "$*" "*The '$1' command completed without error."
67+
exit 0
68+
else
69+
echo -e "\t"
70+
echo "The '$1' command terminated WITH ERRORS."
71+
echo -e "\t"
72+
exit 1
3473
fi
3574

36-
echo_if_not_quiet "$*" "*Running $1..."
37-
initial_dir=$(pwd)
38-
case "${command_type}" in
39-
"bash")
40-
source "${command_file}" "$2" "$3" "$4" "$5"
41-
;;
42-
"php")
43-
44-
/usr/bin/php7.0 "${WPLIB_BOX_INCLUDES_DIR}/run-command.php" --args "${WPLIB_BOX_COMMAND}" "$2" "$3" "$4" "$5"
45-
;;
46-
esac
47-
cd "${initial_dir}"
48-
echo_if_not_quiet "$*" "*Done."
75+
#check_updates_available "$*"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Installs node and bower dependencies and compiles assets.
4+
#
5+
# Usage: box build-dependencies
6+
#
7+
8+
echo "Not yet implemented"
9+
exit
10+
11+
echo "Installing and updating dependencies..."
12+
cd WPLIB_BOX_DIR
13+
sudo npm install && bower install
14+
15+
echo "Compiling dependencies..."
16+
grunt build
17+
18+

guest/cli/commands/help

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ for file in $WPLIB_BOX_COMMANDS_DIR/*; do
1515
done
1616
echo
1717
echo IMPORTANT! These commands WILL BE CHANGING in a future release of WPLib Box. Be warned!
18-
echo
18+

guest/cli/commands/pantheon-clone

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Usage
4+
#
5+
# $1 String ID for host to deploy to as definded in /vagrant/wplib.box.json.
6+
# $2 Optional String Directory to clone into. Default is "pantheon"
7+
#
8+
#
9+
10+
verify_user_config || error=1
11+
12+
deploy_host="$1"
13+
14+
clone_dir=$(default "$2" "pantheon")
15+
16+
project_name=$(read_config "project.name" "require")
17+
if [ "" == "${project_name}" ]; then
18+
echo -e "\tERROR: The config file wplib.box.json does not have a .project.name or is not a valid JSON file."
19+
echo -e "\t"
20+
return 1
21+
fi
22+
23+
if [ "" == "${deploy_host}" ]; then
24+
echo -e "\tERROR: You must specify a target host to deploy TO:"
25+
echo -e "\t"
26+
echo -e "\t\tbox deploy {host}"
27+
echo -e "\t"
28+
echo -e "\tWhere {host} is one of:"
29+
echo -e "\t"
30+
index=0
31+
while :; do
32+
host=$(read_config "hosts | keys[$index]" )
33+
if [ "" == "${host}" ]; then
34+
break
35+
fi
36+
echo -e "\t\t- ${host}"
37+
index=$(( $index+1 ))
38+
done
39+
echo -e "\t"
40+
return 2
41+
fi
42+
43+
git_url=$(read_config "deployment.git_url" "require")
44+
if [ "" == "${git_url}" ]; then
45+
echo -e "\tERROR: The config file wplib.box.json does not have a ${selector}."
46+
echo -e "\t"
47+
return 3
48+
fi
49+
50+
if [[ -d "${clone_dir}" || -d "$(pwd)/${clone_dir}" ]]; then
51+
echo -e "\tERROR: The directory to clone into already exists: ${clone_dir}."
52+
echo -e "\t"
53+
return 4
54+
fi
55+
56+
57+
#
58+
# Clone the site from our repo on Pantheon
59+
#
60+
echo_if_not_quiet "$*" "=Cloning ${project_name} from Pantheon ${deploy_host} to directory ${clone_dir}..."
61+
62+
git clone "${git_url}" "${clone_dir}" || return $?
63+
64+
cd "${clone_dir}"

0 commit comments

Comments
 (0)