Init bare git repos for apps on install

This commit is contained in:
Chris Wanstrath 2026-03-05 13:09:25 -08:00
parent 0a8287970d
commit 27860c5e32

View File

@ -13,8 +13,6 @@ DEST=~/toes
APPS_DIR=~/apps
DATA_DIR=~/data
BUNDLED_APPS="clock code cron env git metrics"
# ── Helpers ──────────────────────────────────────────────
quiet() { "$@" > /dev/null 2>&1; }
@ -82,18 +80,37 @@ info "Installing dependencies"
quiet bun install
info "Building"
rm -rf dist
quiet bun run build
# ── Bundled apps ─────────────────────────────────────────
REPOS_DIR="$DATA_DIR/repos"
mkdir -p "$REPOS_DIR"
info "Installing bundled apps"
for app in $BUNDLED_APPS; do
[ -d "$DEST/apps/$app" ] || continue
for app_dir in "$DEST"/apps/*/; do
app=$(basename "$app_dir")
[ -f "$app_dir/package.json" ] || continue
echo " $app"
cp -r "$DEST/apps/$app" "$APPS_DIR/"
cp -a "$app_dir" "$APPS_DIR/$app"
if [ -f "$APPS_DIR/$app/package.json" ]; then
quiet bun install --frozen-lockfile --cwd "$APPS_DIR/$app" || quiet bun install --cwd "$APPS_DIR/$app"
fi
# Initialize bare repo for git-based versioning
bare="$REPOS_DIR/$app.git"
if [ ! -d "$bare" ]; then
quiet git init --bare -b main "$bare"
git -C "$bare" config http.receivepack true
fi
tmp=$(mktemp -d)
cp -a "$app_dir"/. "$tmp"/
quiet git -C "$tmp" init -b main
quiet git -C "$tmp" add -A
quiet git -C "$tmp" -c user.name=toes -c user.email=toes@localhost commit -m "install"
quiet git -C "$tmp" push --force "$bare" main
rm -rf "$tmp"
done
# ── Systemd ──────────────────────────────────────────────