mirror of
https://github.com/mattermost/mattermost.git
synced 2026-04-08 18:47:20 -04:00
* Port scripts/update-versions to a shell script * Update the scripts to change the version to use jq * Add the shared package * Update webapp/scripts/CLAUDE.OPTIONAL.md * Update webapp/scripts/CLAUDE.OPTIONAL.md
64 lines
2 KiB
Bash
Executable file
64 lines
2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
# See LICENSE.txt for license information.
|
|
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
echo "Usage: scripts/update-versions.sh monorepo_version"
|
|
exit 1
|
|
}
|
|
|
|
if [ $# -ne 1 ]; then
|
|
usage
|
|
fi
|
|
|
|
version="$1"
|
|
if ! echo "$version" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$'; then
|
|
# The version provided appears to be invalid
|
|
usage
|
|
fi
|
|
|
|
# These workspaces and packages within the monorepo all synchronize their versions with the web app and server
|
|
workspaces=(
|
|
channels
|
|
platform/client
|
|
platform/mattermost-redux
|
|
platform/shared
|
|
platform/types
|
|
)
|
|
packages=(
|
|
@mattermost/client
|
|
@mattermost/shared
|
|
@mattermost/types
|
|
)
|
|
|
|
packages_json=$(printf '%s\n' "${packages[@]}" | jq -R . | jq -s .)
|
|
workspaces_json=$(printf '%s\n' "${workspaces[@]}" | jq -R . | jq -s .)
|
|
|
|
# In each package's package.json, update the version of that package and any of the other workspace packages to match
|
|
for workspace in "${workspaces[@]}"; do
|
|
pkg_json="${workspace}/package.json"
|
|
jq --arg version "$version" --argjson packages "$packages_json" '
|
|
.version = $version |
|
|
reduce $packages[] as $pkg (.;
|
|
|
|
reduce ["dependencies", "devDependencies", "peerDependencies"][] as $section (.;
|
|
if .[$section][$pkg] then .[$section][$pkg] = $version else . end
|
|
)
|
|
)
|
|
' "$pkg_json" > "${pkg_json}.tmp" && mv "${pkg_json}.tmp" "$pkg_json"
|
|
done
|
|
|
|
# Then go through the package-lock.json and make those same changes
|
|
jq --arg version "$version" --argjson packages "$packages_json" --argjson workspaces "$workspaces_json" '
|
|
reduce $workspaces[] as $ws (.;
|
|
.packages[$ws].version = $version |
|
|
reduce $packages[] as $pkg (.;
|
|
reduce ["dependencies", "devDependencies", "peerDependencies"][] as $section (.;
|
|
if .packages[$ws][$section][$pkg] then .packages[$ws][$section][$pkg] = $version else . end
|
|
)
|
|
)
|
|
)
|
|
' package-lock.json > package-lock.json.tmp && mv package-lock.json.tmp package-lock.json
|