2022-07-05 06:12:59 -07:00
|
|
|
#!/usr/bin/env bash
|
2022-06-30 03:10:10 -07:00
|
|
|
|
|
|
|
## /!\ This file must be used at the root of the prometheus project
|
|
|
|
## This script provides utils method to help to release and verify the readiness of each libs under the folder ui/
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
current=$(pwd)
|
|
|
|
root_ui_folder=${current}/web/ui
|
|
|
|
|
|
|
|
cd "${root_ui_folder}"
|
|
|
|
|
|
|
|
files=("../../LICENSE" "../../CHANGELOG.md")
|
|
|
|
workspaces=$(jq -r '.workspaces[]' < package.json)
|
|
|
|
|
|
|
|
function copy() {
|
|
|
|
for file in "${files[@]}"; do
|
|
|
|
for workspace in ${workspaces}; do
|
|
|
|
if [ -f "${file}" ]; then
|
|
|
|
cp "${file}" "${workspace}"/"$(basename "${file}")"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function publish() {
|
|
|
|
dry_run="${1}"
|
|
|
|
cmd="npm publish --access public"
|
|
|
|
if [[ "${dry_run}" == "dry-run" ]]; then
|
|
|
|
cmd+=" --dry-run"
|
|
|
|
fi
|
|
|
|
for workspace in ${workspaces}; do
|
2024-04-18 06:00:27 -07:00
|
|
|
# package "mantine-ui" is private so we shouldn't try to publish it.
|
|
|
|
if [[ "${workspace}" != "mantine-ui" ]]; then
|
2022-06-30 03:10:10 -07:00
|
|
|
cd "${workspace}"
|
|
|
|
eval "${cmd}"
|
|
|
|
cd "${root_ui_folder}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkPackage() {
|
|
|
|
version=${1}
|
|
|
|
if [[ "${version}" == v* ]]; then
|
|
|
|
version="${version:1}"
|
|
|
|
fi
|
|
|
|
for workspace in ${workspaces}; do
|
|
|
|
cd "${workspace}"
|
|
|
|
package_version=$(npm run env | grep npm_package_version | cut -d= -f2-)
|
|
|
|
if [ "${version}" != "${package_version}" ]; then
|
|
|
|
echo "version of ${workspace} is not the correct one"
|
|
|
|
echo "expected one: ${version}"
|
|
|
|
echo "current one: ${package_version}"
|
|
|
|
echo "please use ./ui_release --bump-version ${version}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
cd "${root_ui_folder}"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function clean() {
|
|
|
|
for file in "${files[@]}"; do
|
|
|
|
for workspace in ${workspaces}; do
|
|
|
|
f="${workspace}"/"$(basename "${file}")"
|
|
|
|
if [ -f "${f}" ]; then
|
|
|
|
rm "${f}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function bumpVersion() {
|
|
|
|
version="${1}"
|
|
|
|
if [[ "${version}" == v* ]]; then
|
|
|
|
version="${version:1}"
|
|
|
|
fi
|
|
|
|
# upgrade the @prometheus-io/* dependencies on all packages
|
|
|
|
for workspace in ${workspaces}; do
|
2022-12-24 09:30:11 -08:00
|
|
|
# sed -i syntax is different on mac and linux
|
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
|
|
sed -E -i "" "s|(\"@prometheus-io/.+\": )\".+\"|\1\"${version}\"|" "${workspace}"/package.json
|
|
|
|
else
|
|
|
|
sed -E -i "s|(\"@prometheus-io/.+\": )\".+\"|\1\"${version}\"|" "${workspace}"/package.json
|
|
|
|
fi
|
2022-06-30 03:10:10 -07:00
|
|
|
done
|
2022-12-29 02:23:46 -08:00
|
|
|
# increase the version on all packages
|
2023-09-01 01:38:15 -07:00
|
|
|
npm version "${version}" --workspaces --include-workspace-root
|
2022-06-30 03:10:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if [[ "$1" == "--copy" ]]; then
|
|
|
|
copy
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $1 == "--publish" ]]; then
|
|
|
|
publish "${@:2}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $1 == "--check-package" ]]; then
|
|
|
|
checkPackage "${@:2}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $1 == "--bump-version" ]]; then
|
|
|
|
bumpVersion "${@:2}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $1 == "--clean" ]]; then
|
|
|
|
clean
|
|
|
|
fi
|