Skip to content

Commit d96a052

Browse files
fix: update version script for webapp rename (#391)
1 parent 42673d4 commit d96a052

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

update_version.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -euo pipefail
88
# Examples: 1.2.3, 1.0.0-alpha.1, 2.0.0-beta.1, 1.2.3+build.123
99
#
1010
# This script updates the version in:
11-
# - webapp/package.json & webapp/package-lock.json (for "hephaestus")
11+
# - webapp/package.json & webapp/package-lock.json (for "webapp")
1212
# - root package-lock.json (top-level version)
1313
# - Java source: server/application-server/src/main/java/de/tum/in/www1/hephaestus/OpenAPIConfiguration.java
1414
# - YAML config: server/application-server/src/main/resources/application.yml
@@ -33,8 +33,8 @@ PARAM=$1
3333
if [[ "$PARAM" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
3434
# Direct version specified (used by semantic-release)
3535
NEW_VERSION="$PARAM"
36-
# Extract the current version from webapp/package.json (the authoritative version for "hephaestus")
37-
CURRENT_VERSION=$(awk '/"name": "hephaestus"/ {found=1} found && /"version":/ { sub(/.*"version": "/, ""); sub(/".*/, ""); print; exit }' webapp/package.json)
36+
# Extract the current version from webapp/package.json (the authoritative version for "webapp")
37+
CURRENT_VERSION=$(awk '/"name": "webapp"/ {found=1} found && /"version":/ { sub(/.*"version": "/, ""); sub(/".*/, ""); print; exit }' webapp/package.json)
3838
if [[ -z "$CURRENT_VERSION" ]]; then
3939
echo "Error: Could not determine current version from webapp/package.json"
4040
exit 1
@@ -66,9 +66,9 @@ elif [[ "$PARAM" == "major" || "$PARAM" == "minor" || "$PARAM" == "patch" ]]; th
6666
echo "$major.$minor.$patch"
6767
}
6868

69-
# Extract the current version from webapp/package.json (the authoritative version for "hephaestus")
69+
# Extract the current version from webapp/package.json (the authoritative version for "webapp")
7070
# This uses awk to strip everything before/after the version string.
71-
CURRENT_VERSION=$(awk '/"name": "hephaestus"/ {found=1} found && /"version":/ { sub(/.*"version": "/, ""); sub(/".*/, ""); print; exit }' webapp/package.json)
71+
CURRENT_VERSION=$(awk '/"name": "webapp"/ {found=1} found && /"version":/ { sub(/.*"version": "/, ""); sub(/".*/, ""); print; exit }' webapp/package.json)
7272
if [[ -z "$CURRENT_VERSION" ]]; then
7373
echo "Error: Could not determine current version from webapp/package.json"
7474
exit 1
@@ -85,7 +85,7 @@ fi
8585
# Update webapp/package.json
8686
awk -v old_version="$CURRENT_VERSION" -v new_version="$NEW_VERSION" '
8787
BEGIN {found_name = 0}
88-
/"name": "hephaestus"/ {found_name = 1}
88+
/"name": "webapp"/ {found_name = 1}
8989
found_name && /"version":/ {
9090
sub("\"version\": \"" old_version "\"", "\"version\": \"" new_version "\"")
9191
found_name = 0
@@ -97,7 +97,7 @@ awk -v old_version="$CURRENT_VERSION" -v new_version="$NEW_VERSION" '
9797
if [[ -f webapp/package-lock.json ]]; then
9898
awk -v old_version="$CURRENT_VERSION" -v new_version="$NEW_VERSION" '
9999
BEGIN {found_name = 0}
100-
/"name": "hephaestus"/ {found_name = 1}
100+
/"name": "webapp"/ {found_name = 1}
101101
found_name && /"version":/ {
102102
sub("\"version\": \"" old_version "\"", "\"version\": \"" new_version "\"")
103103
found_name = 0
@@ -108,7 +108,7 @@ fi
108108

109109
# Update root package-lock.json (if it exists)
110110
# 1) Update the top-level version field (before the packages block)
111-
# 2) Update the first hephaestus entry's immediate version (mirrors webapp logic)
111+
# 2) Update the webapp workspace's version entry
112112
if [[ -f package-lock.json ]]; then
113113
# 1) Top-level version (only within header before "packages":)
114114
awk -v old_version="$CURRENT_VERSION" -v new_version="$NEW_VERSION" '
@@ -121,13 +121,13 @@ if [[ -f package-lock.json ]]; then
121121
{ print }
122122
' package-lock.json > package-lock.json.tmp && mv package-lock.json.tmp package-lock.json
123123

124-
# 2) First hephaestus name+version pair (e.g., packages[""] or packages["webapp"]) — matches the pattern you provided
124+
# 2) Version entry for the webapp workspace
125125
awk -v old_version="$CURRENT_VERSION" -v new_version="$NEW_VERSION" '
126-
BEGIN {found_name = 0}
127-
/"name": "hephaestus"/ {found_name = 1}
128-
found_name && /"version":/ {
126+
BEGIN {found_webapp = 0}
127+
/"webapp"[[:space:]]*:/ {found_webapp = 1}
128+
found_webapp && /"version":/ {
129129
sub("\"version\": \"" old_version "\"", "\"version\": \"" new_version "\"")
130-
found_name = 0
130+
found_webapp = 0
131131
}
132132
{print}
133133
' package-lock.json > package-lock.json.tmp && mv package-lock.json.tmp package-lock.json

0 commit comments

Comments
 (0)