-
Notifications
You must be signed in to change notification settings - Fork 3
/
skinny.bat
executable file
·406 lines (372 loc) · 12.2 KB
/
skinny.bat
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
@ECHO OFF
REM
REM skinny command for Windows
REM
SET command=%1
SET option=%2
IF NOT DEFINED command (
GOTO show_help
)
IF EXIST "ivy2" (
XCOPY ivy2\* %HOMEPATH%\.ivy2\. /E /D /q
RMDIR ivy2 /s /q
)
IF %command%==new (
ECHO Sorry to say, this operation is not supported yet on Windows...
GOTO script_eof
)
IF %command%==upgrade (
ECHO Sorry to say, this operation is not supported yet on Windows...
GOTO script_eof
)
IF %command%==run (
GOTO run
)
IF %command%==server (
GOTO run
)
IF %command%==s (
GOTO run
)
IF %command%==debug (
GOTO debug
)
IF %command%==d (
GOTO debug
)
IF %command%==clean (
sbt clean
GOTO script_eof
)
IF %command%==update (
sbt update
GOTO script_eof
)
IF %command%==console (
sbt "dev/console"
GOTO script_eof
)
IF %command%==compile (
sbt "dev/compile"
GOTO script_eof
)
IF "%command%"=="~compile" (
sbt "project dev" "~;compile"
GOTO script_eof
)
IF %command%==test (
SET SKINNY_ENV=test
sbt "dev/test"
GOTO script_eof
)
IF "%command%"=="~test" (
SET SKINNY_ENV=test
sbt "project dev" "~;test"
GOTO script_eof
)
IF %command%==test-quick (
SET SKINNY_ENV=test
sbt "dev/testQuick"
GOTO script_eof
)
IF %command%==testQuick (
SET SKINNY_ENV=test
sbt "dev/testQuick"
GOTO script_eof
)
IF "%command%"=="~test-quick" (
SET SKINNY_ENV=test
sbt "project dev" "~;testQuick"
GOTO script_eof
)
IF "%command%"=="~testQuick" (
SET SKINNY_ENV=test
sbt "project dev" "~;testQuick"
GOTO script_eof
)
IF %command%==test-only (
SET SKINNY_ENV=test
sbt "dev/test-only %2"
GOTO script_eof
)
IF %command%==testOnly (
SET SKINNY_ENV=test
sbt "dev/test-only %2"
GOTO script_eof
)
IF "%command%"=="~test-only" (
SET SKINNY_ENV=test
sbt "project dev" "~;testOnly %2"
GOTO script_eof
)
IF "%command%"=="~testOnly" (
SET SKINNY_ENV=test
sbt "project dev" "~;testOnly %2"
GOTO script_eof
)
IF "%command%"=="test:coverage" (
SET SKINNY_ENV=test
sbt "coverage" "dev/test"
GOTO script_eof
)
IF "%command%"=="scalajs:watch" (
SET SUB_COMMAND="~;fastOptJS"
GOTO scalajs_task
)
IF "%command%"=="scalajs:package" (
SET SUB_COMMAND="fullOptJS"
GOTO scalajs_task
)
SET is_generator=false
SET generator_params=
IF "%command%"=="g" SET is_generator=true
IF "%command%"=="generate" SET is_generator=true
IF "%is_generator%"=="true" (
IF "%2"=="" (
ECHO Usage: skinny g/generate [type] [options...]
) ELSE (
:generator_loop_begin
IF "%2"=="" GOTO generator_loop_end
SET generator_params=%generator_params% %2
SHIFT
GOTO generator_loop_begin
:generator_loop_end
REM Delete the head whitespace character
SET generator_params=%generator_params:~1%
RMDIR task\src\main\resources /S /q
RMDIR task\target /S /q
MKDIR task\src\main\resources
XCOPY src\main\resources task\src\main\resources /E /D /q
DEL task\src\main\resources\logback.xml /Q
sbt "task/run generate:%generator_params%"
)
GOTO script_eof
)
IF "%command%"=="task:clean" (
RMDIR task\src\main\resources /S /q
MKDIR task\src\main\resources
XCOPY src\main\resources task\src\main\resources /E /D /q
DEL task\src\main\resources\logback.xml /Q
sbt "task/clean"
GOTO script_eof
)
SET is_task_run=false
SET task_run_params=
IF "%command%"=="task:run" SET is_task_run=true
IF "%is_task_run%"=="true" (
:task_run_loop_begin
IF "%2"=="" GOTO task_run_loop_end
SET task_run_params=%task_run_params% %2
SHIFT
GOTO task_run_loop_begin
:task_run_loop_end
REM Delete the head whitespace character
SET task_run_params=%task_run_params:~1%
RMDIR task\src\main\resources /S /q
MKDIR task\src\main\resources
XCOPY src\main\resources task\src\main\resources /E /D /q
DEL task\src\main\resources\logback.xml /Q
sbt "task/run %task_run_params%"
GOTO script_eof
)
IF "%command%"=="routes" (
RMDIR task\src\main\resources /S /q
RMDIR task\target /S /q
MKDIR task\src\main\resources
XCOPY src\main\resources task\src\main\resources /E /D /q
DEL task\src\main\resources\logback.xml /Q
sbt "task/run routes"
GOTO script_eof
)
IF "%command%"=="db:migrate" (
RMDIR task\src\main\resources /S /q
RMDIR task\target /S /q
MKDIR task\src\main\resources
XCOPY src\main\resources task\src\main\resources /E /D /q
DEL task\src\main\resources\logback.xml /Q
sbt "task/run db:migrate %2"
GOTO script_eof
)
IF "%command%"=="db:repair" (
RMDIR task\src\main\resources /S /q
RMDIR task\target /S /q
MKDIR task\src\main\resources
XCOPY src\main\resources task\src\main\resources /E /D /q
DEL task\src\main\resources\logback.xml /Q
sbt "task/run db:repair %2"
GOTO script_eof
)
IF %command%==eclipse (
IF NOT EXIST "project\_skinny_eclipse.sbt" (
ECHO addSbtPlugin^(^"com.typesafe.sbteclipse^" %% ^"sbteclipse-plugin^" %% ^"5.2.4^"^) > "project\_skinny_eclipse.sbt"
)
sbt eclipse
GOTO script_eof
)
SET is_gen_idea=false
IF "%command%"=="idea" SET is_gen_idea=true
IF "%command%"=="gen-idea" SET is_gen_idea=true
IF "%is_gen_idea%"=="true" (
sbt gen-idea
GOTO script_eof
)
IF %command%==package (
RMDIR build /S /q
MKDIR build
XCOPY src\* build\src\* /E /D /q
RMDIR task\src\main\resources /S /q
RMDIR task\target /S /q
MKDIR task\src\main\resources
XCOPY src\main\resources task\src\main\resources /E /D /q
DEL task\src\main\resources\logback.xml /Q
sbt "task/run assets:precompile" "build/package"
GOTO script_eof
)
IF "%command%"=="package:standalone" (
IF NOT EXIST "project\_skinny_assembly.sbt" (
ECHO addSbtPlugin^(^"com.eed3si9n^" %% ^"sbt-assembly^" %% ^"0.14.7^"^) > "project\_skinny_assembly.sbt"
(
ECHO mainClass in assembly := Some^(^"skinny.standalone.JettyLauncher^"^)
ECHO _root_.sbt.Keys.test in assembly := {}
ECHO.resourceGenerators in Compile += ^(Def.task {
ECHO. val ^(managedBase, base^) = ^(resourceManaged.value, baseDirectory.value^)
ECHO. val webappBase = base / "src" / "main" / "webapp"
ECHO. for ^( ^(from, to^) ^<- ^webappBase ** "*" `pair` Path.rebase(webappBase, managedBase / "main/"^) ^)
ECHO. yield {
ECHO. Sync.copy^(from, to^)
ECHO. to
ECHO. }
ECHO.}^).taskValue
)> "_skinny_assembly_settings.sbt"
)
RMDIR standalone-build /S /q
MKDIR standalone-build
XCOPY src\* standalone-build\src\* /E /D /q
xcopy _skinny_assembly_settings.sbt standalone-build\ /q
RMDIR task\src\main\resources /S /q
RMDIR task\target /S /q
MKDIR task\src\main\resources
XCOPY src\main\resources task\src\main\resources /E /D /q
DEL task\src\main\resources\logback.xml /Q
sbt "task/run assets:precompile" "standaloneBuild/assembly"
GOTO script_eof
)
IF %command%==publish (
rmdir build /S /q
mkdir build
xcopy src\* build\src\* /E /D /q
RMDIR task\src\main\resources /S /q
RMDIR task\target /S /q
MKDIR task\src\main\resources
XCOPY src\main\resources task\src\main\resources /E /D /q
DEL task\src\main\resources\logback.xml /Q
sbt "task/run assets:precompile" "build/publish"
GOTO script_eof
)
REM ***************************************************************************
REM Didn't select command.
REM ***************************************************************************
:show_help
ECHO.
ECHO Usage: skinny [COMMAND] [OPTIONS]...
ECHO.
ECHO new : will create new Skinny application
ECHO upgrade : will upgrade Skinny app project
ECHO run/server/s : will run application for local development
ECHO debug/d : will run application with JDWP. default port 5005
ECHO clean : will clear target directory
ECHO update : will run sbt update
ECHO console : will run sbt console
ECHO compile : will compile all the classes
ECHO ~compile : will compile all the classes when changes are detected
ECHO db:migrate : will execute database migration
ECHO db:repair : will recover when previous migration failed
ECHO routes : will display routes information"
ECHO test : will run all the tests
ECHO ~test : will run all the tests when changes are detected
ECHO testQuick : will run only failed tests
ECHO ~testQuick : will run only failed tests when changes are detected
ECHO testOnly : will run the specified test
ECHO ~testOnly : will run the specified test when changes are detected
ECHO test:coverage : will run all the tests and output coverage reports
ECHO package : will create *.war file to deploy
ECHO package:standalone : will create *.jar file to run as stand alone app
ECHO publish : will publish *.war file to repository
ECHO.
ECHO scalajs:watch : will watch Scala.js Scala code change and convert to JS
ECHO scalajs:package : will convert Scala.js Scala code to JS file
ECHO.
ECHO eclipse : will setup Scala IDE settings
ECHO idea/gen-idea : will setup IntelliJ IDEA settings
ECHO.
ECHO task:clean : will clean task project's target directory
ECHO task:run : will run tasks
ECHO.
ECHO g/generate controller : will generate controller
ECHO g/generate model : will generate model
ECHO g/generate migration : will generate db migration file
ECHO.
ECHO g/generate scaffold : will generate scaffold files with ssp templates
ECHO g/generate scaffold:scaml : will generate scaffold files with scaml templates
ECHO g/generate scaffold:jade : will generate scaffold files with jade templates
ECHO.
ECHO g/generate reverse-scaffold : will generate from existing database
ECHO g/generate reverse-scaffold:scaml : will generate from existing database
ECHO g/generate reverse-scaffold:jade : will generate from existing database
GOTO script_eof
REM ***************************************************************************
REM run command
REM ***************************************************************************
:run
IF "%option%"=="-precompile" (
sbt "project precompileDev" "~;container:restart"
) ELSE IF "%option%"=="--precompile" (
sbt "project precompileDev" "~;container:restart"
) ELSE (
sbt "~;container:restart"
)
GOTO script_eof
REM ***************************************************************************
REM debug command
REM ***************************************************************************
:debug
IF "%option%"=="-precompile" (
IF "%3"=="" (
sbt-debug 5005 "project precompileDev" "~;container:restart"
) ELSE (
sbt-debug %3 "project precompileDev" "~;container:restart"
)
) ELSE IF "%option%"=="--precompile" (
IF "%3"=="" (
sbt-debug 5005 "project precompileDev" "~;container:restart"
) ELSE (
sbt-debug %3 "project precompileDev" "~;container:restart"
)
) ELSE (
IF "%2"=="" (
sbt-debug 5005 "~;container:restart"
) ELSE (
sbt-debug %2 "~;container:restart"
)
)
GOTO script_eof
:scalajs_task
IF NOT EXIST "project\_skinny_scalajs.sbt" (
ECHO resolvers += "scala-js-release" at "http://dl.bintray.com/scala-js/scala-js-releases" > "project\_skinny_scalajs.sbt"
ECHO addSbtPlugin^("org.scala-js" %% "sbt-scalajs" %% "0.6.24"^) >> "project\_skinny_scalajs.sbt"
ECHO lazy val scalajs = ^(project in file^("src/main/webapp/WEB-INF/assets"^)^).settings^( > "_skinny_scalajs_settings.sbt"
ECHO name := "application", // JavaScript file name >> "_skinny_scalajs_settings.sbt"
ECHO scalaVersion := "2.12.6", >> "_skinny_scalajs_settings.sbt"
ECHO unmanagedSourceDirectories in Compile ^<= baseDirectory^(_ / "scala"^).value, >> "_skinny_scalajs_settings.sbt"
ECHO fullResolvers ~= { _.filterNot^(_.name == "jcenter"^) }, >> "_skinny_scalajs_settings.sbt"
ECHO libraryDependencies ++= Seq^( >> "_skinny_scalajs_settings.sbt"
ECHO "org.scala-js" %%%%%% "scalajs-dom" %% "0.9.6", >> "_skinny_scalajs_settings.sbt"
ECHO "be.doeraene" %%%%%% "scalajs-jquery" %% "0.9.4", >> "_skinny_scalajs_settings.sbt"
ECHO "io.monix" %%%% "minitest" %% "2.1.1" %% "test" >> "_skinny_scalajs_settings.sbt"
ECHO ^), >> "_skinny_scalajs_settings.sbt"
ECHO crossTarget in Compile := baseDirectory^(_ / ".." / ".." / "assets" / "js"^).value >> "_skinny_scalajs_settings.sbt"
ECHO ^).enablePlugins^(ScalaJSPlugin^) >> "_skinny_scalajs_settings.sbt"
)
sbt "project scalajs" %SUB_COMMAND%
GOTO script_eof
:script_eof