Improve script to allow running on builder/package.json

This commit is contained in:
Adria Navarro 2024-01-16 14:00:33 +01:00
parent 4b0737832d
commit 40fba919ec
1 changed files with 2 additions and 14 deletions

View File

@ -3,26 +3,14 @@
packages_to_remove="@budibase/backend-core @budibase/bbui @budibase/builder @budibase/cli @budibase/client @budibase/frontend-core @budibase/pro @budibase/sdk @budibase/server @budibase/shared-core @budibase/string-templates @budibase/types @budibase/worker"
package_json_path="$1"
package_json=$(cat "$package_json_path")
process_package() {
pkg_path="$1"
package_json=$(cat "$pkg_path")
has_changes=false
for package_name in $packages_to_remove; do
if echo "$package_json" | jq -e --arg package_name "$package_name" '.dependencies | has($package_name)' > /dev/null; then
package_json=$(echo "$package_json" | jq "del(.dependencies[\"$package_name\"])")
has_changes=true
fi
jq "del(.dependencies[\"$package_name\"])" $pkg_path > tmp_file.json && mv tmp_file.json $pkg_path
jq "del(.resolutions[\"$package_name\"])" $pkg_path > tmp_file.json && mv tmp_file.json $pkg_path
done
if [ "$has_changes" = true ]; then
echo "$package_json" > "$pkg_path"
fi
}
process_package "$package_json_path"
package_json=$(cat "$package_json_path")
echo "$package_json" | jq "del(.resolutions)" > "$1"