chore: fix shell scripts lint errors

This commit is contained in:
jo 2022-11-24 21:14:59 +01:00 committed by JuniorJPDJ
commit d47fef0806
23 changed files with 359 additions and 228 deletions

View file

@ -1,12 +1,20 @@
#!/usr/bin/env -S bash -eux
#!/usr/bin/env bash
cd "$(dirname $0)/.." # change into base directory
set -eux
cd "$(dirname "$0")/.." # change into base directory
FOMANTIC_SRC_PATH="node_modules/fomantic-ui-css"
find "$FOMANTIC_SRC_PATH/components" -name "*.min.css" -delete
mkdir -p "$FOMANTIC_SRC_PATH/tweaked"
find node_modules/fomantic-ui-css/components -name "*.min.css" -delete
mkdir -p node_modules/fomantic-ui-css/tweaked
echo 'Removing google font…'
sed -i '/@import url(/d' node_modules/fomantic-ui-css/components/site.css
sed -i '/@import url(/d' "$FOMANTIC_SRC_PATH/components/site.css"
echo "Replacing hardcoded values by CSS vars…"
scripts/fix-fomantic-css.py node_modules/fomantic-ui-css node_modules/fomantic-ui-css/tweaked
scripts/fix-fomantic-css.py "$FOMANTIC_SRC_PATH" "$FOMANTIC_SRC_PATH/tweaked"
echo 'Fixing jQuery import…'
sed -i '1s/^/import jQuery from "jquery"\n/' `find node_modules/fomantic-ui-css/ -name '*.js'`
# shellcheck disable=SC2046
sed -i '1s/^/import jQuery from "jquery"\n/' $(find "$FOMANTIC_SRC_PATH" -name '*.js')

View file

@ -1,13 +1,16 @@
#!/usr/bin/env -S bash -eux
#!/usr/bin/env bash
cd "$(dirname $0)/.." # change into base directory
set -eux
cd "$(dirname "$0")/.." # change into base directory
# shellcheck disable=SC1091
source scripts/utils.sh
locales=$(jq -r '.[].code' src/locales.json | grep -v 'en_US')
mkdir -p src/translations
for locale in $locales; do
$(npm_binaries)/gettext-compile locales/$locale/LC_MESSAGES/app.po --output src/translations/$locale.json
"$(npm_binaries)/gettext-compile" "locales/$locale/LC_MESSAGES/app.po" --output "src/translations/$locale.json"
done
# find locales -name '*.po' | xargs $(npm_binaries)/.bin/gettext-compile --output src/translations.json
# find locales -name '*.po' | xargs "$(npm_binaries)/.bin/gettext-compile" --output src/translations.json

View file

@ -1,35 +1,48 @@
#!/usr/bin/env -S bash -eux
#!/usr/bin/env bash
cd "$(dirname $0)/.." # change into base directory
set -eux
cd "$(dirname "$0")/.." # change into base directory
# shellcheck disable=SC1091
source scripts/utils.sh
locales=$(jq -r '.[].code' src/locales.json)
locales_dir="locales"
sources=$(find src -name '*.vue' -o -name '*.html' 2> /dev/null)
js_sources=$(find src -name '*.vue' -o -name '*.js')
touch $locales_dir/app.pot
GENERATE=${GENERATE-true}
touch "$locales_dir/app.pot"
GENERATE="${GENERATE-true}"
# Create a main .pot template, then generate .po files for each available language.
# Extract gettext strings from templates files and create a POT dictionary template.
$(npm_binaries)/gettext-extract --attribute v-translate --quiet --output $locales_dir/app.pot $sources
# shellcheck disable=SC2086
"$(npm_binaries)/gettext-extract" --attribute v-translate --quiet --output "$locales_dir/app.pot" $sources
# shellcheck disable=SC2086
xgettext --language=JavaScript --keyword=npgettext:1c,2,3 \
--from-code=utf-8 --join-existing --no-wrap \
--package-name=$(node -e "console.log(require('./package.json').name);") \
--package-version=$(node -e "console.log(require('./package.json').version);") \
--output $locales_dir/app.pot $js_sources \
--no-wrap
--from-code=utf-8 --join-existing --no-wrap \
--package-name="$(jq -r '.name' package.json)" \
--package-version="$(jq -r '.version' package.json)" \
--output "$locales_dir/app.pot" $js_sources \
--no-wrap
# Fix broken files path/lines in pot
sed -e 's|#: src/|#: front/src/|' -i $locales_dir/app.pot
sed -e 's|#: src/|#: front/src/|' -i "$locales_dir/app.pot"
if [ $GENERATE = 'true' ]; then
# Generate .po files for each available language.
echo $locales
for lang in $locales; do \
po_file=$locales_dir/$lang/LC_MESSAGES/app.po; \
echo "msgmerge --update $po_file "; \
mkdir -p $(dirname $po_file); \
[ -f $po_file ] && msgmerge --lang=$lang --update $po_file $locales_dir/app.pot --no-wrap || msginit --no-wrap --no-translator --locale=$lang --input=$locales_dir/app.pot --output-file=$po_file; \
msgattrib --no-wrap --no-obsolete -o $po_file $po_file; \
done;
if [ "$GENERATE" = 'true' ]; then
# Generate .po files for each available language.
echo "$locales"
for lang in $locales; do
po_file="$locales_dir/$lang/LC_MESSAGES/app.po"
echo "msgmerge --update $po_file"
mkdir -p "$(dirname "$po_file")"
if [[ -f "$po_file" ]]; then
msgmerge --lang="$lang" --update "$po_file" "$locales_dir/app.pot" --no-wrap
else
msginit --no-wrap --no-translator --locale="$lang" --input="$locales_dir/app.pot" --output-file="$po_file"
fi
msgattrib --no-wrap --no-obsolete -o "$po_file" "$po_file"
done
fi

View file

@ -1,12 +1,16 @@
#!/usr/bin/env -S bash -eux
#!/usr/bin/env bash
set -eux
integration_branch="translations-integration"
git remote add weblate https://translate.funkwhale.audio/git/funkwhale/front/ || echo "remote already exists"
git fetch weblate
git checkout weblate/develop
git reset --hard weblate/develop
git checkout -b $integration_branch || git checkout $integration_branch
git checkout -b "$integration_branch" || git checkout "$integration_branch"
git reset --hard weblate/develop
git push -f origin $integration_branch
git push -f origin "$integration_branch"
echo "Branch created on pushed on origin/$integration_branch"
echo "Open a merge request by visiting https://dev.funkwhale.audio/funkwhale/funkwhale/merge_requests/new?merge_request%5Bsource_branch%5D=$integration_branch"

View file

@ -1,5 +1,11 @@
#!/usr/bin/env -S bash -eux
#!/usr/bin/env bash
npm_binaries () {
command -v yarn > /dev/null && yarn bin || npm bin
set -eux
npm_binaries() {
if command -v yarn > /dev/null; then
yarn bin
else
npm bin
fi
}