11#! /bin/bash
22
3- # Function to get current version from package.json
43get_current_version () {
54 local package_json=$1
65 if [ -f " $package_json " ]; then
@@ -11,7 +10,6 @@ get_current_version() {
1110 fi
1211}
1312
14- # Function to get package name from package.json
1513get_package_name () {
1614 local package_json=$1
1715 if [ -f " $package_json " ]; then
@@ -22,7 +20,12 @@ get_package_name() {
2220 fi
2321}
2422
25- # Function to update version
23+ if [ -n " $( git status --porcelain) " ]; then
24+ echo " Error: There are uncommitted changes in the working directory"
25+ echo " Please commit or stash these changes before proceeding"
26+ exit 1
27+ fi
28+
2629update_version () {
2730 local package_dir=$1
2831 local version_type=$2
@@ -44,28 +47,23 @@ update_version() {
4447 esac
4548}
4649
47- # Main script
4850echo " Starting package version management..."
4951
50- # Get root package version
5152root_package_json=" packages/laravel-echo/package.json"
5253current_version=$( get_current_version " $root_package_json " )
5354echo " "
5455echo " Current version: $current_version "
5556echo " "
5657
57- # Get version type once
5858read -p " Update version? (patch/minor/major): " version_type
5959echo " "
6060
61- # Iterate through packages directory
6261for package_dir in packages/* ; do
6362 if [ -d " $package_dir " ]; then
6463 echo " Updating version for $package_dir "
6564
6665 cd $package_dir
6766
68- # Update version
6967 update_version " $package_dir " " $version_type "
7068
7169 cd ../..
@@ -74,22 +72,36 @@ for package_dir in packages/*; do
7472 fi
7573done
7674
77- # Get new version from root package
7875new_version=$( get_current_version " $root_package_json " )
7976
80- # Install dependencies
8177echo " Updating lock file..."
8278pnpm i
8379
84- # Create single git tag
80+ echo " Staging package.json files..."
81+ git add " **/package.json"
82+ echo " "
83+
84+ echo " Committing version changes..."
85+ git commit -m " v$new_version "
86+ echo " "
87+
8588echo " "
8689echo " Creating git tag: v$new_version "
8790git tag " v$new_version "
8891echo " "
8992
9093echo " Running release process..."
9194echo " "
92- pnpm -r run release
95+
96+ for package_dir in packages/* ; do
97+ if [ -d " $package_dir " ]; then
98+ echo " Releasing $package_dir "
99+ cd $package_dir
100+ pnpm run release
101+ cd ../..
102+ echo " "
103+ fi
104+ done
93105
94106# Echo joke
95107echo " Released! (Released!) (Released!)"
0 commit comments