-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathml.bat
140 lines (112 loc) · 2.4 KB
/
ml.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
@echo off
set RUBYFOUND=
for %%e in (%PATHEXT%) do (
for %%X in (ruby%%e) do (
if not defined RUBYFOUND (
set RUBYFOUND=%%~$PATH:X
)
)
)
if not defined RUBYFOUND goto needruby
if "%1"=="self-test" goto selftest
IF not "%1"=="new" goto rubydeployer
SHIFT
IF "%1"=="" goto usage
set app_name=%1
SHIFT
set GITFOUND=
for %%e in (%PATHEXT%) do (
for %%X in (git%%e) do (
if not defined GITFOUND (
set GITFOUND=%%~$PATH:X
)
)
)
if not defined GITFOUND goto needgit
IF EXIST %app_name% GOTO alreadyexists
set BRANCH=master
set INIT_GIT=0
set APPTYPE=mvc
:loop
if not "%1"=="" (
if "%1"=="--branch" (
set BRANCH=%2
shift
)
if "%1"=="--app-type" (
set APPTYPE=%2
shift
)
shift
goto :loop
)
if not "%APPTYPE%"=="mvc" if not "%APPTYPE%"=="rest" if not "%APPTYPE%"=="hybrid" (
echo Valid values for app-type are mvc, rest and hybrid. Aborting.
exit /b
)
echo.
echo Creating new Application: %app_name%...
cmd /c git clone git://github.com/marklogic/roxy.git -b %BRANCH% %app_name%
pushd %app_name%
rmdir /Q /S .git
del /F /Q .gitignore
if "%APPTYPE%"=="rest" (
REM For a REST application, we won't be using the MVC code. Remove it.
REM mvc and hybrid apps will use it.
rmdir /S /Q src
mkdir src
echo.
echo No initial source code is provided for REST apps. You can copy code from Application Builder under the source directory.
)
cmd /c ml init %app_name% --app-type=%APPTYPE%
popd
echo done
echo.
IF NOT EXIST %app_name% GOTO end
if not "%1"=="--git" goto end
pushd %app_name%
echo Creating a git repository
echo.
cmd /c git init
cmd /c git add .
cmd /c git commit -q -m "Initial Commit"
echo ...done
echo.
popd
goto end
:selftest
if NOT EXIST deploy\test\test_main.rb GOTO missingdeploy
ruby -Ideploy -Ideploy\lib -Ideploy\test deploy\test\test_main.rb
goto end
:rubydeployer
if NOT EXIST deploy\lib\ml.rb GOTO missingdeploy
ruby -Ideploy -Ideploy\lib deploy\lib\ml.rb %*
goto end
:missingdeploy
echo.
echo You must run this command inside a valid Roxy Project
echo.
goto end
:needruby
echo.
echo Ruby is required to run the ml scripts.
echo.
goto end
:needgit
echo.
echo Git is required to use the new command.
echo.
goto end
:alreadyexists
echo.
echo %app_name% already exists. Aborting
echo.
goto end
:usage
echo Usage: ml new app-name [--git]
echo.
echo.
echo use --git to automatically configure a git repo
echo.
goto end
:end