This repository has been archived by the owner on Jan 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
254 lines (222 loc) · 7.26 KB
/
build.xml
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?xml version="1.0" encoding="UTF-8"?>
<project name="Laravel Project" default="welcome" basedir="../" description="Laravel Project Build Targets">
<property name="reserved.env_name" value="testing" />
<property name="env_name" value="" />
<target name="welcome">
<echo message="==================================================" />
<echo message="Hello, welcome to ${phing.project.name} build script!" />
<echo message="There are 2 options 'install' and 'update'" />
<echo message="run 'phing install' when installing a new copy" />
<echo message="run 'phing update' when updating an existing copy" />
<echo message="==================================================" />
</target>
<target name="update">
<echo message="==================================================" />
<echo message="Update laravel and run any database migrations." />
<echo message="You must also have composer and git installed." />
<echo message="Hit enter to accept defaults." />
<echo message="Please make sure your local app is up to date first." level="warning" />
<echo message="==================================================" />
<if>
<isfalse value="${env_name}"/>
<then>
<propertyprompt
propertyName="env_name"
promptText="What is your Laravel environment name?"
defaultValue="local"
/>
</then>
</if>
<if>
<isfalse value="${env_name}"/>
<then>
<fail message="Invalid environment name!" />
</then>
<elseif>
<equals arg1="${env_name}" arg2="${reserved.env_name}" />
<then>
<fail message="Environment name cannot be '${reserved.env_name}'" />
</then>
</elseif>
</if>
<if>
<available file='app/config/${env_name}' type='dir' />
<then>
<!-- do nothing -->
<echo message="Environment found.." />
</then>
<else>
<fail message="Environment 'app/config/${env_name}' doesn't exist." />
</else>
</if>
<!-- composer -->
<echo message="Checking packages..." />
<exec
command="composer update"
passthru="true"
/>
<echo message="Done." />
<!-- migrations -->
<echo message="Running migrations..." />
<exec
command="php artisan migrate --env=${env_name}"
passthru="true"
/>
<exec
command="php artisan kevbaldwyn:migrate-packages --env=${env_name}"
passthru="true"
/>
<echo message="Done." />
</target>
<target name="install">
<echo message="==================================================" />
<echo message="Before installing you must have created a database," />
<echo message="and have the connection details ready." />
<echo message="You must also have composer and git installed." />
<echo message="Hit enter to accept defaults." />
<echo message="==================================================" />
<propertyprompt
propertyName="env_name"
promptText="What is your Laravel environment name. This will create the directory 'app/config/[your-environment-name]' - do not use '${reserved.env_name}'"
defaultValue="local"
/>
<if>
<isfalse value="${env_name}"/>
<then>
<fail message="Invalid environment name!" />
</then>
<elseif>
<equals arg1="${env_name}" arg2="${reserved.env_name}" />
<then>
<fail message="Environment name cannot be '${reserved.env_name}'" />
</then>
</elseif>
<elseif>
<available file='app/config/${env_name}' type='dir' />
<then>
<fail message="The environment 'app/config/${env_name}' already exists." />
</then>
</elseif>
</if>
<propertyprompt
propertyName="env_host"
promptText="The environment host name of the site, ie 'dev.mylocalserver.local', 'localhost', or 'www.example.com'"
/>
<if>
<isfalse value="${env_host}"/>
<then>
<fail message="Invalid environment host name!" />
</then>
</if>
<echo message="Database settings..." />
<propertyprompt
propertyName="db.host"
promptText="Database Host"
defaultValue="localhost"
/>
<propertyprompt
propertyName="db.name"
promptText="Database name"
/>
<if>
<isfalse value="${db.name}"/>
<then>
<fail message="Invalid database name!" />
</then>
</if>
<propertyprompt
propertyName="db.user"
promptText="Database username"
defaultValue="root"
/>
<propertyprompt
propertyName="db.pass"
promptText="Database password"
/>
<propertyprompt
propertyName="db.seedit"
promptText="Would you like to seed the database if available, (y/n)"
defaultValue="y"
/>
<if>
<equals arg1="${db.seedit}" arg2="y" />
<then>
<property name="db.seedflag" value="--seed " />
</then>
<else>
<property name="db.seedflag" value="" />
</else>
</if>
<!-- configure db -->
<echo message="Configuring db..." />
<mkdir dir="app/config/${env_name}" />
<if>
<available file='app/config/${env_name}/database.php' type='file' />
<then>
<delete file="app/config/${env_name}/database.php" failonerror="false" />
</then>
</if>
<copy file="build/database.txt" tofile="app/config/${env_name}/database.php" overwrite="true">
<filterchain>
<replaceregexp>
<regexp pattern="#DB_HOST#" replace="${db.host}" ignoreCase="false" />
<regexp pattern="#DB_NAME#" replace="${db.name}" ignoreCase="false" />
<regexp pattern="#DB_USER#" replace="${db.user}" ignoreCase="false" />
<regexp pattern="#DB_PASS#" replace="${db.pass}" ignoreCase="false" />
</replaceregexp>
</filterchain>
</copy>
<if>
<available file='app/config/${env_name}/app.php' type='file' />
<then>
<delete file="app/config/${env_name}/app.php" failonerror="false" />
</then>
</if>
<copy file="build/app.txt" tofile="app/config/${env_name}/app.php" overwrite="true">
<filterchain>
<replaceregexp>
<regexp pattern="#HOST#" replace="${env_host}" ignoreCase="false" />
</replaceregexp>
</filterchain>
</copy>
<echo message="Done." />
<echo message="Writing environment..." />
<if>
<available file='bootstrap/start-tmp.php' type='file' />
<then>
<delete file="bootstrap/start-tmp.php" failonerror="false" />
</then>
</if>
<copy file="bootstrap/start.php" tofile="bootstrap/start-tmp.php" overwrite="true">
<filterchain>
<replaceregexp>
<regexp pattern="detectEnvironment\(array\(" replace="detectEnvironment(array(${line.separator}${line.separator} '${env_name}' => array('${env_host}')," />
</replaceregexp>
</filterchain>
</copy>
<delete file="bootstrap/start.php" failonerror="false" />
<copy file="bootstrap/start-tmp.php" tofile="bootstrap/start.php" overwrite="true" />
<delete file="bootstrap/start-tmp.php" failonerror="false" />
<echo message="Done." />
<!-- amend .gitignore -->
<append destFile=".gitignore" text="${line.separator}app/config/${env_name}" />
<!-- composer -->
<echo message="Checking packages..." />
<exec
command="composer install"
passthru="true"
/>
<echo message="Done." />
<!-- migrations -->
<echo message="Running db migrations..." />
<exec
command="php artisan migrate ${db.seedflag}--env=${env_name}"
passthru="true"
/>
<exec
command="php artisan kevbaldwyn:migrate-packages --env=${env_name}"
passthru="true"
/>
<echo message="Done." />
</target>
</project>