diff --git a/scripts/install_collections.sh b/scripts/install_collections.sh index a0838d3..b38e359 100755 --- a/scripts/install_collections.sh +++ b/scripts/install_collections.sh @@ -45,11 +45,10 @@ while read -r manifest_path; do # Use yq to update items.src # 1. Prepend relative dir to everything # 2. Fix absolute paths to remain absolute - cp "$manifest_path" "${manifest_path}.tmp" - yq -i e " + cat "$manifest_path" | yq e " .[] .items[] .src |= \"$rel_dir\" + . | .[] .items[] .src |= sub(\"^$rel_dir/\", \"\") - " "${manifest_path}.tmp" + " | tee "${manifest_path}.tmp" > /dev/null cat "${manifest_path}.tmp" >> "$MERGED_MANIFEST" rm "${manifest_path}.tmp" fi @@ -63,7 +62,7 @@ if [ ! -s "$MERGED_MANIFEST" ]; then fi # 3. Parse Collections from Config -COLLECTIONS_LIST=$(yq '.copilot.collections[]' "$CONFIG_FILE" | tr '\n' ' ') +COLLECTIONS_LIST=$(cat "$CONFIG_FILE" | yq '.copilot.collections[]' | tr '\n' ' ') if [ -z "$COLLECTIONS_LIST" ]; then echo "⚠️ No collections found in config file." @@ -76,33 +75,33 @@ process_collection() { local col_name=$1 echo " 📦 Processing Collection: $col_name" - if ! yq -e ".${col_name}" "$MERGED_MANIFEST" > /dev/null; then + if ! cat "$MERGED_MANIFEST" | yq -e ".${col_name}" > /dev/null; then echo " ❌ Error: Collection '$col_name' not found in any manifest." exit 1 fi # Handle Includes (Recursion) local includes - includes=$(yq ".${col_name}.includes[]" "$MERGED_MANIFEST" 2>/dev/null || true) + includes=$(cat "$MERGED_MANIFEST" | yq ".${col_name}.includes[]" 2>/dev/null || true) for included_col in $includes; do process_collection "$included_col" done # Handle Items local count - count=$(yq ".${col_name}.items | length" "$MERGED_MANIFEST") + count=$(cat "$MERGED_MANIFEST" | yq ".${col_name}.items | length") if [ "$count" -gt 0 ]; then for ((i=0; i $dest" - + if [ -d "$full_src" ]; then # Folder Copy mkdir -p "$dest" diff --git a/scripts/local_sync.sh b/scripts/local_sync.sh index 3246c7c..0b1acd2 100644 --- a/scripts/local_sync.sh +++ b/scripts/local_sync.sh @@ -56,7 +56,7 @@ fi echo -e "${BLUE}📄 Using config:${NC} $CONFIG_FILE" -VERSION=$(yq '.copilot.version' "$CONFIG_FILE") +VERSION=$(cat "$CONFIG_FILE" | yq '.copilot.version') if [ "$VERSION" == "null" ] || [ -z "$VERSION" ]; then echo -e "${RED}❌ Error: Could not read '.copilot.version' from $CONFIG_FILE${NC}" exit 1 diff --git a/scripts/validate_collections.sh b/scripts/validate_collections.sh index a1397d6..3577ec5 100755 --- a/scripts/validate_collections.sh +++ b/scripts/validate_collections.sh @@ -32,7 +32,7 @@ FAILED=0 while read -r manifest; do # Get keys (collection names) # We use -r to get raw output (no quotes) - keys=$(yq e 'keys | .[]' "$manifest" 2>/dev/null || true) + keys=$(cat "$manifest" | yq e 'keys | .[]' 2>/dev/null || true) for key in $keys; do if [[ -n "${ALL_COLLECTIONS[$key]}" ]]; then @@ -56,11 +56,11 @@ echo " - Checking referential integrity..." while read -r manifest; do manifest_dir=$(dirname "$manifest") - keys=$(yq e 'keys | .[]' "$manifest" 2>/dev/null || true) + keys=$(cat "$manifest" | yq e 'keys | .[]' 2>/dev/null || true) for col in $keys; do # Check Includes - includes=$(yq e ".[\"$col\"].includes[]" "$manifest" 2>/dev/null || true) + includes=$(cat "$manifest" | yq e ".[\"$col\"].includes[]" 2>/dev/null || true) for inc in $includes; do if [[ -z "${ALL_COLLECTIONS[$inc]}" ]]; then echo -e "${RED}❌ Error: Collection '$col' (in $manifest) includes missing collection '$inc'${NC}" @@ -69,10 +69,10 @@ while read -r manifest; do done # Check Assets - count=$(yq e ".[\"$col\"].items | length" "$manifest") + count=$(cat "$manifest" | yq e ".[\"$col\"].items | length") if [ "$count" -gt 0 ]; then for ((i=0; i