From 0efc25834c330f5f766828ad049338eb9b771238 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Sun, 1 Mar 2026 09:45:50 -0800 Subject: [PATCH] Delete git repo on app removal via app:delete event --- apps/git/20260228-000000/index.tsx | 7 ++++++- src/server/api/sync.ts | 8 +------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/git/20260228-000000/index.tsx b/apps/git/20260228-000000/index.tsx index 8e0b688..183943b 100644 --- a/apps/git/20260228-000000/index.tsx +++ b/apps/git/20260228-000000/index.tsx @@ -1,6 +1,6 @@ import { Hype } from '@because/hype' import { define, stylesToCSS } from '@because/forge' -import { baseStyles, ToolScript, theme } from '@because/toes/tools' +import { baseStyles, ToolScript, theme, on } from '@because/toes/tools' import { mkdirSync } from 'fs' import { mkdir, readdir, readlink, rm, stat } from 'fs/promises' import { join, resolve } from 'path' @@ -406,6 +406,11 @@ async function withDeployLock(repo: string, fn: () => Promise): Promise mkdirSync(REPOS_DIR, { recursive: true }) +on('app:delete', async ({ app: name }) => { + const bare = repoPath(name) + if (await dirExists(bare)) await rm(bare, { recursive: true, force: true }) +}) + app.get('/ok', c => c.text('ok')) app.get('/styles.css', c => diff --git a/src/server/api/sync.ts b/src/server/api/sync.ts index 2563ee6..09c0b45 100644 --- a/src/server/api/sync.ts +++ b/src/server/api/sync.ts @@ -2,11 +2,10 @@ import { APPS_DIR, allApps, emit, registerApp, removeApp, restartApp, startApp } import { computeHash, generateManifest } from '../sync' import { loadGitignore } from '@gitignore' import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, symlinkSync, unlinkSync, watch, writeFileSync } from 'fs' -import { dirname, join, resolve } from 'path' +import { dirname, join } from 'path' import { Hype } from '@because/hype' const MAX_VERSIONS = 5 -const REPOS_DIR = resolve(process.env.DATA_DIR ?? '.', 'repos') interface FileChangeEvent { hash?: string @@ -211,11 +210,6 @@ router.delete('/apps/:app', c => { removeApp(appName) rmSync(appPath, { recursive: true }) - - // Remove bare git repo if one exists - const repoPath = join(REPOS_DIR, `${appName}.git`) - if (existsSync(repoPath)) rmSync(repoPath, { recursive: true }) - return c.json({ ok: true }) })