mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 09:31:41 -05:00
Add shellcheck to travis
This commit is contained in:
parent
59a2147172
commit
78e662efef
8 changed files with 65 additions and 49 deletions
|
@ -5,6 +5,12 @@ cache:
|
|||
directories:
|
||||
- node_modules
|
||||
|
||||
script:
|
||||
- bash -c 'GLOBIGNORE="node_modules" shellcheck **/*.sh'
|
||||
- npm install
|
||||
- npm run test
|
||||
- npm run lint
|
||||
|
||||
notifications:
|
||||
webhooks:
|
||||
urls:
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
set -e
|
||||
|
||||
echoerr() {
|
||||
red="\033[31m"
|
||||
normal="\e[0m"
|
||||
echo -e "$red$@$normal" >&2
|
||||
red="\\033[31m"
|
||||
normal="\\e[0m"
|
||||
echo -e "$red$*$normal" >&2
|
||||
}
|
||||
|
||||
sedEscape() {
|
||||
|
@ -68,7 +68,7 @@ sed -i.bak "s/REPLACE_ME_WITH_SED/$(sedEscape "$native_file_final")/" "$manifest
|
|||
chmod +x "$native_file"
|
||||
|
||||
# Requirements for native messenger
|
||||
python_path=$(which python3) || python_path=""
|
||||
python_path=$(command -v python3) || python_path=""
|
||||
if [[ -x "$python_path" ]]; then
|
||||
sed -i.bak "1s/.*/#!$(sedEscape /usr/bin/env) $(sedEscape "$python_path")/" "$native_file"
|
||||
mv "$native_file" "$native_file_final"
|
||||
|
|
|
@ -6,5 +6,5 @@ imports=$(find src/static/themes -name '*.css'| awk -F"/" '{ printf "@import url
|
|||
|
||||
|
||||
for css in build/static/css/*.css; do
|
||||
printf '%s\n%s\n' "$imports" "$(cat $css)" > $css
|
||||
printf '%s\n%s\n' "$imports" "$(cat "$css")" > "$css"
|
||||
done
|
||||
|
|
|
@ -6,18 +6,18 @@ CLEANSLATE="node_modules/cleanslate/docs/files/cleanslate.css"
|
|||
TRIDACTYL_LOGO="src/static/logo/Tridactyl_64px.png"
|
||||
|
||||
isWindowsMinGW() {
|
||||
local is_mingw="False"
|
||||
is_mingw="False"
|
||||
if [ "$(uname | cut -c 1-5)" = "MINGW" ] \
|
||||
|| [ "$(uname | cut -c 1-4)" = "MSYS" ]; then
|
||||
is_mingw="True"
|
||||
fi
|
||||
|
||||
echo -n "${is_mingw}"
|
||||
printf "%s" "${is_mingw}"
|
||||
}
|
||||
|
||||
if [ "$(isWindowsMinGW)" = "True" ]; then
|
||||
WIN_PYTHON="py -3"
|
||||
NPM_BIN_DIR="$(cygpath $(npm bin))"
|
||||
NPM_BIN_DIR="$(cygpath "$(npm bin)")"
|
||||
PATH=$NPM_BIN_DIR:$PATH
|
||||
else
|
||||
PATH="$(npm bin):$PATH"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env sh
|
||||
|
||||
gitversion=$(git describe --tags | cut -d"-" -f2-)
|
||||
manversion=$(grep '"version":' ./src/manifest.json | cut -d":" -f2 | tr -d \" | tr -d , | cut -d" " -f2)
|
||||
version=$manversion-$gitversion
|
||||
|
||||
sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'$version'/' ./build/background.js
|
||||
sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'$version'/' ./build/static/newtab.html
|
||||
sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'"$version"'/' ./build/background.js
|
||||
sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'"$version"'/' ./build/static/newtab.html
|
||||
rm ./build/background.js.bak
|
||||
rm ./build/static/newtab.html.bak
|
||||
|
|
|
@ -2,15 +2,18 @@
|
|||
|
||||
# Combine tutorial markdown and template
|
||||
|
||||
cd src/static/clippy
|
||||
if ! cd src/static/clippy; then
|
||||
echo "Failed to cd in src/static/clippy. Aborting."
|
||||
exit
|
||||
fi
|
||||
|
||||
pages=$(ls *.md)
|
||||
pages=$(ls ./*.md)
|
||||
dest="../../../generated/static/clippy/"
|
||||
|
||||
for page in $pages
|
||||
do
|
||||
fileroot=$(echo $page | cut -d'.' -f-1)
|
||||
fileroot=$(echo "$page" | cut -d'.' -f-1)
|
||||
sed "/REPLACETHIS/,$ d" tutor.template.html > "$dest$fileroot.html"
|
||||
"$(npm bin)/marked" $page >> "$dest$fileroot.html"
|
||||
"$(npm bin)/marked" "$page" >> "$dest$fileroot.html"
|
||||
sed "1,/REPLACETHIS/ d" tutor.template.html >> "$dest$fileroot.html"
|
||||
done
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
# Combine newtab markdown and template
|
||||
|
||||
cd src/static
|
||||
if ! cd src/static ; then
|
||||
echo "Failed to cd in src/static. Aborting."
|
||||
exit
|
||||
fi
|
||||
|
||||
newtab="../../generated/static/newtab.html"
|
||||
newtabtemp="../../generated/static/newtab.temp.html"
|
||||
|
@ -13,17 +16,19 @@ sed "1,/REPLACETHIS/ d" newtab.template.html >> "$newtabtemp"
|
|||
|
||||
# Why think when you can pattern match?
|
||||
|
||||
sed "/REPLACE_ME_WITH_THE_CHANGE_LOG_USING_SED/,$ d" "$newtabtemp" > "$newtab"
|
||||
(
|
||||
sed "/REPLACE_ME_WITH_THE_CHANGE_LOG_USING_SED/,$ d" "$newtabtemp"
|
||||
# Note: If you're going to change this HTML, make sure you don't break the JS in src/newtab.ts
|
||||
echo """
|
||||
cat <<EOF
|
||||
<input type="checkbox" id="spoilerbutton" />
|
||||
<label for="spoilerbutton" onclick=""><div id="nagbar-changelog">New features!</div>Changelog</label>
|
||||
<div id="changelog" class="spoiler">
|
||||
""" >> "$newtab"
|
||||
"$(npm bin)/marked" ../../CHANGELOG.md >> "$newtab"
|
||||
EOF
|
||||
"$(npm bin)/marked" ../../CHANGELOG.md
|
||||
echo """
|
||||
</div>
|
||||
""" >> "$newtab"
|
||||
sed "1,/REPLACE_ME_WITH_THE_CHANGE_LOG_USING_SED/ d" "$newtabtemp" >> "$newtab"
|
||||
"""
|
||||
sed "1,/REPLACE_ME_WITH_THE_CHANGE_LOG_USING_SED/ d" "$newtabtemp"
|
||||
) > "$newtab"
|
||||
|
||||
rm "$newtabtemp"
|
||||
|
|
|
@ -26,34 +26,35 @@ MIN_WINE_VER="4"
|
|||
MIN_7ZIP_VER="16"
|
||||
|
||||
checkRequiredVersions() {
|
||||
if [ -z "$(7z \
|
||||
| awk '/Version/{print $3}' \
|
||||
| grep "${MIN_7ZIP_VER}")" ]; then
|
||||
if ! 7z | awk '/Version/{print $3}' | grep -q "${MIN_7ZIP_VER}"; then
|
||||
colorEcho \
|
||||
"[-] p7zip minimum version ${MIN_7ZIP_VER} required\n" \
|
||||
'[-] p7zip minimum version '"${MIN_7ZIP_VER}"' required\n' \
|
||||
"alert"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [ -z "$(wine --version 2> /dev/null \
|
||||
| grep "wine-${min_wine_ver}")" ]; then
|
||||
if ! wine --version 2> /dev/null | grep -q "wine-${MIN_WINE_VER}"; then
|
||||
colorecho \
|
||||
"[-] wine minimum version ${min_wine_ver} required\n" \
|
||||
'[-] wine minimum version '"${MIN_WINE_VER}"' required\n' \
|
||||
"alert"
|
||||
exit -1
|
||||
fi
|
||||
}
|
||||
|
||||
stripWhitespace() {
|
||||
local input="$@"
|
||||
printf "${input}\n" | tr -d "[:space:]"
|
||||
local input="$*"
|
||||
printf '%s\n' "${input}" | tr -d "[:space:]"
|
||||
}
|
||||
|
||||
colorEcho() {
|
||||
local COLOR_RESET=$(tput sgr0 2>/dev/null)
|
||||
local COLOR_BOLD=$(tput bold 2>/dev/null)
|
||||
local COLOR_BAD=$(tput setaf 1 2>/dev/null)
|
||||
local COLOR_GOOD=$(tput setaf 2 2>/dev/null)
|
||||
local COLOR_RESET;
|
||||
COLOR_RESET="$(tput sgr0 2>/dev/null)"
|
||||
local COLOR_BOLD;
|
||||
COLOR_BOLD="$(tput bold 2>/dev/null)"
|
||||
local COLOR_BAD;
|
||||
COLOR_BAD="$(tput setaf 1 2>/dev/null)"
|
||||
local COLOR_GOOD;
|
||||
COLOR_GOOD="$(tput setaf 2 2>/dev/null)"
|
||||
|
||||
local str="$1"
|
||||
local color="${COLOR_GOOD}${COLOR_BOLD}"
|
||||
|
@ -63,19 +64,20 @@ colorEcho() {
|
|||
color="${COLOR_BAD}${COLOR_BOLD}"
|
||||
fi
|
||||
|
||||
printf "${color}${str}${COLOR_RESET}"
|
||||
printf '%s' "${color}${str}${COLOR_RESET}"
|
||||
}
|
||||
|
||||
checkPrerequisite() {
|
||||
local bin_name="$1"
|
||||
local bin_loc=$(which "${bin_name}" 2>/dev/null)
|
||||
local bin_loc;
|
||||
bin_loc="$(command -v "${bin_name}" 2>/dev/null)"
|
||||
|
||||
if [ -z "${bin_loc}" ] \
|
||||
|| [ ! -f "${bin_loc}" ]; then
|
||||
printf " - '$1' not found, quitting ...\n"
|
||||
printf '%s\n' " - '$1' not found, quitting ..."
|
||||
exit -1
|
||||
else
|
||||
printf " - '${bin_name}' found at ${bin_loc}\n"
|
||||
printf '%s\n' " - '${bin_name}' found at ${bin_loc}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -86,7 +88,7 @@ mainFunction() {
|
|||
|
||||
|
||||
## Check prerequisites
|
||||
colorEcho "[+] Checking prerequisites ...\n"
|
||||
colorEcho '[+] Checking prerequisites ...\n'
|
||||
for bin in ${PREREQUISITES}; do
|
||||
checkPrerequisite "${bin}"
|
||||
done
|
||||
|
@ -102,7 +104,7 @@ mainFunction() {
|
|||
|
||||
|
||||
## Download Python and Pip
|
||||
colorEcho "[+] Downloading necessary files ...\n"
|
||||
colorEcho '[+] Downloading necessary files ...\n'
|
||||
|
||||
if [ ! -f "${WINPY_EXE}" ]; then
|
||||
wget \
|
||||
|
@ -112,7 +114,7 @@ mainFunction() {
|
|||
|
||||
if [ ! "$(sha256sum "${WINPY_EXE}" \
|
||||
| cut -d" " -f1)" = ${WINPY_HASH} ]; then
|
||||
colorEcho "[-] ${WINPY_EXE} has incorrect hash, quitting ...\n"
|
||||
colorEcho '[-] '"${WINPY_EXE}"' has incorrect hash, quitting ...\n'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -122,17 +124,17 @@ mainFunction() {
|
|||
local winepython="wine $PYDIR/python.exe"
|
||||
|
||||
if [ ! -f "$PYDIR/python.exe" ]; then
|
||||
colorEcho "[+] Extract Python-${PYVER}\n"
|
||||
colorEcho '[+] Extract Python-'${PYVER}'\n'
|
||||
7z x "${DLDIR}/winpython-${PYVER}.exe" "python-$PYVER" -o"$BUILDROOT"
|
||||
|
||||
$winepython -m pip install --upgrade pip
|
||||
|
||||
colorEcho "[+] Installing PyInstaller ...\n"
|
||||
colorEcho '[+] Installing PyInstaller ...\n'
|
||||
$winepython -m pip install pyinstaller
|
||||
fi
|
||||
|
||||
## Compile with PyInstaller
|
||||
colorEcho "[+] Compiling with PyInstaller under Wine ...\n"
|
||||
colorEcho '[+] Compiling with PyInstaller under Wine ...\n'
|
||||
rm -rf "${OUTDIR}"
|
||||
PYTHONHASHSEED=1 wine "$PYDIR"/Scripts/pyinstaller.exe \
|
||||
--clean \
|
||||
|
@ -146,7 +148,7 @@ mainFunction() {
|
|||
"$TRIDIR/native/native_main.py"
|
||||
|
||||
## Test the compiled EXE
|
||||
colorEcho "[+] Checking compiled binary ...\n"
|
||||
colorEcho '[+] Checking compiled binary ...\n'
|
||||
OUTFILE="${OUTDIR}/native_main.exe"
|
||||
cp "$OUTFILE" "$TRIDIR"/web-ext-artifacts/
|
||||
|
||||
|
@ -155,11 +157,11 @@ mainFunction() {
|
|||
"$TRIDIR/native/gen_native_message.py" cmd..version \
|
||||
| wine "$TRIDIR"/web-ext-artifacts/native_main.exe
|
||||
|
||||
printf "\n"
|
||||
colorEcho "[+] PyInstaller with Wine was successful!\n"
|
||||
printf '\n'
|
||||
colorEcho '[+] PyInstaller with Wine was successful!\n'
|
||||
else
|
||||
colorEcho \
|
||||
"[-] PyInstaller compilation failed, quitting ...\n" \
|
||||
'[-] PyInstaller compilation failed, quitting ...\n' \
|
||||
"alert"
|
||||
exit -1
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue