Add helpers for overlaying package.json

This commit is contained in:
su-ex 2021-09-28 12:46:07 +02:00
parent 312b0ef380
commit 8ecdbb82b0
No known key found for this signature in database
GPG Key ID: D743C50C8B61984C

View File

@ -90,15 +90,15 @@ automatic_i18n_reversion() {
local skip_commit="$1"
pushd "$SCHILDI_ROOT/matrix-react-sdk" > /dev/null
revert_i18n_changes "$i18n_path" $skip_commit
revert_i18n_changes "$i18n_path" "$skip_commit"
popd > /dev/null
pushd "$SCHILDI_ROOT/element-web" > /dev/null
revert_i18n_changes "$i18n_path" $skip_commit
revert_i18n_changes "$i18n_path" "$skip_commit"
popd > /dev/null
pushd "$SCHILDI_ROOT/element-desktop" > /dev/null
revert_i18n_changes "$i18n_path" $skip_commit
revert_i18n_changes "$i18n_path" "$skip_commit"
popd > /dev/null
}
@ -124,3 +124,50 @@ automatic_i18n_adjustment() {
apply_i18n_changes "$i18n_path"
popd > /dev/null
}
revert_packagejson_changes() {
local path="$1"
local skip_commit="$2"
git checkout upstream/master -- "$path"
if [[ "$skip_commit" != [Yy]* ]]; then
git commit -m "Automatic package.json reversion" || true
fi
}
apply_packagejson_overlay() {
local orig_path="$1"
local overlay_path="$2"
# see: https://stackoverflow.com/a/24904276
new_content=`jq -s '.[0] * .[1]' "$orig_path" "$overlay_path"`
echo "$new_content" > "$orig_path"
git add "$orig_path"
git commit -m "Automatic package.json adjustment" || true
}
automatic_packagejson_reversion() {
local skip_commit="$1"
pushd "$SCHILDI_ROOT/element-web" > /dev/null
revert_packagejson_changes "package.json" "$skip_commit"
popd > /dev/null
pushd "$SCHILDI_ROOT/element-desktop" > /dev/null
revert_packagejson_changes "package.json" "$skip_commit"
popd > /dev/null
}
automatic_packagejson_adjustment() {
# element-web
pushd "$SCHILDI_ROOT/element-web" > /dev/null
apply_packagejson_overlay "package.json" "overlay-package.json"
popd > /dev/null
# element-desktop
pushd "$SCHILDI_ROOT/element-desktop" > /dev/null
apply_packagejson_overlay "package.json" "overlay-package.json"
popd > /dev/null
}