Improve script to allow running on builder/package.json
This commit is contained in:
parent
4b0737832d
commit
40fba919ec
|
@ -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"
|
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_path="$1"
|
||||||
package_json=$(cat "$package_json_path")
|
|
||||||
|
|
||||||
process_package() {
|
process_package() {
|
||||||
pkg_path="$1"
|
pkg_path="$1"
|
||||||
package_json=$(cat "$pkg_path")
|
|
||||||
has_changes=false
|
|
||||||
|
|
||||||
for package_name in $packages_to_remove; do
|
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
|
jq "del(.dependencies[\"$package_name\"])" $pkg_path > tmp_file.json && mv tmp_file.json $pkg_path
|
||||||
package_json=$(echo "$package_json" | jq "del(.dependencies[\"$package_name\"])")
|
jq "del(.resolutions[\"$package_name\"])" $pkg_path > tmp_file.json && mv tmp_file.json $pkg_path
|
||||||
has_changes=true
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$has_changes" = true ]; then
|
|
||||||
echo "$package_json" > "$pkg_path"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process_package "$package_json_path"
|
process_package "$package_json_path"
|
||||||
|
|
||||||
package_json=$(cat "$package_json_path")
|
|
||||||
echo "$package_json" | jq "del(.resolutions)" > "$1"
|
|
||||||
|
|
Loading…
Reference in New Issue