From 07e0273dbc5ef2f5bb6e4ac770c07bcbb0aa69b0 Mon Sep 17 00:00:00 2001 From: defiQUG Date: Tue, 7 Apr 2026 22:10:10 -0700 Subject: [PATCH] chore(submodules): record the-order + smom artifact hygiene; add surgical clean helper - Bump the-order to drop tracked tsc output under packages/*/src (dist is canonical). - Bump smom-dbis-138 to gitignore/untrack Foundry artifacts/. - submodules-clean: print dirty count and names first. - scripts/maintenance/surgical-clean-submodule-artifacts.sh for repeat idempotent cleanup. Made-with: Cursor --- .../surgical-clean-submodule-artifacts.sh | 85 +++++++++++++++++++ scripts/verify/submodules-clean.sh | 6 ++ smom-dbis-138 | 2 +- the-order | 2 +- 4 files changed, 93 insertions(+), 2 deletions(-) create mode 100755 scripts/maintenance/surgical-clean-submodule-artifacts.sh diff --git a/scripts/maintenance/surgical-clean-submodule-artifacts.sh b/scripts/maintenance/surgical-clean-submodule-artifacts.sh new file mode 100755 index 0000000..3c0eced --- /dev/null +++ b/scripts/maintenance/surgical-clean-submodule-artifacts.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +# Surgical cleanup: remove *generated* files wrongly tracked in known submodules. +# Does not discard intentional source edits (.ts, .go, .md WIP stays dirty until you commit/stash). +# +# Applies: +# the-order — gitignore + untrack tsc emit under packages/*/src (outDir is dist/) +# smom-dbis-138 — gitignore + untrack Foundry artifacts/ +# +# Idempotent: safe to re-run after commits already landed (no-op if nothing tracked). +# +# Usage: +# bash scripts/maintenance/surgical-clean-submodule-artifacts.sh [--dry-run] +# +# After this script, commit *inside* each submodule, then update the parent pointer: +# cd the-order && git add .gitignore && git status && git commit -m "chore: …" +# cd ../smom-dbis-138 && git commit -am "chore: …" # if only .gitignore+artifacts +# cd .. && git add the-order smom-dbis-138 && git commit -m "chore(submodules): artifact hygiene" + +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/../.." && pwd)" +cd "$ROOT" + +DRY=false +[[ "${1:-}" == "--dry-run" ]] && DRY=true + +log() { echo "[surgical-clean] $*"; } + +clean_the_order() { + local sub="$ROOT/the-order" + [[ -d "$sub/.git" ]] || return 0 + log "the-order: ensure .gitignore rules for packages/**/src emit" + if $DRY; then + grep -q 'packages/\*\*/src/\*\*' "$sub/.gitignore" 2>/dev/null && log " (gitignore already has package src emit rules)" + return 0 + fi + # Rules are committed in submodule; re-apply only if file missing patterns + if ! grep -q 'packages/\*\*/src/\*\*/\*\.js$' "$sub/.gitignore" 2>/dev/null; then + log " WARN: the-order/.gitignore missing expected emit rules — merge from main or run prior hygiene commit" + fi + local cnt + cnt=$(git -C "$sub" ls-files 2>/dev/null | grep -E '^packages/[^/]+/src/.*\.(js|js\.map|d\.ts\.map)$' | grep -v 'base58-universal' | wc -l) || cnt=0 + cnt=$(echo "$cnt" | tr -d ' ') + if [[ "${cnt:-0}" -eq 0 ]]; then + cnt=$(git -C "$sub" ls-files 2>/dev/null | grep -E '^packages/[^/]+/src/.*\.d\.ts$' | grep -v 'base58-universal' | wc -l) || cnt=0 + cnt=$(echo "$cnt" | tr -d ' ') + fi + if [[ "${cnt:-0}" -eq 0 ]]; then + log "the-order: no stray tracked emit under packages/*/src (OK)" + return 0 + fi + log "the-order: removing $cnt tracked emit file(s) from index" + git -C "$sub" ls-files | grep -E '^packages/[^/]+/src/.*\.(js|js\.map|d\.ts\.map)$' | grep -v 'base58-universal' | xargs -r git -C "$sub" rm -f --cached + git -C "$sub" ls-files | grep -E '^packages/[^/]+/src/.*\.d\.ts$' | grep -v 'packages/auth/src/types/base58-universal\.d\.ts$' | xargs -r git -C "$sub" rm -f --cached +} + +clean_smom() { + local sub="$ROOT/smom-dbis-138" + [[ -d "$sub/.git" ]] || return 0 + local n + n=$(git -C "$sub" ls-files 2>/dev/null | grep -c '^artifacts/' || true) + if [[ "${n:-0}" -eq 0 ]]; then + log "smom-dbis-138: no tracked artifacts/ (OK)" + return 0 + fi + if $DRY; then + log "smom-dbis-138: would git rm -r --cached artifacts/ ($n files)" + return 0 + fi + log "smom-dbis-138: git rm -r --cached artifacts/ ($n files)" + git -C "$sub" rm -r -f --cached artifacts/ 2>/dev/null || true + if [[ -d "$sub/artifacts" ]]; then + rm -rf "$sub/artifacts" + fi +} + +if ! grep -q '^artifacts/' "$ROOT/smom-dbis-138/.gitignore" 2>/dev/null; then + log "WARN: smom-dbis-138/.gitignore should contain 'artifacts/' (add before next commit)" +fi + +clean_the_order +clean_smom + +log "Done. Run: bash scripts/verify/submodules-clean.sh" +log "Other submodules with only source/config edits need manual commit or stash (not touched here)." diff --git a/scripts/verify/submodules-clean.sh b/scripts/verify/submodules-clean.sh index ecf40bd..b0847b1 100755 --- a/scripts/verify/submodules-clean.sh +++ b/scripts/verify/submodules-clean.sh @@ -2,6 +2,9 @@ # Exit 0 if every submodule has a clean working tree (no modified/untracked files). # Use in CI or after merges: bash scripts/verify/submodules-clean.sh # Set SKIP_EXIT=1 to report dirty submodules without failing. +# +# Common fix (TypeScript monorepos): compiler output in packages/*/src/*.js — belongs in dist/; +# see the-order/.gitignore pattern and SUBMODULE_HYGIENE.md. set -euo pipefail ROOT="$(cd "$(dirname "$0")/../.." && pwd)" cd "$ROOT" @@ -11,6 +14,7 @@ tmp="$(mktemp)" trap 'rm -f "$tmp"' EXIT dirty=0 +dirty_names=() while IFS= read -r subpath; do [[ -z "$subpath" ]] && continue if ! git -C "$ROOT/$subpath" rev-parse --git-dir >/dev/null 2>&1; then @@ -19,12 +23,14 @@ while IFS= read -r subpath; do out="$(git -C "$ROOT/$subpath" status --porcelain 2>/dev/null || true)" if [[ -n "$out" ]]; then dirty=1 + dirty_names+=("$subpath") printf '%s\n' "=== $subpath ===" >>"$tmp" printf '%s\n' "$out" >>"$tmp" fi done < <(git config --file .gitmodules --get-regexp '^submodule\..*\.path$' | awk '{print $2}' | sort -u) if (( dirty )); then + echo "submodules-clean: ${#dirty_names[@]} dirty submodule(s): ${dirty_names[*]}" >&2 echo "submodules-clean: dirty submodule working trees:" >&2 cat "$tmp" >&2 if [[ "$SKIP_EXIT" != "1" ]]; then diff --git a/smom-dbis-138 b/smom-dbis-138 index 7678218..0fb7bba 160000 --- a/smom-dbis-138 +++ b/smom-dbis-138 @@ -1 +1 @@ -Subproject commit 7678218172eac5e742770c7963a6be668f0ec39d +Subproject commit 0fb7bba07bb54326bb5ea573db5a35287a834b3a diff --git a/the-order b/the-order index 27c4012..923b703 160000 --- a/the-order +++ b/the-order @@ -1 +1 @@ -Subproject commit 27c4012431f47715626f0411336133b4f7818a89 +Subproject commit 923b703d974576943d78852ff1be0147adcf6fcc