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