Reorganization

This commit is contained in:
2025-12-26 23:27:20 -06:00
parent ed06a43ea4
commit b2839c10a5
18 changed files with 1 additions and 1 deletions

View File

75
scripts/fix/paths.sh Normal file
View File

@@ -0,0 +1,75 @@
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Copyright (C) 2025 Moko Consulting <hello@mokoconsulting.tech>
#
# This file is part of a Moko Consulting project.
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License (./LICENSE.md).
# -----------------------------------------------------------------------------
# FILE INFORMATION
# DEFGROUP: MokoStandards
# INGROUP: Generic.Script
# REPO: https://github.com/mokoconsulting-tech/MokoStandards
# PATH: /scripts/fix_paths.sh
# VERSION: 03.05.00
# BRIEF: Replace Windows-style path separators with POSIX separators in text files.#
# Purpose:
# - Normalize path separators in text files to forward slashes (/).
# - Intended for CI validation and optional remediation workflows.
# - Skips binary files and version control metadata.
# - Preserves file contents aside from path separator normalization.
#
# Usage:
# ./scripts/fix_paths.sh
# =============================================================================
set -euo pipefail
ROOT_DIR="${1:-.}"
info() {
echo "INFO: $*"
}
warn() {
echo "WARN: $*" 1>&2
}
die() {
echo "ERROR: $*" 1>&2
exit 1
}
command -v find >/dev/null 2>&1 || die "find not available"
command -v sed >/dev/null 2>&1 || die "sed not available"
command -v file >/dev/null 2>&1 || die "file not available"
info "Scanning for text files under: $ROOT_DIR"
while IFS= read -r -d '' file; do
if file "$file" | grep -qi "text"; then
if grep -q '\\\\' "$file"; then
sed -i.bak 's#\\\\#/#g' "$file" && rm -f "$file.bak"
info "Normalized paths in $file"
fi
fi
done < <(
find "$ROOT_DIR" \
-type f \
-not -path "*/.git/*" \
-not -path "*/node_modules/*" \
-print0
)
info "Path normalization complete."

73
scripts/fix/tabs.sh Normal file
View File

@@ -0,0 +1,73 @@
#!/usr/bin/env bash
# ============================================================================
# Copyright (C) 2025 Moko Consulting <hello@mokoconsulting.tech>
#
# This file is part of a Moko Consulting project.
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# FILE INFORMATION
# DEFGROUP: MokoStandards
# INGROUP: GitHub.Actions.Utilities
# REPO: https://github.com/mokoconsulting-tech/MokoStandards
# PATH: /scripts/fix_tabs.sh
# VERSION: 03.05.00
# BRIEF: Utility script to replace tab characters with two spaces in YAML files.
# NOTE: Intended for local developer use. Not executed automatically in CI.
# ============================================================================
set -euo pipefail
log() {
printf '%s\n' "$*"
}
log "[fix_tabs] Scope: *.yml, *.yaml"
log "[fix_tabs] Action: replace tab characters with two spaces"
changed=0
# Determine file list
if command -v git >/dev/null 2>&1 && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
files=$(git ls-files '*.yml' '*.yaml' 2>/dev/null || true)
else
files=$(find . -type f \( -name '*.yml' -o -name '*.yaml' \) -print 2>/dev/null || true)
fi
if [ -z "${files}" ]; then
log "[fix_tabs] No YAML files found. Nothing to fix."
exit 0
fi
while IFS= read -r f; do
[ -n "$f" ] || continue
[ -f "$f" ] || continue
if LC_ALL=C grep -q $'\t' -- "$f"; then
log "[fix_tabs] Fixing tabs in: $f"
# Replace literal tab characters with exactly two spaces
sed -i 's/\t/ /g' "$f"
changed=1
else
log "[fix_tabs] Clean: $f"
fi
done <<< "${files}"
if [ "$changed" -eq 1 ]; then
log "[fix_tabs] Completed with modifications"
else
log "[fix_tabs] No changes required"
fi