Skip to content

Commit eaad9b0

Browse files
feat: update template dependencies during release (#226)
1 parent 9cb3875 commit eaad9b0

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ jobs:
2424
id: changesets
2525
uses: changesets/action@v1
2626
with:
27-
version: pnpm run version
27+
version: |
28+
pnpm run version
29+
./scripts/update-template-dependencies.sh
2830
commit: 'chore: version packages'
2931
title: 'chore: version packages'
3032
publish: pnpm publish:npm
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Updating all @rnef/* dependencies to match CLI version..."
5+
6+
# Get the version from packages/cli/package.json
7+
CLI_VERSION=$(jq -r '.version' packages/cli/package.json)
8+
echo "Using CLI version: $CLI_VERSION"
9+
10+
# Function to update package.json files
11+
update_package_json() {
12+
local file=$1
13+
echo "Processing $file..."
14+
15+
# Create a temporary file
16+
temp_file=$(mktemp)
17+
18+
# Update all @rnef/* dependencies to match CLI version
19+
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("@rnef/") then .value = $version else . end) |
26+
from_entries
27+
)
28+
else . end |
29+
30+
if has("devDependencies") then
31+
.devDependencies = (
32+
.devDependencies |
33+
to_entries |
34+
map(if .key | startswith("@rnef/") then .value = $version else . end) |
35+
from_entries
36+
)
37+
else . end
38+
' "$file" > "$temp_file"
39+
40+
# Replace the original file with the updated one
41+
mv "$temp_file" "$file"
42+
}
43+
44+
# Find all package.json files in templates directory and update them
45+
find ./templates -name "package.json" -not -path "*/node_modules/*" | while read -r file; do
46+
update_package_json "$file"
47+
done
48+
49+
# Find all package.json files in packages/*/template directories and update them
50+
find ./packages -path "*/template/*" -name "package.json" -not -path "*/node_modules/*" | while read -r file; do
51+
update_package_json "$file"
52+
done
53+
54+
echo "Done! All @rnef/* dependencies have been updated to version ^$CLI_VERSION."

0 commit comments

Comments
 (0)