@@ -25,86 +25,95 @@ ERRORS_FILE="$GITHUB_ACTION_PATH/data/codes.json"
2525CONFIG_FILE=" just.config.js"
2626CONFIG_DATA=" just.config.json"
2727source $GITHUB_ACTION_PATH /src/modules/errmsg.sh
28+ source $GITHUB_ACTION_PATH /src/modules/color.sh
2829if [ " $INPUT_PATH " == " " ]; then
2930 INPUT_PATH=" ."
3031elif [ -z " $INPUT_PATH " ]; then
3132 INPUT_PATH=" ."
3233fi
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
4445installNodejs () {
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
6574if [ -f " $CONFIG_DATA " ]; then
6675 ERROR_MESSAGE=$( ErrorMessage " run.sh" " 0113" )
67- echo " $ERROR_MESSAGE " && exit 1
76+ echo -e " $ERROR_MESSAGE " && exit 1
6877fi
6978
7079if [ ! -f " $CONFIG_FILE " ]; then
7180 ERROR_MESSAGE=$( ErrorMessage " run.sh" " 0108" )
72- echo " $ERROR_MESSAGE " && exit 1
81+ echo -e " $ERROR_MESSAGE " && exit 1
7382fi
7483
7584CONFIG_JSON=$( node -e " console.log(JSON.stringify(require('./just.config.js')));" )
7685if [ $? -ne 0 ]; then
7786 ERROR_MESSAGE=$( ErrorMessage " run.sh" " 0109" )
78- echo " $ERROR_MESSAGE " && exit 1
87+ echo -e " $ERROR_MESSAGE " && exit 1
7988fi
8089echo " Parsed just.config.js module.exports: $CONFIG_JSON " # debug
8190echo " $CONFIG_JSON " > " $CONFIG_DATA "
8291
8392if [ -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
8695fi
8796
8897TYPE=$( echo " $CONFIG_JSON " | jq -r ' .type' )
8998if [ -z " $TYPE " ]; then
9099 ERROR_MESSAGE=$( ErrorMessage " run.sh" " 0110" )
91- echo " $ERROR_MESSAGE " && exit 1
100+ echo -e " $ERROR_MESSAGE " && exit 1
92101fi
93102
94103if [[ " $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
97106fi
98107
99108_just_d=" no" && \
100109if [[ " $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 "
147156elif [ " $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 "
153162elif [ " $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 "
158167elif [ " $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 "
179188fi
0 commit comments