From c8bf68fa2dbfb15f29c7a4cea333f8f41539336e Mon Sep 17 00:00:00 2001 From: Herwin Date: Thu, 18 Apr 2024 18:00:28 +0200 Subject: [PATCH] Moved build scripts into "scripts/", Updated readme Update .gitignore, compile-clean.cmd, and 38 more files... --- .gitignore | 2 ++ readme.md | 6 ++--- .../compile-clean.cmd | 4 ++-- .../compile-content.cmd | 4 ++-- .../compile-js-external.cmd | 6 ++--- .../compile-js-site.cmd | 2 +- compile-sass.cmd => scripts/compile-sass.cmd | 7 +----- .../compile-strings.cmd | 3 +-- compile.bat => scripts/compile.cmd | 0 .../compile_strings.py | 0 compress.bat => scripts/compress.cmd | 19 ++++++++++----- .../content_index_maker.py | 0 .../content_item_converter.py | 0 .../legacy/compile-js-decimal.cmd | 0 .../legacy/compile-tools.cmd | 0 .../legacy/fix-import-path.js | 0 .../legacy/minify-php.bat | 0 .../legacy/php-relinker.js | 0 scripts/nodejs-setup.cmd | 23 +++++++++++++++++++ package.json => scripts/package.json | 0 scripts/python-setup.cmd | 22 ++++++++++++++++++ requirements.txt => scripts/requirements.txt | 0 22 files changed, 73 insertions(+), 25 deletions(-) rename compile-clean.cmd => scripts/compile-clean.cmd (83%) rename compile-content.cmd => scripts/compile-content.cmd (68%) rename compile-js-external.cmd => scripts/compile-js-external.cmd (90%) rename compile-js-site.cmd => scripts/compile-js-site.cmd (96%) rename compile-sass.cmd => scripts/compile-sass.cmd (73%) rename compile-strings.cmd => scripts/compile-strings.cmd (63%) rename compile.bat => scripts/compile.cmd (100%) rename compile_strings.py => scripts/compile_strings.py (100%) rename compress.bat => scripts/compress.cmd (87%) rename content_index_maker.py => scripts/content_index_maker.py (100%) rename content_item_converter.py => scripts/content_item_converter.py (100%) rename compile-js-decimal.cmd => scripts/legacy/compile-js-decimal.cmd (100%) rename compile-tools.cmd => scripts/legacy/compile-tools.cmd (100%) rename fix-import-path.js => scripts/legacy/fix-import-path.js (100%) rename minify-php.bat => scripts/legacy/minify-php.bat (100%) rename php-relinker.js => scripts/legacy/php-relinker.js (100%) create mode 100644 scripts/nodejs-setup.cmd rename package.json => scripts/package.json (100%) create mode 100644 scripts/python-setup.cmd rename requirements.txt => scripts/requirements.txt (100%) diff --git a/.gitignore b/.gitignore index 5953431..cf50c04 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ # Node.JS node_modules/ package-lock.json +scripts/node_modules/ +scripts/package-lock.json # Static resources resources/DecimalJs/ diff --git a/readme.md b/readme.md index 8c3bff2..0d096f5 100644 --- a/readme.md +++ b/readme.md @@ -37,7 +37,7 @@ in a single file that can be used by the [L10N PHP utility](commons/langs.php). It works by listing all subfolders in a location as language keys and assigning the content of each `.json` file to that language key. -See [compile_strings.py](compile_strings.py) and [compile.bat](compile.bat). +See [compile_strings.py](scripts/compile_strings.py) and [compile.cmd](scripts/compile.cmd). ### TypeScript Perineal Care This utility simply fixes the munted import paths that Typescript produces by replacing a given import name by @@ -46,7 +46,7 @@ another one with the proper extensions. While not perfect, it works.
That's still better than Typescript could ever do with a maintainable *tsconfig* file... -See [fix-import-path.js](fix-import-path.js) and [compile.bat](compile.bat). +See [fix-import-path.js](scripts/legacy/fix-import-path.js) and [compile.bat](scripts/compile.cmd). ### Minified PHP Import Fixer Unfinished utility that will be used to change import paths in minified PHP files. @@ -54,7 +54,7 @@ Unfinished utility that will be used to change import paths in minified PHP file The main goal here is to fix some weird and unfixable text-spacing issues with line returns in the generated HTML document. -See [php-relinker.js](php-relinker.js). +See [php-relinker.js](scripts/legacy/php-relinker.js). ## Requirements diff --git a/compile-clean.cmd b/scripts/compile-clean.cmd similarity index 83% rename from compile-clean.cmd rename to scripts/compile-clean.cmd index fb21992..b380f98 100644 --- a/compile-clean.cmd +++ b/scripts/compile-clean.cmd @@ -1,8 +1,8 @@ @echo off setlocal enabledelayedexpansion -:: Going into the script's directory -cd /D "%~dp0" +:: Going into the project's root directory +cd /D "%~dp0\..\" :clean diff --git a/compile-content.cmd b/scripts/compile-content.cmd similarity index 68% rename from compile-content.cmd rename to scripts/compile-content.cmd index 5e26393..2d0831a 100644 --- a/compile-content.cmd +++ b/scripts/compile-content.cmd @@ -12,11 +12,11 @@ echo ------------------------------ :content-compile-index echo Compiling index files... -python content_index_maker.py ./content/raw_index/ ./content/index.json +python content_index_maker.py ../content/raw_index/ ../content/index.json :content-compile-items echo Compiling content item files... -python content_item_converter.py ./content/raw_items/ ./content/items/ +python content_item_converter.py ../content/raw_items/ ../content/items/ :content-end diff --git a/compile-js-external.cmd b/scripts/compile-js-external.cmd similarity index 90% rename from compile-js-external.cmd rename to scripts/compile-js-external.cmd index 24b3fd2..2b216df 100644 --- a/compile-js-external.cmd +++ b/scripts/compile-js-external.cmd @@ -13,10 +13,10 @@ echo --------------------------- :js-external-decimaljs-minify echo Minifying Decimal.JS pushd %CD% -cd %~dp0\resources\DecimalJs\10.4.3\ +cd %~dp0\..\resources\DecimalJs\10.4.3\ echo ^> resources\DecimalJs\10.4.3\decimal.mjs call "%~dp0node_modules\.bin\terser" decimal.mjs -c -m --toplevel -o decimal.min.mjs -cd %~dp0\resources\DecimalJsLight\2.5.1\ +cd %~dp0\..\resources\DecimalJsLight\2.5.1\ echo ^> resources\DecimalJsLight\2.5.1\decimal.mjs call "%~dp0node_modules\.bin\terser" decimal.mjs -c -m --toplevel -o decimal.min.mjs popd @@ -24,7 +24,7 @@ popd :js-external-highlightjs echo Handling HighlightJS pushd %CD% -cd %~dp0\resources\HighlightJS\ +cd %~dp0\..\resources\HighlightJS\ echo ^> Clearing old files del /Q /S /F highlight.js 2> nul 1> nul del /Q /S /F highlight.min.js 2> nul 1> nul diff --git a/compile-js-site.cmd b/scripts/compile-js-site.cmd similarity index 96% rename from compile-js-site.cmd rename to scripts/compile-js-site.cmd index 6719b7a..299e290 100644 --- a/compile-js-site.cmd +++ b/scripts/compile-js-site.cmd @@ -13,7 +13,7 @@ echo -------------------------------- :js-nibblepoker-minify echo Minifying nibblepoker.js pushd %CD% -cd %~dp0\resources\NibblePoker\js\ +cd %~dp0\..\resources\NibblePoker\js\ echo ^> resources\NibblePoker\js\nibblepoker.js call "%~dp0node_modules\.bin\terser" nibblepoker.js -c -m -o nibblepoker.min.js echo ^> resources\NibblePoker\js\nibblepoker-code.js diff --git a/compile-sass.cmd b/scripts/compile-sass.cmd similarity index 73% rename from compile-sass.cmd rename to scripts/compile-sass.cmd index 44a89e1..b74bce6 100644 --- a/compile-sass.cmd +++ b/scripts/compile-sass.cmd @@ -13,7 +13,7 @@ echo ----------------------- :sass-compile echo Compiling SASS files... pushd %CD% -cd %~dp0\resources\NibblePoker\scss\ +cd %~dp0\..\resources\NibblePoker\scss\ call "%~dp0node_modules\.bin\sass" nibblepoker.scss:../css/nibblepoker.css -q call "%~dp0node_modules\.bin\sass" nibblepoker.scss:../css/nibblepoker.min.css -q --style compressed call "%~dp0node_modules\.bin\sass" snowflakes.scss:../css/snowflakes.css -q @@ -21,11 +21,6 @@ call "%~dp0node_modules\.bin\sass" snowflakes.scss:../css/snowflakes.min.css -q call "%~dp0node_modules\.bin\sass" debugger.scss:../css/debugger.css -q call "%~dp0node_modules\.bin\sass" debugger.scss:../css/debugger.min.css -q --style compressed popd -pushd %CD% -cd %~dp0\wiki\scss\ -call "%~dp0node_modules\.bin\sass" nibblepoker-wiki.scss:../css/nibblepoker-wiki.css -q -call "%~dp0node_modules\.bin\sass" nibblepoker-wiki.scss:../css/nibblepoker-wiki.min.css -q --style compressed -popd :sass-end diff --git a/compile-strings.cmd b/scripts/compile-strings.cmd similarity index 63% rename from compile-strings.cmd rename to scripts/compile-strings.cmd index 860ba40..61a7e33 100644 --- a/compile-strings.cmd +++ b/scripts/compile-strings.cmd @@ -12,8 +12,7 @@ echo ---------------------- :lang-compile echo Compiling lang files... -python compile_strings.py ./commons/strings/ ./commons/strings.json -python compile_strings.py ./wiki/strings/ ./wiki/strings.json +python compile_strings.py ../commons/strings/ ../commons/strings.json :lang-end diff --git a/compile.bat b/scripts/compile.cmd similarity index 100% rename from compile.bat rename to scripts/compile.cmd diff --git a/compile_strings.py b/scripts/compile_strings.py similarity index 100% rename from compile_strings.py rename to scripts/compile_strings.py diff --git a/compress.bat b/scripts/compress.cmd similarity index 87% rename from compress.bat rename to scripts/compress.cmd index eb77f87..5f9948e 100644 --- a/compress.bat +++ b/scripts/compress.cmd @@ -1,12 +1,13 @@ @echo off setlocal enabledelayedexpansion -:: Going into the script's directory -cd /D "%~dp0" - - :compile -call "%~dp0compile.bat" +call "%~dp0compile.cmd" + +:compile-path-fix +:: Going into the project's root directory +cd /D "%~dp0\..\" + :compile-end @@ -25,7 +26,10 @@ echo ^> %NP_ZIP_NAME% echo Preparing environment variable... set NP_ZIP_CONTENT= set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "about/" -set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "commons/*.php" "commons/strings.json" "commons/DOM/" "commons/content/" +set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "commons/*.php" +set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "commons/strings.json" +set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "commons/DOM/" +set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "commons/content/" set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "contact/" set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "content/*.*" set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "content/items/" @@ -64,6 +68,9 @@ set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "resources/NibblePoker/js/*.js" set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "resources/NibblePoker/sounds/" set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "resources/Quantum/" set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "resources/SplideJs/dist/" +set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "tools/*" +set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "tools/items/*.json" +set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "tools/items/*/*" set NP_ZIP_CONTENT=%NP_ZIP_CONTENT% "./.htaccess" "./*.php" "./favicon.*" "./.env" ::echo ^>%NP_ZIP_CONTENT% diff --git a/content_index_maker.py b/scripts/content_index_maker.py similarity index 100% rename from content_index_maker.py rename to scripts/content_index_maker.py diff --git a/content_item_converter.py b/scripts/content_item_converter.py similarity index 100% rename from content_item_converter.py rename to scripts/content_item_converter.py diff --git a/compile-js-decimal.cmd b/scripts/legacy/compile-js-decimal.cmd similarity index 100% rename from compile-js-decimal.cmd rename to scripts/legacy/compile-js-decimal.cmd diff --git a/compile-tools.cmd b/scripts/legacy/compile-tools.cmd similarity index 100% rename from compile-tools.cmd rename to scripts/legacy/compile-tools.cmd diff --git a/fix-import-path.js b/scripts/legacy/fix-import-path.js similarity index 100% rename from fix-import-path.js rename to scripts/legacy/fix-import-path.js diff --git a/minify-php.bat b/scripts/legacy/minify-php.bat similarity index 100% rename from minify-php.bat rename to scripts/legacy/minify-php.bat diff --git a/php-relinker.js b/scripts/legacy/php-relinker.js similarity index 100% rename from php-relinker.js rename to scripts/legacy/php-relinker.js diff --git a/scripts/nodejs-setup.cmd b/scripts/nodejs-setup.cmd new file mode 100644 index 0000000..2dbecaa --- /dev/null +++ b/scripts/nodejs-setup.cmd @@ -0,0 +1,23 @@ +@echo off +setlocal enabledelayedexpansion + +:: Going into the script's directory +cd /D "%~dp0" + + +:nodejs +echo. +echo Setting up NodeJS... +echo -------------------- + +:nodejs-install +echo Installing packages... +pushd %CD% +call npm install +popd + + +:nodejs-end + + +:end diff --git a/package.json b/scripts/package.json similarity index 100% rename from package.json rename to scripts/package.json diff --git a/scripts/python-setup.cmd b/scripts/python-setup.cmd new file mode 100644 index 0000000..f5d5f23 --- /dev/null +++ b/scripts/python-setup.cmd @@ -0,0 +1,22 @@ +@echo off +setlocal enabledelayedexpansion + +:: Going into the script's directory +cd /D "%~dp0" + + +:python +echo. +echo Setting up Python... +echo -------------------- + +:python-install +echo Installing packages... +pushd %CD% +call pip install -r requirements.txt +popd + +:python-end + + +:end diff --git a/requirements.txt b/scripts/requirements.txt similarity index 100% rename from requirements.txt rename to scripts/requirements.txt