-
Notifications
You must be signed in to change notification settings - Fork 1
/
rename.sh
executable file
·79 lines (63 loc) · 1.94 KB
/
rename.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
currentApplicationId="com.waloszek.nextmovie"
currentProjectName="next_movie"
currentAppName="Next Movie"
androidManifestLocation="./android/app/src/main/AndroidManifest.xml"
iosPlistLocation="./ios/Runner/Info.plist"
lines="----------------------"
menuOptions="$lines\n1.Rename All\n2.Change bundleId\n3.Change project name\n4.Change app name\n$lines\nChoose option:"
pleaseWait="Setting new strings. Please wait.."
chooseNewBundleId="Please choose a new bundleId:"
chooseNewAppName="Please choose a new application name:"
chooseProjectName="Please choose a new project name:"
main () {
installDependenciesIfNeeded
export LC_ALL=C
echo -e "$menuOptions"
read choice
case "$choice" in
"1") changeAll ;;
"2") changeBundleId ;;
"3") changeProjectName ;;
"4") changeAppName ;;
*) echo "💩"
esac
}
installDependenciesIfNeeded() {
which -s brew
if [[ $? != 0 ]] ; then
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
if ! brew ls --versions gnu-sed > /dev/null; then
brew install gnu-sed
fi
}
findAndRename () {
find "$1" \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 gsed -i s/"$2"/"$3"/g
}
changeAll() {
changeBundleId
changeProjectName
changeAppName
}
changeBundleId () {
echo "$chooseNewBundleId"
read newApplicationId
echo "$pleaseWait"
findAndRename ./ "$currentApplicationId" "$newApplicationId"
}
changeProjectName () {
echo "$chooseProjectName"
read newProjectName
echo "$pleaseWait"
findAndRename ./ "$currentProjectName" "$newProjectName"
}
changeAppName () {
echo "$chooseNewAppName"
IFS= read -r newAppName
echo "$pleaseWait"
findAndRename "$androidManifestLocation" "$currentAppName" "$newAppName"
findAndRename "$iosPlistLocation" "$currentAppName" "$newAppName"
findAndRename ./rename.sh "$currentAppName" "$newAppName"
}
main