Skip to content

Commit 2857708

Browse files
updates
1 parent 0d4d808 commit 2857708

File tree

9 files changed

+136
-55
lines changed

9 files changed

+136
-55
lines changed

data/codes.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,19 @@
8686
},
8787
{
8888
"code": "0205",
89-
"message": "Error occurred during Node.js installation. Retrying to install Node.js with console output enabled...",
89+
"message": "Error occurred during Node.js installation. Retrying to install Node.js with console output enabled... (Attempt #4)",
90+
"crashed": false,
91+
"link": ""
92+
},
93+
{
94+
"code": "0207",
95+
"message": "Error occurred during Node.js installation. Retrying to install Node.js with console output enabled... (Attempt #2)",
96+
"crashed": false,
97+
"link": ""
98+
},
99+
{
100+
"code": "0208",
101+
"message": "Error occurred during Node.js installation. Retrying to install Node.js... (Attempt #3)",
90102
"crashed": false,
91103
"link": ""
92104
}

src/documentation/checks.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ config=$(cat just.config.json)
2727
docs_config=$(echo "$config" | jq -r '.docs_config')
2828
if ! echo "$config" | jq -e '.docs_config' > /dev/null; then
2929
ERROR_MESSAGE=$(ErrorMessage "docs/checks.sh" "0118")
30-
echo "$ERROR_MESSAGE" && exit 1
30+
echo -e "$ERROR_MESSAGE" && exit 1
3131
fi
3232

3333
validate_docs_config() {
3434
local metatitle=$(echo "$config" | jq -r '.docs_config.metatitle' > /dev/null)
3535
if [[ -z "$metatitle" ]]; then
3636
local ERROR_MESSAGE=$(ErrorMessage "docs/checks.sh" "0119")
37-
echo "$ERROR_MESSAGE" && exit 1
37+
echo -e "$ERROR_MESSAGE" && exit 1
3838
fi
3939
local domain=$(echo "$config" | jq -r '.docs_config.domain' > /dev/null)
4040
if [[ -z "$domain" ]]; then
4141
local ERROR_MESSAGE=$(ErrorMessage "docs/checks.sh" "0120")
42-
echo "$ERROR_MESSAGE" && exit 1
42+
echo -e "$ERROR_MESSAGE" && exit 1
4343
fi
4444
}
4545

src/modules/color.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2025 JustStudio. <https://juststudio.is-a.dev/>
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
#!/bin/bash
24+
_RESET='\033[0m'
25+
_RED='\033[0;31m'
26+
_GREEN='\033[0;32m'
27+
_ORANGE='\033[0;33m'
28+
_BLUE='\033[0;34m'
29+
_PURPLE='\033[0;35m'
30+
_CYAN='\033[0;36m'
31+
_LIGHTGRAY='\033[0;37m'
32+
_DARKGRAY='\033[1;30m'
33+
_LIGHTRED='\033[1;31m'
34+
_LIGHTGREEN='\033[1;32m'
35+
_YELLOW='\033[1;33m'
36+
_LIGHTBLUE='\033[1;34m'
37+
_LIGHTPURPLE='\033[1;35m'
38+
_LIGHTCYAN='\033[1;36m'
39+
_WHITE='\033[1;37m'
40+
41+
export _RESET
42+
export _RED
43+
export _GREEN
44+
export _ORANGE
45+
export _BLUE
46+
export _PURPLE
47+
export _CYAN
48+
export _LIGHTGRAY
49+
export _DARKGRAY
50+
export _LIGHTRED
51+
export _LIGHTGREEN
52+
export _YELLOW
53+
export _LIGHTBLUE
54+
export _LIGHTPURPLE
55+
export _LIGHTCYAN
56+
export _WHITE

src/modules/errmsg.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,28 @@
2424
ERRORS_FILE="$GITHUB_ACTION_PATH/data/codes.json"
2525
ERROR_PREFIX="Just an Ultimate Site Tool"
2626
NEWLINES="\n\n\n\n"
27+
source $GITHUB_ACTION_PATH/src/modules/color.sh
2728

2829
ErrorMessage() {
2930
local ERROR_CODE=$2
3031
local ERROR_MESSAGE=${3:-$(jq -r ".[\"$1\"][] | select(.code==\"$ERROR_CODE\") | .message" "$ERRORS_FILE")}
3132
local ERROR_LINK=$(jq -r ".[\"$1\"][] | select(.code==\"$ERROR_CODE\") | .link" "$ERRORS_FILE")
3233
local ERROR_TYPE="Error"
34+
local ERROR_COLOR=$_RED
3335
if [[ $ERROR_CODE == 02* ]]; then
3436
ERROR_TYPE="Warning"
37+
ERROR_COLOR=$_YELLOW
3538
fi
36-
echo -e "$NEWLINES $ERROR_PREFIX: $ERROR_TYPE $ERROR_CODE: $ERROR_MESSAGE $ERROR_LINK $NEWLINES"
39+
echo -e "$NEWLINES$ERROR_COLOR$ERROR_PREFIX: $ERROR_TYPE $ERROR_CODE: $ERROR_MESSAGE $ERROR_LINK$_RESET$NEWLINES"
3740
}
3841

3942
_justMessage() {
4043
local MESSAGE=$1
41-
echo -e "$NEWLINES $ERROR_PREFIX: INFO: $MESSAGE $NEWLINES"
44+
echo -e "$NEWLINES$ERROR_PREFIX: INFO:$MESSAGE $NEWLINES"
4245
}
4346

4447
customErrorMessage() {
45-
echo -e "$NEWLINES $ERROR_PREFIX: $1 $2: $3 $NEWLINES"
48+
echo -e "$NEWLINES$ERROR_PREFIX: $1 $2: $3 $NEWLINES"
4649
}
4750

4851
export -f ErrorMessage

src/postprocessor/create_api_endpoints.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ source $GITHUB_ACTION_PATH/src/modules/errmsg.sh
2626

2727
if [ -d "deploy/api" ]; then
2828
local ERROR_MESSAGE=$(ErrorMessage "postprocessor/create_api_endpoints.sh" "0102")
29-
echo "$ERROR_MESSAGE" && exit 1
29+
echo -e "$ERROR_MESSAGE" && exit 1
3030
fi
3131
mkdir -p deploy/api/
3232

src/postprocessor/modify_deployment.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525
source $GITHUB_ACTION_PATH/src/modules/errmsg.sh
2626
if [ -d "deploy/_just" ]; then
2727
local ERROR_MESSAGE=$(ErrorMessage "postprocessor/modify_deployment.sh" "0103")
28-
echo "$ERROR_MESSAGE" && exit 1
28+
echo -e "$ERROR_MESSAGE" && exit 1
2929
fi
3030
mkdir -p deploy/_just/
3131

3232
if [ -d "_just/dangerously-insert-files/_just" ]; then
3333
local ERROR_MESSAGE=$(ErrorMessage "postprocessor/modify_deployment.sh" "0104")
34-
echo "$ERROR_MESSAGE" && exit 1
34+
echo -e "$ERROR_MESSAGE" && exit 1
3535
fi
3636
if [ -d "_just/dangerously-insert-files/_next" ]; then
3737
local ERROR_MESSAGE=$(ErrorMessage "postprocessor/modify_deployment.sh" "0105")
38-
echo "$ERROR_MESSAGE" && exit 1
38+
echo -e "$ERROR_MESSAGE" && exit 1
3939
fi
4040

4141
echo -e "\n----------------\n\n_just Chunks:\n"

src/postprocessor/override_deployment.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ done
4545

4646
if [ -f "deploy/404.html" ]; then
4747
local ERROR_MESSAGE=$(ErrorMessage "postprocessor/override_deployment.sh" "0202")
48-
echo "$ERROR_MESSAGE"
48+
echo -e "$ERROR_MESSAGE"
4949
fi
5050
if [ ! -f "deploy/404.html" ]; then
5151
cp _just/404.html deploy/404.html

src/redirect/checks.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@
2222

2323
#!/bin/bash
2424
source $GITHUB_ACTION_PATH/src/modules/errmsg.sh
25+
source $GITHUB_ACTION_PATH/src/modules/color.sh
2526
config=$(cat just.config.json)
2627

2728
redirect_config_=$(echo "$config" | jq -r '.redirect_config')
2829
if ! echo "$config" | jq -e '.redirect_config' > /dev/null; then
2930
local ERROR_MESSAGE=$(ErrorMessage "redirect/checks.sh" "0117")
30-
echo "$ERROR_MESSAGE" && exit 1
31+
echo -e "$ERROR_MESSAGE" && exit 1
3132
fi
3233

3334
validate_redirect_config() {
3435
local url=$(echo "$config" | jq -r '.redirect_config.url' > /dev/null)
3536
if [[ -z "$url" ]]; then
3637
local ERROR_MESSAGE=$(ErrorMessage "redirect/checks.sh" "0114")
37-
echo "$ERROR_MESSAGE" && exit 1
38+
echo -e "$ERROR_MESSAGE" && exit 1
3839
fi
3940
}
4041

@@ -47,10 +48,10 @@ validate_paths() {
4748
local path_=$(echo "$path" | jq -r '.path_')
4849
if [[ -z "$url"]]; then
4950
local ERROR_MESSAGE=$(customErrorMessage "Error" "0115" "Missing \"url\" in item #$countt in \"paths\" in \"redirect_config\" in \"module.exports\" at \"just.config.js\" file.")
50-
echo "$ERROR_MESSAGE" && exit 1
51+
echo -e "$_RED$ERROR_MESSAGE$_RESET" && exit 1
5152
elif [[ -z "$path_" ]]; then
5253
local ERROR_MESSAGE= $(customErrorMessage "Error" "0116" "Missing \"path_\" in item #$countt in \"paths\" in \"redirect_config\" in \"module.exports\" at \"just.config.js\" file.")
53-
echo "$ERROR_MESSAGE" && exit 1
54+
echo -e "$_RED$ERROR_MESSAGE$_RESET" && exit 1
5455
fi
5556
countt=$((countt + 1))
5657
done

src/run.sh

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,86 +25,95 @@ ERRORS_FILE="$GITHUB_ACTION_PATH/data/codes.json"
2525
CONFIG_FILE="just.config.js"
2626
CONFIG_DATA="just.config.json"
2727
source $GITHUB_ACTION_PATH/src/modules/errmsg.sh
28+
source $GITHUB_ACTION_PATH/src/modules/color.sh
2829
if [ "$INPUT_PATH" == ""]; then
2930
INPUT_PATH="."
3031
elif [ -z "$INPUT_PATH" ]; then
3132
INPUT_PATH="."
3233
fi
3334

34-
VERSION=$(echo "$GITHUB_ACTION_PATH" | grep -oP '(?<=/v)[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?')
35-
msg1=$(_justMessage "Running Just an Ultimate Site Tool v$VERSION")
36-
msg2=$(_justMessage "Installing Node.js")
37-
msg3=$(_justMessage "Installed Node.js")
38-
msg4=$(_justMessage "Postprocessing completed")
39-
msg5=$(_justMessage "Generating completed")
40-
msg6=$(_justMessage "Compressing completed")
41-
msg9=$(_justMessage "Generating completed")
42-
echo "$msg1"
35+
VERSION=$(echo "$GITHUB_ACTION_PATH" | grep -oP '(?<=/v)[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?') || $GITHUB_SHA
36+
msg1=$(_justMessage "$_PURPLE Running Just an Ultimate Site Tool$_DARKGRAY v$VERSION$_RESET")
37+
msg2=$(_justMessage "$_BLUE Installing Node.js$_RESET")
38+
msg3=$(_justMessage "$_BLUE Installed Node.js$_RESET")
39+
msg4=$(_justMessage "$_GREEN Postprocessing completed$_RESET")
40+
msg5=$(_justMessage "$_GREEN Generating completed$_RESET")
41+
msg6=$(_justMessage "$_GREEN Compressing completed$_RESET")
42+
msg9=$(_justMessage "$_GREEN Generating completed$_RESET")
43+
echo -e "$msg1"
4344

4445
installNodejs() {
45-
echo "$msg2"
46-
sudo apt-get remove -y nodejs npm || true
47-
sudo apt-get update -qq
48-
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
49-
sudo apt-get install -y nodejs
46+
echo -e "$msg2"
47+
sudo apt-get remove -y nodejs npm > /dev/null 2>&1 || true
48+
sudo apt-get update -qq > /dev/null 2>&1
49+
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - > /dev/null 2>&1
50+
sudo apt-get install -y nodejs > /dev/null 2>&1
5051
if ! command -v node > /dev/null; then
51-
local ERROR_MESSAGE=$(ErrorMessage "run.sh" "0205")
52-
echo "$ERROR_MESSAGE"
53-
sudo apt update -qq && sudo apt install -y nodejs npm > /dev/null 2>&1
54-
if [ $? -ne 0 ]; then
55-
local ERROR_MESSAGE=$(ErrorMessage "run.sh" "0205")
56-
echo "$ERROR_MESSAGE"
57-
sudo apt update
58-
sudo apt install -y nodejs npm
52+
local ERROR_MESSAGE=$(ErrorMessage "run.sh" "0207")
53+
echo -e "$ERROR_MESSAGE"
54+
sudo apt-get remove -y nodejs npm || true
55+
sudo apt-get update -qq
56+
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
57+
sudo apt-get install -y nodejs
58+
if ! command -v node > /dev/null; then
59+
local ERROR_MESSAGE=$(ErrorMessage "run.sh" "0208")
60+
echo -e "$ERROR_MESSAGE"
61+
sudo apt update -qq && sudo apt install -y nodejs npm > /dev/null 2>&1
62+
if [ $? -ne 0 ]; then
63+
local ERROR_MESSAGE=$(ErrorMessage "run.sh" "0205")
64+
echo -e "$ERROR_MESSAGE"
65+
sudo apt update
66+
sudo apt install -y nodejs npm
67+
fi
5968
fi
6069
fi
61-
echo "$msg3"
70+
echo -e "$msg3"
6271
node --version
6372
}
6473

6574
if [ -f "$CONFIG_DATA" ]; then
6675
ERROR_MESSAGE=$(ErrorMessage "run.sh" "0113")
67-
echo "$ERROR_MESSAGE" && exit 1
76+
echo -e "$ERROR_MESSAGE" && exit 1
6877
fi
6978

7079
if [ ! -f "$CONFIG_FILE" ]; then
7180
ERROR_MESSAGE=$(ErrorMessage "run.sh" "0108")
72-
echo "$ERROR_MESSAGE" && exit 1
81+
echo -e "$ERROR_MESSAGE" && exit 1
7382
fi
7483

7584
CONFIG_JSON=$(node -e "console.log(JSON.stringify(require('./just.config.js')));")
7685
if [ $? -ne 0 ]; then
7786
ERROR_MESSAGE=$(ErrorMessage "run.sh" "0109")
78-
echo "$ERROR_MESSAGE" && exit 1
87+
echo -e "$ERROR_MESSAGE" && exit 1
7988
fi
8089
echo "Parsed just.config.js module.exports: $CONFIG_JSON" # debug
8190
echo "$CONFIG_JSON" > "$CONFIG_DATA"
8291

8392
if [ -z "$(echo "$CONFIG_JSON" | jq -r '.module.exports')" ]; then
8493
ERROR_MESSAGE=$(ErrorMessage "run.sh" "0112")
85-
echo "$ERROR_MESSAGE" && exit 1
94+
echo -e "$ERROR_MESSAGE" && exit 1
8695
fi
8796

8897
TYPE=$(echo "$CONFIG_JSON" | jq -r '.type')
8998
if [ -z "$TYPE" ]; then
9099
ERROR_MESSAGE=$(ErrorMessage "run.sh" "0110")
91-
echo "$ERROR_MESSAGE" && exit 1
100+
echo -e "$ERROR_MESSAGE" && exit 1
92101
fi
93102

94103
if [[ "$TYPE" != "postprocessor" && "$TYPE" != "redirect" && "$TYPE" != "compress" && "$TYPE" != "docs" ]]; then
95104
ERROR_MESSAGE=$(ErrorMessage "run.sh" "0111")
96-
echo "$ERROR_MESSAGE" && exit 1
105+
echo -e "$ERROR_MESSAGE" && exit 1
97106
fi
98107

99108
_just_d="no" && \
100109
if [[ "$TYPE" != "compress" && ! ( "$TYPE" == "docs" && "$INPUT_PATH" != "." ) ]]; then
101110
if [ -d "deploy" ]; then
102111
ERROR_MESSAGE=$(ErrorMessage "important_dirs" "0106")
103-
echo "$ERROR_MESSAGE" && exit 1
112+
echo -e "$ERROR_MESSAGE" && exit 1
104113
fi
105114
if [ -d "_just_data" ]; then
106115
ERROR_MESSAGE=$(ErrorMessage "important_dirs" "0107")
107-
echo "$ERROR_MESSAGE" && exit 1
116+
echo -e "$ERROR_MESSAGE" && exit 1
108117
fi
109118
mkdir -p deploy
110119
mkdir -p _just_data
@@ -113,11 +122,11 @@ elif [ "$TYPE" == "docs" ]; then
113122
_just_dir=$(echo "$INPUT_PATH/_just" | sed 's#//*#/#g')
114123
if [ -d "$JDD" ]; then
115124
ERROR_MESSAGE=$(ErrorMessage "important_dirs" "0125")
116-
echo "$ERROR_MESSAGE" && exit 1
125+
echo -e "$ERROR_MESSAGE" && exit 1
117126
fi
118127
if [ -d "$_just_dir" ]; then
119128
ERROR_MESSAGE=$(ErrorMessage "important_dirs" "0125")
120-
echo "$ERROR_MESSAGE" && exit 1
129+
echo -e "$ERROR_MESSAGE" && exit 1
121130
fi
122131
mkdir -p "$JDD"
123132
mkdir -p "$_just_dir"
@@ -133,7 +142,7 @@ if [ "$TYPE" == "postprocessor" ]; then
133142
if [ "$postprocessor_checks" == "0101" ]; then
134143
ERROR_MESSAGE=$(ErrorMessage "postprocessor/checks.sh" "0101")
135144
fi
136-
echo "$ERROR_MESSAGE" && exit 1
145+
echo -e "$ERROR_MESSAGE" && exit 1
137146
fi
138147
} && \
139148
bash $GITHUB_ACTION_PATH/src/postprocessor/prepare_deployment.sh && \
@@ -143,18 +152,18 @@ if [ "$TYPE" == "postprocessor" ]; then
143152
installNodejs && \
144153
node $GITHUB_ACTION_PATH/src/compress.js "deploy" && \
145154
bash $GITHUB_ACTION_PATH/src/postprocessor/build_map.sh && \
146-
echo "$msg4"
155+
echo -e "$msg4"
147156
elif [ "$TYPE" == "redirect" ]; then
148157
mkdir -p deploy/_just
149158
installNodejs && \
150159
bash $GITHUB_ACTION_PATH/src/redirect/checks.sh && \
151160
node $GITHUB_ACTION_PATH/src/redirect/index.js && \
152-
echo "$msg5"
161+
echo -e "$msg5"
153162
elif [ "$TYPE" == "compress" ]; then
154163
mkdir -p deploy && \
155164
installNodejs && \
156165
node $GITHUB_ACTION_PATH/src/compress.js "$INPUT_PATH" && \
157-
echo "$msg6"
166+
echo -e "$msg6"
158167
elif [ "$TYPE" == "docs" ]; then
159168
HTML=$(cat "$GITHUB_ACTION_PATH/src/documentation/templates/page.html")
160169
CSS=$(cat "$GITHUB_ACTION_PATH/src/documentation/templates/page.css")
@@ -166,7 +175,7 @@ elif [ "$TYPE" == "docs" ]; then
166175
fi
167176
if [[ -d "_just" && "$_just_d" == "no" ]]; then
168177
local ERROR_MESSAGE=$(ErrorMessage "important_dirs" "0121")
169-
echo "$ERROR_MESSAGE" && exit 1
178+
echo -e "$ERROR_MESSAGE" && exit 1
170179
fi && \
171180
mkdir -p _just && \
172181
mkdir -p deploy && \
@@ -175,5 +184,5 @@ elif [ "$TYPE" == "docs" ]; then
175184
node "$GITHUB_ACTION_PATH/src/documentation/index.js" "$HTML" "$CSS" "$JS" "$INPUT_PATH" "$GITHUB_REPOSITORY" "$GITHUB_REPOSITORY_OWNER" "$CUSTOMCSS" && \
176185
node $GITHUB_ACTION_PATH/src/compress.js "$INPUT_PATH" && \
177186
node "$GITHUB_ACTION_PATH/src/documentation/logs.js" "$INPUT_PATH" && \
178-
echo "$msg9"
187+
echo -e "$msg9"
179188
fi

0 commit comments

Comments
 (0)