Skip to content

Commit fd39560

Browse files
author
Thomas G.
committed
fix: 🐛 correct crlf
1 parent 5e495af commit fd39560

9 files changed

Lines changed: 117 additions & 118 deletions

File tree

install.sh

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,34 @@ help
2828

2929
# If 'all' argument is provided, set stubs and features to install all default features
3030
if [ -n "$all" ]; then
31-
echo "${Yellow}Add default features${None}"
31+
echo -e "${Yellow}Add default features${End}"
3232
stubs=1
3333
features=$(sed '/^\s*\/\//d' $source/stubs/.devcontainer/devcontainer.json | jq -r '.features | to_entries[] | select(.key | contains("tomgrv/devcontainer-features"))| .key|
3434
split("/")[-1] | split(":")[0]')
3535
fi
3636

3737
# If 'upd' argument is provided, set stubs and features to update all features
3838
if [ -n "$upd" ]; then
39-
echo "${Green}Update features${None}"
39+
echo -e "${Green}Update features${End}"
4040
stubs=1
4141
features=$(sed '/^\s*\/\//d' $source/.devcontainer/devcontainer.json | jq -r '.features | to_entries[] | select(.key | contains("tomgrv/devcontainer-features"))| .key|
4242
split("/")[-1] | split(":")[0]')
4343
fi
4444

4545
# If 'stubs' argument is provided, indicate that stubs are selected
4646
if [ -n "$stubs" ]; then
47-
echo "${Green}Stubs selected${None}"
47+
echo -e "${Green}Stubs selected${End}"
4848
fi
4949

5050
# If 'package' argument is provided, use the specified package.json file
5151
if [ -n "$package" ]; then
5252
file="$package"
5353
if [ ! -f "$file" ]; then
54-
echo "${Red}File not found: $file${None}"
54+
echo -e "${Red}File not found: $file${End}"
5555
exit
5656
fi
5757

58-
echo "${Green}Using $file${None}"
58+
echo -e "${Green}Using $file${End}"
5959

6060
# Extract features from the package.json file if not already set
6161
if [ -z "$features" ]; then
@@ -65,16 +65,16 @@ fi
6565

6666
# If no features are selected, display an error message
6767
if [ -z "$features" ]; then
68-
echo "${Red}No features selected${None}"
68+
echo -e "${Red}No features selected${End}"
6969
else
70-
echo "${Green}Selected features: $features${None}"
70+
echo -e "${Green}Selected features: $features${End}"
7171
fi
7272

7373
# Merge all files from the stub folder to the root using git merge-file if stubs are selected
7474
if [ -n "$stubs" ]; then
75-
echo "${Yellow}Installing stubs...${None}"
75+
echo -e "${Yellow}Installing stubs...${End}"
7676
$source/src/common-utils/_configure-feature.sh -s $source .
77-
echo "${Green}Stubs installed${None}"
77+
echo -e "${Green}Stubs installed${End}"
7878
fi
7979

8080
# If features are selected, proceed with installation
@@ -86,47 +86,46 @@ if [ -n "$features" ]; then
8686
# Check if the script is running inside a container
8787
if [ "$CODESPACES" != "true" ] && [ "$REMOTE_CONTAINERS" != "true" ]; then
8888

89-
echo "${Red}You are not in a container${None}"
89+
echo -e "${Red}You are not in a container${End}"
9090

9191
# Run the install.sh script for each selected feature
9292
for feature in $features; do
9393
if [ -f "$source/src/$feature/install.sh" ]; then
94-
echo "${Yellow}Running src/$feature/install.sh...${None}"
94+
echo -e "${Yellow}Running src/$feature/install.sh...${End}"
9595
sh $source/src/$feature/install.sh
96-
echo "${Green}$feature installed${None}"
96+
echo -e "${Green}$feature installed${End}"
9797
else
98-
echo "${Red}$feature not found${None}"
98+
echo -e "${Red}$feature not found${End}"
9999
fi
100100
done
101101

102102
# Run the configure.sh script for each selected feature
103103
for feature in $features; do
104104
if [ -d "/tmp/$feature" ]; then
105-
echo "${Yellow}Configuring /tmp/$feature...${None}"
105+
echo -e "${Yellow}Configuring /tmp/$feature...${End}"
106106
sh $source/src/common-utils/_configure-feature.sh -s /tmp/$feature $feature
107-
echo "${Green}$feature configured${None}"
107+
echo -e "${Green}$feature configured${End}"
108108
else
109-
echo "${Red}$feature not found${None}"
109+
echo -e "${Red}$feature not found${End}"
110110
fi
111111
done
112112

113-
elif [ -n "$stubs" ]
114-
then
113+
elif [ -n "$stubs" ]; then
115114

116-
# stubs are selected, configure stubs of the selected features
115+
# stubs are selected, configure stubs of the selected features
117116
for feature in $features; do
118-
echo "${Yellow}Deploying stubs for $feature...${None}"
117+
echo -e "${Yellow}Deploying stubs for $feature...${End}"
119118
$source/src/common-utils/_configure-feature.sh -s $source/src/$feature $feature
120-
echo "${Green}Stubs for $feature deployed${None}"
119+
echo -e "${Green}Stubs for $feature deployed${End}"
121120
done
122-
121+
123122
else
124123
# If inside a container, suggest using devutils as devcontainer features
125-
echo "${Purple}You are in a container: use devutils as devcontainer features:${None}"
124+
echo -e "${Purple}You are in a container: use devutils as devcontainer features:${End}"
126125
for feature in $features; do
127-
echo "${Purple}ghcr.io/tomgrv/devcontainer-features/$feature${None}"
126+
echo -e "${Purple}ghcr.io/tomgrv/devcontainer-features/$feature${End}"
128127
done
129-
128+
130129
fi
131130
fi
132131

src/common-utils/_configure-feature.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
# Source colors script
44
. zz_colors
@@ -12,7 +12,7 @@ help
1212
)
1313

1414
if [ -z "$feature" ]; then
15-
echo "Usage: configure-feature <feature>"
15+
echo -e "Usage: configure-feature <feature>\r"
1616
exit 1
1717
fi
1818

@@ -22,16 +22,16 @@ export source=${source:-/usr/local/share/$feature}
2222
# Get the indent size from devcontainer.json with jq, default to 2 if not found
2323
export tabSize=4
2424

25-
echo "Configuring feature <${Purple}$feature${None}>"
26-
echo "from <$source>"
25+
echo -e "Configuring feature <${Purple}$feature${None}>\r"
26+
echo -e "from <$source>\r"
2727

2828
# Go to the module root
2929
cd "$(git rev-parse --show-toplevel)" >/dev/null
3030

3131
# Deploy stubs if existing
3232
if [ -d $source/stubs ]; then
3333

34-
echo "${Blue}Deploy stubs${None}"
34+
echo -e "${Blue}Deploy stubs${End}"
3535

3636
find $source/stubs -type f -name ".*" -o -type f | while read file; do
3737

@@ -50,14 +50,14 @@ if [ -d $source/stubs ]; then
5050
# Remove # occurrences in the file path
5151
dest=$(echo $dest | sed 's/\/\#/\//g')
5252

53-
echo "Add '$dest' to .gitignore"
53+
echo -e "Add '$dest' to .gitignore\r"
5454

5555
# Add to .gitignore if not already there
56-
grep -qxF $dest .gitignore || echo "$dest" >>.gitignore
56+
grep -qxF $dest .gitignore || echo -e "$dest" >>.gitignore
5757
fi
5858

5959
# Merge the file
60-
echo "${Yellow}Merging '$dest'...${None}"
60+
echo -e "${Yellow}Merging '$dest'...${End}"
6161
git merge-file -p -L current -L base -L stubs $dest /dev/null $file >$dest
6262

6363
# Apply the same permissions as the original file
@@ -67,7 +67,7 @@ if [ -d $source/stubs ]; then
6767
fi
6868

6969
# Log the merging process
70-
echo "${Blue}Merge all package folder json files into top level xxx.json${None}"
70+
echo -e "${Blue}Merge all package folder json files into top level xxx.json${End}"
7171

7272
for package in package composer; do
7373

@@ -77,19 +77,19 @@ for package in package composer; do
7777
echo "{}" >$package.json
7878
else
7979
# Pre-sort the existing package.json
80-
echo "${Yellow}Pre-merge normalize $package.json${None}"
80+
echo -e "${Yellow}Pre-merge normalize $package.json${End}"
8181
normalize-json -s -a -i -t ${tabSize:-4} $package.json
8282
fi
8383

8484
# Merge all package folder json files into the top-level package.json
8585
find $source -maxdepth 1 -name _*.$package.json | sort | while read file; do
86-
echo "${Yellow}Merge $file in $package.json${None}"
86+
echo -e "${Yellow}Merge $file in $package.json${End}"
8787
jq --indent ${tabSize:-4} -s '.[0] * .[1]' $file $package.json >/tmp/$package.json && mv -f /tmp/$package.json $package.json
8888
done
8989

9090
done
9191

9292
# Call all configure-xxx.sh scripts
9393
find $source -maxdepth 1 -name configure-*.sh | sort | while read file; do
94-
echo "${Yellow}Run $file${None}"
94+
echo -e "${Yellow}Run $file${End}"
9595
done

src/common-utils/_install-bin.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
# Source colors script
44
. zz_colors
@@ -9,16 +9,16 @@ eval $(
99
)
1010

1111
if [ -z "$feature" ]; then
12-
echo "Usage: install-bin <feature>"
12+
echo -e "Usage: install-bin <feature>\r"
1313
exit 1
1414
fi
1515

16-
echo "Installing bin scripts for <${Purple}$feature${None}>..."
16+
echo -e "Installing bin scripts for <${Purple}$feature${None}>...\r"
1717

1818
# Find all shell scripts in the target directory, make them executable, and create symbolic links in /usr/local/bin
1919
find $target -type f -name "_*.sh" -exec echo {} \; -exec chmod +x {} \; | while read file; do
2020
# Create a symbolic link in /usr/local/bin with the script name (without the leading underscore and .sh extension)
2121
link=/usr/local/bin/$(basename $file | sed 's/^_//;s/.sh$//')
2222
ln -sf $file $link
23-
echo "${Green}Linked '$file' to '$link'${None}"
23+
echo -e "${Green}Linked '$file' to '$link'${End}"
2424
done
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
# Source colors script
44
. zz_colors
@@ -9,28 +9,28 @@ eval $(
99
)
1010

1111
if [ -z "$feature" ]; then
12-
echo "Usage: install-feature <feature>"
12+
echo -e "Usage: install-feature <feature>\r"
1313
exit 1
1414
fi
1515

16-
echo "Installing feature <${Purple}$feature${None}>..."
16+
echo -e "Installing feature <${Purple}$feature${None}>...\r"
1717

1818
# Copy stubs to the target directory
1919
if [ -d $source/stubs ]; then
20-
echo "${Blue}Copying stubs to '$target'...${None}"
20+
echo -e "${Blue}Copying stubs to '$target'...${End}"
2121
mkdir -p $target/stubs && cp -r $source/stubs/* $target/stubs
2222
else
23-
echo "${Yellow}No stubs found in '$source'${None}"
23+
echo -e "${Yellow}No stubs found in '$source'${End}"
2424
fi
2525

2626
# Install specific utils by copying them to the target directory and making them executable
2727
find $source \( -name "_*" -o -name "configure-*.sh" -o -path "stubs" \) -type f -exec cp {} $target \;
2828
find $target -type f -name "*.sh" -exec chmod +x {} \;
2929

3030
# Call all the install-xxx scripts in the feature directory
31-
echo "${Blue}Calling all install scripts in '$source'...${None}"
31+
echo -e "${Blue}Calling all install scripts in '$source'...${End}"
3232
find $source -type f -name "install-*.sh" | while read script; do
33-
echo "${Yellow}Calling $script...${None}"
33+
echo -e "${Yellow}Calling $script...${End}"
3434
sh $script "$@"
35-
echo "${Green}Done!${None}"
35+
echo -e "${Green}Done!${End}"
3636
done

0 commit comments

Comments
 (0)