66# bin/ci-switch-config latest # Ruby 3.4, Node 22, latest deps
77# bin/ci-switch-config status # Show current configuration
88
9- set -e
9+ set -euo pipefail
1010
1111SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
1212PROJECT_ROOT=" $( cd " $SCRIPT_DIR /.." && pwd) "
@@ -67,30 +67,34 @@ show_status() {
6767 echo " "
6868 echo " Dependency versions:"
6969
70+ SHAKAPACKER_GEM=" "
7071 if [ -f " $PROJECT_ROOT /Gemfile.development_dependencies" ]; then
71- SHAKAPACKER_GEM=$( grep ' gem "shakapacker"' " $PROJECT_ROOT /Gemfile.development_dependencies" | sed -E ' s/.*"([0-9.]+)".*/\1/' )
72- echo " Shakapacker (gem): $SHAKAPACKER_GEM "
72+ SHAKAPACKER_GEM=$( grep ' gem "shakapacker"' " $PROJECT_ROOT /Gemfile.development_dependencies" | sed -E ' s/.*"([0-9.]+)".*/\1/' || echo " " )
73+ echo " Shakapacker (gem): ${ SHAKAPACKER_GEM:- not found} "
7374 fi
7475
76+ SHAKAPACKER_NPM=" "
7577 if [ -f " $PROJECT_ROOT /spec/dummy/package.json" ]; then
76- SHAKAPACKER_NPM=$( grep ' "shakapacker"' " $PROJECT_ROOT /spec/dummy/package.json" | sed -E ' s/.*"([0-9.]+)".*/\1/' )
77- echo " Shakapacker (npm): $SHAKAPACKER_NPM "
78+ SHAKAPACKER_NPM=$( grep ' "shakapacker"' " $PROJECT_ROOT /spec/dummy/package.json" | sed -E ' s/.*"([0-9.]+)".*/\1/' || echo " " )
79+ echo " Shakapacker (npm): ${ SHAKAPACKER_NPM:- not found} "
7880 fi
7981
82+ REACT_ROOT=" "
8083 if [ -f " $PROJECT_ROOT /package.json" ]; then
81- REACT_ROOT=$( grep ' "react":' " $PROJECT_ROOT /package.json" | head -1 | sed -E ' s/.*"([^"]+)".*/\1/' )
82- echo " React (root): $REACT_ROOT "
84+ REACT_ROOT=$( grep ' "react":' " $PROJECT_ROOT /package.json" | head -1 | sed -E ' s/.*"([^"]+)".*/\1/' || echo " " )
85+ echo " React (root): ${ REACT_ROOT:- not found} "
8386 fi
8487
88+ REACT_DUMMY=" "
8589 if [ -f " $PROJECT_ROOT /spec/dummy/package.json" ]; then
86- REACT_DUMMY=$( grep ' "react":' " $PROJECT_ROOT /spec/dummy/package.json" | sed -E ' s/.*"([^"]+)".*/\1/' )
87- echo " React (dummy): $REACT_DUMMY "
90+ REACT_DUMMY=$( grep ' "react":' " $PROJECT_ROOT /spec/dummy/package.json" | sed -E ' s/.*"([^"]+)".*/\1/' || echo " " )
91+ echo " React (dummy): ${ REACT_DUMMY:- not found} "
8892 fi
8993
9094 echo " "
91- if [[ " $SHAKAPACKER_GEM " == " 8.2.0" ]] && [[ " $REACT_ROOT " == " 18.0.0" ]]; then
95+ if [[ " ${ SHAKAPACKER_GEM} " == " 8.2.0" ]] && [[ " ${ REACT_ROOT} " == " 18.0.0" ]]; then
9296 echo -e " Current config: ${GREEN} minimum${NC} (matches CI: Ruby 3.2, Node 20, minimum deps)"
93- elif [[ " $SHAKAPACKER_GEM " == " 9.3.0" ]] && [[ " $REACT_ROOT " =~ 19 ]]; then
97+ elif [[ " ${ SHAKAPACKER_GEM} " == " 9.3.0" ]] && [[ " ${ REACT_ROOT} " =~ 19 ]]; then
9498 echo -e " Current config: ${GREEN} latest${NC} (matches CI: Ruby 3.4, Node 22, latest deps)"
9599 else
96100 echo -e " Current config: ${YELLOW} unknown/mixed${NC} "
@@ -108,9 +112,9 @@ switch_to_minimum() {
108112 # Check if we have git changes
109113 if ! git diff --quiet || ! git diff --cached --quiet; then
110114 print_warning " You have uncommitted changes. This script will modify files."
111- read -p " Continue? (y/N) " -n 1 -r
115+ read -p " Continue? (y/N) " -n 1 -r REPLY
112116 echo
113- if [[ ! $ REPLY =~ ^[Yy]$ ]]; then
117+ if [[ ! " ${ REPLY} " =~ ^[Yy]$ ]]; then
114118 echo " Aborted."
115119 exit 1
116120 fi
@@ -188,9 +192,9 @@ restore_to_latest() {
188192 # Check if we have git changes
189193 if ! git diff --quiet || ! git diff --cached --quiet; then
190194 print_warning " You have uncommitted changes. This script will restore from git."
191- read -p " Continue? This will discard changes to package.json, Gemfile, etc. (y/N) " -n 1 -r
195+ read -p " Continue? This will discard changes to package.json, Gemfile, etc. (y/N) " -n 1 -r REPLY
192196 echo
193- if [[ ! $ REPLY =~ ^[Yy]$ ]]; then
197+ if [[ ! " ${ REPLY} " =~ ^[Yy]$ ]]; then
194198 echo " Aborted."
195199 exit 1
196200 fi
0 commit comments