Initial Commit
This commit is contained in:
131
scripts/copy-wip-from-suaveplan.sh
Normal file
131
scripts/copy-wip-from-suaveplan.sh
Normal file
@@ -0,0 +1,131 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copy yet-to-be-migrated packages from ../suaveplan/packages/<tier>/<pkg>/ into
|
||||
# wip/<category>/<pkg>/, where <category> comes from scripts/folder-reorg/assignment.yml
|
||||
# (the source of truth for the eventual packages/<category>/<pkg>/ destination).
|
||||
#
|
||||
# Skips packages already present in packages/<category>/<pkg>/.
|
||||
# Pre-cleans ../suaveplan of node_modules / .turbo / coverage / dist to speed cp -r.
|
||||
#
|
||||
# Usage: bash scripts/copy-wip-from-suaveplan.sh [--dry-run] [--no-clean]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
GENESIS="/home/paul/web/genesis"
|
||||
SUAVEPLAN="/home/paul/web/suaveplan"
|
||||
ASSIGNMENT="$GENESIS/scripts/folder-reorg/assignment.yml"
|
||||
WIP="$GENESIS/wip"
|
||||
|
||||
DRY=0
|
||||
CLEAN=1
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--dry-run) DRY=1 ;;
|
||||
--no-clean) CLEAN=0 ;;
|
||||
*) echo "unknown flag: $arg" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
run() {
|
||||
if [[ $DRY -eq 1 ]]; then
|
||||
echo "DRY: $*"
|
||||
else
|
||||
eval "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 1. Pre-clean ../suaveplan to speed up copying.
|
||||
# ---------------------------------------------------------------------------
|
||||
if [[ $CLEAN -eq 1 ]]; then
|
||||
echo "==> Pruning node_modules / .turbo / coverage / dist under $SUAVEPLAN"
|
||||
# -prune avoids descending into already-matched dirs.
|
||||
run "find '$SUAVEPLAN' \\( \
|
||||
-type d -name node_modules -o \
|
||||
-type d -name .turbo -o \
|
||||
-type d -name coverage -o \
|
||||
-type d -name dist \
|
||||
\\) -prune -exec rm -rf {} +"
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 2. Parse assignment.yml -> emit "<category> <pkg>" lines.
|
||||
# Format is plain YAML:
|
||||
# category:
|
||||
# - pkg-a
|
||||
# - pkg-b
|
||||
# Skip __retired__ / __retired_categories__ / blank / comment lines.
|
||||
# ---------------------------------------------------------------------------
|
||||
pairs() {
|
||||
awk '
|
||||
/^[[:space:]]*#/ { next }
|
||||
/^[[:space:]]*$/ { next }
|
||||
/^[A-Za-z][A-Za-z0-9_-]*:[[:space:]]*$/ {
|
||||
cat = $1
|
||||
sub(/:$/, "", cat)
|
||||
if (cat == "__retired__" || cat == "__retired_categories__") {
|
||||
cat = ""
|
||||
}
|
||||
next
|
||||
}
|
||||
/^[[:space:]]*-[[:space:]]+/ {
|
||||
if (cat == "") next
|
||||
pkg = $0
|
||||
sub(/^[[:space:]]*-[[:space:]]+/, "", pkg)
|
||||
sub(/[[:space:]].*$/, "", pkg)
|
||||
print cat, pkg
|
||||
}
|
||||
' "$ASSIGNMENT"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 3. For each (category, pkg): copy if missing in packages/, present in suaveplan,
|
||||
# and not already in wip/.
|
||||
# ---------------------------------------------------------------------------
|
||||
copied=0
|
||||
skipped_present=0
|
||||
skipped_in_wip=0
|
||||
skipped_no_source=0
|
||||
|
||||
while read -r category pkg; do
|
||||
[[ -z "$category" || -z "$pkg" ]] && continue
|
||||
|
||||
dest_final="$GENESIS/packages/$category/$pkg"
|
||||
dest_wip="$WIP/$category/$pkg"
|
||||
|
||||
if [[ -d "$dest_final" ]]; then
|
||||
skipped_present=$((skipped_present + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ -d "$dest_wip" ]]; then
|
||||
skipped_in_wip=$((skipped_in_wip + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
# Find source under any tier: packages/{universal,browser,react,server,three,finance,mcp,python}/<pkg>
|
||||
src=""
|
||||
for tier_dir in "$SUAVEPLAN"/packages/*/; do
|
||||
candidate="${tier_dir}${pkg}"
|
||||
if [[ -d "$candidate" ]]; then
|
||||
src="$candidate"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "$src" ]]; then
|
||||
skipped_no_source=$((skipped_no_source + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
echo " copy: $src -> wip/$category/$pkg"
|
||||
run "mkdir -p '$WIP/$category'"
|
||||
run "cp -r '$src' '$dest_wip'"
|
||||
copied=$((copied + 1))
|
||||
done < <(pairs)
|
||||
|
||||
echo
|
||||
echo "==> Done"
|
||||
echo " copied : $copied"
|
||||
echo " skipped (in packages/): $skipped_present"
|
||||
echo " skipped (in wip/) : $skipped_in_wip"
|
||||
echo " skipped (no source) : $skipped_no_source"
|
||||
Reference in New Issue
Block a user