From fdbeb0e9b124ee970e77b9d08050b6a557ec4e81 Mon Sep 17 00:00:00 2001 From: jekkos Date: Wed, 14 Oct 2026 09:22:56 +0200 Subject: [PATCH] refactor: move Windows build scripts into tools/build, drop CI4 migration scripts (#4729) Also clarify in build.ps1, build-steps.ps1 and build-package.ps1 that the '.\tools\Build\...' example is a repository-root command and that callers in other directories must provide a valid path to the scripts Remove the one-off CI3->CI4 migration tooling that is no longer needed: tools/ci4-lang-migration/ and tools/ci4-upgrade-language-interpolation/. Docker is kept at the repository root rather than under tools/, per review feedback. The Windows build scripts remain in tools/build/. Root-relative docker paths are restored in .gitignore, BUILD.md, INSTALL.md, gulpfile.js, and the build-release workflow. --------- Co-authored-by: objecttothis <17935339+objecttothis@users.noreply.github.com> --- .gitignore | 1 + BUILD.md | 2 +- docker/install-nginx.sh | 2 +- docker/uninstall.sh | 2 +- .../build/build-package.ps1 | 10 ++++++--- .../build/build-steps.ps1 | 10 ++++++--- build.ps1 => tools/build/build.ps1 | 10 ++++++--- tools/ci4-lang-migration/convert.php | 10 --------- tools/ci4-lang-migration/convert.sh | 18 ---------------- .../run_sed_scripts.sh | 21 ------------------- .../sed_Attributes.sh | 13 ------------ .../sed_Bootstrap_tables.sh | 14 ------------- .../sed_Common.sh | 15 ------------- .../sed_Giftcards.sh | 17 --------------- .../sed_Items.sh | 18 ---------------- .../sed_Login.sh | 15 ------------- .../sed_Sales.sh | 18 ---------------- .../sed_Taxes.sh | 13 ------------ .../sed_sv_Common.sh | 6 ------ 19 files changed, 25 insertions(+), 190 deletions(-) rename build-package.ps1 => tools/build/build-package.ps1 (89%) rename build-steps.ps1 => tools/build/build-steps.ps1 (91%) rename build.ps1 => tools/build/build.ps1 (79%) delete mode 100644 tools/ci4-lang-migration/convert.php delete mode 100755 tools/ci4-lang-migration/convert.sh delete mode 100755 tools/ci4-upgrade-language-interpolation/run_sed_scripts.sh delete mode 100755 tools/ci4-upgrade-language-interpolation/sed_Attributes.sh delete mode 100755 tools/ci4-upgrade-language-interpolation/sed_Bootstrap_tables.sh delete mode 100755 tools/ci4-upgrade-language-interpolation/sed_Common.sh delete mode 100755 tools/ci4-upgrade-language-interpolation/sed_Giftcards.sh delete mode 100755 tools/ci4-upgrade-language-interpolation/sed_Items.sh delete mode 100755 tools/ci4-upgrade-language-interpolation/sed_Login.sh delete mode 100755 tools/ci4-upgrade-language-interpolation/sed_Sales.sh delete mode 100755 tools/ci4-upgrade-language-interpolation/sed_Taxes.sh delete mode 100755 tools/ci4-upgrade-language-interpolation/sed_sv_Common.sh diff --git a/.gitignore b/.gitignore index 6d066cb9e..f788b02a0 100644 --- a/.gitignore +++ b/.gitignore @@ -57,6 +57,7 @@ $RECYCLE.BIN/ # Other build/ +!tools/build/ generate_languages.php dist docs diff --git a/BUILD.md b/BUILD.md index ee7f04cc2..95c71c46b 100644 --- a/BUILD.md +++ b/BUILD.md @@ -42,7 +42,7 @@ Using an `.env` file is a convenient approach to store OSPOS configuration. I've added the following Powershell scripts to make my life a bit easier, which I share with you. -* `build.ps1` - Which runs the build but also restores the .env from a backup I make of it in a specifically placed folder. I place a copy of the configured .env file in a folder that has the following path from the working folder: `../env//.env` +* `tools/build/build.ps1` - Which runs the build but also restores the .env from a backup I make of it in a specifically placed folder. I place a copy of the configured .env file in a folder that has the following path from the working folder: `../env//.env` ### Containerized setup Development using docker has the advantage that all the application's dependencies are contained within the docker environment. During development we want to have a live version of the code in the container when we edit it. This is accomplished by mounting the application folder within the /app of the docker container. diff --git a/docker/install-nginx.sh b/docker/install-nginx.sh index 3eaa4a291..5f7e24d7d 100644 --- a/docker/install-nginx.sh +++ b/docker/install-nginx.sh @@ -1,6 +1,6 @@ #!/bin/bash -cd docker +cd "$(dirname "$0")" # load local environment variables if [ ! -e ".env" ]; then diff --git a/docker/uninstall.sh b/docker/uninstall.sh index 920afcdfb..1a796c532 100644 --- a/docker/uninstall.sh +++ b/docker/uninstall.sh @@ -1,6 +1,6 @@ #!/bin/bash -cd docker +cd "$(dirname "$0")" . ./.env diff --git a/build-package.ps1 b/tools/build/build-package.ps1 similarity index 89% rename from build-package.ps1 rename to tools/build/build-package.ps1 index f1d0c9e61..b0753ef1b 100644 --- a/build-package.ps1 +++ b/tools/build/build-package.ps1 @@ -1,8 +1,9 @@ # ------------------------------------------------------ # Run this Powershell script to "build" OSPOS. -# Execute this script from a terminal starting -# with the project root as the working directory. -# Use ".\build.ps1" +# The script moves to the repository root itself, so it can +# be invoked from any working directory. +# Use ".\tools\build\build-package.ps1" from the repository root (if you are in +# another directory, provide a valid path to this script) # The leading ".\" tells Powershell that you trust it. # ------------------------------------------------------ # Tested with: @@ -11,6 +12,9 @@ # npm version 9.4.2 # ------------------------------------------------------ +# Run from the repository root (two levels up from tools/build/) +Set-Location -Path (Split-Path -Parent (Split-Path -Parent $PSScriptRoot)) + Write-Output "=============================================================================" Write-Output "Before continuing, delete the package-lock.json and clear the dependencies" Write-Output "from package.json" diff --git a/build-steps.ps1 b/tools/build/build-steps.ps1 similarity index 91% rename from build-steps.ps1 rename to tools/build/build-steps.ps1 index 05fa37a9d..8b4c753a1 100644 --- a/build-steps.ps1 +++ b/tools/build/build-steps.ps1 @@ -1,11 +1,15 @@ # ---------------------------------------------------------------- # Run this Powershell script to "build" OSPOS (one step at a time). -# Execute this script from a terminal starting -# with the project root as the working directory. -# Use ".\build-steps.ps1" +# The script moves to the repository root itself, so it can be +# invoked from any working directory. +# Use ".\tools\build\build-steps.ps1" from the repository root (if you are in +# another directory, provide a valid path to this script) # The leading ".\" tells Powershell that you trust it. # ---------------------------------------------------------------- +# Run from the repository root (two levels up from tools/build/) +Set-Location -Path (Split-Path -Parent (Split-Path -Parent $PSScriptRoot)) + Write-Output "=============================================================================" Write-Output "1. Run Composer Install and npm install" Write-Output "=============================================================================" diff --git a/build.ps1 b/tools/build/build.ps1 similarity index 79% rename from build.ps1 rename to tools/build/build.ps1 index 3cbbafa17..a0793af17 100644 --- a/build.ps1 +++ b/tools/build/build.ps1 @@ -1,11 +1,15 @@ # ------------------------------------------------------ # Run this Powershell script to "build" OSPOS. -# Execute this script from a terminal starting -# with the project root as the working directory. -# Use ".\build.ps1" +# The script moves to the repository root itself, so it can +# be invoked from any working directory. +# Use ".\tools\build\build.ps1" from the repository root (if you are in +# another directory, provide a valid path to this script) # The leading ".\" tells Powershell that you trust it. # ------------------------------------------------------ +# Run from the repository root (two levels up from tools/build/) +Set-Location -Path (Split-Path -Parent (Split-Path -Parent $PSScriptRoot)) + Write-Output "=============================================================================" Write-Output "Run Composer Install" Write-Output "=============================================================================" diff --git a/tools/ci4-lang-migration/convert.php b/tools/ci4-lang-migration/convert.php deleted file mode 100644 index d7ac8aa91..000000000 --- a/tools/ci4-lang-migration/convert.php +++ /dev/null @@ -1,10 +0,0 @@ -$value) { - echo "\t\"$key\" => \"".addcslashes($value, '"')."\",\n"; -} -echo "];"; diff --git a/tools/ci4-lang-migration/convert.sh b/tools/ci4-lang-migration/convert.sh deleted file mode 100755 index 6eb10f244..000000000 --- a/tools/ci4-lang-migration/convert.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -projectdir=$(pwd)/../../ -git checkout master $projectdir/application/language -for file in $projectdir/application/language/**/*.php; do - f=$(basename $file) - name=${f^} - output=$(dirname $file)/${name%_lang.php}.php - output=${output/application/app} - output=${output/language/Language} - path=${file/$projectdir\//} - docker run -v "$projectdir:/root" php:cli-alpine -c php /root/tools/ci4-lang-migration/convert.php /root/$path > $output; - prefix=$(basename ${output,,} .php); - [ "$prefix" = "bootstrap_tables" ] && prefix="tables" - sed -i "s/\(\s*\)\"${prefix}_/\1\"/g" $output -done -rm -rf "$projectdir/application" -git add $projectdir/application/language diff --git a/tools/ci4-upgrade-language-interpolation/run_sed_scripts.sh b/tools/ci4-upgrade-language-interpolation/run_sed_scripts.sh deleted file mode 100755 index 630ffd3ae..000000000 --- a/tools/ci4-upgrade-language-interpolation/run_sed_scripts.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/bash -#This Linux bash script is part of OSPOS CI4 Upgrade -#Developed and tested on Fedora 38 - -echo -n "Counting ..." -BASEURL="../../" -DONE=`find ${BASEURL}app/Language -name "*.php" -exec grep -oP "{[0-9]}" {} \; | wc -l` -TODO=`find ${BASEURL}app/Language -name "*.php" -exec grep -oP "%[0-9]|٪[0-9]|[0-9]٪|[0-9]%|% [0-9]|٪ [0-9]|{[a-z].*?}" {} \; | wc -l` -echo " $DONE placeholders are converted and $TODO yet to do" -FILES="sed_*.sh" -for f in $FILES -do - echo -n "Processing $f file..." - bash "$f" "$BASEURL" - echo "completed." -done -echo -n "Counting ..." -COMPLETE=`find ${BASEURL}app/Language -name "*.php" -exec grep -oP "{[0-9]}" {} \; | wc -l` -MISSED=`find ${BASEURL}app/Language -name "*.php" -exec grep -oP "%[0-9]|٪[0-9]|[0-9]٪|[0-9]%|% [0-9]|٪ [0-9]|{[a-z].*?}" {} \; | wc -l` -echo " $COMPLETE placeholders are converted and $MISSED were missed" -echo "All done" diff --git a/tools/ci4-upgrade-language-interpolation/sed_Attributes.sh b/tools/ci4-upgrade-language-interpolation/sed_Attributes.sh deleted file mode 100755 index 1dd02732f..000000000 --- a/tools/ci4-upgrade-language-interpolation/sed_Attributes.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/bash -#This Linux bash script is part of OSPOS CI4 Upgrade -#Developed and tested on Fedora 38 -#Converts CI3 %x parameters into CI4 {x} parameters -#Multiple parameters must be processed individually to ensure -#correct handling of parameters in different positions depending -#upon whether the language is L to R or R to L -#Revereses changes previously made to files in en-US language. - -echo -n "fixing en-US..." -find ${1}app/Language -type f -name Attributes.php -exec sed -i -E -e 's/("definition_error_adding_updating")(.*?)(\{definition_name\})(.*?)/\1\2{0}\4/;' {} \; -echo -n "fixing others..." -find ${1}app/Language -type f -name Attributes.php -exec sed -i -E -e 's/("definition_error_adding_updating")(.*?)(%1|٪1|1٪|1%|% 1|٪ 1)(.*)/\1\2{0}\4/;' {} \; diff --git a/tools/ci4-upgrade-language-interpolation/sed_Bootstrap_tables.sh b/tools/ci4-upgrade-language-interpolation/sed_Bootstrap_tables.sh deleted file mode 100755 index 8757e4b3d..000000000 --- a/tools/ci4-upgrade-language-interpolation/sed_Bootstrap_tables.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/bash -#This Linux bash script is part of OSPOS CI4 Upgrade -#Developed and tested on Fedora 38 -#Converts CI3 %x parameters into CI4 {name} parameters -#Multiple parameters must be processed individually to ensure -#correct handling of parameters in different positions depending -#upon whether the language is L to R or R to L -#Revereses changes previously made to files in en-US language. - -echo -n "fixing en-US..." -find ${1}app/Language -type f -name Bootstrap_tables.php -exec sed -i -E -e 's/("tables_page_from_to")(.*?)(\{pageFrom\})(.*)/\1\2{0}\4/;' {} \; -find ${1}app/Language -type f -name Bootstrap_tables.php -exec sed -i -E -e 's/("tables_page_from_to")(.*?)(\{pageTo\})(.*)/\1\2{1}\4/;' {} \; -find ${1}app/Language -type f -name Bootstrap_tables.php -exec sed -i -E -e 's/("tables_page_from_to")(.*?)(\{totalRows\})(.*)/\1\2{2}\4/;' {} \; -find ${1}app/Language -type f -name Bootstrap_tables.php -exec sed -i -E -e 's/("tables_rows_per_page")(.*?)(\{pageNumber\})(.*)/\1\2{0}\4/;' {} \; diff --git a/tools/ci4-upgrade-language-interpolation/sed_Common.sh b/tools/ci4-upgrade-language-interpolation/sed_Common.sh deleted file mode 100755 index 9c858f6f8..000000000 --- a/tools/ci4-upgrade-language-interpolation/sed_Common.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/bash -#This Linux bash script is part of OSPOS CI4 Upgrade -#Developed and tested on Fedora 38 -#Converts CI3 %x parameters into CI4 {x} parameters -#Multiple parameters must be processed individually to ensure -#correct handling of parameters in different positions depending -#upon whether the language is L to R or R to L -#Revereses changes previously made to files in en-US language. - -echo -n "fixing en-US..." -find ${1}app/Language -type f -name Common.php -exec sed -i -E -e 's/("copyrights")(.*?)(\{current_year\})(.*)/\1\2{0}\4/;' {} \; -find ${1}app/Language -type f -name Common.php -exec sed -i -E -e 's/("migration_needed")(.*?)(\{version\})(.*)/\1\2{0}\4/;' {} \; -echo -n "fixing others..." -find ${1}app/Language -type f -name Common.php -exec sed -i -E -e 's/("copyrights")(.*?)(%1|٪1|1٪|1%|% 1|٪ 1)(.*)/\1\2{0}\4/;' {} \; -find ${1}app/Language -type f -name Common.php -exec sed -i -E -e 's/("migration_needed")(.*?)(%1|٪1|1٪|1%|% 1|٪ 1)(.*)/\1\2{0}\4/;' {} \; diff --git a/tools/ci4-upgrade-language-interpolation/sed_Giftcards.sh b/tools/ci4-upgrade-language-interpolation/sed_Giftcards.sh deleted file mode 100755 index d3b750985..000000000 --- a/tools/ci4-upgrade-language-interpolation/sed_Giftcards.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/bash -#This Linux bash script is part of OSPOS CI4 Upgrade -#Developed and tested on Fedora 38 -#Converts CI3 %x parameters into CI4 {x} parameters -#Multiple parameters must be processed individually to ensure -#correct handling of parameters in different positions depending -#upon whether the language is L to R or R to L -#Revereses changes previously made to files in en-US language. - -echo -n "fixing en-US..." -find ${1}app/Language -type f -name Giftcards.php -exec sed -i -E -e 's/("cannot_use")(.*?)(\{giftcard_num\})(.*)/\1\2{0}\4/;' {} \; -find ${1}app/Language -type f -name Giftcards.php -exec sed -i -E -e 's/("remaining_balance")(.*?)(\{giftcard_num\})(.*)/\1\2{0}\4/;' {} \; -find ${1}app/Language -type f -name Giftcards.php -exec sed -i -E -e 's/("remaining_balance")(.*?)(\{balance\})(.*)/\1\2{1}\4/;' {} \; -echo -n "fixing others..." -find ${1}app/Language -type f -name Giftcards.php -exec sed -i -E -e 's/("cannot_use")(.*?)(%1|٪1|1٪|1%|% 1|٪ 1)(.*)/\1\2{0}\4/;' {} \; -find ${1}app/Language -type f -name Giftcards.php -exec sed -i -E -e 's/("remaining_balance")(.*?)(%1|٪1|1٪|1%|% 1|٪ 1)(.*)/\1\2{0\}\4/;' {} \; -find ${1}app/Language -type f -name Giftcards.php -exec sed -i -E -e 's/("remaining_balance")(.*?)(%2|٪2|2٪|2%|% 2|٪ 2)(.*)/\1\2{1}\4/;' {} \; diff --git a/tools/ci4-upgrade-language-interpolation/sed_Items.sh b/tools/ci4-upgrade-language-interpolation/sed_Items.sh deleted file mode 100755 index 49600f8c4..000000000 --- a/tools/ci4-upgrade-language-interpolation/sed_Items.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/bash -#This Linux bash script is part of OSPOS CI4 Upgrade -#Developed and tested on Fedora 38 -#Converts CI3 %x parameters into CI4 {x} parameters -#Multiple parameters must be processed individually to ensure -#correct handling of parameters in different positions depending -#upon whether the language is L to R or R to L -#This script handles an R to L typo which had the parameters entered as -#1% and 2% instead of %1 and %2 in two languages. -#The %1 rendered on screen as %1, but copied and pasted as 1% which was very confusing -#Revereses changes previously made to files in en-US language. - -echo -n "fixing en-US..." -find ${1}app/Language -type f -name Items.php -exec sed -i -E -e 's/("csv_import_partially_failed")(.*?)(\{count\})(.*)/\1\2{0}\4/;' {} \; -find ${1}app/Language -type f -name Items.php -exec sed -i -E -e 's/("csv_import_partially_failed")(.*?)(\{failures\})(.*)/\1\2{1}\4/;' {} \; -echo -n "fixing others..." -find ${1}app/Language -type f -name Items.php -exec sed -i -E -e 's/("csv_import_partially_failed")(.*?)(%1|٪1|1٪|1%|% 1|٪ 1)(.*)/\1\2{0}\4/;' {} \; -find ${1}app/Language -type f -name Items.php -exec sed -i -E -e 's/("csv_import_partially_failed")(.*?)(%2|٪2|2٪|2%|% 2|٪ 2)(.*)/\1\2{1}\4/;' {} \; diff --git a/tools/ci4-upgrade-language-interpolation/sed_Login.sh b/tools/ci4-upgrade-language-interpolation/sed_Login.sh deleted file mode 100755 index 81b61bea3..000000000 --- a/tools/ci4-upgrade-language-interpolation/sed_Login.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/bash -#This Linux bash script is part of OSPOS CI4 Upgrade -#Developed and tested on Fedora 38 -#Converts CI3 %x parameters into CI4 {x} parameters -#Multiple parameters must be processed individually to ensure -#correct handling of parameters in different positions depending -#upon whether the language is L to R or R to L -#Revereses changes previously made to files in en-US language. - -echo -n "fixing en-US..." -find ${1}app/Language -type f -name Login.php -exec sed -i -E -e 's/("migration_needed")(.*?)(\{version\})(.*)/\1\2{0}\4/;' {} \; -find ${1}app/Language -type f -name Login.php -exec sed -i -E -e 's/("welcome")(.*?)(\{install_name\})(.*)/\1\2{0}\4/;' {} \; -echo -n "fixing others..." -find ${1}app/Language -type f -name Login.php -exec sed -i -E -e 's/("migration_needed")(.*?)(%1|٪1|1٪|1%|% 1|٪ 1)(.*)/\1\2{0}\4/;' {} \; -find ${1}app/Language -type f -name Login.php -exec sed -i -E -e 's/("welcome")(.*?)(%1|٪1|1٪|1%|% 1|٪ 1)(.*)/\1\2{0}\4/;' {} \; diff --git a/tools/ci4-upgrade-language-interpolation/sed_Sales.sh b/tools/ci4-upgrade-language-interpolation/sed_Sales.sh deleted file mode 100755 index ebbb655cf..000000000 --- a/tools/ci4-upgrade-language-interpolation/sed_Sales.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/bash -#This Linux bash script is part of OSPOS CI4 Upgrade -#Developed and tested on Fedora 38 -#Converts CI3 %x parameters into CI4 {x} parameters -#Multiple parameters must be processed individually to ensure -#correct handling of parameters in different positions depending -#upon whether the language is L to R or R to L -#This script handles an R to L typo which had the parameters entered as -#1% instead of %1 in two languages. -#The %1 rendered on screen as %1, but copied and pasted as 1% which was very confusing -#Revereses changes previously made to files in en-US language. - -echo -n "fixing en-US..." -find ${1}app/Language -type f -name Sales.php -exec sed -i -E -e 's/("invoice_number_duplicate")(.*?)(\{invoice_number\})(.*)/\1\2{0}\4/;' {} \; -find ${1}app/Language -type f -name Sales.php -exec sed -i -E -e 's/("quantity_of_items")(.*?)(\{quantity\})(.*)/\1\2{0}\4/;' {} \; -echo -n "fixing others..." -find ${1}app/Language -type f -name Sales.php -exec sed -i -E -e 's/("invoice_number_duplicate")(.*?)(%1|٪1|1٪|1%|% 1|٪ 1)(.*)/\1\2{0}\4/;' {} \; -find ${1}app/Language -type f -name Sales.php -exec sed -i -E -e 's/("quantity_of_items")(.*?)(%1|٪1|1٪|1%|% 1|٪ 1)(.*)/\1\2{0}\4/;' {} \; diff --git a/tools/ci4-upgrade-language-interpolation/sed_Taxes.sh b/tools/ci4-upgrade-language-interpolation/sed_Taxes.sh deleted file mode 100755 index 4a163506d..000000000 --- a/tools/ci4-upgrade-language-interpolation/sed_Taxes.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/bash -#This Linux bash script is part of OSPOS CI4 Upgrade -#Developed and tested on Fedora 38 -#Converts CI3 %x parameters into CI4 {x} parameters -#Multiple parameters must be processed individually to ensure -#correct handling of parameters in different positions depending -#upon whether the language is L to R or R to L -#Revereses changes previously made to files in en-US language. - -echo -n "fixing en-US..." -find ${1}app/Language -type f -name Taxes.php -exec sed -i -E -e 's/("tax_group_not_unique")(.*?)(\{group\})(.*)/\1\2{0}\4/;' {} \; -echo -n "fixing others..." -find ${1}app/Language -type f -name Taxes.php -exec sed -i -E -e 's/("tax_group_not_unique")(.*?)(%1|٪1|1٪|1%|% 1|٪ 1)(.*)/\1\2{0}\4/;' {} \; diff --git a/tools/ci4-upgrade-language-interpolation/sed_sv_Common.sh b/tools/ci4-upgrade-language-interpolation/sed_sv_Common.sh deleted file mode 100755 index ec807f2c3..000000000 --- a/tools/ci4-upgrade-language-interpolation/sed_sv_Common.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/bash -#This Linux bash script is part of OSPOS CI4 Upgrade -#Developed and tested on Fedora 38 -#This script fixes a typo in the target file: {} was used instead of []. - -find ${1}app/Language -type f -name Common.php -exec sed -i -E -e 's/("none_selected_text")(.*?)(\{Inget valt\})(.*)/\1\2[Inget valt]\4/g' {} \;