@@ -22,16 +22,22 @@ export source=${source:-/usr/local/share/$feature}
2222# Get the indent size from devcontainer.json with jq, default to 2 if not found
2323export tabSize=4
2424
25- echo " Configuring feature <$ {Purple} $feature ${None} > ${End} "
26- echo " from < $source > ${End }"
25+ zz_log i " Configure feature <{Purple $feature }> "
26+ zz_log - " From {U $source }"
2727
2828# Go to the module root
2929cd " $( git rev-parse --show-toplevel) " > /dev/null
3030
31+ # Ensure the source directory exists
32+ if [ ! -d $source ]; then
33+ zz_log e " Source directory <$source > does not exist"
34+ exit 1
35+ fi
36+
3137# Deploy stubs if existing
3238if [ -d $source /stubs ]; then
3339
34- echo " ${Blue} Deploy stubs${End} "
40+ zz_log i " Deploy stubs"
3541
3642 find $source /stubs -type f -name " .*" -o -type f | while read file; do
3743
@@ -50,14 +56,15 @@ if [ -d $source/stubs ]; then
5056 # Remove # occurrences in the file path
5157 dest=$( echo $dest | sed ' s/\/\#/\//g' )
5258
53- echo " Add '$dest ' to .gitignore${End} "
59+ # Add to .gitignore if not already there
60+ zz_log i " Add {U $dest } to .gitignore"
5461
5562 # Add to .gitignore if not already there
5663 grep -qxF $dest .gitignore || echo -e " $dest " >> .gitignore
5764 fi
5865
5966 # Merge the file
60- echo -e " ${Yellow} Merging ' $dest '... ${End }"
67+ zz_log i " Merge {U $file } in {U $dest }"
6168 git merge-file -p -L current -L base -L stubs $dest /dev/null $file > $dest
6269
6370 # Apply the same permissions as the original file
@@ -67,30 +74,29 @@ if [ -d $source/stubs ]; then
6774fi
6875
6976# Log the merging process
70- echo " ${Blue} Merge all package folder json files into top level xxx.json${End} "
77+ zz_log i " Merge all package folder json files into top level xxx.json"
7178
7279for package in package composer; do
7380
7481 # Create package.json if it does not exist or is empty
7582 if [ ! -f $package .json -o ! -s $package .json ]; then
7683 # Create an empty package.json
7784 echo " {}" > $package .json
78- else
79- # Pre-sort the existing package.json
80- echo " ${Yellow} Pre-merge normalize $package .json${End} "
81- normalize-json -s -a -i -t ${tabSize:- 4} $package .json
8285 fi
8386
8487 # Merge all package folder json files into the top-level package.json
8588 find $source -maxdepth 1 -name _* .$package .json | sort | while read file; do
86- echo " ${Yellow} Merge $file in $package .json${End }"
89+ zz_log i " Merge {U $file } in {U $package .json}"
8790 jq --indent ${tabSize:- 4} -s ' .[0] * .[1]' $file $package .json > /tmp/$package .json && mv -f /tmp/$package .json $package .json
8891 done
8992
93+ # Post merge normalize package.json
94+ zz_log i " Post-merge normalize {U $package .json}"
95+ normalize-json -s -a -i -t ${tabSize:- 4} $package .json
9096done
9197
9298# Call all configure-xxx.sh scripts
9399find $source -maxdepth 1 -name configure-* .sh | sort | while read file; do
94- echo " ${Yellow} Run $file ${End }"
100+ zz_log i " Run {U $file }"
95101 $file
96102done
0 commit comments