From 593b389ccb474bc7008fc0fd3566c4222af5fb87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Sat, 29 Oct 2022 15:09:55 +0200 Subject: [PATCH] Add build command. --- isidore.sh | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/isidore.sh b/isidore.sh index 07c1446..c186f75 100755 --- a/isidore.sh +++ b/isidore.sh @@ -119,6 +119,8 @@ function check_in_project() ## function new_project() { + echo "$PROJECT_NAME v$ISIDORE_VERSION" + NEW_PROJECT_DIR=$1 NEW_PROJECT_NAME=$2 mkdir $NEW_PROJECT_DIR @@ -127,9 +129,13 @@ function new_project() echo \ "" >> $NEW_PROJECT_DIR/config.php echo "$ISIDORE_VERSION" > $NEW_PROJECT_DIR/.isidore-version + + echo "New project created." + echo "Consider taking a look at the $NEW_PROJECT_DIR/config.php file." } ## @@ -145,11 +151,41 @@ function clean_project() echo "Project cleaned." } +## +# Build the project. +## +function build_project() +{ + check_in_project + + mkdir -p ./output/ + WORKDESK="/tmp/isidore-workdesk" + CFG_HEADER_FILE="$WORKDESK/config-header.php" + mkdir -p $WORKDESK + for i in $(find site/ -name '*.php') + do + echo "" > $CFG_HEADER_FILE + mkdir -p $WORKDESK/${i%/*} + cat $CFG_HEADER_FILE $i > $WORKDESK/$i + # the 4 offset is to avoid including `site/` + : ${i:4} + OUT_DIR="./output/${_%/*}" + mkdir -p $OUT_DIR + : ${i: :-4} + OUT_FILE="$OUT_DIR/${_##*/}" + php $WORKDESK/$i > $OUT_FILE + done + + rm -r $WORKDESK +} + set_config_vars case $1 in new) new_project $2 $3;; + build) + build_project;; clean) clean_project;; help)