Skip to content

Commit e9b84f6

Browse files
committed
internal: fix script updating template versions
1 parent 9fd9c40 commit e9b84f6

File tree

1 file changed

+26
-42
lines changed

1 file changed

+26
-42
lines changed
Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -e
33

4-
echo "Updating all @rock-js/* dependencies to match CLI version..."
4+
echo "Updating all @rock-js/* and rock dependencies to match CLI version..."
55

66
# Get the version from packages/cli/package.json
77
CLI_VERSION=$(jq -r '.version' packages/cli/package.json)
@@ -15,59 +15,43 @@ update_package_json() {
1515
# Create a temporary file
1616
temp_file=$(mktemp)
1717

18-
# Update all @rock-js/* dependencies to match CLI version
18+
# Update all @rock-js/* and rock dependencies to match CLI version
1919
jq --arg version "^$CLI_VERSION" '
20-
# Only update if the field exists
21-
if has("dependencies") then
22-
.dependencies = (
23-
.dependencies |
24-
to_entries |
25-
map(if .key | startswith("@rock-js/") then .value = $version else . end) |
20+
# Helper function to update dependencies
21+
def update_deps(deps):
22+
if deps then
23+
deps |
24+
to_entries |
25+
map(
26+
if (.key | startswith("@rock-js/")) or (.key == "rock") then
27+
.value = $version
28+
else
29+
.
30+
end
31+
) |
2632
from_entries
27-
)
28-
else . end |
29-
30-
if has("devDependencies") then
31-
.devDependencies = (
32-
.devDependencies |
33-
to_entries |
34-
map(if .key | startswith("@rock-js/") then .value = $version else . end) |
35-
from_entries
36-
)
37-
38-
else . end |
39-
40-
if has("optionalDependencies") then
41-
.optionalDependencies = (
42-
.optionalDependencies |
43-
to_entries |
44-
map(if .key | startswith("@rock-js/") then .value = $version else . end) |
45-
from_entries
46-
)
33+
else
34+
deps
35+
end;
4736
48-
else . end |
49-
50-
if has("peerDependencies") then
51-
.peerDependencies = (
52-
.peerDependencies |
53-
to_entries |
54-
map(if .key | startswith("@rock-js/") then .value = $version else . end) |
55-
from_entries
56-
)
57-
else . end
37+
# Update only existing dependency types
38+
if has("dependencies") then .dependencies = update_deps(.dependencies) else . end |
39+
if has("devDependencies") then .devDependencies = update_deps(.devDependencies) else . end |
40+
if has("optionalDependencies") then .optionalDependencies = update_deps(.optionalDependencies) else . end |
41+
if has("peerDependencies") then .peerDependencies = update_deps(.peerDependencies) else . end
5842
' "$file" > "$temp_file"
5943

6044
# Replace the original file with the updated one
6145
mv "$temp_file" "$file"
6246
}
6347

48+
# Function to update package.json version
6449
update_package_json_version() {
6550
local file=$1
6651
echo "Updating version in $file..."
6752

68-
# Get the version from packages/cli/package.json
69-
CLI_VERSION=$(jq -r '.version' packages/cli/package.json)
70-
echo "Using CLI version: $CLI_VERSION"
53+
# Create a temporary file
54+
temp_file=$(mktemp)
7155

7256
# Update the version in the package.json file
7357
jq --arg version "$CLI_VERSION" '.version = $version' "$file" > "$temp_file"
@@ -87,4 +71,4 @@ find ./packages -path "*/template/*" -name "package.json" -not -path "*/node_mod
8771
update_package_json "$file"
8872
done
8973

90-
echo "Done! All @rock-js/* dependencies have been updated to version ^$CLI_VERSION."
74+
echo "Done! All @rock-js/* and rock dependencies have been updated to version ^$CLI_VERSION."

0 commit comments

Comments
 (0)