-
Notifications
You must be signed in to change notification settings - Fork 67
/
config.sh
executable file
·113 lines (93 loc) · 3.11 KB
/
config.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
Cyan='\033[0;36m'
Default='\033[0;m'
projectName=""
httpsRepo=""
sshRepo=""
homePage=""
confirmed="n"
getProjectName() {
read -p "Enter Project Name: " projectName
if test -z "$projectName"; then
getProjectName
fi
}
getHTTPSRepo() {
read -p "Enter HTTPS Repo URL: " httpsRepo
if test -z "$httpsRepo"; then
getHTTPSRepo
fi
}
getSSHRepo() {
read -p "Enter SSH Repo URL: " sshRepo
if test -z "$sshRepo"; then
getSSHRepo
fi
}
getHomePage() {
read -p "Enter Home Page URL: " homePage
if test -z "$homePage"; then
getHomePage
fi
}
getInfomation() {
getProjectName
getHTTPSRepo
getSSHRepo
getHomePage
echo -e "\n${Default}================================================"
echo -e " Project Name : ${Cyan}${projectName}${Default}"
echo -e " HTTPS Repo : ${Cyan}${httpsRepo}${Default}"
echo -e " SSH Repo : ${Cyan}${sshRepo}${Default}"
echo -e " Home Page URL : ${Cyan}${homePage}${Default}"
echo -e "================================================\n"
}
echo -e "\n"
while [ "$confirmed" != "y" -a "$confirmed" != "Y" ]
do
if [ "$confirmed" == "n" -o "$confirmed" == "N" ]; then
getInfomation
fi
read -p "confirm? (y/n):" confirmed
done
mkdir -p "../${projectName}/${projectName}/${projectName}"
licenseFilePath="../${projectName}/FILE_LICENSE"
gitignoreFilePath="../${projectName}/.gitignore"
specFilePath="../${projectName}/${projectName}.podspec"
readmeFilePath="../${projectName}/readme.md"
uploadFilePath="../${projectName}/upload.sh"
podfilePath="../${projectName}/Podfile"
echo "copy to $licenseFilePath"
cp -f ./templates/FILE_LICENSE "$licenseFilePath"
echo "copy to $gitignoreFilePath"
cp -f ./templates/gitignore "$gitignoreFilePath"
echo "copy to $specFilePath"
cp -f ./templates/pod.podspec "$specFilePath"
echo "copy to $readmeFilePath"
cp -f ./templates/readme.md "$readmeFilePath"
echo "copy to $uploadFilePath"
cp -f ./templates/upload.sh "$uploadFilePath"
echo "copy to $podfilePath"
cp -f ./templates/Podfile "$podfilePath"
echo "editing..."
sed -i "" "s%__ProjectName__%${projectName}%g" "$gitignoreFilePath"
sed -i "" "s%__ProjectName__%${projectName}%g" "$readmeFilePath"
sed -i "" "s%__ProjectName__%${projectName}%g" "$uploadFilePath"
sed -i "" "s%__ProjectName__%${projectName}%g" "$podfilePath"
sed -i "" "s%__ProjectName__%${projectName}%g" "$specFilePath"
sed -i "" "s%__HomePage__%${homePage}%g" "$specFilePath"
sed -i "" "s%__HTTPSRepo__%${httpsRepo}%g" "$specFilePath"
echo "edit finished"
echo "cleaning..."
cd ../$projectName
git init
git remote add origin $sshRepo &> /dev/null
git rm -rf --cached ./Pods/ &> /dev/null
git rm --cached Podfile.lock &> /dev/null
git rm --cached .DS_Store &> /dev/null
git rm -rf --cached $projectName.xcworkspace/ &> /dev/null
git rm -rf --cached $projectName.xcodeproj/xcuserdata/`whoami`.xcuserdatad/xcschemes/$projectName.xcscheme &> /dev/null
git rm -rf --cached $projectName.xcodeproj/project.xcworkspace/xcuserdata/ &> /dev/null
echo "clean finished"
say "finished"
echo "finished"