diff --git a/apps/git/index.tsx b/apps/git/index.tsx index 5db1eb9..20adc19 100644 --- a/apps/git/index.tsx +++ b/apps/git/index.tsx @@ -227,24 +227,6 @@ async function deploy(repoName: string): Promise<{ ok: boolean; error?: string } return { ok: false, error: `git archive failed: ${archiveErr || tarErr}` } } - // Verify package.json with scripts.toes exists - const pkgPath = join(tmpDir, 'package.json') - if (!(await Bun.file(pkgPath).exists())) { - await rm(tmpDir, { recursive: true, force: true }) - return { ok: false, error: 'No package.json found in repository' } - } - - try { - const pkg = JSON.parse(await Bun.file(pkgPath).text()) - if (!pkg.scripts?.toes) { - await rm(tmpDir, { recursive: true, force: true }) - return { ok: false, error: 'package.json missing scripts.toes entry' } - } - } catch { - await rm(tmpDir, { recursive: true, force: true }) - return { ok: false, error: 'Invalid package.json' } - } - // Stop the app before swapping directories await stopIfRunning(repoName) @@ -661,6 +643,28 @@ function RepoListPage({ baseUrl, external, repos, tunnelUrl }: RepoListPageProps mkdirSync(REPOS_DIR, { recursive: true }) +// Auto-deploy bare repos that don't have a corresponding app directory +async function deployUndeployedRepos() { + const repos = await listRepos() + for (const name of repos) { + const appDir = join(APPS_DIR, name) + if (await dirExists(appDir)) continue + + const bare = repoPath(name) + if (!(await hasCommits(bare))) continue + + console.log(`Auto-deploying undeployed repo: ${name}`) + const result = await deploy(name) + if (result.ok) { + await activateApp(name) + } else { + console.error(`Auto-deploy failed for ${name}: ${result.error}`) + } + } +} + +deployUndeployedRepos() + on('app:delete', async ({ app: name }) => { const bare = repoPath(name) if (await dirExists(bare)) await rm(bare, { recursive: true, force: true }) diff --git a/src/server/apps.ts b/src/server/apps.ts index a06878a..3cb4cef 100644 --- a/src/server/apps.ts +++ b/src/server/apps.ts @@ -345,7 +345,7 @@ export const update = () => { function allAppDirs() { return readdirSync(APPS_DIR, { withFileTypes: true }) - .filter(e => e.isDirectory() && existsSync(join(APPS_DIR, e.name, 'package.json'))) + .filter(e => e.isDirectory() && !e.name.startsWith('.')) .map(e => e.name) .sort() }