Skip to content
This repository was archived by the owner on Jan 29, 2021. It is now read-only.

Commit 904403c

Browse files
committed
Added command line arguments
1 parent d393b82 commit 904403c

File tree

1 file changed

+42
-35
lines changed

1 file changed

+42
-35
lines changed

build.xml

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project name="Laravel Project" default="welcome" basedir="../" description="Laravel Project Build Targets">
33

4-
<property name="reserved.env.name" value="testing" />
4+
<property name="reserved.env_name" value="testing" />
55

6+
<property name="env_name" value="" />
7+
68
<target name="welcome">
79
<echo message="==================================================" />
810
<echo message="Hello, welcome to ${phing.project.name} build script!" />
@@ -21,34 +23,39 @@
2123
<echo message="Hit enter to accept defaults." />
2224
<echo message="Please make sure your local app is up to date first." level="warning" />
2325
<echo message="==================================================" />
24-
25-
<propertyprompt
26-
propertyName="env.name"
27-
promptText="What is your Laravel environment name?"
28-
defaultValue="local"
29-
/>
26+
27+
<if>
28+
<isfalse value="${env_name}"/>
29+
<then>
30+
<propertyprompt
31+
propertyName="env_name"
32+
promptText="What is your Laravel environment name?"
33+
defaultValue="local"
34+
/>
35+
</then>
36+
</if>
3037

3138
<if>
32-
<isfalse value="${env.name}"/>
39+
<isfalse value="${env_name}"/>
3340
<then>
3441
<fail message="Invalid environment name!" />
3542
</then>
3643
<elseif>
37-
<equals arg1="${env.name}" arg2="${reserved.env.name}" />
44+
<equals arg1="${env_name}" arg2="${reserved.env_name}" />
3845
<then>
39-
<fail message="Environment name cannot be '${reserved.env.name}'" />
46+
<fail message="Environment name cannot be '${reserved.env_name}'" />
4047
</then>
4148
</elseif>
4249
</if>
4350

4451
<if>
45-
<available file='app/config/${env.name}' type='dir' />
52+
<available file='app/config/${env_name}' type='dir' />
4653
<then>
4754
<!-- do nothing -->
4855
<echo message="Environment found.." />
4956
</then>
5057
<else>
51-
<fail message="Environment 'app/config/${env.name}' doesn't exist." />
58+
<fail message="Environment 'app/config/${env_name}' doesn't exist." />
5259
</else>
5360
</if>
5461

@@ -63,11 +70,11 @@
6370
<!-- migrations -->
6471
<echo message="Running migrations..." />
6572
<exec
66-
command="php artisan migrate --env=${env.name}"
73+
command="php artisan migrate --env=${env_name}"
6774
passthru="true"
6875
/>
6976
<exec
70-
command="php artisan kevbaldwyn:migrate-packages --env=${env.name}"
77+
command="php artisan kevbaldwyn:migrate-packages --env=${env_name}"
7178
passthru="true"
7279
/>
7380
<echo message="Done." />
@@ -85,37 +92,37 @@
8592
<echo message="==================================================" />
8693

8794
<propertyprompt
88-
propertyName="env.name"
89-
promptText="What is your Laravel environment name. This will create the directory 'app/config/[your-environment-name]' - do not use '${reserved.env.name}'"
95+
propertyName="env_name"
96+
promptText="What is your Laravel environment name. This will create the directory 'app/config/[your-environment-name]' - do not use '${reserved.env_name}'"
9097
defaultValue="local"
9198
/>
9299

93100
<if>
94-
<isfalse value="${env.name}"/>
101+
<isfalse value="${env_name}"/>
95102
<then>
96103
<fail message="Invalid environment name!" />
97104
</then>
98105
<elseif>
99-
<equals arg1="${env.name}" arg2="${reserved.env.name}" />
106+
<equals arg1="${env_name}" arg2="${reserved.env_name}" />
100107
<then>
101-
<fail message="Environment name cannot be '${reserved.env.name}'" />
108+
<fail message="Environment name cannot be '${reserved.env_name}'" />
102109
</then>
103110
</elseif>
104111
<elseif>
105-
<available file='app/config/${env.name}' type='dir' />
112+
<available file='app/config/${env_name}' type='dir' />
106113
<then>
107-
<fail message="The environment 'app/config/${env.name}' already exists." />
114+
<fail message="The environment 'app/config/${env_name}' already exists." />
108115
</then>
109116
</elseif>
110117
</if>
111118

112119
<propertyprompt
113-
propertyName="env.host"
120+
propertyName="env_host"
114121
promptText="The environment host name of the site, ie 'dev.mylocalserver.local', 'localhost', or 'www.example.com'"
115122
/>
116123

117124
<if>
118-
<isfalse value="${env.host}"/>
125+
<isfalse value="${env_host}"/>
119126
<then>
120127
<fail message="Invalid environment host name!" />
121128
</then>
@@ -166,14 +173,14 @@
166173

167174
<!-- configure db -->
168175
<echo message="Configuring db..." />
169-
<mkdir dir="app/config/${env.name}" />
176+
<mkdir dir="app/config/${env_name}" />
170177
<if>
171-
<available file='app/config/${env.name}/database.php' type='file' />
178+
<available file='app/config/${env_name}/database.php' type='file' />
172179
<then>
173-
<delete file="app/config/${env.name}/database.php" failonerror="false" />
180+
<delete file="app/config/${env_name}/database.php" failonerror="false" />
174181
</then>
175182
</if>
176-
<copy file="build/database.txt" tofile="app/config/${env.name}/database.php" overwrite="true">
183+
<copy file="build/database.txt" tofile="app/config/${env_name}/database.php" overwrite="true">
177184
<filterchain>
178185
<replaceregexp>
179186
<regexp pattern="#DB_HOST#" replace="${db.host}" ignoreCase="false" />
@@ -184,15 +191,15 @@
184191
</filterchain>
185192
</copy>
186193
<if>
187-
<available file='app/config/${env.name}/app.php' type='file' />
194+
<available file='app/config/${env_name}/app.php' type='file' />
188195
<then>
189-
<delete file="app/config/${env.name}/app.php" failonerror="false" />
196+
<delete file="app/config/${env_name}/app.php" failonerror="false" />
190197
</then>
191198
</if>
192-
<copy file="build/app.txt" tofile="app/config/${env.name}/app.php" overwrite="true">
199+
<copy file="build/app.txt" tofile="app/config/${env_name}/app.php" overwrite="true">
193200
<filterchain>
194201
<replaceregexp>
195-
<regexp pattern="#HOST#" replace="${env.host}" ignoreCase="false" />
202+
<regexp pattern="#HOST#" replace="${env_host}" ignoreCase="false" />
196203
</replaceregexp>
197204
</filterchain>
198205
</copy>
@@ -208,7 +215,7 @@
208215
<copy file="bootstrap/start.php" tofile="bootstrap/start-tmp.php" overwrite="true">
209216
<filterchain>
210217
<replaceregexp>
211-
<regexp pattern="detectEnvironment\(array\(" replace="detectEnvironment(array(${line.separator}${line.separator} '${env.name}' => array('${env.host}')," />
218+
<regexp pattern="detectEnvironment\(array\(" replace="detectEnvironment(array(${line.separator}${line.separator} '${env_name}' => array('${env_host}')," />
212219
</replaceregexp>
213220
</filterchain>
214221
</copy>
@@ -219,7 +226,7 @@
219226

220227

221228
<!-- amend .gitignore -->
222-
<append destFile=".gitignore" text="${line.separator}app/config/${env.name}" />
229+
<append destFile=".gitignore" text="${line.separator}app/config/${env_name}" />
223230

224231
<!-- composer -->
225232
<echo message="Checking packages..." />
@@ -232,11 +239,11 @@
232239
<!-- migrations -->
233240
<echo message="Running db migrations..." />
234241
<exec
235-
command="php artisan migrate ${db.seedflag}--env=${env.name}"
242+
command="php artisan migrate ${db.seedflag}--env=${env_name}"
236243
passthru="true"
237244
/>
238245
<exec
239-
command="php artisan kevbaldwyn:migrate-packages --env=${env.name}"
246+
command="php artisan kevbaldwyn:migrate-packages --env=${env_name}"
240247
passthru="true"
241248
/>
242249
<echo message="Done." />

0 commit comments

Comments
 (0)