-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2cb1a3
commit a6712d5
Showing
2 changed files
with
20 additions
and
8 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 |
---|---|---|
@@ -1,30 +1,40 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
set -eo pipefail | ||
|
||
NEW_PROJECT_NAME=$1 | ||
if [[ -z "${NEW_PROJECT_NAME}" ]]; then | ||
echo "NEW_PROJECT_NAME is not set" | ||
exit 1 | ||
fi | ||
|
||
NEW_PROJECT_BUNDLE_ID_PREFIX=$2 | ||
if [[ -z "${NEW_PROJECT_BUNDLE_ID_PREFIX}" ]]; then | ||
echo "NEW_PROJECT_BUNDLE_ID_PREFIX is not set" | ||
exit 1 | ||
fi | ||
|
||
# `find` returns folders before their children, so this will always rename the parent folder first. | ||
# We re-run `find` every iteration so that the path is correct after renaming a parent folder. | ||
echo "Moving files..." | ||
while FILE=$(find . -name '*SwiftProjectTemplate*' | head -n1) && [ -n "$FILE" ]; do | ||
NEW_FILE=$(echo $FILE | sed -e "s/SwiftProjectTemplate/$NEW_PROJECT_NAME/") | ||
echo "mv \"$FILE\" \"$NEW_FILE\"" | ||
mv "$FILE" "$NEW_FILE" | ||
done | ||
git add -A | ||
echo "Files moved." | ||
|
||
# Replace references to `SwiftProjectTemplate` | ||
echo "Replacing references to SwiftProjectTemplate..." | ||
git ls-files --cached --modified --others --exclude-standard -z | | ||
xargs -0 sed -i '' -e "s/SwiftProjectTemplate/$NEW_PROJECT_NAME/g" | ||
xargs -0 -I {} sed -i.template-specialization-backup "s/SwiftProjectTemplate/$NEW_PROJECT_NAME/g" {} | ||
|
||
# Replace bundle identifier | ||
echo "Replacing bundle identifier..." | ||
git ls-files --cached --modified --others --exclude-standard -z | | ||
xargs -0 sed -i '' -e "s/com.github.georgelyon/$NEW_PROJECT_BUNDLE_ID_PREFIX/g" | ||
xargs -0 -I {} sed -i.template-specialization-backup "s/com.github.georgelyon/$NEW_PROJECT_BUNDLE_ID_PREFIX/g" {} | ||
|
||
echo "Removing backup files..." | ||
find . -name '*.template-specialization-backup' -exec rm {} \; | ||
git add -A | ||
|
||
echo "Done." |