forked from defunkt/toes
Remove package.json requirement, auto-deploy bare repos
This commit is contained in:
parent
63b0709649
commit
aebafdf496
|
|
@ -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 })
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user