mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
feat: templ_static_files_validator
super_build.bat script was removed because it became unnecessary after transitioning to a Docker-based build process which provides cross-platform build capability more efficiently (and Windows scripting sucks). Also added templ_static_files_validator.sh that validates existence of files linked in HTML within the specified directory. Can be useful when working on frontend to make sure static files will load properly.
This commit is contained in:
@@ -1,37 +0,0 @@
|
|||||||
@echo off
|
|
||||||
|
|
||||||
setlocal
|
|
||||||
|
|
||||||
set "GOARCH=amd64"
|
|
||||||
set "OUTPUT_DIR=./bin"
|
|
||||||
|
|
||||||
set "GO_FILE_PATH=./main/main.go"
|
|
||||||
set "PROGRAM_NAME=GohCMS"
|
|
||||||
|
|
||||||
REM Compile for Windows
|
|
||||||
set "GOOS=windows"
|
|
||||||
go build -o "%OUTPUT_DIR%\%PROGRAM_NAME%_windows.exe" "%GO_FILE_PATH%"
|
|
||||||
if %errorlevel% neq 0 (
|
|
||||||
echo Compilation for Windows failed.
|
|
||||||
exit /b %errorlevel%
|
|
||||||
)
|
|
||||||
|
|
||||||
REM Compile for Linux
|
|
||||||
set "GOOS=linux"
|
|
||||||
go build -o "%OUTPUT_DIR%\%PROGRAM_NAME%_linux" "%GO_FILE_PATH%"
|
|
||||||
if %errorlevel% neq 0 (
|
|
||||||
echo Compilation for Linux failed.
|
|
||||||
exit /b %errorlevel%
|
|
||||||
)
|
|
||||||
|
|
||||||
REM Compile for macOS
|
|
||||||
set "GOOS=darwin"
|
|
||||||
go build -o "%OUTPUT_DIR%\%PROGRAM_NAME%_darwin" "%GO_FILE_PATH%"
|
|
||||||
if %errorlevel% neq 0 (
|
|
||||||
echo Compilation for macOS failed.
|
|
||||||
exit /b %errorlevel%
|
|
||||||
)
|
|
||||||
|
|
||||||
echo Compilation successful for all platforms.
|
|
||||||
|
|
||||||
endlocal
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
find_html_files() {
|
||||||
|
local directory="$1"
|
||||||
|
find "$directory" -type f -name "*.html"
|
||||||
|
}
|
||||||
|
|
||||||
|
extract_referenced_files() {
|
||||||
|
local html_file="$1"
|
||||||
|
grep -oP '(?<=src="/static/|href="/static/)[^"]+' "$html_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
is_link() {
|
||||||
|
local path="$1"
|
||||||
|
[[ "$path" =~ ^https?://.* ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_referenced_files() {
|
||||||
|
local source_dir="$1"
|
||||||
|
local target_dir="$2"
|
||||||
|
|
||||||
|
local html_files
|
||||||
|
html_files=$(find_html_files "$source_dir")
|
||||||
|
|
||||||
|
for html_file in $html_files; do
|
||||||
|
local referenced_files
|
||||||
|
referenced_files=$(extract_referenced_files "$html_file")
|
||||||
|
|
||||||
|
for referenced_file in $referenced_files; do
|
||||||
|
referenced_file="${referenced_file#/}"
|
||||||
|
|
||||||
|
if is_link "$referenced_file"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
local full_referenced_path="$target_dir$referenced_file"
|
||||||
|
|
||||||
|
if [ ! -e "$full_referenced_path" ]; then
|
||||||
|
echo "Error: $full_referenced_path not found (referenced in $html_file)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
source_dir="./adapters/secondary/gateways/web/templates/"
|
||||||
|
target_dir="./api/static/"
|
||||||
|
|
||||||
|
validate_referenced_files "$source_dir" "$target_dir"
|
||||||
|
|
||||||
|
echo "All files referenced in HTML files are present in $target_dir"
|
||||||
Reference in New Issue
Block a user