Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 34 additions & 25 deletions add-cakephp-version
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ usage ()
{
cat <<EOT

${0##*/}
This script will download and create a CakePHP "core" folder for
the version number specified as the command line argument in
whatever folder it lives in. You must relocate this script to its
own directory where it can spawn new folders for each Cake version
without interfering with a git repo. This should be somewhere
central on your system where all Cake projects can symlink to the
${0##*/}
This script will download and create a CakePHP "core" folder for
the version number specified as the command line argument in
whatever folder it lives in. You must relocate this script to its
own directory where it can spawn new folders for each Cake version
without interfering with a git repo. This should be somewhere
central on your system where all Cake projects can symlink to the
individual Cake version required.

Usage:
bin/${0##*/} x.y.z [-f]

Pass a CakePHP release number as the first argument.

Specify '-f' as the second argument to forcibly replace the
cakes/${0##*/} x.y[.z] [-f]

Pass a CakePHP release number (or major.minor for latest) as
the first argument.

Specify '-f' as the second argument to forcibly replace the
cakephp repo.


Expand All @@ -31,7 +32,6 @@ if [ "$1" = '-h' ]; then
usage
fi


umask a+rw

DIR="$( cd -P "$( dirname "$0" )" >/dev/null 2>&1 && pwd )";
Expand All @@ -45,7 +45,7 @@ if [ "$2" = '-f' ]; then
fi


# Just a little precaution since this script comes bundled in the
# Just a little precaution since this script comes bundled in the
# CakePHP-Skeleton's bin/ folder, but should't be used from there.
if [ "${DIR##*/}" = 'bin' ]; then
echo "!!! The script has detected you are trying to run it from the bin/ folder."
Expand All @@ -58,15 +58,6 @@ if [ -n "$1" ]; then
else
usage
fi
DESTDIR="${DIR}/cake_${TAG}"

# Automatically replace an existing copy of the version.
if [ -d "${DESTDIR}" ]; then
echo "## Recreating Cake core v${TAG}" >&2
rm -rf ${DESTDIR}
else
echo "## Creating Cake core v${TAG}" >&2
fi

# If configured, reuse the existing temp folder (if present).
if [ $REUSE_REPO -gt 0 ] && [ -d "${TMPDIR}" ]; then
Expand All @@ -87,13 +78,31 @@ echo "## Fetching updates from remote." >&2
cd ${TMPDIR}
git fetch

# "Fill in" the full version number if we were only given a major and minor.
NUM_DOTS=$( tr -dc '.' <<<"$TAG" | awk '{ print length; }' )
if [ $NUM_DOTS -lt 2 ]; then
echo "## Determining latest point release." >&2
POINTRELEASE=$( git tag -l | grep "^${TAG}[0-9\.]*$" | sed "s/${TAG}\.//" | sort -n | tail -1 )
TAG="${TAG}.${POINTRELEASE}"
fi

echo "## Verifying requested tag: ${TAG}" >&2
git show-ref --tags --quiet --verify -- "refs/tags/$1"
git show-ref --tags --quiet --verify -- "refs/tags/${TAG}"
if [ $? -ne 0 ]; then
echo "!! Tag does not exist in the repo. Please check your input and try again."
echo "!! Tag '$TAG' does not exist in the repo. Please check your input and try again."
exit 1
fi

DESTDIR="${DIR}/cake_${TAG}"

# Automatically replace an existing copy of the version.
if [ -d "${DESTDIR}" ]; then
echo "## Recreating Cake core v${TAG}" >&2
rm -rf ${DESTDIR}
else
echo "## Creating Cake core v${TAG}" >&2
fi

echo "## Staging snapshot." >&2
mkdir ${DESTDIR}
git archive $TAG --format=zip > archive.zip
Expand Down
3 changes: 2 additions & 1 deletion db-backup
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ if (isset($argv[1]) && $argv[1] == '-h') {
// Set up variables.
$dir = getcwd();
$backupDir = $dir . '/backups';
$dbConfigFile = $dir . '/Config/database.php';
$configDir = $dir . '/Config';
$dbConfigFile = $configDir . '/database.php';
$date = date('Ymd-His');
if (!is_readable($dbConfigFile)) {
echo "!! Failed to read database config file: '{$dbConfigFile}'" . PHP_EOL;
Expand Down
3 changes: 2 additions & 1 deletion db-loadschema
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ fi

# Variable initialization.
DIR="$( cd -P "$( dirname "$0" )"/.. >/dev/null 2>&1 && pwd )"
APP_DIR="$DIR"
BIN_DIR="$DIR/bin"
CONFIG_DIR="$DIR/Config"
CONFIG_DIR="$APP_DIR/Config"
MIGRATION_DIR="$CONFIG_DIR/Migration"
CAKE_SHELL="$DIR/Console/cake"
DEFAULT_SCHEMAPHP="$CONFIG_DIR/Schema/schema.php"
Expand Down
4 changes: 2 additions & 2 deletions db-login
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ fi


DIR="$( cd -P "$( dirname "$0" )"/.. >/dev/null 2>&1 && pwd )"
BINDIR="${DIR}/bin"
BIN_DIR="$DIR/bin"

# Holy yuck, but nothing else works!
eval $( ${BINDIR}/db-credentials )
eval $( ${BIN_DIR}/db-credentials )

CMD="mysql --host=${DB_HOST} --database=${DB_NAME} --user=${DB_USER}"
PATTERN=" |'"
Expand Down
83 changes: 56 additions & 27 deletions db-sample-data
Original file line number Diff line number Diff line change
@@ -1,38 +1,67 @@
#!/usr/bin/env bash
# Script is designed to dump frequently updated data from production for
# importing into a local development database. Currently has hardcoded
# $TABLES and needs to be abstracted to work for "any" project more easily.
# beporter@users.sourceforge.net, 2013-03-08
#
# Run from web root directory on production.
#
# Example:
# bin/db-sample-data database dbuser password

echo "WORK IN PROGRESS";
exit 0;

#---------------------------------------------------------------------
usage ()
{
cat <<EOT

${0##*/}
Dumps frequently updated data from production to a web-accessible
file for downloading and importing into a local development
database. Prompts with the download URL and waits for a response
from the user to delete the file. Pass the names of the DB tables
you wish to download as arguments. Without arguments, will dump
the entire \$default database.

Usage:
bin/${0##*/} [table] [table2] [table3]


EOT

exit 0
}
if [ "$1" = '-h' ]; then
usage
fi

if [ -z "$1" ]; then
TABLES=''
else
TABLES="--tables "$*""
fi
DIR="$( cd -P "$( dirname "$0" )"/.. >/dev/null 2>&1 && pwd )"
APP_DIR="$DIR"
BIN_DIR="${DIR}/bin"


# Configuration vars. Set these appropriately for your app and environment.
TABLES="table1 table2 table3"
WEBROOT_PATH="webroot/"
PUBLIC_URL="http://mysite.com"
PUBLIC_URL=""
WEBROOT_PATH="$APP_DIR/webroot/"


# Internal var setup.
DB=$1
USER=$2
PASS=$3
eval $( ${BIN_DIR}/db-credentials ) # Yuck, but nothing else works!
DATE=$(date +%Y-%m-%d)
OPTIONS="--skip-add-drop-table --no-create-info"
TMP_PATH="tmp/"
DESTINATION_FILE="${DB}_sample_data_$DATE.sql"
TMP_PATH="$APP_DIR/tmp/"
DESTINATION_NAME="${DB_NAME}_sample_data_${DATE}"

# Generate the dump, compress it and move it into place.
cd "${TMP_PATH}"
mysqldump --host="${DB_HOST}" --user="${DB_USER}" -p${DB_PASS} ${OPTIONS} ${DB_NAME} $TABLES > "${DESTINATION_NAME}.sql"
zip -rq9 "${WEBROOT_PATH}${DESTINATION_NAME}.zip" "${DESTINATION_NAME}.sql"
rm -f "${DESTINATION_NAME}.sql"

mysqldump -u ${USER} -p${PASS} ${OPTIONS} ${DB} --tables ${TABLES} > "${TMP_PATH}${DESTINATION_FILE}"
zip -rv9 "${WEBROOT_PATH}${DESTINATION}.zip" "${TMP_PATH}${DESTINATION_FILE}"
rm -f "${TMP_PATH}${DESTINATION_FILE}"
echo "Download URL: ${PUBLIC_URL}/${DESTINATION}.zip"
read -p "Delete ${PUBLIC_URL}/${DESTINATION}.zip? [Y/n]: " ARG_DELETEFILE
# Prompt to download the file, then delete it.
echo "## Download URL: ${PUBLIC_URL}/${DESTINATION_NAME}.zip"
read -p "?? Delete ${PUBLIC_URL}/${DESTINATION_NAME}.zip? [Y/n]: " ARG_DELETEFILE
case $ARG_DELETEFILE in
[Yy]*|* ) rm -f "${WEBROOT_PATH}${DESTINATION}.zip"; echo "File deleted." break;;
[Nn]* ) echo "File REMAINS! Please clean it up when you are done to prevent data leaks." break;;
[Yy]*|*)
rm -f "${WEBROOT_PATH}${DESTINATION_NAME}.zip"
echo "## File deleted."
;;
[Nn]*)
echo "## File REMAINS! Please clean it up when you are done to prevent data leaks."
;;
esac
7 changes: 4 additions & 3 deletions db-showupdates
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ if [ "$1" = '-h' ]; then
fi

DIR="$( cd -P "$( dirname "$0" )"/.. >/dev/null 2>&1 && pwd )"
SQLFILE="$DIR/Config/sql/db_updates.sql"
TMP_A="$DIR/tmp/db_updates.a.sql"
TMP_B="$DIR/tmp/db_updates.b.sql"
APP_DIR="." # Must be relative to git root.
SQLFILE="$APP_DIR/Config/sql/db_updates.sql"
TMP_A="$APP_DIR/tmp/db_updates.a.sql"
TMP_B="$APP_DIR/tmp/db_updates.b.sql"

#@TODO: Add a -s (silent) flag for db-apply-updates.sh to use to suppress all "for humans" output.

Expand Down
2 changes: 1 addition & 1 deletion deps-install
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ echo "## Running installs for all dependency management tools found.";
"$BINDIR/git-submodules"

# Install PEAR packages if config file is present.
if [ -e "$PEAR_PACKAGES_FILE" ]; then
if [ -r "$PEAR_PACKAGES_FILE" ]; then
PEAR="$( which pear )"
if [ $? -gt 0 ]; then
echo "!! Found pear config file '$PEAR_PACKAGES_FILE', but pear is not present on this system."
Expand Down
16 changes: 15 additions & 1 deletion docs-generate
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,18 @@ fi
DIR="$( cd -P "$( dirname "$0" )"/.. >/dev/null 2>&1 && pwd )"
CFG_FILE="$DIR/Config/phpdoc.xml"

bin/phpdoc.php --configuration="${CFG_FILE}" "$@"
# Bail out if phpcs isn't available to us
PHPDOC="$( which phpdoc )"
if [ $? -gt 0 ]; then
PHPDOC="$BIN_DIR/phpdoc"
test -x $PHPDOC
fi
if [ $? -gt 0 ]; then
echo "!! The 'phpdoc' command was not found on this system."
echo ""
exit 1
fi
echo "## Found phpdoc at: ${PHPDOC}"


$PHPDOC --configuration="${CFG_FILE}" "$@"
6 changes: 2 additions & 4 deletions git-currentbranch
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,5 @@ if [ "$1" = '-h' ]; then
usage
fi

#@TODO: Works, but throws a fatal error message if run in a non-git dir. We need to suppress that output.

git rev-parse --quiet --abbrev-ref HEAD
exit $?
git rev-parse --quiet --abbrev-ref HEAD 2>/dev/null
exit $?
8 changes: 8 additions & 0 deletions paths
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ fi

echo "!! @TODO: Write the script!"
exit 1

# core (cake or Lib/Cake)
# app
# backups
# config
# tmp
# webroot
# lib
4 changes: 2 additions & 2 deletions rename-empty
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ fi
if [ -n "$1" ]; then
DIR=$1
else
DIR="$( cd -P "$( dirname "$0" )"/.. && pwd )";
DIR="$( cd -P "$( dirname "$0" )"/.. >/dev/null 2>&1 && pwd )"
fi
find $DIR -name "empty" -exec sh -c 'mv "$0" "${0%empty}.gitkeep"' {} \;
find $DIR -name "empty" -type f -exec sh -c 'mv "$0" "${0%empty}.gitkeep"' {} \;
5 changes: 4 additions & 1 deletion run-codesniffer
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ else
COVERAGE="--report-full --report-summary"
fi

$PHPCS -p --extensions=php --standard=CakePHP ${COVERAGE} ${SNIFF_FOLDERS[@]}
# @TODO: Detect which to use. Ours should be a dependency of the shell-scripts so it's always available though.
CODE_STANDARD=CakePHP
CODE_STANDARD=Vendor/loadsys/loadsys_codesniffer/Loadsys
$PHPCS -p --extensions=php --standard="$CODE_STANDARD" ${COVERAGE} ${SNIFF_FOLDERS[@]}

if [ $SAVE_REPORTS ] && [ $? -eq 0 ]; then
echo "## Full report created at: ${FULL_REPORT_FILE}"
Expand Down
5 changes: 5 additions & 0 deletions run-in-vagrant
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ else
eval "$@"
fi

# It is important that the last command is either the `vagrant ssh`
# or the `eval ...` so that the exit code of **this** script
# is the exit code from those calls.


# Logic matrix:
# vagrant installed + outside vm (no /vagrant mount point) = run in vagrant
# vagrant installed + inside vm = run native
Expand Down
26 changes: 26 additions & 0 deletions semver-get-pointrelease
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Search a list of local git tags for the "latest" matching the input argument.
# Input must be in the form of: x.y
# Can't rely on `sort -V` since it requires GNU coreutils.

if [ -z $1 ]; then
exit 1
fi

if [ -z $2 ]; then
REPO_DIR=.
else
REPO_DIR=$2
fi

git --work-tree="$REPO_DIR" --git-dir="$REPO_DIR/.git" tag -l 1>&2

MAJOR_MINOR=$1
POINTRELEASE=$( git --work-tree="$REPO_DIR" --git-dir="$REPO_DIR/.git" tag -l | grep "^$MAJOR_MINOR" | sed "s/$MAJOR_MINOR\.//" | sort -n | tail -1 )


if [ -z $POINTRELEASE ]; then
exit 2
fi

echo "$MAJOR_MINOR.$POINTRELEASE"
Loading