#!/usr/bin/env bash # ============================================================================ # Copyright (C) 2025 Moko Consulting # # This file is part of a Moko Consulting project. # # SPDX-License-Identifier: GPL-3.0-or-later # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program (./LICENSE.md). # ============================================================================ # ============================================================================ # FILE INFORMATION # ============================================================================ # DEFGROUP: Script.Fix # INGROUP: Version.Management # REPO: https://github.com/mokoconsulting-tech/moko-cassiopeia # PATH: /scripts/fix/versions.sh # VERSION: 01.00.00 # BRIEF: Update version numbers across repository files # NOTE: Updates manifest, package.json, and other version references # ============================================================================ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)" . "${SCRIPT_DIR}/lib/common.sh" # ---------------------------------------------------------------------------- # Usage and validation # ---------------------------------------------------------------------------- usage() { cat <<-USAGE Usage: $0 Update version numbers across repository files. Arguments: VERSION Semantic version in format X.Y.Z (e.g., 3.5.0) Examples: $0 3.5.0 $0 1.2.3 USAGE exit 1 } validate_version() { local v="$1" if ! printf '%s' "$v" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then die "Invalid version format: $v (expected X.Y.Z)" fi } # ---------------------------------------------------------------------------- # Main # ---------------------------------------------------------------------------- [ $# -eq 1 ] || usage VERSION="$1" validate_version "${VERSION}" log_info "Updating version to: ${VERSION}" # Source Joomla manifest utilities . "${SCRIPT_DIR}/lib/joomla_manifest.sh" # Find and update manifest MANIFEST="$(find_manifest src)" log_info "Updating manifest: ${MANIFEST}" # Cross-platform sed helper sed_inplace() { local expr="$1" local file="$2" if sed --version >/dev/null 2>&1; then sed -i -E "${expr}" "${file}" else sed -i '' -E "${expr}" "${file}" fi } # Update version in manifest XML if grep -q '' "${MANIFEST}"; then sed_inplace "s|[^<]*|${VERSION}|g" "${MANIFEST}" log_info "✓ Updated manifest version" else log_warn "No tag found in manifest" fi # Update package.json if it exists if [ -f "package.json" ]; then if command -v python3 >/dev/null 2>&1; then python3 - <