#!/bin/bash # dot-project - generate .project files for B2C Commerce cartridges # # Usage: # dot-project [code_version_directory] # dot-project -h # # Creates a .project XML file in each subdirectory of the given directory # (or the current directory), allowing them to be recognized as Salesforce # B2C Commerce (Demandware) cartridges by Eclipse/UX Studio/Prophet Debugger. # Each .project file uses the subdirectory name as the project name. _dot_project() ( local SCRIPT_NAME; SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")" case "${BASH_SOURCE[0]}" in /dev/*|/proc/*) SCRIPT_NAME="" ;; esac case "$SCRIPT_NAME" in ""|bash|sh|zsh|dash) SCRIPT_NAME="dot-project" ;; esac _error() { echo "[ERR][$SCRIPT_NAME] $*" >&2; } _show_help() { local s; [ -t 1 ] && s=$'\033[4m' || s='' local r; [ -t 1 ] && r=$'\033[24m' || r='' echo "NAME" echo " $SCRIPT_NAME - generate .project files for B2C Commerce cartridges" echo "SYNOPSIS" echo " $SCRIPT_NAME [${s}code_version_directory${r}]" echo " $SCRIPT_NAME -h" echo "DESCRIPTION" echo " Creates a .project XML file in each subdirectory of the given directory" echo " (or the current directory), allowing them to be recognized as Salesforce" echo " B2C Commerce (Demandware) cartridges by Eclipse/UX Studio/Prophet Debugger." echo " Each .project file uses the subdirectory name as the project name." echo "OPTIONS" echo " -h, --help Show this help message" echo "EXIT STATUS" echo " 0 Success (includes no-op cases: nonexistent dir, write errors" echo " per-file logged to stderr but not propagated)" } case "${1-}" in -h|--help) _show_help; return 0 ;; esac # Default to current directory local code_version="${1:-"."}" # Create a .project file in each subdirectory (cartridge) local cartridge for cartridge in "${code_version%"/"}"/*; do # remove trailing slash, if present, to avoid doubling if [ -d "$cartridge" ]; then local project_file="$cartridge/.project" if cat <"$project_file"; then $(basename "$cartridge") com.demandware.studio.core.beehiveElementBuilder com.demandware.studio.core.beehiveNature DOT_PROJECT_TEMPLATE echo "Generated $project_file" else _error "Failed to create $project_file" fi fi done ) _dot_project "$@" __dot_project_rc=$? unset -f _dot_project if [ -n "${BASH_SOURCE[0]}" ] && [ "${BASH_SOURCE[0]}" != "$0" ]; then eval "unset __dot_project_rc; return $__dot_project_rc" fi eval "unset __dot_project_rc; exit $__dot_project_rc"