11#! /bin/bash
22
3- # Script to install dependencies and update RealtimeKit packages in all samples
3+ # Script to install dependencies and update RealtimeKit packages in all examples
44# Exits on first error to prevent cascading failures
55
66set -e # Exit on any error
3737
3838# Get script directory
3939SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
40- SAMPLES_DIR =" $SCRIPT_DIR /samples "
40+ EXAMPLES_DIR =" $SCRIPT_DIR /examples "
4141
4242# Get latest package versions
4343print_info " Fetching latest package versions..."
@@ -58,26 +58,26 @@ rm -rf node_modules package-lock.json
5858print_info " Nuking NPM Cache due to trust issues..."
5959npm cache clean --force
6060
61- print_info " Installing dependencies in all sample repositories..."
61+ print_info " Installing dependencies in all example repositories..."
6262
63- # Process each sample directory
64- for sample_dir in " $SAMPLES_DIR " /* ; do
65- if [ -d " $sample_dir " ] && [ -f " $sample_dir /package.json" ]; then
66- sample_name =$( basename " $sample_dir " )
63+ # Process each example directory
64+ for example_dir in " $EXAMPLES_DIR " /* ; do
65+ if [ -d " $example_dir " ] && [ -f " $example_dir /package.json" ]; then
66+ example_name =$( basename " $example_dir " )
6767 echo " "
68- print_info " === Processing $sample_name ==="
68+ print_info " === Processing $example_name ==="
6969
70- cd " $sample_dir " || {
71- print_error " Failed to enter directory $sample_dir "
70+ cd " $example_dir " || {
71+ print_error " Failed to enter directory $example_dir "
7272 exit 1
7373 }
7474
7575 # Clean install - remove node_modules
76- print_info " Cleaning node_modules in $sample_name ..."
76+ print_info " Cleaning node_modules in $example_name ..."
7777 rm -rf node_modules
7878
7979 # Ensure all required RealtimeKit packages are present in package.json
80- print_info " Ensuring all RealtimeKit packages are present in $sample_name ..."
80+ print_info " Ensuring all RealtimeKit packages are present in $example_name ..."
8181
8282 # Function to add package if not present
8383 add_package_if_missing () {
@@ -96,7 +96,7 @@ for sample_dir in "$SAMPLES_DIR"/*; do
9696 add_package_if_missing " @cloudflare/realtimekit-ui-addons" " $REALTIMEKIT_UI_ADDONS_VERSION "
9797
9898 # Update package.json versions
99- print_info " Updating package.json versions in $sample_name ..."
99+ print_info " Updating package.json versions in $example_name ..."
100100
101101 # Update RealtimeKit packages in package.json
102102 if grep -q " @cloudflare/realtimekit\" " package.json; then
@@ -120,16 +120,16 @@ for sample_dir in "$SAMPLES_DIR"/*; do
120120 fi
121121
122122 # Single npm install after updating all versions
123- print_info " Installing all dependencies in $sample_name ..."
123+ print_info " Installing all dependencies in $example_name ..."
124124 if ! npm install --legacy-peer-deps --no-workspaces; then
125- print_error " Failed to install dependencies in $sample_name "
125+ print_error " Failed to install dependencies in $example_name "
126126 exit 1
127127 fi
128128
129129 cd - > /dev/null
130- print_success " ✓ Completed $sample_name "
130+ print_success " ✓ Completed $example_name "
131131 fi
132132done
133133
134134echo " "
135- print_success " 🎉 All samples processed successfully!"
135+ print_success " 🎉 All examples processed successfully!"
0 commit comments