@@ -25,86 +25,95 @@ ERRORS_FILE="$GITHUB_ACTION_PATH/data/codes.json"
25
25
CONFIG_FILE=" just.config.js"
26
26
CONFIG_DATA=" just.config.json"
27
27
source $GITHUB_ACTION_PATH /src/modules/errmsg.sh
28
+ source $GITHUB_ACTION_PATH /src/modules/color.sh
28
29
if [ " $INPUT_PATH " == " " ]; then
29
30
INPUT_PATH=" ."
30
31
elif [ -z " $INPUT_PATH " ]; then
31
32
INPUT_PATH=" ."
32
33
fi
33
34
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 "
43
44
44
45
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
50
51
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
59
68
fi
60
69
fi
61
- echo " $msg3 "
70
+ echo -e " $msg3 "
62
71
node --version
63
72
}
64
73
65
74
if [ -f " $CONFIG_DATA " ]; then
66
75
ERROR_MESSAGE=$( ErrorMessage " run.sh" " 0113" )
67
- echo " $ERROR_MESSAGE " && exit 1
76
+ echo -e " $ERROR_MESSAGE " && exit 1
68
77
fi
69
78
70
79
if [ ! -f " $CONFIG_FILE " ]; then
71
80
ERROR_MESSAGE=$( ErrorMessage " run.sh" " 0108" )
72
- echo " $ERROR_MESSAGE " && exit 1
81
+ echo -e " $ERROR_MESSAGE " && exit 1
73
82
fi
74
83
75
84
CONFIG_JSON=$( node -e " console.log(JSON.stringify(require('./just.config.js')));" )
76
85
if [ $? -ne 0 ]; then
77
86
ERROR_MESSAGE=$( ErrorMessage " run.sh" " 0109" )
78
- echo " $ERROR_MESSAGE " && exit 1
87
+ echo -e " $ERROR_MESSAGE " && exit 1
79
88
fi
80
89
echo " Parsed just.config.js module.exports: $CONFIG_JSON " # debug
81
90
echo " $CONFIG_JSON " > " $CONFIG_DATA "
82
91
83
92
if [ -z " $( echo " $CONFIG_JSON " | jq -r ' .module.exports' ) " ]; then
84
93
ERROR_MESSAGE=$( ErrorMessage " run.sh" " 0112" )
85
- echo " $ERROR_MESSAGE " && exit 1
94
+ echo -e " $ERROR_MESSAGE " && exit 1
86
95
fi
87
96
88
97
TYPE=$( echo " $CONFIG_JSON " | jq -r ' .type' )
89
98
if [ -z " $TYPE " ]; then
90
99
ERROR_MESSAGE=$( ErrorMessage " run.sh" " 0110" )
91
- echo " $ERROR_MESSAGE " && exit 1
100
+ echo -e " $ERROR_MESSAGE " && exit 1
92
101
fi
93
102
94
103
if [[ " $TYPE " != " postprocessor" && " $TYPE " != " redirect" && " $TYPE " != " compress" && " $TYPE " != " docs" ]]; then
95
104
ERROR_MESSAGE=$( ErrorMessage " run.sh" " 0111" )
96
- echo " $ERROR_MESSAGE " && exit 1
105
+ echo -e " $ERROR_MESSAGE " && exit 1
97
106
fi
98
107
99
108
_just_d=" no" && \
100
109
if [[ " $TYPE " != " compress" && ! ( " $TYPE " == " docs" && " $INPUT_PATH " ! = " ." ) ]]; then
101
110
if [ -d " deploy" ]; then
102
111
ERROR_MESSAGE=$( ErrorMessage " important_dirs" " 0106" )
103
- echo " $ERROR_MESSAGE " && exit 1
112
+ echo -e " $ERROR_MESSAGE " && exit 1
104
113
fi
105
114
if [ -d " _just_data" ]; then
106
115
ERROR_MESSAGE=$( ErrorMessage " important_dirs" " 0107" )
107
- echo " $ERROR_MESSAGE " && exit 1
116
+ echo -e " $ERROR_MESSAGE " && exit 1
108
117
fi
109
118
mkdir -p deploy
110
119
mkdir -p _just_data
@@ -113,11 +122,11 @@ elif [ "$TYPE" == "docs" ]; then
113
122
_just_dir=$( echo " $INPUT_PATH /_just" | sed ' s#//*#/#g' )
114
123
if [ -d " $JDD " ]; then
115
124
ERROR_MESSAGE=$( ErrorMessage " important_dirs" " 0125" )
116
- echo " $ERROR_MESSAGE " && exit 1
125
+ echo -e " $ERROR_MESSAGE " && exit 1
117
126
fi
118
127
if [ -d " $_just_dir " ]; then
119
128
ERROR_MESSAGE=$( ErrorMessage " important_dirs" " 0125" )
120
- echo " $ERROR_MESSAGE " && exit 1
129
+ echo -e " $ERROR_MESSAGE " && exit 1
121
130
fi
122
131
mkdir -p " $JDD "
123
132
mkdir -p " $_just_dir "
@@ -133,7 +142,7 @@ if [ "$TYPE" == "postprocessor" ]; then
133
142
if [ " $postprocessor_checks " == " 0101" ]; then
134
143
ERROR_MESSAGE=$( ErrorMessage " postprocessor/checks.sh" " 0101" )
135
144
fi
136
- echo " $ERROR_MESSAGE " && exit 1
145
+ echo -e " $ERROR_MESSAGE " && exit 1
137
146
fi
138
147
} && \
139
148
bash $GITHUB_ACTION_PATH /src/postprocessor/prepare_deployment.sh && \
@@ -143,18 +152,18 @@ if [ "$TYPE" == "postprocessor" ]; then
143
152
installNodejs && \
144
153
node $GITHUB_ACTION_PATH /src/compress.js " deploy" && \
145
154
bash $GITHUB_ACTION_PATH /src/postprocessor/build_map.sh && \
146
- echo " $msg4 "
155
+ echo -e " $msg4 "
147
156
elif [ " $TYPE " == " redirect" ]; then
148
157
mkdir -p deploy/_just
149
158
installNodejs && \
150
159
bash $GITHUB_ACTION_PATH /src/redirect/checks.sh && \
151
160
node $GITHUB_ACTION_PATH /src/redirect/index.js && \
152
- echo " $msg5 "
161
+ echo -e " $msg5 "
153
162
elif [ " $TYPE " == " compress" ]; then
154
163
mkdir -p deploy && \
155
164
installNodejs && \
156
165
node $GITHUB_ACTION_PATH /src/compress.js " $INPUT_PATH " && \
157
- echo " $msg6 "
166
+ echo -e " $msg6 "
158
167
elif [ " $TYPE " == " docs" ]; then
159
168
HTML=$( cat " $GITHUB_ACTION_PATH /src/documentation/templates/page.html" )
160
169
CSS=$( cat " $GITHUB_ACTION_PATH /src/documentation/templates/page.css" )
@@ -166,7 +175,7 @@ elif [ "$TYPE" == "docs" ]; then
166
175
fi
167
176
if [[ -d " _just" && " $_just_d " == " no" ]]; then
168
177
local ERROR_MESSAGE=$( ErrorMessage " important_dirs" " 0121" )
169
- echo " $ERROR_MESSAGE " && exit 1
178
+ echo -e " $ERROR_MESSAGE " && exit 1
170
179
fi && \
171
180
mkdir -p _just && \
172
181
mkdir -p deploy && \
@@ -175,5 +184,5 @@ elif [ "$TYPE" == "docs" ]; then
175
184
node " $GITHUB_ACTION_PATH /src/documentation/index.js" " $HTML " " $CSS " " $JS " " $INPUT_PATH " " $GITHUB_REPOSITORY " " $GITHUB_REPOSITORY_OWNER " " $CUSTOMCSS " && \
176
185
node $GITHUB_ACTION_PATH /src/compress.js " $INPUT_PATH " && \
177
186
node " $GITHUB_ACTION_PATH /src/documentation/logs.js" " $INPUT_PATH " && \
178
- echo " $msg9 "
187
+ echo -e " $msg9 "
179
188
fi
0 commit comments