Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 33 additions & 29 deletions _build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ setlocal enabledelayedexpansion
SET "dlurl=https://github.com/HL7/fhir-ig-publisher/releases/latest/download/publisher.jar"
SET "publisher_jar=publisher.jar"
SET "input_cache_path=%CD%\input-cache\"
IF DEFINED FHIR_PUBLISHER_HOME (
SET "publisher_home=%FHIR_PUBLISHER_HOME%"
) ELSE (
SET "publisher_home=%USERPROFILE%\.fhir\tools\publisher"
)
SET "skipPrompts=false"
SET "upper_path=..\"
SET "scriptdlroot=https://raw.githubusercontent.com/HL7/ig-publisher-scripts/main"
Expand All @@ -23,10 +28,16 @@ IF EXIST "%input_cache_path%%publisher_jar%" (
SET "jar_location=%upper_path%%publisher_jar%"
ECHO Found publisher.jar in parent folder
) ELSE (
SET "jar_location=not_found"
SET "default_choice=1"
SET "default_reason=publisher not found"
ECHO publisher.jar not found in input-cache or parent folder
ECHO Checking for publisher.jar in %publisher_home%
IF EXIST "%publisher_home%\%publisher_jar%" (
SET "jar_location=%publisher_home%\%publisher_jar%"
ECHO Found publisher.jar in FHIR publisher home
) ELSE (
SET "jar_location=not_found"
SET "default_choice=1"
SET "default_reason=publisher not found"
ECHO publisher.jar not found in input-cache, parent folder, or FHIR publisher home
)
)
)

Expand Down Expand Up @@ -179,32 +190,25 @@ IF DEFINED ARG (
GOTO processflags
)

FOR %%x IN ("%CD%") DO SET upper_path=%%~dpx

ECHO.
IF NOT EXIST "%input_cache_path%%publisher_jar%" (
IF NOT EXIST "%upper_path%%publisher_jar%" (
SET jarlocation="%input_cache_path%%publisher_jar%"
SET jarlocationname=Input Cache
ECHO IG Publisher is not yet in input-cache or parent folder.
REM we don't use jarlocation below because it will be empty because we're in a bracketed if statement
GOTO create
) ELSE (
ECHO IG Publisher FOUND in parent folder
SET jarlocation="%upper_path%%publisher_jar%"
SET jarlocationname=Parent folder
GOTO upgrade
)
) ELSE (
IF EXIST "%input_cache_path%%publisher_jar%" (
ECHO IG Publisher FOUND in input-cache
SET jarlocation="%input_cache_path%%publisher_jar%"
SET jarlocationname=Input Cache
SET "jarlocation=%input_cache_path%%publisher_jar%"
SET "jarlocationname=Input Cache"
GOTO upgrade
)
SET "jarlocation=%publisher_home%\%publisher_jar%"
SET "jarlocationname=FHIR Publisher Home"
IF EXIST "%publisher_home%\%publisher_jar%" (
ECHO IG Publisher FOUND in FHIR publisher home
GOTO upgrade
)
ECHO IG Publisher is not yet in input-cache or FHIR publisher home.
GOTO create

:create
IF DEFINED FORCE (
MKDIR "%input_cache_path%" 2> NUL
MKDIR "%publisher_home%" 2> NUL
GOTO download
)

Expand All @@ -214,8 +218,8 @@ IF "%skipPrompts%"=="true" (
SET /p create="Download? (Y/N) "
)
IF /I "%create%"=="Y" (
ECHO Will place publisher jar here: %input_cache_path%%publisher_jar%
MKDIR "%input_cache_path%" 2> NUL
ECHO Will place publisher jar here: %jarlocation%
MKDIR "%publisher_home%" 2> NUL
GOTO download
)
GOTO done
Expand Down Expand Up @@ -327,7 +331,7 @@ IF NOT "%jar_location%"=="not_found" (
ECHO IG Publisher FOUND, Publishing...
java %JAVA_OPTS% -jar "%jar_location%" -ig . %txoption% %extraArgs%
) ELSE (
ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run the script and update the publisher. Aborting...
ECHO IG Publisher NOT FOUND in input-cache, parent folder, or FHIR publisher home. Please run the script and update the publisher. Aborting...
)

GOTO endscript
Expand All @@ -343,7 +347,7 @@ ECHO jar_location is: %jar_location%
IF NOT "%jar_location%"=="not_found" (
java %JAVA_OPTS% -jar "%jar_location%" -ig . %txoption% -no-sushi %extraArgs%
) ELSE (
ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run the script and update the publisher. Aborting...
ECHO IG Publisher NOT FOUND in input-cache, parent folder, or FHIR publisher home. Please run the script and update the publisher. Aborting...
)

GOTO endscript
Expand All @@ -359,7 +363,7 @@ ECHO jar_location is: %jar_location%
IF NOT "%jar_location%"=="not_found" (
java %JAVA_OPTS% -jar "%jar_location%" -ig . %txoption% %extraArgs%
) ELSE (
ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run the script and update the publisher. Aborting...
ECHO IG Publisher NOT FOUND in input-cache, parent folder, or FHIR publisher home. Please run the script and update the publisher. Aborting...
)

GOTO endscript
Expand All @@ -373,7 +377,7 @@ ECHO jar_location is: %jar_location%
IF NOT "%jar_location%"=="not_found" (
java %JAVA_OPTS% -jar "%jar_location%" -ig . %txoption% -watch %extraArgs%
) ELSE (
ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run the script and update the publisher. Aborting...
ECHO IG Publisher NOT FOUND in input-cache, parent folder, or FHIR publisher home. Please run the script and update the publisher. Aborting...
)

GOTO endscript
Expand Down
26 changes: 20 additions & 6 deletions _build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set -e
dlurl="https://github.com/HL7/fhir-ig-publisher/releases/latest/download/publisher.jar"
publisher_jar="publisher.jar"
input_cache_path="$(pwd)/input-cache/"
publisher_home="${FHIR_PUBLISHER_HOME:-$HOME/.fhir/tools/publisher}"
skipPrompts=false
upper_path="../"
scriptdlroot="https://raw.githubusercontent.com/HL7/ig-publisher-scripts/main"
Expand All @@ -19,9 +20,12 @@ function check_jar_location() {
elif [ -f "${upper_path}${publisher_jar}" ]; then
jar_location="${upper_path}${publisher_jar}"
echo "Found publisher.jar in parent folder"
elif [ -f "${publisher_home}/${publisher_jar}" ]; then
jar_location="${publisher_home}/${publisher_jar}"
echo "Found publisher.jar in FHIR publisher home"
else
jar_location="not_found"
echo "publisher.jar not found in input-cache or parent folder"
echo "publisher.jar not found in input-cache, parent folder, or FHIR publisher home"
fi
}

Expand Down Expand Up @@ -58,16 +62,24 @@ function check_internet_connection() {


function update_publisher() {
echo "Publisher jar location: ${input_cache_path}${publisher_jar}"
if [ -f "${input_cache_path}${publisher_jar}" ]; then
update_location="${input_cache_path}${publisher_jar}"
update_location_name="input-cache"
else
update_location="${publisher_home}/${publisher_jar}"
update_location_name="FHIR publisher home"
fi
echo "Publisher jar location: ${update_location}"
if [ "$skipPrompts" = "true" ]; then
confirm="Y"
else
read -p "Download or update publisher.jar? (Y/N): " confirm
fi
if [[ "$confirm" =~ ^[Yy]$ ]]; then
echo "Downloading latest publisher.jar (~200 MB)..."
mkdir -p "$input_cache_path"
curl -L "$dlurl" -o "${input_cache_path}${publisher_jar}"
mkdir -p "$(dirname "$update_location")"
curl -L "$dlurl" -o "$update_location"
echo "Publisher updated in ${update_location_name}"
else
echo "Skipped downloading publisher.jar"
fi
Expand Down Expand Up @@ -98,10 +110,12 @@ function run_publisher() {
local extra_flags=("$@")
if [ "$jar_location" != "not_found" ]; then
echo "jar_location is: $jar_location"
export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF-8"
if [[ "$JAVA_TOOL_OPTIONS" != *"-Dfile.encoding=UTF-8"* ]]; then
export JAVA_TOOL_OPTIONS+=" -Dfile.encoding=UTF-8"
fi
java $JAVA_OPTS -jar "$jar_location" -ig . "${extra_flags[@]}"
else
echo "IG Publisher NOT FOUND in input-cache or parent folder. Please run update. Aborting..."
echo "IG Publisher NOT FOUND in input-cache, parent folder, or FHIR publisher home. Please run update. Aborting..."
fi
}

Expand Down
9 changes: 8 additions & 1 deletion _genonce.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
@ECHO OFF
SET publisher_jar=publisher.jar
SET input_cache_path=%CD%\input-cache
IF DEFINED FHIR_PUBLISHER_HOME (
SET "publisher_home=%FHIR_PUBLISHER_HOME%"
) ELSE (
SET "publisher_home=%USERPROFILE%\.fhir\tools\publisher"
)

ECHO Checking internet connection...
powershell -Command "try { $r=[System.Net.WebRequest]::Create('https://tx.fhir.org/r4/metadata'); $r.Timeout=4000; $r.GetResponse().Close(); exit 0 } catch { exit 1 }"
Expand All @@ -21,8 +26,10 @@ IF EXIST "%input_cache_path%\%publisher_jar%" (
JAVA -jar "%input_cache_path%\%publisher_jar%" -ig . %txoption% %*
) ELSE If exist "..\%publisher_jar%" (
JAVA -jar "..\%publisher_jar%" -ig . %txoption% %*
) ELSE IF EXIST "%publisher_home%\%publisher_jar%" (
JAVA -jar "%publisher_home%\%publisher_jar%" -ig . %txoption% %*
) ELSE (
ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
ECHO IG Publisher NOT FOUND in input-cache, parent folder, or FHIR publisher home. Please run _updatePublisher. Aborting...
)

PAUSE
26 changes: 15 additions & 11 deletions _genonce.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
#!/bin/bash
publisher_jar=publisher.jar
input_cache_path=./input-cache/
publisher_home="${FHIR_PUBLISHER_HOME:-$HOME/.fhir/tools/publisher}"
echo Checking internet connection...
curl -sSf tx.fhir.org > /dev/null

if [ $? -eq 0 ]; then
if curl -sSf tx.fhir.org > /dev/null; then
echo "Online"
txoption=""
txoption=()
else
echo "Offline"
txoption="-tx n/a"
txoption=(-tx n/a)
fi

echo "$txoption"
echo "${txoption[*]}"

export JAVA_TOOL_OPTIONS="$JAVA_TOOL_OPTIONS -Dfile.encoding=UTF-8"

publisher=$input_cache_path/$publisher_jar
publisher="${input_cache_path}${publisher_jar}"
if test -f "$publisher"; then
java -jar $publisher -ig . $txoption $*
java -jar "$publisher" -ig . "${txoption[@]}" "$@"

else
publisher=../$publisher_jar
publisher="../${publisher_jar}"
if test -f "$publisher"; then
java -jar $publisher -ig . $txoption $*
java -jar "$publisher" -ig . "${txoption[@]}" "$@"
else
echo IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
publisher="${publisher_home}/${publisher_jar}"
if test -f "$publisher"; then
java -jar "$publisher" -ig . "${txoption[@]}" "$@"
else
echo IG Publisher NOT FOUND in input-cache, parent folder, or FHIR publisher home. Please run _updatePublisher. Aborting...
fi
fi
fi
42 changes: 20 additions & 22 deletions _updatePublisher.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ SETLOCAL
SET dlurl=https://github.com/HL7/fhir-ig-publisher/releases/latest/download/publisher.jar
SET publisher_jar=publisher.jar
SET input_cache_path=%CD%\input-cache\
IF DEFINED FHIR_PUBLISHER_HOME (
SET "publisher_home=%FHIR_PUBLISHER_HOME%"
) ELSE (
SET "publisher_home=%USERPROFILE%\.fhir\tools\publisher"
)
SET skipPrompts=false

SET scriptdlroot=https://raw.githubusercontent.com/HL7/ig-publisher-scripts/main
Expand Down Expand Up @@ -40,44 +45,37 @@ IF DEFINED ARG (
GOTO processflags
)

FOR %%x IN ("%CD%") DO SET upper_path=%%~dpx

ECHO.
IF NOT EXIST "%input_cache_path%%publisher_jar%" (
IF NOT EXIST "%upper_path%%publisher_jar%" (
SET jarlocation="%input_cache_path%%publisher_jar%"
SET jarlocationname=Input Cache
ECHO IG Publisher is not yet in input-cache or parent folder.
REM we don't use jarlocation below because it will be empty because we're in a bracketed if statement
GOTO create
) ELSE (
ECHO IG Publisher FOUND in parent folder
SET jarlocation="%upper_path%%publisher_jar%"
SET jarlocationname=Parent folder
GOTO upgrade
)
) ELSE (
IF EXIST "%input_cache_path%%publisher_jar%" (
ECHO IG Publisher FOUND in input-cache
SET jarlocation="%input_cache_path%%publisher_jar%"
SET jarlocationname=Input Cache
SET "jarlocation=%input_cache_path%%publisher_jar%"
SET "jarlocationname=Input Cache"
GOTO upgrade
)
SET "jarlocation=%publisher_home%\%publisher_jar%"
SET "jarlocationname=FHIR Publisher Home"
IF EXIST "%publisher_home%\%publisher_jar%" (
ECHO IG Publisher FOUND in FHIR publisher home
GOTO upgrade
)
ECHO IG Publisher is not yet in input-cache or FHIR publisher home.
GOTO create

:create
IF DEFINED FORCE (
MKDIR "%input_cache_path%" 2> NUL
MKDIR "%publisher_home%" 2> NUL
GOTO download
)

IF "%skipPrompts%"=="y" (
SET create=Y
) ELSE (
ECHO Will place publisher jar here: %input_cache_path%%publisher_jar%
ECHO Will place publisher jar here: %jarlocation%
SET /p create="Ok? (Y/N) "
)
IF /I "%create%"=="Y" (
ECHO Will place publisher jar here: %input_cache_path%%publisher_jar%
MKDIR "%input_cache_path%" 2> NUL
ECHO Will place publisher jar here: %jarlocation%
MKDIR "%publisher_home%" 2> NUL
GOTO download
)
GOTO done
Expand Down
Loading
Loading