-
Notifications
You must be signed in to change notification settings - Fork 1
/
autoGenerator.sh
executable file
Β·161 lines (134 loc) Β· 3.82 KB
/
autoGenerator.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
source ./helperShells/applicationMaker.sh
source ./helperShells/frameworkMaker.sh
source ./helperShells/projectDescriptionMaker.sh
source ./helperShells/dependencyDescriptionMaker.sh
main=
includes=()
includeOnlys=()
frameworks=()
main_set=false
while [ "$1" != "" ]; do
case $1 in
--main ) if $main_set; then
echo "You can only use the --main option once."
exit 1
fi
shift
main=$1
main_set=true
;;
--include ) shift
includes+=("$1")
;;
--includeOnly ) shift
includeOnlys+=("$1")
;;
--framework ) shift
frameworks+=("$1")
;;
* ) echo "Unknown Input: $1"
exit 1
esac
shift
done
if [ -z "$main" ] && [ -z "$frameworks" ]; then
echo "The Main project name is not set."
echo "Would you like to set the default project name as "TuistProject"? (Y/N)"
read yesToContinue
if [ "$yesToContinue" == "N" ] ; then
echo "Exiting the process. π"
exit 1
elif [ "$yesToContinue" == "Y" ] ; then
echo "The TuistProject project will be created. π"
main="TuistProject"
else
echo "Unknown input π"
exit 1
fi
fi
echo "π Start to generate Tuist Projects!"
GeneratorRoot=$(pwd)
echo "βοΈ What is the name of your new project folder?"
echo "βοΈ Your Name of new project folder is : "
read projectName
echo "Nice Name! π"
echo "π I will create the $projectName folder once I finish generating the Tuist hierarchy as you wish."
if [ -d $projectName ]; then
echo "The $projectName is already Exist. π
"
echo "You want to replace the $projectName and Re-create? (Y/N)"
read yesToDelete
if [ "$yesToDelete" == "Y" ]; then
rm -rf $projectName
else
echo "OK. I will Reserve your $projectName π«‘"
exit 1
fi
fi
mkdir $projectName && cd $projectName
TuistProjectRoot=$GeneratorRoot/$projectName
tuist init
cd Tuist
echo 'import ProjectDescription
let config = Config()
' > Config.swift
setDependenciesDefault
cd $TuistProjectRoot
rm -rf Plugins
rm -rf Targets
echo 'import ProjectDescription
let workspaceName = "workspace"
let workspace = Workspace(
name: workspaceName,
projects: [
"Projects/*"
]
)' > Workspace.swift
rm Project.swift
mkdir Projects
cd Tuist && cd ProjectDescriptionHelpers
templateDescriptionHelper "$main"
frameworkDescriptionHelper
scriptsDescriptionHelper
dependencyDescriptionHelper
cd $TuistProjectRoot && cd Projects
ProjectsPath=$(pwd)
mkdir Tool && cd Tool
cd $TuistProjectRoot
echo "π¦ Fetching Test Dependencies 'Quick' and 'Nimble'"
tuist fetch -u
echo "π Fetching Dependencies Completed! π"
cd $GeneratorRoot
cp -r temp/Lint $projectName/Projects/Tool/
if [ -n "$main" ] && [ -z "$frameworks" ]; then
cd $projectName && cd Projects
makeMainApp $projectName $mainApp
tuist generate -n
echo "β
$mainApp Generated!"
fi
cd $TuistProjectRoot
for aFramework in "${frameworks[@]}"; do
cd $ProjectsPath
makeFramework "$aFramework"
tuist generate -n
echo "β
$aFramework Generated!"
done
cd $TuistProjectRoot
for anApplication in "${includeOnlys[@]}"; do
cd $ProjectsPath
makeIncludeOnlyApplication "$anApplication"
echo "β
$anApplication Generated!"
tuist generate -n
done
cd $TuistProjectRoot
for anApplication in "${includes[@]}"; do
cd $ProjectsPath
makeIncludeApplication "$anApplication"
tuist generate -n
echo "β
$anApplication Generated!"
done
cd $TuistProjectRoot
echo 'π All Project has Generated! π«‘'
cd ../
mv ./$projectName ~/
echo "π± Your new project is: $HOME/$projectName π±"