Skip to content

Commit fd993ad

Browse files
committed
Issue 155, extra info around IPA use cases
1 parent 699bbb3 commit fd993ad

File tree

4 files changed

+393
-3
lines changed

4 files changed

+393
-3
lines changed

_build.new.bat

Lines changed: 386 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,386 @@
1+
@ECHO OFF
2+
setlocal enabledelayedexpansion
3+
4+
SET "dlurl=https://github.com/HL7/fhir-ig-publisher/releases/latest/download/publisher.jar"
5+
SET "publisher_jar=publisher.jar"
6+
SET "input_cache_path=%CD%\input-cache\"
7+
SET "skipPrompts=false"
8+
SET "upper_path=..\"
9+
SET "scriptdlroot=https://raw.githubusercontent.com/HL7/ig-publisher-scripts/main"
10+
SET "build_bat_url=%scriptdlroot%/_build.bat"
11+
SET "build_sh_url=%scriptdlroot%/_build.sh"
12+
13+
14+
15+
:: Debugging statements to check jar file location
16+
ECHO Checking for publisher.jar in %input_cache_path%
17+
IF EXIST "%input_cache_path%%publisher_jar%" (
18+
SET "jar_location=%input_cache_path%%publisher_jar%"
19+
ECHO Found publisher.jar in input-cache
20+
) ELSE (
21+
ECHO Checking for publisher.jar in %upper_path%
22+
IF EXIST "%upper_path%%publisher_jar%" (
23+
SET "jar_location=%upper_path%%publisher_jar%"
24+
ECHO Found publisher.jar in parent folder
25+
) ELSE (
26+
SET "jar_location=not_found"
27+
SET "default_choice=1"
28+
ECHO publisher.jar not found in input-cache or parent folder
29+
)
30+
)
31+
32+
33+
:: Handle command-line argument to bypass the menu
34+
IF NOT "%~1"=="" (
35+
IF /I "%~1"=="update" SET "userChoice=1"
36+
IF /I "%~1"=="build" SET "userChoice=2"
37+
IF /I "%~1"=="nosushi" SET "userChoice=3"
38+
IF /I "%~1"=="notx" SET "userChoice=4"
39+
IF /I "%~1"=="jekyll" SET "userChoice=5"
40+
IF /I "%~1"=="clean" SET "userChoice=6"
41+
IF /I "%~1"=="exit" SET "userChoice=0"
42+
GOTO executeChoice
43+
)
44+
45+
echo ---------------------------------------------------------------
46+
ECHO Checking internet connection...
47+
PING tx.fhir.org -4 -n 1 -w 4000 >nul 2>&1 && SET "online_status=true" || SET "online_status=false"
48+
49+
IF "%online_status%"=="true" (
50+
ECHO We're online and tx.fhir.org is available.
51+
FOR /F "tokens=2 delims=:" %%a IN ('curl -s https://api.github.com/repos/HL7/fhir-ig-publisher/releases/latest ^| findstr "tag_name"') DO SET "latest_version=%%a"
52+
SET "latest_version=!latest_version:"=!"
53+
SET "latest_version=!latest_version: =!"
54+
SET "latest_version=!latest_version:~0,-1!"
55+
) ELSE (
56+
ECHO We're offline or tx.fhir.org is not available, can only run the publisher without TX...
57+
SET "txoption=-tx n/a"
58+
SET "latest_version=unknown"
59+
SET "default_choice=4"
60+
)
61+
62+
echo ---------------------------------------------------------------
63+
64+
65+
IF NOT "%jar_location%"=="not_found" (
66+
FOR /F "tokens=*" %%i IN ('java "-Dfile.encoding=UTF-8" -jar "%jar_location%" -v 2^>^&1') DO SET "publisher_version=%%i"
67+
SET "publisher_version=!publisher_version:"=!"
68+
ECHO Detected publisher version: !publisher_version!
69+
) ELSE (
70+
SET "publisher_version=unknown"
71+
ECHO publisher.jar location is not found
72+
)
73+
74+
ECHO Publisher version: !publisher_version!; Latest is !latest_version!
75+
76+
IF NOT "%online_status%"=="true" (
77+
ECHO We're offline.
78+
) ELSE (
79+
IF NOT "!publisher_version!"=="!latest_version!" (
80+
ECHO An update is recommended.
81+
SET "default_choice=1"
82+
) ELSE (
83+
ECHO Publisher is up to date.
84+
SET "default_choice=2"
85+
)
86+
)
87+
88+
echo ---------------------------------------------------------------
89+
echo.
90+
91+
echo Please select an option:
92+
echo 1. Download or update publisher
93+
echo 2. Build IG
94+
echo 3. Build IG - no sushi
95+
echo 4. Build IG - force no TX server
96+
echo 5. Jekyll build
97+
echo 6. Clean up temp directories
98+
echo 0. Exit
99+
:: echo [Press Enter for default (%default_choice%) or type an option number:]
100+
echo.
101+
102+
:: Using CHOICE to handle input with timeout
103+
:: ECHO [Enter=Continue, 1-7=Option, 0=Exit]
104+
choice /C 12345670 /N /CS /D %default_choice% /T 5 /M "Choose an option number or wait 5 seconds for default (%default_choice%):"
105+
SET "userChoice=%ERRORLEVEL%"
106+
107+
108+
:executeChoice
109+
echo You selected: %userChoice%
110+
111+
IF "%userChoice%"=="1" GOTO downloadpublisher
112+
IF "%userChoice%"=="2" GOTO publish_once
113+
IF "%userChoice%"=="3" GOTO publish_nosushi
114+
IF "%userChoice%"=="4" GOTO publish_notx
115+
IF "%userChoice%"=="5" GOTO debugjekyll
116+
IF "%userChoice%"=="6" GOTO clean
117+
IF "%userChoice%"=="0" EXIT /B
118+
119+
:end
120+
121+
122+
123+
:debugjekyll
124+
echo Running Jekyll build...
125+
jekyll build -s temp/pages -d output
126+
GOTO end
127+
128+
129+
:clean
130+
echo Cleaning up directories...
131+
if exist ".\input-cache\publisher.jar" (
132+
echo Preserving publisher.jar and removing other files in .\input-cache...
133+
move ".\input-cache\publisher.jar" ".\"
134+
rmdir /s /q ".\input-cache"
135+
mkdir ".\input-cache"
136+
move ".\publisher.jar" ".\input-cache"
137+
) else (
138+
if exist ".\input-cache\" (
139+
rmdir /s /q ".\input-cache"
140+
)
141+
)
142+
if exist ".\temp\" (
143+
rmdir /s /q ".\temp"
144+
echo Removed: .\temp
145+
)
146+
if exist ".\output\" (
147+
rmdir /s /q ".\output"
148+
echo Removed: .\output
149+
)
150+
if exist ".\template\" (
151+
rmdir /s /q ".\template"
152+
echo Removed: .\template
153+
)
154+
155+
GOTO end
156+
157+
158+
159+
160+
161+
:downloadpublisher
162+
ECHO Downloading Publisher...
163+
:processflags
164+
SET ARG=%1
165+
IF DEFINED ARG (
166+
IF "%ARG%"=="-f" SET FORCE=true
167+
IF "%ARG%"=="--force" SET FORCE=true
168+
SHIFT
169+
GOTO processflags
170+
)
171+
172+
FOR %%x IN ("%CD%") DO SET upper_path=%%~dpx
173+
174+
ECHO.
175+
IF NOT EXIST "%input_cache_path%%publisher_jar%" (
176+
IF NOT EXIST "%upper_path%%publisher_jar%" (
177+
SET jarlocation="%input_cache_path%%publisher_jar%"
178+
SET jarlocationname=Input Cache
179+
ECHO IG Publisher is not yet in input-cache or parent folder.
180+
REM we don't use jarlocation below because it will be empty because we're in a bracketed if statement
181+
GOTO create
182+
) ELSE (
183+
ECHO IG Publisher FOUND in parent folder
184+
SET jarlocation="%upper_path%%publisher_jar%"
185+
SET jarlocationname=Parent folder
186+
GOTO upgrade
187+
)
188+
) ELSE (
189+
ECHO IG Publisher FOUND in input-cache
190+
SET jarlocation="%input_cache_path%%publisher_jar%"
191+
SET jarlocationname=Input Cache
192+
GOTO upgrade
193+
)
194+
195+
:create
196+
IF DEFINED FORCE (
197+
MKDIR "%input_cache_path%" 2> NUL
198+
GOTO download
199+
)
200+
201+
IF "%skipPrompts%"=="y" (
202+
SET create=Y
203+
) ELSE (
204+
SET /p create="Download? (Y/N) "
205+
)
206+
IF /I "%create%"=="Y" (
207+
ECHO Will place publisher jar here: %input_cache_path%%publisher_jar%
208+
MKDIR "%input_cache_path%" 2> NUL
209+
GOTO download
210+
)
211+
GOTO done
212+
213+
:upgrade
214+
IF "%skipPrompts%"=="y" (
215+
SET overwrite=Y
216+
) ELSE (
217+
SET /p overwrite="Overwrite %jarlocation%? (Y/N) "
218+
)
219+
220+
IF /I "%overwrite%"=="Y" (
221+
GOTO download
222+
)
223+
GOTO done
224+
225+
:download
226+
ECHO Downloading most recent publisher to %jarlocationname% - it's ~200 MB, so this may take a bit
227+
228+
FOR /f "tokens=4-5 delims=. " %%i IN ('ver') DO SET VERSION=%%i.%%j
229+
IF "%version%" == "10.0" GOTO win10
230+
IF "%version%" == "6.3" GOTO win8.1
231+
IF "%version%" == "6.2" GOTO win8
232+
IF "%version%" == "6.1" GOTO win7
233+
IF "%version%" == "6.0" GOTO vista
234+
235+
ECHO Unrecognized version: %version%
236+
GOTO done
237+
238+
:win10
239+
CALL POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%dlurl%\",\"%jarlocation%\") } else { Invoke-WebRequest -Uri "%dlurl%" -Outfile "%jarlocation%" }
240+
241+
GOTO done
242+
243+
:win7
244+
rem this may be triggering the antivirus - bitsadmin.exe is a known threat
245+
rem CALL bitsadmin /transfer GetPublisher /download /priority normal "%dlurl%" "%jarlocation%"
246+
247+
rem this didn't work in win 10
248+
rem CALL Start-BitsTransfer /priority normal "%dlurl%" "%jarlocation%"
249+
250+
rem this should work - untested
251+
call (New-Object Net.WebClient).DownloadFile('%dlurl%', '%jarlocation%')
252+
GOTO done
253+
254+
:win8.1
255+
:win8
256+
:vista
257+
GOTO done
258+
259+
260+
261+
:done
262+
263+
264+
265+
266+
ECHO.
267+
ECHO Updating scripts
268+
IF "%skipPrompts%"=="y" (
269+
SET updateScripts=Y
270+
) ELSE (
271+
SET /p updateScripts="Update scripts? (Y/N) "
272+
)
273+
IF /I "%updateScripts%"=="Y" (
274+
GOTO scripts
275+
)
276+
GOTO end
277+
278+
279+
:scripts
280+
281+
REM Download all batch files (and this one with a new name)
282+
283+
SETLOCAL DisableDelayedExpansion
284+
285+
286+
287+
:dl_script_1
288+
ECHO Updating _build.sh
289+
call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%build_sh_url%\",\"_build.new.sh\") } else { Invoke-WebRequest -Uri "%build_sh_url%" -Outfile "_build.new.sh" }
290+
if %ERRORLEVEL% == 0 goto upd_script_1
291+
echo "Errors encountered during download: %errorlevel%"
292+
goto dl_script_2
293+
:upd_script_1
294+
start copy /y "_build.new.sh" "_build.sh" ^&^& del "_build.new.sh" ^&^& exit
295+
296+
297+
:dl_script_2
298+
ECHO Updating _build.bat
299+
call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%build_bat_url%\",\"_build.new.bat\") } else { Invoke-WebRequest -Uri "%build_bat_url%" -Outfile "_build.new.bat" }
300+
if %ERRORLEVEL% == 0 goto upd_script_2
301+
echo "Errors encountered during download: %errorlevel%"
302+
goto end
303+
:upd_script_2
304+
start copy /y "_build.new.bat" "_build.bat" ^&^& del "_build.new.bat" ^&^& exit
305+
306+
307+
GOTO end
308+
309+
310+
:publish_once
311+
312+
SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
313+
314+
:: Debugging statements before running publisher
315+
ECHO 1jar_location is: %jar_location%
316+
IF NOT "%jar_location%"=="not_found" (
317+
java %JAVA_OPTS% -jar "%jar_location%" -ig . %txoption% %*
318+
) ELSE (
319+
ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
320+
)
321+
322+
GOTO end
323+
324+
325+
326+
:publish_nosushi
327+
328+
SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
329+
330+
:: Debugging statements before running publisher
331+
ECHO 3jar_location is: %jar_location%
332+
IF NOT "%jar_location%"=="not_found" (
333+
java %JAVA_OPTS% -jar "%jar_location%" -ig . %txoption% -no-sushi %*
334+
) ELSE (
335+
ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
336+
)
337+
338+
GOTO end
339+
340+
341+
:publish_notx
342+
SET txoption=-tx n/a
343+
344+
SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
345+
346+
:: Debugging statements before running publisher
347+
ECHO 2jar_location is: %jar_location%
348+
IF NOT "%jar_location%"=="not_found" (
349+
java %JAVA_OPTS% -jar "%jar_location%" -ig . %txoption% %*
350+
) ELSE (
351+
ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
352+
)
353+
354+
GOTO end
355+
356+
357+
358+
359+
:publish_continuous
360+
361+
SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
362+
363+
:: Debugging statements before running publisher
364+
ECHO Checking %input_cache_path% for publisher.jar
365+
IF EXIST "%input_cache_path%\%publisher_jar%" (
366+
java %JAVA_OPTS% -jar "%input_cache_path%\%publisher_jar%" -ig . %txoption% -watch %*
367+
) ELSE (
368+
ECHO Checking %upper_path% for publisher.jar
369+
IF EXIST "..\%publisher_jar%" (
370+
java %JAVA_OPTS% -jar "..\%publisher_jar%" -ig . %txoption% -watch %*
371+
) ELSE (
372+
ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
373+
)
374+
)
375+
376+
GOTO end
377+
378+
379+
:end
380+
381+
:: Pausing at the end
382+
383+
384+
IF NOT "%skipPrompts%"=="true" (
385+
PAUSE
386+
)

_gencontinuous.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#!/bin/bash
2-
./_genonce.sh -watch
1+
#!/bin/bash
2+
./_genonce.sh -watch

0 commit comments

Comments
 (0)