From 1efd045a838e1c61dec78c76542d3bd8acefcb6e Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sun, 20 Jul 2025 22:07:17 +0200 Subject: [PATCH] Final clean-up of all Bash scripts except examples/**/*.sh and spine-godot/build/*.sh --- formatters/logging/logging.sh | 5 +- formatters/logging/terminal-logging-guide.md | 175 +++---------------- spine-android/publish.sh | 67 ++++--- spine-flutter/compile-wasm.sh | 42 ++--- spine-flutter/publish.sh | 40 ++--- spine-flutter/setup.sh | 32 ++-- spine-haxe/build.sh | 5 +- spine-haxe/publish.sh | 32 ++-- spine-ios/setup.sh | 16 +- spine-libgdx/publish.sh | 74 ++++---- spine-ts/publish.sh | 43 ++--- spine-ue/setup.sh | 16 +- 12 files changed, 201 insertions(+), 346 deletions(-) diff --git a/formatters/logging/logging.sh b/formatters/logging/logging.sh index a710637a1..2cd6f56cd 100644 --- a/formatters/logging/logging.sh +++ b/formatters/logging/logging.sh @@ -68,7 +68,7 @@ log_fail() { } log_warn() { - echo -e "${YELLOW}!${NC}" + echo -e " ${YELLOW}!${NC} ${YELLOW}$1${NC}" } log_skip() { @@ -82,11 +82,10 @@ log_error_output() { # Final summary log_summary() { - echo "" echo -e "${BOLD}$1${NC}" } # Detailed output (errors, etc.) log_detail() { - echo -e "${GRAY}$1${NC}" + echo -e " ${GRAY}$1${NC}" } \ No newline at end of file diff --git a/formatters/logging/terminal-logging-guide.md b/formatters/logging/terminal-logging-guide.md index 5f5f83081..87e70d0e2 100644 --- a/formatters/logging/terminal-logging-guide.md +++ b/formatters/logging/terminal-logging-guide.md @@ -1,88 +1,25 @@ # Terminal Logging Style Guide -This guide defines the terminal output style for all bash scripts in the Spine Runtimes project. - -## Design Principles - -1. **Minimal visual noise** - Use color sparingly for emphasis, not decoration -2. **Clear hierarchy** - Different levels of information have distinct visual treatments -3. **Consistent spacing** - Clean vertical rhythm throughout output -4. **Accessible** - Readable and meaningful even without colors -5. **Scannable** - Easy to quickly identify successes, failures, and important information - -## Visual Hierarchy - -### 1. Title (`log_title`) -- **Purpose**: Main script/tool name -- **Style**: Bold with vertical spacing -- **Usage**: Once at the beginning of script execution +## Functions ```bash -log_title "Spine-C++ Build" -``` - -### 2. Action + Result (inline format) -- **Purpose**: Individual operations with immediate result -- **Style**: Action on same line as result for density -- **Usage**: `log_action` followed immediately by `log_ok/fail/warn/skip` - -```bash -log_action "Building all variants" -log_ok # Green ✓ on same line - -log_action "Testing headless-test" -log_fail # Red ✗ on same line -``` - -**Results**: -- `log_ok` - Green ✓ (success) -- `log_fail` - Red ✗ (failure) -- `log_warn` - Yellow ! (warning) -- `log_skip` - Gray - (skipped) - -### 4. Error Output (`log_error_output`) -- **Purpose**: Full error output when operations fail -- **Style**: Normal text (not grayed), prominent -- **Usage**: Show command output after failures - -```bash -log_action "Building" -if BUILD_OUTPUT=$(command 2>&1); then - log_ok -else - log_fail - log_error_output "$BUILD_OUTPUT" -fi -``` - -### 5. Detail (`log_detail`) -- **Purpose**: Secondary information, debug info (not errors) -- **Style**: Gray text, indented -- **Usage**: Additional context, platform info - -```bash -log_detail "Platform: Darwin" -log_detail "Branch: main" -``` - -### 6. Summary (`log_summary`) -- **Purpose**: Final result or conclusion -- **Style**: Bold with vertical spacing -- **Usage**: End of script execution - -```bash -log_summary "✓ All tests passed (5/5)" -log_summary "✗ Tests failed (3/5)" -``` - -## Complete Example - -```bash -#!/bin/bash source ../formatters/logging/logging.sh +log_title "Script Name" # Bold title +log_action "Doing something" # Action with inline result +log_ok # Green ✓ +log_fail # Red ✗ +log_warn # Yellow ! +log_skip # Gray - +log_error_output "$OUTPUT" # Show command output on errors +log_detail "Extra info" # Gray secondary text +log_summary "✓ All done" # Bold conclusion +``` + +## Pattern + +```bash log_title "Spine-C++ Build" -log_detail "Platform: $(uname)" log_action "Configuring debug build" if CMAKE_OUTPUT=$(cmake --preset=debug . 2>&1); then @@ -101,88 +38,20 @@ else log_error_output "$BUILD_OUTPUT" exit 1 fi - -log_summary "✓ Build successful" ``` -## Output Preview +## Output -**Success case:** ``` Spine-C++ Build -Platform: Darwin - Configuring debug build... ✓ Building... ✓ - -✓ Build successful ``` -**Failure case:** -``` -Spine-C++ Build -Platform: Darwin +## Rules - Configuring debug build... ✗ -CMake Error: Could not find cmake file... -(full error output shown prominently) -``` - -## Error Handling Best Practices - -1. **Capture output**: Use `OUTPUT=$(command 2>&1)` to capture both stdout and stderr -2. **Check exit codes**: Always check if critical operations succeeded -3. **Show errors prominently**: Use `log_error_output` for command failures (not grayed) -4. **Fail fast**: Exit immediately on critical failures -5. **Use inline results**: `log_action` + `log_ok/fail` for dense, scannable output - -## Calling Other Scripts - -When calling other bash scripts that have their own logging: - -1. **Trust their logging**: Don't wrap calls in redundant log actions -2. **Capture output for errors**: Use `OUTPUT=$(script.sh 2>&1)` to capture output and only show on failure -3. **Let them handle success**: Avoid "script completed" messages when the script shows its own status - -**Good**: -```bash -# Let the script handle its own logging -../formatters/format.sh cpp - -# Or capture output and only show on error -if output=$(./setup.sh 2>&1); then - log_ok "Setup completed" -else - log_fail "Setup failed" - log_detail "$output" -fi -``` - -**Avoid**: -```bash -# This creates duplicate logging -log_action "Formatting C++ files" -../formatters/format.sh cpp -log_ok "C++ formatting completed" -``` - -```bash -if BUILD_OUTPUT=$(./build.sh clean release 2>&1); then - log_ok "Build completed" -else - log_fail "Build failed" - log_detail "$BUILD_OUTPUT" - exit 1 -fi -``` - -## Usage - -1. Source the utilities in your script: -```bash -source ../formatters/logging/logging.sh -``` - -2. Follow the hierarchy patterns shown above -3. Use appropriate functions for each type of output -4. Test output both with and without color support \ No newline at end of file +- Always capture command output of commands following log_action: `OUTPUT=$(command 2>&1)` +- Show errors prominently with `log_error_output` +- Use inline results: `log_action` + `log_ok/fail` +- Let sub-scripts handle their own logging, e.g. do not log "Building Spine-C++" when calling `spine-cpp/build.sh` +- Do not capture output of sub-scripts like you do for "normal" commands. That would swallow their logging. \ No newline at end of file diff --git a/spine-android/publish.sh b/spine-android/publish.sh index b93bea247..9c07d9efb 100755 --- a/spine-android/publish.sh +++ b/spine-android/publish.sh @@ -5,63 +5,62 @@ cd "$(dirname "$0")" # Source logging utilities source ../formatters/logging/logging.sh +# Modern Central Portal Publishing Setup: +# 1. Set up PGP key for signing: gpg --generate-key +# 2. Create Central Portal account at https://central.sonatype.com/ +# 3. Generate user token in Central Portal settings +# 4. Create ~/.gradle/gradle.properties with: +# MAVEN_USERNAME= +# MAVEN_PASSWORD= +# signing.gnupg.passphrase= +# +# Version Configuration: +# - Edit spine-libgdx/gradle.properties and update the 'version' property (single source of truth) +# - For releases: version=4.2.9 (no -SNAPSHOT suffix) +# - For snapshots: version=4.2.9-SNAPSHOT (with -SNAPSHOT suffix) + log_title "Spine Android Publisher" -log_detail "Modern Central Portal Publishing Setup:" -log_detail "1. Set up PGP key for signing: gpg --generate-key" -log_detail "2. Create Central Portal account at https://central.sonatype.com/" -log_detail "3. Generate user token in Central Portal settings" -log_detail "4. Create ~/.gradle/gradle.properties with:" -log_detail " MAVEN_USERNAME=" -log_detail " MAVEN_PASSWORD=" -log_detail " signing.gnupg.passphrase=" -log_detail "" -log_detail "Version Configuration:" -log_detail "- Edit spine-libgdx/gradle.properties and update the 'version' property (single source of truth)" -log_detail "- For releases: version=4.2.9 (no -SNAPSHOT suffix)" -log_detail "- For snapshots: version=4.2.9-SNAPSHOT (with -SNAPSHOT suffix)" - -log_section "Reading Version Configuration" log_action "Reading version from spine-libgdx gradle.properties" -if VERSION=$(grep '^version=' ../spine-libgdx/gradle.properties | cut -d'=' -f2); then - log_ok "Version found: $VERSION" +if VERSION=$(grep '^version=' ../spine-libgdx/gradle.properties | cut -d'=' -f2 2>&1); then + log_ok + log_detail "Version found: $VERSION" else - log_fail "Failed to read version from ../spine-libgdx/gradle.properties" + log_fail + log_error_output "Failed to read version from ../spine-libgdx/gradle.properties" exit 1 fi -log_section "Publishing to Central Portal" if echo "$VERSION" | grep -q "SNAPSHOT"; then log_detail "Detected SNAPSHOT version" log_action "Publishing SNAPSHOT version $VERSION to Central Portal" - if output=$(./gradlew :spine-android:publishReleasePublicationToSonaTypeRepository --info 2>&1); then - log_ok "Successfully published SNAPSHOT version $VERSION" - log_summary "Android SNAPSHOT published successfully to Central Portal" + if GRADLE_OUTPUT=$(./gradlew :spine-android:publishReleasePublicationToSonaTypeRepository --info 2>&1); then + log_ok + log_summary "✓ Android SNAPSHOT published successfully to Central Portal" else - log_fail "Failed to publish SNAPSHOT version" - log_detail "$output" + log_fail + log_error_output "$GRADLE_OUTPUT" exit 1 fi else log_detail "Detected RELEASE version" - log_action "Publishing RELEASE version $VERSION to Central Portal via JReleaser" log_action "Publishing to SonaType repository" - if output=$(./gradlew :spine-android:publishReleasePublicationToSonaTypeRepository -PRELEASE 2>&1); then - log_ok "Successfully published to SonaType repository" + if GRADLE_OUTPUT=$(./gradlew :spine-android:publishReleasePublicationToSonaTypeRepository -PRELEASE 2>&1); then + log_ok else - log_fail "Failed to publish to SonaType repository" - log_detail "$output" + log_fail + log_error_output "$GRADLE_OUTPUT" exit 1 fi log_action "Deploying via JReleaser" - if output=$(./gradlew :spine-android:jreleaserDeploy -PRELEASE --info 2>&1); then - log_ok "Successfully deployed via JReleaser" - log_summary "Android RELEASE published successfully to Central Portal" + if GRADLE_OUTPUT=$(./gradlew :spine-android:jreleaserDeploy -PRELEASE --info 2>&1); then + log_ok + log_summary "✓ Android RELEASE published successfully to Central Portal" else - log_fail "Failed to deploy via JReleaser" - log_detail "$output" + log_fail + log_error_output "$GRADLE_OUTPUT" exit 1 fi fi \ No newline at end of file diff --git a/spine-flutter/compile-wasm.sh b/spine-flutter/compile-wasm.sh index ff04daec2..4539865f2 100755 --- a/spine-flutter/compile-wasm.sh +++ b/spine-flutter/compile-wasm.sh @@ -7,30 +7,30 @@ source ../formatters/logging/logging.sh log_title "Spine Flutter WASM Compiler" -log_section "Preparing Build Environment" log_action "Creating assets directory" -if mkdir -p lib/assets/; then - log_ok "Assets directory created" +if MKDIR_OUTPUT=$(mkdir -p lib/assets/ 2>&1); then + log_ok else - log_fail "Failed to create assets directory" + log_fail + log_error_output "$MKDIR_OUTPUT" exit 1 fi log_action "Creating pre.js module file" -if echo "const module = {};" > pre.js; then - log_ok "pre.js created successfully" +if ECHO_OUTPUT=$(echo "const module = {};" > pre.js 2>&1); then + log_ok else - log_fail "Failed to create pre.js" + log_fail + log_error_output "$ECHO_OUTPUT" exit 1 fi -log_section "Compiling WASM" log_detail "Using -O2 optimization to preserve function names" log_detail "The Closure compiler in -O3 would scramble native function names" log_action "Compiling spine-cpp to WASM" # Build the emscripten command -if output=$(em++ \ +if EMCC_OUTPUT=$(em++ \ -Isrc/spine-cpp/include \ -O2 --closure 1 -fno-rtti -fno-exceptions \ -s STRICT=1 \ @@ -47,27 +47,29 @@ if output=$(em++ \ -s EXPORT_NAME=libspine_flutter \ src/spine-cpp-lite/spine-cpp-lite.cpp $(find src/spine-cpp/src -type f) \ -o lib/assets/libspine_flutter.js 2>&1); then - log_ok "WASM compilation completed successfully" + log_ok else - log_fail "WASM compilation failed" - log_detail "$output" + log_fail + log_error_output "$EMCC_OUTPUT" rm -f pre.js exit 1 fi -log_section "Build Results" log_action "Listing generated assets" -if ls -lah lib/assets; then - log_ok "Assets generated successfully" +if LS_OUTPUT=$(ls -lah lib/assets 2>&1); then + log_ok + log_detail "$LS_OUTPUT" else - log_warn "Could not list assets directory" + log_warn + log_detail "$LS_OUTPUT" fi log_action "Cleaning up temporary files" -if rm pre.js; then - log_ok "Cleaned up pre.js" +if RM_OUTPUT=$(rm pre.js 2>&1); then + log_ok else - log_warn "Could not remove pre.js" + log_warn + log_detail "$RM_OUTPUT" fi -log_summary "WASM compilation completed successfully" \ No newline at end of file +log_summary "✓ WASM compilation completed successfully" \ No newline at end of file diff --git a/spine-flutter/publish.sh b/spine-flutter/publish.sh index d4da13bb9..73998c4f2 100755 --- a/spine-flutter/publish.sh +++ b/spine-flutter/publish.sh @@ -7,41 +7,27 @@ source ../formatters/logging/logging.sh log_title "Spine Flutter Publisher" -log_section "Preparation" -log_action "Setting up environment" -if output=$(./setup.sh 2>&1); then - log_ok "Setup completed successfully" -else - log_fail "Setup failed" - log_detail "$output" - exit 1 -fi +# Let setup.sh handle its own logging +./setup.sh -log_action "Compiling WASM" -if output=$(./compile-wasm.sh 2>&1); then - log_ok "WASM compilation completed successfully" -else - log_fail "WASM compilation failed" - log_detail "$output" - exit 1 -fi +# Let compile-wasm.sh handle its own logging +./compile-wasm.sh -log_section "Publishing to Dart Pub" log_action "Running dry-run publish" -if output=$(dart pub publish --dry-run 2>&1); then - log_ok "Dry-run publish completed successfully" +if DART_OUTPUT=$(dart pub publish --dry-run 2>&1); then + log_ok else - log_fail "Dry-run publish failed" - log_detail "$output" + log_fail + log_error_output "$DART_OUTPUT" exit 1 fi log_action "Publishing to Dart Pub" -if output=$(dart pub publish 2>&1); then - log_ok "Successfully published to Dart Pub" - log_summary "Flutter package published successfully" +if DART_OUTPUT=$(dart pub publish 2>&1); then + log_ok + log_summary "✓ Flutter package published successfully" else - log_fail "Failed to publish to Dart Pub" - log_detail "$output" + log_fail + log_error_output "$DART_OUTPUT" exit 1 fi \ No newline at end of file diff --git a/spine-flutter/setup.sh b/spine-flutter/setup.sh index e85ba3953..22fa7e7c2 100755 --- a/spine-flutter/setup.sh +++ b/spine-flutter/setup.sh @@ -10,38 +10,40 @@ log_title "Spine Flutter Setup" log_detail "CocoaPods requires all source files to be under the same folder hierarchy" log_detail "as the podspec file resides in. Copying spine-cpp sources to platform folders." -log_section "Copying Spine C++ Sources" - log_action "Copying spine-cpp to iOS Classes" -if cp -r ../spine-cpp/spine-cpp ios/Classes 2>/dev/null; then - log_ok "iOS Classes updated successfully" +if CP_OUTPUT=$(cp -r ../spine-cpp/spine-cpp ios/Classes 2>&1); then + log_ok else - log_fail "Failed to copy spine-cpp to iOS Classes" + log_fail + log_error_output "$CP_OUTPUT" exit 1 fi log_action "Copying spine-cpp to macOS Classes" -if cp -r ../spine-cpp/spine-cpp macos/Classes 2>/dev/null; then - log_ok "macOS Classes updated successfully" +if CP_OUTPUT=$(cp -r ../spine-cpp/spine-cpp macos/Classes 2>&1); then + log_ok else - log_fail "Failed to copy spine-cpp to macOS Classes" + log_fail + log_error_output "$CP_OUTPUT" exit 1 fi log_action "Copying spine-cpp to src directory" -if cp -r ../spine-cpp/spine-cpp src 2>/dev/null; then - log_ok "src directory updated successfully" +if CP_OUTPUT=$(cp -r ../spine-cpp/spine-cpp src 2>&1); then + log_ok else - log_fail "Failed to copy spine-cpp to src directory" + log_fail + log_error_output "$CP_OUTPUT" exit 1 fi log_action "Copying spine-cpp-lite to src directory" -if cp -r ../spine-cpp/spine-cpp-lite src 2>/dev/null; then - log_ok "spine-cpp-lite copied successfully" +if CP_OUTPUT=$(cp -r ../spine-cpp/spine-cpp-lite src 2>&1); then + log_ok else - log_fail "Failed to copy spine-cpp-lite to src directory" + log_fail + log_error_output "$CP_OUTPUT" exit 1 fi -log_summary "Flutter setup completed successfully" \ No newline at end of file +log_summary "✓ Flutter setup completed successfully" \ No newline at end of file diff --git a/spine-haxe/build.sh b/spine-haxe/build.sh index 7b04d3a6f..baba83c9b 100755 --- a/spine-haxe/build.sh +++ b/spine-haxe/build.sh @@ -24,7 +24,6 @@ if echo "$COMMIT_MSG" | grep -qE '^\[haxe\] Release [0-9]+\.[0-9]+\.[0-9]+$'; th log_detail "Version: $VERSION" if [ ! -z "$HAXE_UPDATE_URL" ] && [ ! -z "$BRANCH" ]; then - log_section "Deploy" log_action "Creating release package" if ZIP_OUTPUT=$(zip -r "spine-haxe-$VERSION.zip" \ haxelib.json \ @@ -37,7 +36,7 @@ if echo "$COMMIT_MSG" | grep -qE '^\[haxe\] Release [0-9]+\.[0-9]+\.[0-9]+$'; th log_error_output "$ZIP_OUTPUT" exit 1 fi - + log_action "Uploading to $HAXE_UPDATE_URL$BRANCH" if CURL_OUTPUT=$(curl -f -F "file=@spine-haxe-$VERSION.zip" "$HAXE_UPDATE_URL$BRANCH" 2>&1); then log_ok @@ -46,7 +45,7 @@ if echo "$COMMIT_MSG" | grep -qE '^\[haxe\] Release [0-9]+\.[0-9]+\.[0-9]+$'; th log_error_output "$CURL_OUTPUT" exit 1 fi - + log_summary "✓ Build and deployment successful" else log_skip "Deployment skipped (HAXE_UPDATE_URL and/or BRANCH not set)" diff --git a/spine-haxe/publish.sh b/spine-haxe/publish.sh index 3e53ef777..d2ab2f17f 100755 --- a/spine-haxe/publish.sh +++ b/spine-haxe/publish.sh @@ -16,36 +16,44 @@ newVersion="$major.$minor.$newPatch" log_title "Spine-Haxe Publish" -log_section "Version Update" log_detail "Current version: $currentVersion" log_detail "New version: $newVersion" log_action "Updating haxelib.json" -sed -i '' "s/$currentVersion/$newVersion/" haxelib.json -log_ok "Version updated in haxelib.json" +if SED_OUTPUT=$(sed -i '' "s/$currentVersion/$newVersion/" haxelib.json 2>&1); then + log_ok +else + log_fail + log_error_output "$SED_OUTPUT" + exit 1 +fi -log_section "Confirm" echo "Write Y if you want to commit and push the new version $newVersion." echo "This will trigger a pipeline that will publish the new version on esoteric software server." echo "Do you want to proceed [y/n]?" read answer if [ "$answer" = "Y" ] || [ "$answer" = "y" ]; then - log_section "Publish" log_action "Committing changes" - git add haxelib.json - git commit -m "[haxe] Release $newVersion" - log_ok "Changes committed" + if COMMIT_OUTPUT=$(git add haxelib.json && git commit -m "[haxe] Release $newVersion" 2>&1); then + log_ok + else + log_fail + log_error_output "$COMMIT_OUTPUT" + exit 1 + fi log_action "Pushing to origin" - if git push origin 4.2; then - log_ok "Changes pushed" + if PUSH_OUTPUT=$(git push origin 4.2 2>&1); then + log_ok log_summary "✓ Version $newVersion published successfully" else - log_fail "Push failed" + log_fail + log_error_output "$PUSH_OUTPUT" exit 1 fi else - log_skip "Commit and push cancelled" + log_action "Publishing version" + log_skip log_summary "Version updated locally only" fi \ No newline at end of file diff --git a/spine-ios/setup.sh b/spine-ios/setup.sh index 206b1546a..c7cd069ba 100755 --- a/spine-ios/setup.sh +++ b/spine-ios/setup.sh @@ -7,18 +7,18 @@ source ../formatters/logging/logging.sh log_title "Spine iOS Setup" -log_section "Generating Swift Bindings" log_action "Running spine-cpp-lite code generator" -if output=$(python3 ../spine-cpp/spine-cpp-lite/spine-cpp-lite-codegen.py 2>&1); then - if echo "$output" > Sources/Spine/Spine.Generated.swift; then - log_ok "Swift bindings generated successfully" - log_summary "iOS setup completed successfully" +if PYTHON_OUTPUT=$(python3 ../spine-cpp/spine-cpp-lite/spine-cpp-lite-codegen.py 2>&1); then + if WRITE_OUTPUT=$(echo "$PYTHON_OUTPUT" > Sources/Spine/Spine.Generated.swift 2>&1); then + log_ok + log_summary "✓ iOS setup completed successfully" else - log_fail "Failed to write generated Swift code" + log_fail + log_error_output "$WRITE_OUTPUT" exit 1 fi else - log_fail "Failed to run spine-cpp-lite code generator" - log_detail "$output" + log_fail + log_error_output "$PYTHON_OUTPUT" exit 1 fi diff --git a/spine-libgdx/publish.sh b/spine-libgdx/publish.sh index c7fade7d2..093fbf4f9 100755 --- a/spine-libgdx/publish.sh +++ b/spine-libgdx/publish.sh @@ -5,63 +5,59 @@ cd "$(dirname "$0")" # Source logging utilities source ../formatters/logging/logging.sh +# Modern Central Portal Publishing Setup: +# 1. Set up PGP key for signing: gpg --generate-key +# 2. Create Central Portal account at https://central.sonatype.com/ +# 3. Generate user token in Central Portal settings +# 4. Create ~/.gradle/gradle.properties with: +# MAVEN_USERNAME= +# MAVEN_PASSWORD= +# signing.gnupg.passphrase= +# +# Version Configuration: +# - Edit gradle.properties and update the 'version' property +# - For releases: version=4.2.9 (no -SNAPSHOT suffix) +# - For snapshots: version=4.2.9-SNAPSHOT (with -SNAPSHOT suffix) + log_title "Spine LibGDX Publisher" -log_detail "Modern Central Portal Publishing Setup:" -log_detail "1. Set up PGP key for signing: gpg --generate-key" -log_detail "2. Create Central Portal account at https://central.sonatype.com/" -log_detail "3. Generate user token in Central Portal settings" -log_detail "4. Create ~/.gradle/gradle.properties with:" -log_detail " MAVEN_USERNAME=" -log_detail " MAVEN_PASSWORD=" -log_detail " signing.gnupg.passphrase=" -log_detail "" -log_detail "Version Configuration:" -log_detail "- Edit gradle.properties and update the 'version' property" -log_detail "- For releases: version=4.2.9 (no -SNAPSHOT suffix)" -log_detail "- For snapshots: version=4.2.9-SNAPSHOT (with -SNAPSHOT suffix)" - -log_section "Reading Version Configuration" log_action "Reading version from gradle.properties" -if VERSION=$(grep '^version=' gradle.properties | cut -d'=' -f2); then - log_ok "Version found: $VERSION" +if VERSION=$(grep '^version=' gradle.properties | cut -d'=' -f2 2>&1); then + log_ok + log_detail "Version found: $VERSION" else - log_fail "Failed to read version from gradle.properties" + log_fail + log_error_output "Failed to read version from gradle.properties" exit 1 fi -log_section "Publishing to Central Portal" if echo "$VERSION" | grep -q "SNAPSHOT"; then - log_detail "Detected SNAPSHOT version" log_action "Publishing SNAPSHOT version $VERSION to Central Portal" - if output=$(./gradlew publishReleasePublicationToSonaTypeRepository 2>&1); then - log_ok "Successfully published SNAPSHOT version $VERSION" - log_summary "LibGDX SNAPSHOT published successfully to Central Portal" + if GRADLE_OUTPUT=$(./gradlew publishReleasePublicationToSonaTypeRepository 2>&1); then + log_ok + log_summary "✓ LibGDX SNAPSHOT published successfully to Central Portal" else - log_fail "Failed to publish SNAPSHOT version" - log_detail "$output" + log_fail + log_error_output "$GRADLE_OUTPUT" exit 1 fi else - log_detail "Detected RELEASE version" - log_action "Publishing RELEASE version $VERSION to Central Portal via JReleaser" - - log_action "Publishing to SonaType repository" - if output=$(./gradlew publishReleasePublicationToSonaTypeRepository -PRELEASE 2>&1); then - log_ok "Successfully published to SonaType repository" + log_action "Publishing RELEASE version $VERSION to Central Portal" + if GRADLE_OUTPUT=$(./gradlew publishReleasePublicationToSonaTypeRepository -PRELEASE 2>&1); then + log_ok else - log_fail "Failed to publish to SonaType repository" - log_detail "$output" + log_fail + log_error_output "$GRADLE_OUTPUT" exit 1 fi - + log_action "Deploying via JReleaser" - if output=$(./gradlew jreleaserDeploy -PRELEASE 2>&1); then - log_ok "Successfully deployed via JReleaser" - log_summary "LibGDX RELEASE published successfully to Central Portal" + if GRADLE_OUTPUT=$(./gradlew jreleaserDeploy -PRELEASE 2>&1); then + log_ok + log_summary "✓ LibGDX RELEASE published successfully to Central Portal" else - log_fail "Failed to deploy via JReleaser" - log_detail "$output" + log_fail + log_error_output "$GRADLE_OUTPUT" exit 1 fi fi \ No newline at end of file diff --git a/spine-ts/publish.sh b/spine-ts/publish.sh index 70ab493a5..097867e2b 100755 --- a/spine-ts/publish.sh +++ b/spine-ts/publish.sh @@ -15,11 +15,8 @@ patch=$(echo "$currentVersion" | cut -d. -f3) newPatch=$((patch + 1)) newVersion="$major.$minor.$newPatch" -log_section "Version Management" log_detail "Current version: $currentVersion" log_detail "New version: $newVersion" - -log_section "Updating Package Versions" packages=( "package.json" "spine-canvas/package.json" @@ -37,46 +34,44 @@ packages=( for package in "${packages[@]}"; do log_action "Updating $package" - if sed -i '' "s/$currentVersion/$newVersion/" "$package" 2>/dev/null; then - log_ok "Updated $package" + if SED_OUTPUT=$(sed -i '' "s/$currentVersion/$newVersion/" "$package" 2>&1); then + log_ok else - log_fail "Failed to update $package" + log_fail + log_error_output "$SED_OUTPUT" exit 1 fi done -log_section "Preparing for Publish" log_action "Removing package-lock.json" -if rm package-lock.json 2>/dev/null; then - log_ok "Removed package-lock.json" +if RM_OUTPUT=$(rm package-lock.json 2>&1); then + log_ok else - log_warn "package-lock.json not found or already removed" + log_warn fi log_action "Cleaning @esotericsoftware modules" -if rm -rf node_modules/@esotericsoftware 2>/dev/null; then - log_ok "Cleaned @esotericsoftware modules" +if RM_OUTPUT=$(rm -rf node_modules/@esotericsoftware 2>&1); then + log_ok else - log_warn "@esotericsoftware modules not found or already removed" + log_warn fi -log_section "Installing Dependencies" log_action "Installing workspace dependencies" -if output=$(npm install --workspaces 2>&1); then - log_ok "Dependencies installed successfully" +if NPM_OUTPUT=$(npm install --workspaces 2>&1); then + log_ok else - log_fail "Failed to install dependencies" - log_detail "$output" + log_fail + log_error_output "$NPM_OUTPUT" exit 1 fi -log_section "Publishing to NPM" log_action "Publishing all workspaces" -if output=$(npm publish --access public --workspaces 2>&1); then - log_ok "Successfully published all packages to NPM" - log_summary "TypeScript packages published successfully with version $newVersion" +if NPM_OUTPUT=$(npm publish --access public --workspaces 2>&1); then + log_ok + log_summary "✓ TypeScript packages published successfully with version $newVersion" else - log_fail "Failed to publish packages" - log_detail "$output" + log_fail + log_error_output "$NPM_OUTPUT" exit 1 fi \ No newline at end of file diff --git a/spine-ue/setup.sh b/spine-ue/setup.sh index 75b68a00d..88052dadc 100755 --- a/spine-ue/setup.sh +++ b/spine-ue/setup.sh @@ -7,19 +7,19 @@ source ../formatters/logging/logging.sh log_title "Spine Unreal Engine Setup" -log_section "Updating Spine C++ Sources" log_action "Removing existing spine-cpp directory" -if rm -rf Plugins/SpinePlugin/Source/SpinePlugin/Public/spine-cpp 2>/dev/null; then - log_ok "Existing spine-cpp directory removed" +if RM_OUTPUT=$(rm -rf Plugins/SpinePlugin/Source/SpinePlugin/Public/spine-cpp 2>&1); then + log_ok else - log_warn "No existing spine-cpp directory found" + log_warn fi log_action "Copying updated spine-cpp sources" -if cp -r ../spine-cpp/spine-cpp Plugins/SpinePlugin/Source/SpinePlugin/Public/spine-cpp 2>/dev/null; then - log_ok "spine-cpp sources copied successfully" - log_summary "Unreal Engine setup completed successfully" +if CP_OUTPUT=$(cp -r ../spine-cpp/spine-cpp Plugins/SpinePlugin/Source/SpinePlugin/Public/spine-cpp 2>&1); then + log_ok + log_summary "✓ Unreal Engine setup completed successfully" else - log_fail "Failed to copy spine-cpp sources" + log_fail + log_error_output "$CP_OUTPUT" exit 1 fi \ No newline at end of file