diff --git a/_build/tools/functions/parse-version.sh.inc b/_build/tools/functions/parse-version.sh.inc deleted file mode 100644 index 1b6dcce..0000000 --- a/_build/tools/functions/parse-version.sh.inc +++ /dev/null @@ -1,44 +0,0 @@ -## -# Evaluates a version string -# -# @author Daniel Rudolf -# @link http://picocms.org -# @license http://opensource.org/licenses/MIT -# - -parse_version() { - VERSION_FULL="$1" - - if [ "${VERSION_FULL:0:1}" == "v" ]; then - VERSION_FULL="${VERSION_FULL:1}" - fi - - if [[ "$VERSION_FULL" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9A-Za-z\.\-]+))?(\+([0-9A-Za-z\.\-]+))?$ ]]; then - VERSION_MAJOR="${BASH_REMATCH[1]}" - VERSION_MINOR="${BASH_REMATCH[2]}" - VERSION_PATCH="${BASH_REMATCH[3]}" - VERSION_SUFFIX="${BASH_REMATCH[5]}" - VERSION_BUILD="${BASH_REMATCH[7]}" - - VERSION_STABILITY="stable" - if [[ "$VERSION_SUFFIX" =~ ^(dev|a|alpha|b|beta|RC)?([.-]?[0-9]+)?([.-](dev))?$ ]]; then - if [ "${BASH_REMATCH[1]}" == "dev" ] || [ "${BASH_REMATCH[4]}" == "dev" ]; then - VERSION_STABILITY="dev" - elif [ "${BASH_REMATCH[1]}" == "a" ] || [ "${BASH_REMATCH[1]}" == "alpha" ]; then - VERSION_STABILITY="alpha" - elif [ "${BASH_REMATCH[1]}" == "b" ] || [ "${BASH_REMATCH[1]}" == "beta" ]; then - VERSION_STABILITY="beta" - elif [ "${BASH_REMATCH[1]}" == "RC" ]; then - VERSION_STABILITY="RC" - fi - fi - - VERSION_MILESTONE="$VERSION_MAJOR.$VERSION_MINOR" - VERSION_NAME="$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH" - VERSION_ID="$VERSION_MAJOR$(printf '%02d' "$VERSION_MINOR")$(printf '%02d' "$VERSION_PATCH")" - - return 0 - else - return 1 - fi -} diff --git a/_build/tools/generate-badge.sh b/_build/tools/generate-badge.sh deleted file mode 100755 index 5727e74..0000000 --- a/_build/tools/generate-badge.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash - -## -# Downloads a custom badge from shields.io -# -# All credit goes to the awesome guys at shields.io! -# -# @see http://shields.io/ -# -# @author Daniel Rudolf -# @link http://picocms.org -# @license http://opensource.org/licenses/MIT -# - -set -e - -# parameters -BADGE_FILE_PATH="$1" # target file path -BADGE_SUBJECT="$2" # subject (left half) of the badge -BADGE_STATUS="$3" # status (right half) of the badge -BADGE_COLOR="$4" # color of the badge - -# print parameters -echo "Generating badge..." -printf 'BADGE_FILE_PATH="%s"\n' "$BADGE_FILE_PATH" -printf 'BADGE_SUBJECT="%s"\n' "$BADGE_SUBJECT" -printf 'BADGE_STATUS="%s"\n' "$BADGE_STATUS" -printf 'BADGE_COLOR="%s"\n' "$BADGE_COLOR" -echo - -# download badge from shields.io -printf 'Downloading badge...\n' -TMP_BADGE="$(mktemp -u)" - -curl --location --output "$TMP_BADGE" \ - "https://img.shields.io/badge/$BADGE_SUBJECT-$BADGE_STATUS-$BADGE_COLOR.svg" - -# validate badge -if [ ! -f "$TMP_BADGE" ] || [ ! -s "$TMP_BADGE" ]; then - echo "Unable to generate badge; skipping..." >&2 - exit 1 -fi - -# MIME type image/svg+xml isn't supported at the moment -# -#TMP_BADGE_MIME="$(file --mime-type "$TMP_BADGE" | cut -d ' ' -f 2)" -#if [ "$TMP_BADGE_MIME" != "image/svg+xml" ]; then -# echo "Generated badge should be of type 'image/svg+xml', '$TMP_BADGE_MIME' given; aborting...\n" >&2 -# exit 1 -#fi - -# deploy badge -mv "$TMP_BADGE" "$BADGE_FILE_PATH" - -echo diff --git a/_build/tools/generate-phpdoc.sh b/_build/tools/generate-phpdoc.sh deleted file mode 100755 index f22432a..0000000 --- a/_build/tools/generate-phpdoc.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash - -## -# Generates phpDoc class documentation -# -# @author Daniel Rudolf -# @link http://picocms.org -# @license http://opensource.org/licenses/MIT -# - -set -e - -# parameters -PHPDOC_CONFIG="$1" # phpDoc config file -PHPDOC_CACHE_DIR="$2" # phpDoc cache dir -PHPDOC_TARGET_DIR="$3" # phpDoc output dir -PHPDOC_TITLE="$4" # API docs title - -# print parameters -echo "Generating phpDocs..." -printf 'PHPDOC_CONFIG="%s"\n' "$PHPDOC_CONFIG" -printf 'PHPDOC_CACHE_DIR="%s"\n' "$PHPDOC_CACHE_DIR" -printf 'PHPDOC_TARGET_DIR="%s"\n' "$PHPDOC_TARGET_DIR" -printf 'PHPDOC_TITLE="%s"\n' "$PHPDOC_TITLE" -echo - -# update a separate phpDoc cache -if [ "$PHPDOC_CACHE_DIR" != "-" ]; then - # parse phpDoc files (i.e. update cache) - printf "Update phpDoc cache...\n" - phpdoc project:parse --config "$PHPDOC_CONFIG" \ - --target "$PHPDOC_CACHE_DIR" - - # check for changes - printf '\nCheck for phpDoc cache changes...\n' - if [ -z "$(git status --porcelain "$PHPDOC_CACHE_DIR")" ]; then - printf 'No changes detected; skipping phpDocs renewal...\n\n' - exit 0 - fi - - # NOTE: actually the following command should be `phpdoc project:transform` - # instead of `phpdoc project:run`, but the command seems to be broken... - echo -else - # create temporary cache files in PHPDOC_TARGET_DIR - PHPDOC_CACHE_DIR="$PHPDOC_TARGET_DIR" -fi - -# transform phpDoc files (i.e. rewrite API docs) -printf 'Rewrite phpDocs...\n' -rm -rf "$PHPDOC_TARGET_DIR" -phpdoc project:run --config "$PHPDOC_CONFIG" \ - --cache-folder "$PHPDOC_CACHE_DIR" \ - --target "$PHPDOC_TARGET_DIR" \ - --title "$PHPDOC_TITLE" - -echo diff --git a/_build/tools/github-clone.sh b/_build/tools/github-clone.sh deleted file mode 100755 index e8cb1de..0000000 --- a/_build/tools/github-clone.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -## -# Clones a Git repo -# -# @author Daniel Rudolf -# @link http://picocms.org -# @license http://opensource.org/licenses/MIT -# - -set -e - -# parameters -CLONE_TARGET_DIR="$1" # target directory -CLONE_REPO_URL="$2" # URL of the git repo to clone -CLONE_REPO_BRANCH="$3" # optional branch to checkout - -# print parameters -echo "Cloning repo..." -printf 'CLONE_TARGET_DIR="%s"\n' "$CLONE_TARGET_DIR" -printf 'CLONE_REPO_URL="%s"\n' "$CLONE_REPO_URL" -printf 'CLONE_REPO_BRANCH="%s"\n' "$CLONE_REPO_BRANCH" -echo - -# clone repo -[ -n "$CLONE_REPO_BRANCH" ] || CLONE_REPO_BRANCH="master" -git clone --branch="$CLONE_REPO_BRANCH" "$CLONE_REPO_URL" "$CLONE_TARGET_DIR" - -echo diff --git a/_build/tools/github-commit.sh b/_build/tools/github-commit.sh deleted file mode 100755 index 6521160..0000000 --- a/_build/tools/github-commit.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash - -## -# Commits changes to a Git repo -# -# @author Daniel Rudolf -# @link http://picocms.org -# @license http://opensource.org/licenses/MIT -# - -set -e - -# parameters -COMMIT_MESSAGE="$1" # commit message -shift 1 - -# print parameters -echo "Commiting changes..." -printf 'COMMIT_MESSAGE="%s"\n' "$COMMIT_MESSAGE" -echo - -# stage changes -COMMIT_FILES=() -while [ $# -gt 0 ]; do - if [ -n "$(git status --porcelain "$1")" ]; then - if [ -d "$1" ]; then - git add --all "$1" - elif [ -f "$1" ] || [ -h "$1" ]; then - git add "$1" - else - echo "Unable to commit '$1': No such file, symbolic link or directory" >&2 - exit 1 - fi - - COMMIT_FILES+=( "$1" ) - shift - fi -done - -# commit changes -if [ ${#COMMIT_FILES[@]} -gt 0 ]; then - git commit --message="$COMMIT_MESSAGE" "${COMMIT_FILES[@]}" -fi - -echo diff --git a/_build/tools/github-deploy.sh b/_build/tools/github-deploy.sh deleted file mode 100755 index b7ec649..0000000 --- a/_build/tools/github-deploy.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env bash - -## -# Pushes commits to a GitHub repo -# -# @author Daniel Rudolf -# @link http://picocms.org -# @license http://opensource.org/licenses/MIT -# - -set -e - -# parameters -CHECK_REPO_SLUG="$1" # optional GitHub repo (e.g. picocms/Pico) to check - # its latest commit as basic race condition protection -CHECK_REMOTE_REF="$2" # optional remote Git reference (e.g. heads/master) -CHECK_LOCAL_COMMIT="$3" # optional local commit SHA1 - -# environment variables -# GITHUB_OAUTH_TOKEN GitHub authentication token, see https://github.com/settings/tokens - -# print parameters -echo "Deploying repo..." -printf 'CHECK_REPO_SLUG="%s"\n' "$CHECK_REPO_SLUG" -printf 'CHECK_REMOTE_REF="%s"\n' "$CHECK_REMOTE_REF" -printf 'CHECK_LOCAL_COMMIT="%s"\n' "$CHECK_LOCAL_COMMIT" -echo - -# check for changes -if [ -z "$(git log --oneline '@{upstream}..')" ]; then - printf 'Nothing to deploy; skipping...\n\n' - exit 0 -fi - -# race condition protection for concurrent Travis builds -# this is no definite protection (race conditions are still possible during `git push`), -# but it should give a basic protection without disabling concurrent builds completely -if [ -n "$CHECK_REPO_SLUG" ] && [ -n "$CHECK_REMOTE_REF" ] && [ -n "$CHECK_LOCAL_COMMIT" ]; then - # retrieve information using GitHub APIv3 - echo "Checking latest commit$([ -n "$GITHUB_OAUTH_TOKEN" ] && echo " (authorized)")..." - CHECK_API_URL="https://api.github.com/repos/$CHECK_REPO_SLUG/git/refs/$CHECK_REMOTE_REF" - if [ -n "$GITHUB_OAUTH_TOKEN" ]; then - CHECK_API_RESPONSE="$(curl --fail --silent --show-error --header "Authorization: token $GITHUB_OAUTH_TOKEN" "$CHECK_API_URL")" - else - CHECK_API_RESPONSE="$(curl --fail --silent --show-error "$CHECK_API_URL")" - fi - - # evaluate JSON response - CHECK_REMOTE_COMMIT="$(echo "$CHECK_API_RESPONSE" | php -r " - \$json = json_decode(stream_get_contents(STDIN), true); - if (\$json !== null) { - if (isset(\$json['ref']) && (\$json['ref'] === 'refs/$CHECK_REMOTE_REF')) { - if (isset(\$json['object']) && isset(\$json['object']['sha'])) { - echo \$json['object']['sha']; - } - } - } - ")" - - # compare source reference against the latest commit - if [ "$CHECK_REMOTE_COMMIT" != "$CHECK_LOCAL_COMMIT" ]; then - echo "Latest local commit '$CHECK_LOCAL_COMMIT' doesn't match latest remote commit '$CHECK_REMOTE_COMMIT'; aborting..." >&2 - exit 1 - fi - - echo -fi - -# push changes -printf 'Pushing changes...\n' -git push - -echo diff --git a/_build/tools/github-setup.sh b/_build/tools/github-setup.sh deleted file mode 100755 index a9697cb..0000000 --- a/_build/tools/github-setup.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -## -# Prepares a GitHub repo for deployment -# -# @author Daniel Rudolf -# @link http://picocms.org -# @license http://opensource.org/licenses/MIT -# - -set -e - -# environment variables -# GITHUB_OAUTH_TOKEN GitHub authentication token, see https://github.com/settings/tokens - -# print "parameters" (we don't have any) -echo "Setup repo..." -echo - -# check for git repo -if ! git rev-parse --git-dir > /dev/null 2>&1; then - echo "Not a git repo; aborting..." >&2 - exit 1 -fi - -# setup git -printf 'Preparing repo...\n' -git config push.default simple -git config user.name "Travis CI" -git config user.email "travis-ci@picocms.org" - -if [ -n "$GITHUB_OAUTH_TOKEN" ]; then - git config credential.helper 'store --file=.git/credentials' - (umask 077 && echo "https://GitHub:$GITHUB_OAUTH_TOKEN@github.com" > .git/credentials) -fi - -echo diff --git a/_build/tools/update-cloc-stats.sh b/_build/tools/update-cloc-stats.sh deleted file mode 100755 index 7c3396a..0000000 --- a/_build/tools/update-cloc-stats.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env bash - -## -# Updates the cloc statistics files -# -# @author Daniel Rudolf -# @link http://picocms.org -# @license http://opensource.org/licenses/MIT -# - -set -e - -# parameters -TARGET_FILE="$1" # statistics target file path - -# print parameters -echo "Updating cloc statistics..." -printf 'TARGET_FILE="%s"\n' "$TARGET_FILE" -echo - -# create cloc statistics -create_cloc_stats() { - local CLOC_FILE="$1" - shift - - cloc --yaml --report-file "$CLOC_FILE" \ - --progress-rate 0 \ - --read-lang-def <( - echo "JSON" - echo " filter remove_matches ^\s*$" - echo " extension json" - echo " 3rd_gen_scale 2.50" - echo "Twig" - echo " filter remove_between_general {# #}" - echo " extension twig" - echo " 3rd_gen_scale 2.00" - echo "Markdown" - echo " filter remove_html_comments" - echo " extension md" - echo " 3rd_gen_scale 1.00" - echo "Apache config" - echo " filter remove_matches ^\s*#" - echo " filter remove_inline #.*$" - echo " extension htaccess" - echo " 3rd_gen_scale 1.90" - ) \ - --force-lang PHP,php.dist \ - --force-lang YAML,yml.template \ - "$@" -} - -# remove header from cloc statistics -clean_cloc_stats() { - local LINE="" - local IS_HEADER="no" - while IFS='' read -r LINE || [[ -n "$LINE" ]]; do - if [ "$IS_HEADER" == "yes" ]; then - # skip lines until next entry is reached - [ "${LINE:0:2}" != " " ] || continue - IS_HEADER="no" - elif [ "$LINE" == "header :" ]; then - # header detected - IS_HEADER="yes" - continue - fi - - echo "$LINE" - done < <(tail -n +3 "$1") -} - -# create temporary file -printf 'Creating temporary file...\n' -TMP_FILE="$(mktemp)" -[ -n "$TMP_FILE" ] || exit 1 -echo - -# create statistics -printf 'Creating statistics...\n' -create_cloc_stats "$TMP_FILE" \ - lib index.php -echo - -# remove headers from cloc statistics -printf 'Writing statistics file without header...\n' -clean_cloc_stats "$TMP_FILE" > "$TARGET_FILE" -echo - -# remove temporary file -printf 'Removing temporary file...\n' -rm "$TMP_FILE" -echo diff --git a/_build/tools/update-phpdoc-list.sh b/_build/tools/update-phpdoc-list.sh deleted file mode 100755 index 06cfba6..0000000 --- a/_build/tools/update-phpdoc-list.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env bash - -## -# Updates the phpDoc list -# -# @author Daniel Rudolf -# @link http://picocms.org -# @license http://opensource.org/licenses/MIT -# - -set -e - -# parameters -LIST_FILE_PATH="$1" # target file path -LIST_ID="$2" # phpDoc ID -LIST_TYPE="$3" # phpDoc type -LIST_TITLE="$4" # phpDoc title -LIST_LAST_UPDATE="$5" # phpDoc last update - -# print parameters -echo "Updating phpDoc list..." -printf 'LIST_FILE_PATH="%s"\n' "$LIST_FILE_PATH" -printf 'LIST_ID="%s"\n' "$LIST_ID" -printf 'LIST_TYPE="%s"\n' "$LIST_TYPE" -printf 'LIST_TITLE="%s"\n' "$LIST_TITLE" -printf 'LIST_LAST_UPDATE="%s"\n' "$LIST_LAST_UPDATE" -echo - -# create temporary file -printf 'Creating temporary file...\n' -LIST_TMP_FILE="$(mktemp)" -[ -n "$LIST_TMP_FILE" ] || exit 1 - -exec 3> "$LIST_TMP_FILE" - -# walk through phpDoc list -printf 'Walking through phpDoc list...\n' - -DO_REPLACE="no" -DID_REPLACE="no" -while IFS='' read -r LINE || [[ -n "$LINE" ]]; do - if [ "$DO_REPLACE" == "yes" ]; then - # skip lines until next entry is reached - [ "${LINE:0:2}" != " " ] || continue - DO_REPLACE="no" - - elif [ "$LINE" == "- id: $LIST_ID" ]; then - # update existing entry - printf 'Updating existing entry...\n' - printf -- '- id: %s\n' "$LIST_ID" >&3 - printf -- ' type: %s\n' "$LIST_TYPE" >&3 - printf -- ' title: %s\n' "$LIST_TITLE" >&3 - printf -- ' last_update: %s\n' "$LIST_LAST_UPDATE" >&3 - - DO_REPLACE="yes" - DID_REPLACE="yes" - continue - fi - - echo "$LINE" >&3 -done < "$LIST_FILE_PATH" - -# add new entry -if [ "$DID_REPLACE" == "no" ]; then - printf 'Adding new entry...\n' - printf -- '- id: %s\n' "$LIST_ID" >&3 - printf -- ' type: %s\n' "$LIST_TYPE" >&3 - printf -- ' title: %s\n' "$LIST_TITLE" >&3 - printf -- ' last_update: %s\n' "$LIST_LAST_UPDATE" >&3 -fi - -exec 3>&- - -# move temporary file -printf 'Replacing phpDoc list...\n' -mv "$LIST_TMP_FILE" "$LIST_FILE_PATH" - -echo diff --git a/_build/tools/update-version-file.sh b/_build/tools/update-version-file.sh deleted file mode 100755 index 79afa36..0000000 --- a/_build/tools/update-version-file.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash - -## -# Updates the version file -# -# @author Daniel Rudolf -# @link http://picocms.org -# @license http://opensource.org/licenses/MIT -# - -set -e - -. "$(dirname "$0")/functions/parse-version.sh.inc" - -# parameters -VERSION_FILE_PATH="$1" # target file path -VERSION_STRING="$2" # version string (e.g. 1.0.0-beta.1+7b4ad7f) - -# print parameters -echo "Generating version file..." -printf 'VERSION_FILE_PATH="%s"\n' "$VERSION_FILE_PATH" -printf 'VERSION_STRING="%s"\n' "$VERSION_STRING" -echo - -# evaluate version string (see http://semver.org/) -printf 'Evaluating version string...\n' -if ! parse_version "$VERSION_STRING"; then - echo "Invalid version string; skipping..." >&2 - exit 1 -fi - -# generate version file -printf 'Updating version file...\n' -echo -n "" > "$VERSION_FILE_PATH" -exec 3> "$VERSION_FILE_PATH" - -printf 'full: %s\n' "$VERSION_FULL" >&3 -printf 'name: %s\n' "$VERSION_NAME" >&3 -printf 'milestone: %s\n' "$VERSION_MILESTONE" >&3 -printf 'stability: %s\n' "$VERSION_STABILITY" >&3 -printf 'id: %d\n' "$VERSION_ID" >&3 -printf 'major: %d\n' "$VERSION_MAJOR" >&3 -printf 'minor: %d\n' "$VERSION_MINOR" >&3 -printf 'patch: %d\n' "$VERSION_PATCH" >&3 -printf 'suffix: %s\n' "$VERSION_SUFFIX" >&3 -printf 'build: %s\n' "$VERSION_BUILD" >&3 - -exec 3>&- - -echo