mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat(ocm-cli): workspace repo sync and manager token targeting (#233)
This commit is contained in:
1 parent
e12f319592
commit
a86e4b1238
69 files changed
+4858
-161
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { Hono } from 'hono'
|
||||
import type { Database } from 'bun:sqlite'
|
||||
import { listRepos } from '../../db/queries'
|
||||
import { logger } from '../../utils/logger'
|
||||
import { getErrorMessage } from '../../utils/error-utils'
|
||||
import path from 'path'
|
||||
|
||||
export function createInternalOpenCodeWorkspacesRoutes(db: Database) {
|
||||
const app = new Hono()
|
||||
|
||||
app.get('/', (c) => {
|
||||
try {
|
||||
const repos = listRepos(db)
|
||||
const workspaces = repos
|
||||
.filter((repo) => repo.cloneStatus === 'ready')
|
||||
.map((repo) => ({
|
||||
repoId: repo.id,
|
||||
name: repo.repoUrl
|
||||
? repo.repoUrl.split('/').slice(-1)[0]?.replace('.git', '') || repo.localPath
|
||||
: repo.sourcePath
|
||||
? path.basename(repo.sourcePath)
|
||||
: repo.localPath,
|
||||
branch: repo.branch ?? null,
|
||||
cloneStatus: repo.cloneStatus,
|
||||
directory: repo.fullPath,
|
||||
originUrl: repo.repoUrl ?? null,
|
||||
extra: {
|
||||
repoId: repo.id,
|
||||
localPath: repo.localPath,
|
||||
fullPath: repo.fullPath,
|
||||
},
|
||||
}))
|
||||
return c.json({ workspaces })
|
||||
} catch (error) {
|
||||
logger.error('Failed to list opencode workspaces:', error)
|
||||
return c.json({ error: getErrorMessage(error) }, 500)
|
||||
}
|
||||
})
|
||||
|
||||
return app
|
||||
}
|
||||
Reference in new issue
Block a user