-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Download and Configure scripts (#2)
* Add download script * Update script, add to README * Update template for 5.10 * Add configure.sh with package and executable name * Outputting to text * Update README * Update README to include `Use this template` * Fix README, configure outputs more info * Use executable name in logger label, server name * Use package name not executable name * Get correct base folder
- Loading branch information
1 parent
ec4da62
commit 9467d7b
Showing
9 changed files
with
136 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,3 @@ | |
/Packages | ||
/*.xcodeproj | ||
xcuserdata/ | ||
/Package.resolved |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
# Template | ||
|
||
Template for Hummingbird App | ||
|
||
Either click on `Use this template` or run the following to clone locally | ||
```bash | ||
curl -L https://raw.githubusercontent.com/hummingbird-project/template/configure/scripts/download.sh | bash -s <project-name> | ||
``` | ||
|
||
Then enter the folder created, run `./configure.sh` and follow the instructions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/usr/bin/env bash | ||
|
||
PWD=$(pwd) | ||
TARGET_FOLDER=${1:-$PWD} | ||
BASE_FOLDER=$(basename $TARGET_FOLDER) | ||
CLEAN_BASE_FOLDER=$(echo "$BASE_FOLDER" | sed -e 's/[^a-zA-Z0-9_]/_/g') | ||
|
||
TEMP_FOLDER=$(mktemp -d) | ||
MO="$TEMP_FOLDER"/mo | ||
|
||
cleanup() | ||
{ | ||
rm -rf "$TEMP_FOLDER" | ||
} | ||
|
||
# Download MO bash mustache renderer | ||
download_mo() | ||
{ | ||
curl -sSL https://raw.githubusercontent.com/tests-always-included/mo/master/mo -o "$MO" | ||
chmod a+x "$MO" | ||
} | ||
|
||
read_input_with_default () { | ||
echo -n "[$1] > " | ||
read -r READ_INPUT_RETURN | ||
|
||
if [ -z "$READ_INPUT_RETURN" ]; then | ||
READ_INPUT_RETURN="$1" | ||
fi | ||
} | ||
|
||
run_mustache() | ||
{ | ||
FILES=$1 | ||
for FILE in $FILES; do | ||
$MO "$FILE" > "$TEMP_FOLDER"/tempfile | ||
mv -f "$TEMP_FOLDER"/tempfile "$TARGET_FOLDER/$FILE" | ||
done | ||
} | ||
|
||
run_mustache-template() | ||
{ | ||
echo $1 | ||
#| $MO > "$TEMP_FOLDER"/$2 | ||
echo $2 | ||
} | ||
|
||
exitWithError() | ||
{ | ||
echo "Error: $1" | ||
exit 1 | ||
} | ||
|
||
check_valid() { | ||
if [[ "$HB_PACKAGE_NAME" =~ [^a-zA-Z0-9_] ]]; then | ||
exitWithError "Invalid package name: $HB_PACKAGE_NAME" | ||
fi | ||
} | ||
trap cleanup EXIT $? | ||
|
||
echo "Configuring your Hummingbird project" | ||
|
||
# Download Bash Mustache | ||
download_mo | ||
|
||
if [[ "$TARGET_FOLDER" != "$PWD" ]]; then | ||
echo "Outputting to $TARGET_FOLDER" | ||
mkdir -p "$TARGET_FOLDER"/Sources/App | ||
mkdir -p "$TARGET_FOLDER"/Tests/AppTests | ||
else | ||
echo "Outputting to current folder" | ||
fi | ||
|
||
|
||
|
||
echo -n "Enter your package name: " | ||
read_input_with_default "$CLEAN_BASE_FOLDER" | ||
export HB_PACKAGE_NAME=$READ_INPUT_RETURN | ||
if [[ "$HB_PACKAGE_NAME" =~ [^a-zA-Z0-9_-] ]]; then | ||
exitWithError "Invalid package name: $HB_PACKAGE_NAME" | ||
fi | ||
|
||
echo -n "Enter your executable name: " | ||
read_input_with_default "App" | ||
export HB_EXECUTABLE_NAME=$READ_INPUT_RETURN | ||
if [[ "$HB_EXECUTABLE_NAME" =~ [^a-zA-Z0-9_] ]]; then | ||
exitWithError "Invalid executable name: $HB_EXECUTABLE_NAME" | ||
fi | ||
|
||
# Root level files | ||
FILES=$(find . -maxdepth 1 ! -type d ! -name "*.sh") | ||
run_mustache "$FILES" | ||
# Files in Sources and Tests folder | ||
FILES=$(find Sources Tests ! -type d) | ||
run_mustache "$FILES" | ||
|
||
# README file | ||
cat <<EOF | $MO > $TARGET_FOLDER/README.md | ||
# $HB_PACKAGE_NAME | ||
My awesome project | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
FOLDER=${1:-} | ||
TEMPLATE_VERSION=2.0.0-beta.1 | ||
|
||
if [[ -z "$FOLDER" ]]; then | ||
echo "Missing folder name" | ||
echo "Usage: download.sh <folder>" | ||
exit 1 | ||
fi | ||
|
||
curl -sSL https://github.com/hummingbird-project/template/archive/refs/tags/"$TEMPLATE_VERSION".tar.gz | tar xvz -s /template-2.0.0-beta.1/"$FOLDER"/ |