forked from appium/appium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset.bat
173 lines (156 loc) · 5.27 KB
/
reset.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
@echo off
:: Go to directory containing batch file
FOR /f %%i in ("%0") DO SET curpath=%%~dpi
CD /d %curpath%
:: Flags to determine which parts will be executed
SET doDev=0
SET doSelendroid=0
SET doAndroid=0
SET doVerbose=0
SET doForce=0
SET pigsFly=0
:: Read in command line switches
FOR %%A IN (%*) DO IF "%%A" == "--dev" SET doDev=1
FOR %%A IN (%*) DO IF "%%A" == "--android" SET doAndroid=1
FOR %%A IN (%*) DO IF "%%A" == "--selendroid" SET doSelendroid=1
FOR %%A IN (%*) DO IF "%%A" == "--verbose" SET doVerbose=1
FOR %%A IN (%*) DO IF "%%A" == "--force" SET doForce=1
:: If nothing is flagged do only android
IF %doDev% == 0 IF %doSelendroid% == 0 IF %doAndroid% == 0 SET doAndroid=1
:: Install Package and Dependencies
ECHO.
ECHO =====Installing dependencies with npm=====
ECHO.
CALL :runCmd "npm install ."
:: Install Dev Dependencies
if %doDev% == 1 (
ECHO.
ECHO =====Installing development dependencies with npm=====
ECHO.
CALL :runCmd "npm install . --dev"
ECHO.
)
:: Reset Android
if %doAndroid% == 1 (
ECHO.
ECHO =====Resetting Android=====
ECHO.
CALL :runCmd "node_modules\.bin\grunt configAndroidBootstrap"
CALL :runCmd "node_modules\.bin\grunt buildAndroidBootstrap"
CALL :runCmd "node_modules\.bin\grunt setConfigVer:android"
ECHO.
ECHO =====Reset Android Complete=====
ECHO.
ECHO =====Resetting Unlock.apk=====
ECHO.
CALL :runCmd "RD /S /Q build\unlock_apk | VER > NUL"
CALL :runCmd "MKDIR build\unlock_apk"
ECHO Building Unlock.apk
CALL :runCmd "git submodule update --init submodules\unlock_apk"
CALL :runCmd "PUSHD submodules\unlock_apk"
CALL :runCmd "ant clean"
CALL :runCmd "ant debug"
CALL :runCmd "POPD"
CALL :runCmd "COPY submodules\unlock_apk\bin\unlock_apk-debug.apk build\unlock_apk\unlock_apk-debug.apk"
ECHO.
ECHO =====Reset Unlock.apk Complete=====
:: Reset Android Dev
IF %doDev% == 1 (
ECHO.
ECHO =====Resetting API Demos=====
ECHO.
ECHO Cloning/updating Android test app: ApiDemos
CALL :runCmd "git submodule update --init submodules\ApiDemos"
CALL :runCmd "RD /S /Q sample-code\apps\ApiDemos | VER > NUL"
CALL :runCmd "MKDIR sample-code\apps\ApiDemos"
CALL :runCmd "XCOPY submodules\ApiDemos sample-code\apps\ApiDemos /E /Q"
CALL :runCmd "node_modules\.bin\grunt configAndroidApp:ApiDemos"
CALL :runCmd "node_modules\.bin\grunt buildAndroidApp:ApiDemos"
ECHO.
ECHO =====Reset API Demos Complete=====
)
)
:: Reset Selendroid
IF %doSelendroid% == 1 (
ECHO.
ECHO =====Resetting Selendroid=====
ECHO.
ECHO Clearing out any old modified server apks
CALL :runCmd "RD -/S /Q %windir%\Temp\selendroid*.apk | VER > NUL"
ECHO Cloning/updating selendroid
CALL :runCmd "RD -/S /Q submodules\selendroid\selendroid-server\target | VER > NUL"
CALL :runCmd "git submodule update --init submodules\selendroid"
CALL :runCmd "RD /S /Q selendroid | VER > NUL"
ECHO Building selendroid server and supporting libraries
CALL :runCmd "set MAVEN_OPTS=-Xss1024k"
CALL :runCmd "node_modules\.bin\grunt buildSelendroidServer"
CALL :runCmd "set MAVEN_OPTS="
:: Reset Selendroid Dev
IF %doDev% == 1 (
ECHO.
ECHO =====Resetting Selendroid - Dev=====
ECHO.
ECHO Linking selendroid test app: WebViewDemo
CALL :runCmd "RD /S /Q sample-code\apps\WebViewDemo | VER > NUL"
CALL :runCmd "MKDIR sample-code\apps\WebViewDemo"
CALL :runCmd "XCOPY submodules\selendroid\selendroid-test-app sample-code\apps\WebViewDemo /E /Q"
CALL :uninstallAndroidApp com.example.android.apis.selendroid
CALL :uninstallAndroidApp io.selendroid.testapp
CALL :uninstallAndroidApp io.selendroid.testapp.selendroid
CALL :uninstallAndroidApp org.openqa.selendroid.testapp
CALL :uninstallAndroidApp openqa.selendroid.testapp.selendroid
ECHO.
ECHO =====Reset Selendroid - Dev Complete=====
)
ECHO Setting Selendroid config to Appium's version
CALL :runCmd "node_modules\.bin\grunt setConfigVer:selendroid"
ECHO.
ECHO =====Reset Selendroid Complete=====
)
:: Reset Gappium
IF %pigsFly% == 1 (
ECHO.
ECHO =====Resetting Gappium=====
ECHO.
ECHO Clearing out old links
CALL :runCmd "RD /S /Q sample-code\apps\io.appium.gappium.sampleapp | VER > NUL"
ECHO Cloning/updating Gappium
CALL :runCmd "git submodule update --init submodules\io.appium.gappium.sampleapp"
CALL :runCmd "PUSHD submodules\io.appium.gappium.sampleapp"
ECHO Building Gappium test app
CALL :runCmd "reset.bat"
CALL :runCmd "POPD"
ECHO Linking Gappium test app
CALL :runCmd "XCOPY submodules\io.appium.gappium.sampleapp sample-code\apps\io.appium.gappium.sampleapp /E /Q"
ECHO.
ECHO =====Reset Gappium=====
)
GOTO :EOF
:: Function to uninstall an Android app
:uninstallAndroidApp
ECHO Attempting to uninstall android app %~1
CALL :runCmd "adb uninstall %~1 | VER > NUL"
GOTO :EOF
:: Function to run commands
:runCmd - function to run a command
IF %doVerbose% == 1 ECHO %~1
CALL %~1
IF %ERRORLEVEL% NEQ 0 IF %doForce% == 0 (
CD /D %curpath%
ECHO.
ECHO Stopping because there was an error and --force was not used
CALL :halt 1
)
GOTO :EOF
:: Sets the errorlevel and stops the batch immediately
:halt
CALL :__SetErrorLevel %1
CALL :__ErrorExit 2> NUL
GOTO :EOF
:__ErrorExit
REM Creates a syntax error, stops immediately
()
GOTO :EOF
:__SetErrorLevel
EXIT /B %TIME:~-2%
GOTO :EOF