diff --git a/meet.sh b/meet.sh index 00b4c6d..a0a0c3b 100755 --- a/meet.sh +++ b/meet.sh @@ -379,7 +379,7 @@ add_common_dev_commands() { # Typings watcher. It generates the typings-ready.flag file when done for other watchers to wait on. CMD_NAMES+=("typings-ce") CMD_COLORS+=("bgGreen.black") - CMD_COMMANDS+=("./scripts/dev/watch-typings-ce.sh") + CMD_COMMANDS+=("./scripts/dev/watch-typings.sh ce") # shared-meet-components watcher CMD_NAMES+=("shared-meet-components") @@ -426,7 +426,7 @@ add_pro_commands() { # Typings watcher for PRO edition. It generates the typings-ready.flag file when done for other watchers to wait on. CMD_NAMES+=("typings-pro") CMD_COLORS+=("bgGreen.black") - CMD_COMMANDS+=("./scripts/dev/watch-typings-pro.sh") + CMD_COMMANDS+=("./scripts/dev/watch-typings.sh pro") } # Helper: Add REST API docs and browser-sync commands diff --git a/scripts/dev/watch-typings-ce.sh b/scripts/dev/watch-typings-ce.sh deleted file mode 100755 index 245cc31..0000000 --- a/scripts/dev/watch-typings-ce.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -# Path to the flag file indicating typings are ready -FLAG_PATH="./meet-ce/typings/dist/typings-ready.flag" - -# Remove the flag file if it exists -rm -f $FLAG_PATH - -# Create an empty directory for the flag file if it doesn't exist -mkdir -p "$(dirname "$FLAG_PATH")" - -echo "Starting typings watch mode..." -echo "Waiting for initial compilation..." - -# Run tsc in watch mode -pnpm --filter @openvidu-meet/typings run dev | while read line; do - echo "$line" - - # Check for compilation start (remove flag to signal "not ready") - if echo "$line" | grep -q "File change detected. Starting incremental compilation"; then - rm -f $FLAG_PATH - echo "Typings recompiling..." - fi - - # Check for successful compilation (create flag to signal "ready") - if echo "$line" | grep -q "Found 0 errors"; then - # Add small delay to ensure all files are written to disk - sleep 0.2 - touch $FLAG_PATH - echo "✅ Typings ready!" - fi - - # Check for compilation errors - if echo "$line" | grep -q "error TS"; then - rm -f $FLAG_PATH - echo "❌ Typings compilation failed!" - fi -done diff --git a/scripts/dev/watch-typings-pro.sh b/scripts/dev/watch-typings-pro.sh deleted file mode 100755 index 80e950c..0000000 --- a/scripts/dev/watch-typings-pro.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -# Path to the flag file indicating typings are ready -FLAG_PATH="./meet-pro/typings/dist/typings-ready.flag" - -# Remove the flag file if it exists -rm -f $FLAG_PATH - -# Create an empty directory for the flag file if it doesn't exist -mkdir -p "$(dirname "$FLAG_PATH")" - -echo "Starting typings watch mode..." -echo "Waiting for initial compilation..." - -# Run tsc in watch mode -pnpm --filter @openvidu-meet-pro/typings run dev | while read line; do - echo "$line" - - # Check for compilation start (remove flag to signal "not ready") - if echo "$line" | grep -q "File change detected. Starting incremental compilation"; then - rm -f $FLAG_PATH - echo "Typings recompiling..." - fi - - # Check for successful compilation (create flag to signal "ready") - if echo "$line" | grep -q "Found 0 errors"; then - # Add small delay to ensure all files are written to disk - sleep 0.2 - touch $FLAG_PATH - echo "✅ Typings ready!" - fi - - # Check for compilation errors - if echo "$line" | grep -q "error TS"; then - rm -f $FLAG_PATH - echo "❌ Typings compilation failed!" - fi -done diff --git a/scripts/dev/watch-typings.sh b/scripts/dev/watch-typings.sh new file mode 100755 index 0000000..50b811d --- /dev/null +++ b/scripts/dev/watch-typings.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# Usage: watch-typings.sh [mode] [pnpm-filter] +# mode: ce (default) | pro +# pnpm-filter: optional pnpm filter for running the typings package (defaults to @openvidu-meet/typings) + +set -u + +MODE=${1:-ce} +PNPM_FILTER=${2:-@openvidu-meet/typings} + +case "$MODE" in + ce|CE) + FLAG_PATH="./meet-ce/typings/dist/typings-ready.flag" + ;; + pro|PRO) + FLAG_PATH="./meet-pro/typings/dist/typings-ready.flag" + ;; + *) + echo "Usage: $0 [ce|pro] [pnpm-filter]" + exit 2 + ;; +esac + +# Remove the flag file if it exists +rm -f "$FLAG_PATH" + +# Create the directory for the flag file if it doesn't exist +mkdir -p "$(dirname "$FLAG_PATH")" + +echo "Starting typings watch mode for mode='$MODE' with pnpm filter='$PNPM_FILTER'..." +echo "Waiting for initial compilation..." + +# Run tsc in watch mode via the typings package. We stream the output and look for known patterns. +pnpm --filter "$PNPM_FILTER" run dev | while IFS= read -r line || [ -n "$line" ]; do + echo "$line" + + # Check for compilation start (remove flag to signal "not ready") + if echo "$line" | grep -q "File change detected. Starting incremental compilation"; then + rm -f "$FLAG_PATH" + echo "Typings recompiling..." + fi + + # Check for successful compilation (create flag to signal "ready") + if echo "$line" | grep -q "Found 0 errors"; then + # Add small delay to ensure all files are written to disk + sleep 0.2 + touch "$FLAG_PATH" + echo "✅ Typings ready!" + fi + + # Check for compilation errors + if echo "$line" | grep -q "error TS"; then + rm -f "$FLAG_PATH" + echo "❌ Typings compilation failed!" + fi +done + +exit 0