Skip to content

Commit

Permalink
root: fixed homebrew Formula error issue
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
hollowaykeanho committed Apr 1, 2024
1 parent c213b17 commit 791cb12
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 6 deletions.
43 changes: 43 additions & 0 deletions automataCI/services/io/strings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
43 changes: 43 additions & 0 deletions automataCI/services/io/strings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 5 additions & 3 deletions src/.ci/_package-homebrew_unix-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/.ci/_package-homebrew_windows-any.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 791cb12

Please sign in to comment.