Skip to content

Commit 71cf9a5

Browse files
committed
filenames and publisher
1 parent ccc6b90 commit 71cf9a5

File tree

6 files changed

+353
-1
lines changed

6 files changed

+353
-1
lines changed

_build.sh

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Variables
6+
dlurl="https://github.com/HL7/fhir-ig-publisher/releases/latest/download/publisher.jar"
7+
publisher_jar="publisher.jar"
8+
input_cache_path="$(pwd)/input-cache/"
9+
skipPrompts=false
10+
upper_path="../"
11+
scriptdlroot="https://raw.githubusercontent.com/HL7/ig-publisher-scripts/main"
12+
build_bat_url="${scriptdlroot}/_build.bat"
13+
build_sh_url="${scriptdlroot}/_build.sh"
14+
15+
function check_jar_location() {
16+
if [ -f "${input_cache_path}${publisher_jar}" ]; then
17+
jar_location="${input_cache_path}${publisher_jar}"
18+
echo "Found publisher.jar in input-cache"
19+
elif [ -f "${upper_path}${publisher_jar}" ]; then
20+
jar_location="${upper_path}${publisher_jar}"
21+
echo "Found publisher.jar in parent folder"
22+
else
23+
jar_location="not_found"
24+
echo "publisher.jar not found in input-cache or parent folder"
25+
fi
26+
}
27+
28+
function check_internet_connection() {
29+
if ping -c 1 tx.fhir.org &>/dev/null; then
30+
online=true
31+
echo "We're online and tx.fhir.org is available."
32+
latest_version=$(curl -s https://api.github.com/repos/HL7/fhir-ig-publisher/releases/latest | grep tag_name | cut -d'"' -f4)
33+
else
34+
online=false
35+
echo "We're offline or tx.fhir.org is unavailable."
36+
fi
37+
}
38+
39+
40+
function update_publisher() {
41+
echo "Publisher jar location: ${input_cache_path}${publisher_jar}"
42+
read -p "Download or update publisher.jar? (Y/N): " confirm
43+
if [[ "$confirm" =~ ^[Yy]$ ]]; then
44+
echo "Downloading latest publisher.jar (~200 MB)..."
45+
mkdir -p "$input_cache_path"
46+
curl -L "$dlurl" -o "${input_cache_path}${publisher_jar}"
47+
else
48+
echo "Skipped downloading publisher.jar"
49+
fi
50+
51+
update_scripts_prompt
52+
}
53+
54+
55+
function update_scripts_prompt() {
56+
read -p "Update scripts (_build.bat and _build.sh)? (Y/N): " update_confirm
57+
if [[ "$update_confirm" =~ ^[Yy]$ ]]; then
58+
echo "Updating scripts..."
59+
curl -L "$build_bat_url" -o "_build.new.bat" && mv "_build.new.bat" "_build.bat"
60+
curl -L "$build_sh_url" -o "_build.new.sh" && mv "_build.new.sh" "_build.sh"
61+
chmod +x _build.sh
62+
echo "Scripts updated."
63+
else
64+
echo "Skipped updating scripts."
65+
fi
66+
}
67+
68+
69+
function build_ig() {
70+
if [ "$jar_location" != "not_found" ]; then
71+
args=()
72+
if [ "$online" = "false" ]; then
73+
args+=("-tx" "n/a")
74+
fi
75+
java -Dfile.encoding=UTF-8 -jar "$jar_location" -ig . "${args[@]}" "$@"
76+
else
77+
echo "publisher.jar not found. Please run update."
78+
fi
79+
}
80+
81+
82+
function build_nosushi() {
83+
if [ "$jar_location" != "not_found" ]; then
84+
java -Dfile.encoding=UTF-8 -jar "$jar_location" -ig . -no-sushi "$@"
85+
else
86+
echo "publisher.jar not found. Please run update."
87+
fi
88+
}
89+
90+
function build_notx() {
91+
if [ "$jar_location" != "not_found" ]; then
92+
java -Dfile.encoding=UTF-8 -jar "$jar_location" -ig . -tx n/a "$@"
93+
else
94+
echo "publisher.jar not found. Please run update."
95+
fi
96+
}
97+
98+
function jekyll_build() {
99+
echo "Running Jekyll build..."
100+
jekyll build -s temp/pages -d output
101+
}
102+
103+
function cleanup() {
104+
echo "Cleaning up temp directories..."
105+
if [ -f "${input_cache_path}${publisher_jar}" ]; then
106+
mv "${input_cache_path}${publisher_jar}" ./
107+
rm -rf "${input_cache_path}"*
108+
mkdir -p "$input_cache_path"
109+
mv "$publisher_jar" "$input_cache_path"
110+
fi
111+
rm -rf ./output ./template ./temp
112+
echo "Cleanup complete."
113+
}
114+
115+
check_jar_location
116+
check_internet_connection
117+
118+
# Handle command-line argument or menu
119+
case "$1" in
120+
update) update_publisher ;;
121+
build) build_ig ;;
122+
nosushi) build_nosushi ;;
123+
notx) build_notx ;;
124+
jekyll) jekyll_build ;;
125+
clean) cleanup ;;
126+
exit) exit 0 ;;
127+
*)
128+
# Compute default choice
129+
default_choice=2 # Build by default
130+
131+
if [ "$jar_location" = "not_found" ]; then
132+
default_choice=1 # Download if jar is missing
133+
elif [ "$online" = "false" ]; then
134+
default_choice=4 # Offline build
135+
elif [ -n "$latest_version" ]; then
136+
current_version=$(java -jar "$jar_location" -v 2>/dev/null | tr -d '\r')
137+
if [ "$current_version" != "$latest_version" ]; then
138+
default_choice=1 # Offer update if newer version exists
139+
fi
140+
fi
141+
142+
echo "---------------------------------------------"
143+
echo "Publisher: ${current_version:-unknown}; Latest: ${latest_version:-unknown}"
144+
echo "Publisher location: $jar_location"
145+
echo "Online: $online"
146+
echo "---------------------------------------------"
147+
echo
148+
echo "Please select an option:"
149+
echo "1) Update publisher"
150+
echo "2) Build IG"
151+
echo "3) Build IG without Sushi"
152+
echo "4) Build IG without TX server"
153+
echo "5) Jekyll build"
154+
echo "6) Cleanup temp directories"
155+
echo "0) Exit"
156+
echo
157+
158+
# Read with timeout, but default if nothing entered
159+
echo -n "Choose an option [default: $default_choice]: "
160+
read -t 5 choice || choice="$default_choice"
161+
choice="${choice:-$default_choice}"
162+
echo "You selected: $choice"
163+
164+
case "$choice" in
165+
1) update_publisher ;;
166+
2) build_ig ;;
167+
3) build_nosushi ;;
168+
4) build_notx ;;
169+
5) jekyll_build ;;
170+
6) cleanup ;;
171+
0) exit 0 ;;
172+
*) echo "Invalid option." ;;
173+
esac
174+
;;
175+
176+
esac

_gencontinuous.sh

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

_genonce.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
publisher_jar=publisher.jar
3+
input_cache_path=./input-cache/
4+
echo Checking internet connection...
5+
curl -sSf tx.fhir.org > /dev/null
6+
7+
if [ $? -eq 0 ]; then
8+
echo "Online"
9+
txoption=""
10+
else
11+
echo "Offline"
12+
txoption="-tx n/a"
13+
fi
14+
15+
echo "$txoption"
16+
17+
export JAVA_TOOL_OPTIONS="$JAVA_TOOL_OPTIONS -Dfile.encoding=UTF-8"
18+
19+
publisher=$input_cache_path/$publisher_jar
20+
if test -f "$publisher"; then
21+
java -jar $publisher -ig . $txoption $*
22+
23+
else
24+
publisher=../$publisher_jar
25+
if test -f "$publisher"; then
26+
java -jar $publisher -ig . $txoption $*
27+
else
28+
echo IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
29+
fi
30+
fi

_updatePublisher.sh

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/bin/bash
2+
pubsource=https://github.com/HL7/fhir-ig-publisher/releases/latest/download/
3+
publisher_jar=publisher.jar
4+
dlurl=$pubsource$publisher_jar
5+
6+
input_cache_path=$PWD/input-cache/
7+
8+
scriptdlroot=https://raw.githubusercontent.com/HL7/ig-publisher-scripts/main
9+
update_bat_url=$scriptdlroot/_updatePublisher.bat
10+
gen_bat_url=$scriptdlroot/_genonce.bat
11+
gencont_bat_url=$scriptdlroot/_gencontinuous.bat
12+
gencont_sh_url=$scriptdlroot/_gencontinuous.sh
13+
gen_sh_url=$scriptdlroot/_genonce.sh
14+
update_sh_url=$scriptdlroot/_updatePublisher.sh
15+
build_sh_url=$scriptdlroot/_build.sh
16+
build_bat_url=$scriptdlroot/_build.bat
17+
18+
skipPrompts=false
19+
FORCE=false
20+
21+
if ! type "curl" > /dev/null; then
22+
echo "ERROR: Script needs curl to download latest IG Publisher. Please install curl."
23+
exit 1
24+
fi
25+
26+
while [ "$#" -gt 0 ]; do
27+
case $1 in
28+
-f|--force) FORCE=true ;;
29+
-y|--yes) skipPrompts=true ; FORCE=true ;;
30+
*) echo "Unknown parameter passed: $1. Exiting"; exit 1 ;;
31+
esac
32+
shift
33+
done
34+
35+
echo "Checking internet connection"
36+
curl -sSf tx.fhir.org > /dev/null
37+
38+
if [ $? -ne 0 ] ; then
39+
echo "Offline (or the terminology server is down), unable to update. Exiting"
40+
exit 1
41+
fi
42+
43+
if [ ! -d "$input_cache_path" ] ; then
44+
if [ $FORCE != true ]; then
45+
echo "$input_cache_path does not exist"
46+
message="create it?"
47+
read -r -p "$message" response
48+
else
49+
response=y
50+
fi
51+
fi
52+
53+
if [[ $response =~ ^[yY].*$ ]] ; then
54+
mkdir ./input-cache
55+
fi
56+
57+
publisher="$input_cache_path$publisher_jar"
58+
59+
if test -f "$publisher" ; then
60+
echo "IG Publisher FOUND in input-cache"
61+
jarlocation="$publisher"
62+
jarlocationname="Input Cache"
63+
upgrade=true
64+
else
65+
publisher="../$publisher_jar"
66+
upgrade=true
67+
if test -f "$publisher"; then
68+
echo "IG Publisher FOUND in parent folder"
69+
jarlocation="$publisher"
70+
jarlocationname="Parent Folder"
71+
upgrade=true
72+
else
73+
echo "IG Publisher NOT FOUND in input-cache or parent folder"
74+
jarlocation=$input_cache_path$publisher_jar
75+
jarlocationname="Input Cache"
76+
upgrade=false
77+
fi
78+
fi
79+
80+
if [[ $skipPrompts == false ]]; then
81+
82+
if [[ $upgrade == true ]]; then
83+
message="Overwrite $jarlocation? (Y/N) "
84+
else
85+
echo Will place publisher jar here: "$jarlocation"
86+
message="Ok (enter 'y' or 'Y' to continue, any other key to cancel)?"
87+
fi
88+
read -r -p "$message" response
89+
else
90+
response=y
91+
fi
92+
if [[ $skipPrompts == true ]] || [[ $response =~ ^[yY].*$ ]]; then
93+
94+
echo "Downloading most recent publisher to $jarlocationname - it's ~100 MB, so this may take a bit"
95+
curl -L $dlurl -o "$jarlocation" --create-dirs
96+
else
97+
echo cancelled publisher update
98+
fi
99+
100+
if [[ $skipPrompts != true ]]; then
101+
message="Update scripts? (enter 'y' or 'Y' to continue, any other key to cancel)?"
102+
read -r -p "$message" response
103+
fi
104+
105+
if [[ $skipPrompts == true ]] || [[ $response =~ ^[yY].*$ ]]; then
106+
echo "Downloading most recent scripts "
107+
108+
curl -L $build_bat_url -o /tmp/_build.new
109+
cp /tmp/_build.new _build.bat
110+
rm /tmp/_build.new
111+
112+
113+
curl -L $build_sh_url -o /tmp/_build.new
114+
cp /tmp/_build.new _build.sh
115+
chmod +x _build.sh
116+
rm /tmp/_build.new
117+
118+
curl -L $update_bat_url -o /tmp/_updatePublisher.new
119+
cp /tmp/_updatePublisher.new _updatePublisher.bat
120+
rm /tmp/_updatePublisher.new
121+
122+
curl -L $gen_bat_url -o /tmp/_genonce.new
123+
cp /tmp/_genonce.new _genonce.bat
124+
rm /tmp/_genonce.new
125+
126+
curl -L $gencont_bat_url -o /tmp/_gencontinuous.new
127+
cp /tmp/_gencontinuous.new _gencontinuous.bat
128+
rm /tmp/_gencontinuous.new
129+
130+
curl -L $gencont_sh_url -o /tmp/_gencontinuous.new
131+
cp /tmp/_gencontinuous.new _gencontinuous.sh
132+
chmod +x _gencontinuous.sh
133+
rm /tmp/_gencontinuous.new
134+
135+
curl -L $gen_sh_url -o /tmp/_genonce.new
136+
cp /tmp/_genonce.new _genonce.sh
137+
chmod +x _genonce.sh
138+
rm /tmp/_genonce.new
139+
140+
curl -L $update_sh_url -o /tmp/_updatePublisher.new
141+
cp /tmp/_updatePublisher.new _updatePublisher.sh
142+
chmod +x _updatePublisher.sh
143+
rm /tmp/_updatePublisher.new
144+
fi
File renamed without changes.

sushi-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ menu:
123123
Care Services Directory: care-services.html
124124
Notifications: notification.html
125125
Workflow: workflow.html
126-
CareTeam: careteam.html
126+
CareTeams: careteams.html
127127
Data Localization: localization.html
128128
Consent: consent.html
129129
Authorization: authorization.html

0 commit comments

Comments
 (0)