Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions scripts/install_collections.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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."
Expand All @@ -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<count; i++)); do
local src dest
src=$(yq ".${col_name}.items[$i].src" "$MERGED_MANIFEST")
dest=$(yq ".${col_name}.items[$i].dest" "$MERGED_MANIFEST")
src=$(cat "$MERGED_MANIFEST" | yq ".${col_name}.items[$i].src")
dest=$(cat "$MERGED_MANIFEST" | yq ".${col_name}.items[$i].dest")

# Resolve full path for source
local full_src="$TOOLKIT_DIR/$src"

echo " - Installing $src -> $dest"

if [ -d "$full_src" ]; then
# Folder Copy
mkdir -p "$dest"
Expand Down
2 changes: 1 addition & 1 deletion scripts/local_sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions scripts/validate_collections.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
Expand All @@ -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<count; i++)); do
src=$(yq e ".[\"$col\"].items[$i].src" "$manifest")
src=$(cat "$manifest" | yq e ".[\"$col\"].items[$i].src")

# Resolve Path
if [[ "$src" == /* ]]; then
Expand All @@ -93,7 +93,7 @@ while read -r manifest; do
FAILED=1
elif [ -d "$full_path" ]; then
# If src is a directory, dest MUST end with /
dest=$(yq e ".[\"$col\"].items[$i].dest" "$manifest")
dest=$(cat "$manifest" | yq e ".[\"$col\"].items[$i].dest")
if [[ "$dest" != */ ]]; then
echo -e "${RED}❌ Error: Collection '$col' item '$src' is a directory, so dest '$dest' must end with '/'${NC}"
FAILED=1
Expand Down
Loading