From 791cb12a4498c116997f1a23511a38d7e6db0a6c Mon Sep 17 00:00:00 2001 From: "(Holloway) Chew, Kean Ho" Date: Mon, 1 Apr 2024 17:03:03 +0800 Subject: [PATCH] root: fixed homebrew Formula error issue The current homebrew Formula is giving a lot of issue at the moment. Hence, we need to fix it. This patch fixes homebrew Formula error issue in root repository. Signed-off-by: (Holloway) Chew, Kean Ho --- automataCI/services/io/strings.ps1 | 43 +++++++++++++++++++++++ automataCI/services/io/strings.sh | 43 +++++++++++++++++++++++ src/.ci/_package-homebrew_unix-any.sh | 8 +++-- src/.ci/_package-homebrew_windows-any.ps1 | 8 +++-- 4 files changed, 96 insertions(+), 6 deletions(-) diff --git a/automataCI/services/io/strings.ps1 b/automataCI/services/io/strings.ps1 index 1b4d5d4..0def61a 100644 --- a/automataCI/services/io/strings.ps1 +++ b/automataCI/services/io/strings.ps1 @@ -196,3 +196,46 @@ function STRINGS-To-Uppercase { # execute return $___content.ToUpper() } + + + + +function STRINGS-To-Uppercase-First-Char { + param( + [string]$___content + ) + + + # valdiate input + if ([string]::IsNullOrEmpty($___content)) { + return "" + } + + + # execute + $___buffer = "" + $___resevoir = $___content + $___trigger = $true + while ($___resevoir -ne "") { + ## extract character + $___char = $___resevoir.Substring(0, 1) + if ($___char -eq "``") { + $___char = $___resevoir.Substring(0, 2) + } + $___resevoir = $___resevoir -replace "^${___char}", "" + + ## process characters + if (($___char -eq " ") -or ($___char -eq "`n")) { + $___trigger = $true + } else { + $___char = $___char.ToUpper() + $___trigger = $false + } + + $___buffer += $___char + } + + + # report status + return $___buffer +} diff --git a/automataCI/services/io/strings.sh b/automataCI/services/io/strings.sh index ed16a95..b3f486a 100644 --- a/automataCI/services/io/strings.sh +++ b/automataCI/services/io/strings.sh @@ -200,3 +200,46 @@ STRINGS_To_Uppercase() { # report status return 0 } + + + + +STRINGS_To_Uppercase_First_Char() { + #___content="$1" + + + # validate input + if [ $(STRINGS_Is_Empty "$1") -eq 0 ]; then + printf -- "" + return 1 + fi + + + # execute + ___buffer="" + ___resevoir="$1" + ___trigger=0 + while [ -n "$___resevoir" ]; do + ## extract character + ___char="$(printf -- "%.1s" "$___resevoir")" + if [ "$___char" = '\' ]; then + ___char="$(printf -- "%.2s" "$___resevoir")" + fi + ___resevoir="${___resevoir#*${___char}}" + + ## process character + if [ "$___char" = " " ] || [ "$___char" = "\n" ]; then + ___trigger=0 + elif [ $___trigger -eq 0 ]; then + ___char="$(printf -- "%s" "$___char" | tr '[:lower:]' '[:upper:]')" + ___trigger=1 + fi + + ___buffer="${___buffer}${___char}" + done + + + # report status + printf -- "%b" "$___buffer" + return 0 +} diff --git a/src/.ci/_package-homebrew_unix-any.sh b/src/.ci/_package-homebrew_unix-any.sh index f99caec..beeef14 100644 --- a/src/.ci/_package-homebrew_unix-any.sh +++ b/src/.ci/_package-homebrew_unix-any.sh @@ -21,6 +21,7 @@ if [ "$PROJECT_PATH_ROOT" = "" ]; then fi . "${LIBS_AUTOMATACI}/services/io/fs.sh" +. "${LIBS_AUTOMATACI}/services/io/strings.sh" . "${LIBS_AUTOMATACI}/services/i18n/translations.sh" @@ -56,17 +57,18 @@ PACKAGE_Assemble_HOMEBREW_Content() { ___dest="${_directory}/formula.rb" I18N_Create "$___dest" FS_Write_File "$___dest" "\ -class ${PROJECT_SKU_TITLECASE} < Formula +class $(STRINGS_To_Uppercase_First_Char "$PROJECT_SKU") < Formula desc \"${PROJECT_PITCH}\" homepage \"${PROJECT_CONTACT_WEBSITE}\" license \"${PROJECT_LICENSE}\" - url \"${PROJECT_HOMEBREW_SOURCE_URL}/${PROJECT_VERSION}/{{ TARGET_PACKAGE }}\" + url \"${PROJECT_HOMEBREW_SOURCE_URL}/{{ TARGET_PACKAGE }}\" sha256 \"{{ TARGET_SHASUM }}\" def install chmod 0755, \"bin/${PROJECT_SKU_TITLECASE}\" - bin.install \"bin/${PROJECT_SKU_TITLECASE}\" + libexec.install \"bin/${PROJECT_SKU_TITLECASE}\" + bin.install_symlink libexec/\"${PROJECT_SKU_TITLECASE}\" => \"${PROJECT_SKU_TITLECASE}\" end test do diff --git a/src/.ci/_package-homebrew_windows-any.ps1 b/src/.ci/_package-homebrew_windows-any.ps1 index bbd5206..676aeba 100644 --- a/src/.ci/_package-homebrew_windows-any.ps1 +++ b/src/.ci/_package-homebrew_windows-any.ps1 @@ -20,6 +20,7 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { } . "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" +. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" . "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" @@ -57,17 +58,18 @@ function PACKAGE-Assemble-HOMEBREW-Content { $___dest = "${_directory}\formula.rb" $null = I18N-Create "${___dest}" $___process = FS-Write-File "${___dest}" @" -class ${env:PROJECT_SKU_TITLECASE} < Formula +class $(STRINGS-To-Uppercase-First-Char "${env:PROJECT_SKU_TITLECASE}") < Formula desc "${env:PROJECT_PITCH}" homepage "${env:PROJECT_CONTACT_WEBSITE}" license "${env:PROJECT_LICENSE}" - url "${env:PROJECT_HOMEBREW_SOURCE_URL}/${env:PROJECT_VERSION}/{{ TARGET_PACKAGE }}" + url "${env:PROJECT_HOMEBREW_SOURCE_URL}/{{ TARGET_PACKAGE }}" sha256 "{{ TARGET_SHASUM }}" def install chmod 0755, "bin/${env:PROJECT_SKU_TITLECASE}" - bin.install "bin/${env:PROJECT_SKU_TITLECASE}" + libexec.install "bin/${env:PROJECT_SKU_TITLECASE}" + bin.install_symlink libexec/"${env:PROJECT_SKU_TITLECASE}" => "${env:PROJECT_SKU_TITLECASE}" end test do