fase 1
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
PACKAGE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
REPO_ROOT="${1:-$PWD}"
|
||||
|
||||
if [[ ! -d "${REPO_ROOT}/.git" ]]; then
|
||||
echo "ERROR: ${REPO_ROOT} no parece ser la raíz de apps-registry."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
test -f "${REPO_ROOT}/workloads/ecommerce/kustomization.yaml"
|
||||
|
||||
BACKUP="${REPO_ROOT}/.phase1-backup-$(date +%Y%m%d-%H%M%S)"
|
||||
mkdir -p "${BACKUP}"
|
||||
|
||||
cp -a \
|
||||
"${REPO_ROOT}/workloads/ecommerce/kustomization.yaml" \
|
||||
"${BACKUP}/kustomization.yaml"
|
||||
|
||||
for file in \
|
||||
"workloads/ecommerce/lib/headless/providers/medusa.ts" \
|
||||
"workloads/ecommerce/next.config.ts"; do
|
||||
if [[ -f "${REPO_ROOT}/${file}" ]]; then
|
||||
mkdir -p "${BACKUP}/$(dirname "${file}")"
|
||||
cp -a "${REPO_ROOT}/${file}" "${BACKUP}/${file}"
|
||||
fi
|
||||
done
|
||||
|
||||
cp -a \
|
||||
"${PACKAGE_ROOT}/apps-registry/." \
|
||||
"${REPO_ROOT}/"
|
||||
|
||||
KUSTOMIZATION="${REPO_ROOT}/workloads/ecommerce/kustomization.yaml"
|
||||
|
||||
python3 - "${KUSTOMIZATION}" <<'PY'
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
path = Path(sys.argv[1])
|
||||
text = path.read_text(encoding="utf-8")
|
||||
|
||||
if " - commerce/" not in text:
|
||||
marker = "resources:\n"
|
||||
if marker not in text:
|
||||
raise SystemExit("No se encontró el bloque resources en kustomization.yaml")
|
||||
|
||||
lines = text.splitlines()
|
||||
out = []
|
||||
inserted = False
|
||||
|
||||
for line in lines:
|
||||
if not inserted and line.startswith("patches:"):
|
||||
out.append(" - commerce/")
|
||||
out.append("")
|
||||
inserted = True
|
||||
out.append(line)
|
||||
|
||||
if not inserted:
|
||||
out.append(" - commerce/")
|
||||
|
||||
path.write_text("\n".join(out).rstrip() + "\n", encoding="utf-8")
|
||||
PY
|
||||
|
||||
echo
|
||||
echo "Fase 1 copiada en: ${REPO_ROOT}"
|
||||
echo "Respaldo: ${BACKUP}"
|
||||
echo
|
||||
echo "El frontend NO fue cambiado a Medusa todavía."
|
||||
echo "Revisa los cambios con: git status && git diff"
|
||||
Reference in New Issue
Block a user