mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
Fix Docker build: use pnpm workspaces and route frontend API calls through backend proxy
This commit is contained in:
1 parent
c44b5c22d1
commit
349c130311
38 files changed
+5251
-1689
No files matched your search
+1
-1
@@ -14,5 +14,5 @@ coverage/
|
||||
|
||||
data/
|
||||
workspace/
|
||||
config/
|
||||
/config/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## Commands
|
||||
|
||||
- `npm run dev` - Start both backend (8080) and frontend (5173)
|
||||
- `npm run dev` - Start both backend (5001) and frontend (5173)
|
||||
- `npm run dev:backend` - Backend only: `bun --watch backend/src/index.ts`
|
||||
- `npm run dev:frontend` - Frontend only: `cd frontend && vite`
|
||||
- `npm run build` - Build both backend and frontend
|
||||
@@ -38,4 +38,4 @@
|
||||
- DRY principles, follow existing patterns
|
||||
- ./opencode-src/ is reference only, never commit
|
||||
- Use shared types from workspace package
|
||||
- OpenCode server runs on port 5551, backend API on port 8080
|
||||
- OpenCode server runs on port 5551, backend API on port 5001
|
||||
+24
-26
@@ -18,39 +18,35 @@ RUN apt-get update && apt-get install -y \
|
||||
file \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
|
||||
|
||||
RUN curl -fsSL https://bun.sh/install | bash && \
|
||||
ln -s $HOME/.bun/bin/bun /usr/local/bin/bun
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
FROM base AS deps
|
||||
|
||||
COPY shared ./shared
|
||||
RUN cd shared && npm install
|
||||
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml ./
|
||||
COPY shared/package.json ./shared/
|
||||
COPY backend/package.json ./backend/
|
||||
COPY frontend/package.json ./frontend/
|
||||
|
||||
COPY backend/package.json ./backend/package.json
|
||||
RUN cd backend && npm install
|
||||
|
||||
COPY frontend/package.json frontend/package-lock.json* ./frontend/
|
||||
RUN cd frontend && npm ci --legacy-peer-deps || npm install --legacy-peer-deps
|
||||
|
||||
COPY backend/src ./backend/src
|
||||
COPY frontend/src ./frontend/src
|
||||
COPY frontend/public ./frontend/public
|
||||
COPY frontend/*.* ./frontend/
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
FROM base AS builder
|
||||
|
||||
RUN curl -fsSL https://bun.sh/install | bash && \
|
||||
ln -s $HOME/.bun/bin/bun /usr/local/bin/bun
|
||||
|
||||
COPY --from=deps /app ./
|
||||
COPY shared ./shared
|
||||
COPY backend ./backend
|
||||
COPY frontend/src ./frontend/src
|
||||
COPY frontend/public ./frontend/public
|
||||
COPY frontend/index.html frontend/vite.config.ts frontend/tsconfig*.json frontend/components.json frontend/eslint.config.js ./frontend/
|
||||
|
||||
RUN cd frontend && npm run build
|
||||
RUN NODE_ENV=production bun build backend/src/index.ts --outdir=backend/dist --target=bun --packages=external
|
||||
RUN pnpm --filter frontend build
|
||||
|
||||
FROM base AS runner
|
||||
|
||||
RUN curl -fsSL https://bun.sh/install | bash && \
|
||||
ln -s $HOME/.bun/bin/bun /usr/local/bin/bun
|
||||
|
||||
RUN curl -fsSL https://opencode.ai/install | bash && \
|
||||
ln -s $HOME/.opencode/bin/opencode /usr/local/bin/opencode
|
||||
|
||||
@@ -61,12 +57,14 @@ ENV OPENCODE_SERVER_PORT=5551
|
||||
ENV DATABASE_PATH=/app/data/opencode.db
|
||||
ENV WORKSPACE_PATH=/workspace
|
||||
|
||||
COPY --from=builder /app/backend/dist ./backend/dist
|
||||
COPY --from=builder /app/backend/node_modules ./backend/node_modules
|
||||
COPY --from=builder /app/shared/src ./shared/src
|
||||
COPY --from=builder /app/shared/node_modules ./shared/node_modules
|
||||
COPY --from=builder /app/shared/package.json ./shared/package.json
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/shared ./shared
|
||||
COPY --from=builder /app/backend ./backend
|
||||
COPY --from=builder /app/frontend/dist ./frontend/dist
|
||||
COPY package.json pnpm-workspace.yaml ./
|
||||
|
||||
RUN mkdir -p /app/backend/node_modules/@opencode-webui && \
|
||||
ln -s /app/shared /app/backend/node_modules/@opencode-webui/shared
|
||||
|
||||
COPY scripts/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
RUN chmod +x /docker-entrypoint.sh
|
||||
@@ -79,4 +77,4 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
|
||||
CMD curl -f http://localhost:5003/api/health || exit 1
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["bun", "backend/dist/index.js"]
|
||||
CMD ["bun", "backend/src/index.ts"]
|
||||
@@ -14,7 +14,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@hono/node-server": "^1.19.5",
|
||||
"@opencode-webui/shared": "file:../shared",
|
||||
"@opencode-webui/shared": "workspace:*",
|
||||
"dotenv": "^17.2.3",
|
||||
"hono": "^4.10.1",
|
||||
"zod": "^4.1.12"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export * from '../../../shared/src/config'
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Database } from 'bun:sqlite'
|
||||
import type { Repo, CreateRepoInput } from '../types/repo'
|
||||
import { getReposPath } from '../config'
|
||||
import { getReposPath } from '@opencode-webui/shared'
|
||||
import path from 'path'
|
||||
|
||||
export interface RepoRow {
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
getOpenCodeConfigFilePath,
|
||||
getDatabasePath,
|
||||
ENV
|
||||
} from './config'
|
||||
} from '@opencode-webui/shared'
|
||||
|
||||
const { PORT, HOST } = ENV.SERVER
|
||||
const DB_PATH = getDatabasePath()
|
||||
|
||||
@@ -7,7 +7,7 @@ import { writeFileContent } from '../services/file-operations'
|
||||
import { opencodeServerManager } from '../services/opencode-single-server'
|
||||
import { logger } from '../utils/logger'
|
||||
import { withTransactionAsync } from '../db/transactions'
|
||||
import { getOpenCodeConfigFilePath } from '../config'
|
||||
import { getOpenCodeConfigFilePath } from '@opencode-webui/shared'
|
||||
|
||||
export function createRepoRoutes(database: Database) {
|
||||
const app = new Hono()
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { Database } from 'bun:sqlite'
|
||||
import { SettingsService } from '../services/settings'
|
||||
import { writeFileContent } from '../services/file-operations'
|
||||
import { patchOpenCodeConfig } from '../services/proxy'
|
||||
import { getOpenCodeConfigFilePath } from '../config'
|
||||
import { getOpenCodeConfigFilePath } from '@opencode-webui/shared'
|
||||
import {
|
||||
UserPreferencesSchema,
|
||||
OpenCodeConfigSchema,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { promises as fs } from 'fs'
|
||||
import path from 'path'
|
||||
import { getAuthPath } from '../config'
|
||||
import { getAuthPath } from '@opencode-webui/shared'
|
||||
import { logger } from '../utils/logger'
|
||||
import { AuthCredentialsSchema } from '../../../shared/src/schemas/auth'
|
||||
import type { z } from 'zod'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { promises as fs } from 'fs'
|
||||
import path from 'path'
|
||||
import { logger } from '../utils/logger'
|
||||
import { getReposPath } from '../config'
|
||||
import { getReposPath } from '@opencode-webui/shared'
|
||||
|
||||
export async function readFileContent(filePath: string): Promise<string> {
|
||||
try {
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
getFileStats,
|
||||
listDirectory
|
||||
} from './file-operations'
|
||||
import { FILE_LIMITS, ALLOWED_MIME_TYPES, getReposPath } from '../config'
|
||||
import { FILE_LIMITS, ALLOWED_MIME_TYPES, getReposPath } from '@opencode-webui/shared'
|
||||
|
||||
const SHARED_WORKSPACE_BASE = getReposPath()
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { spawn, execSync } from 'child_process'
|
||||
import path from 'path'
|
||||
import { logger } from '../utils/logger'
|
||||
import { getWorkspacePath, getOpenCodeConfigFilePath, ENV } from '../config'
|
||||
import { getWorkspacePath, getOpenCodeConfigFilePath, ENV } from '@opencode-webui/shared'
|
||||
|
||||
const OPENCODE_SERVER_PORT = ENV.OPENCODE.PORT
|
||||
const OPENCODE_SERVER_DIRECTORY = getWorkspacePath()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { logger } from '../utils/logger'
|
||||
import { ENV } from '../config'
|
||||
import { ENV } from '@opencode-webui/shared'
|
||||
|
||||
const OPENCODE_SERVER_URL = `http://127.0.0.1:${ENV.OPENCODE.PORT}`
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { Database } from 'bun:sqlite'
|
||||
import type { Repo, CreateRepoInput } from '../types/repo'
|
||||
import { logger } from '../utils/logger'
|
||||
import { SettingsService } from './settings'
|
||||
import { getReposPath } from '../config'
|
||||
import { getReposPath } from '@opencode-webui/shared'
|
||||
import path from 'path'
|
||||
|
||||
export async function cloneRepo(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ENV } from '../config'
|
||||
import { ENV } from '@opencode-webui/shared'
|
||||
|
||||
type LogLevel = 'info' | 'warn' | 'error' | 'debug'
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { API_BASE_URL } from '@/constants/api'
|
||||
import { API_BASE_URL } from '@/config'
|
||||
import type { FileInfo } from '@/types/files'
|
||||
|
||||
const API_BASE = API_BASE_URL
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { settingsApi } from "./settings";
|
||||
import axios from "axios";
|
||||
import { API_BASE_URL } from "@/constants/api";
|
||||
import { API_BASE_URL } from "@/config";
|
||||
|
||||
export interface Model {
|
||||
id: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Repo } from './types'
|
||||
import { API_BASE_URL } from '@/constants/api'
|
||||
import { API_BASE_URL } from '@/config'
|
||||
|
||||
const API_BASE = API_BASE_URL
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import type {
|
||||
CreateOpenCodeConfigRequest,
|
||||
UpdateOpenCodeConfigRequest
|
||||
} from './types/settings'
|
||||
import { API_BASE_URL } from '@/constants/api'
|
||||
import { API_BASE_URL } from '@/config'
|
||||
|
||||
export const settingsApi = {
|
||||
getSettings: async (userId = 'default'): Promise<SettingsResponse> => {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Input } from '@/components/ui/input'
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { FolderOpen, Upload, RefreshCw } from 'lucide-react'
|
||||
import type { FileInfo } from '@/types/files'
|
||||
import { API_BASE_URL } from '@/constants/api'
|
||||
import { API_BASE_URL } from '@/config'
|
||||
import { useMobile } from '@/hooks/useMobile'
|
||||
import { useFile } from '@/api/files'
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState } from 'react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Download, Copy, X, Edit3, Save, X as XIcon } from 'lucide-react'
|
||||
import type { FileInfo } from '@/types/files'
|
||||
import { API_BASE_URL } from '@/constants/api'
|
||||
import { API_BASE_URL } from '@/config'
|
||||
|
||||
const API_BASE = API_BASE_URL
|
||||
|
||||
|
||||
@@ -440,7 +440,7 @@ export function PromptInput({
|
||||
onClick={handleModeToggle}
|
||||
className={`px-2 py-1 rounded-md text-xs font-medium border ${modeBg} ${modeColor} hover:opacity-80 transition-opacity cursor-pointer`}
|
||||
>
|
||||
{currentMode.toUpperCase()} MODE
|
||||
{currentMode.toUpperCase()}
|
||||
</button>
|
||||
{isBashMode && (
|
||||
<div className="px-2 py-1 rounded-md text-xs font-medium border bg-purple-500/10 border-purple-500/30 text-purple-600 dark:text-purple-400">
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
export const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:5001'
|
||||
export const OPENCODE_API_ENDPOINT = import.meta.env.VITE_OPENCODE_PORT
|
||||
? `http://localhost:${import.meta.env.VITE_OPENCODE_PORT}`
|
||||
: 'http://localhost:5551'
|
||||
@@ -0,0 +1,18 @@
|
||||
import { createClientConfig, DEFAULTS, ALLOWED_MIME_TYPES, GIT_PROVIDERS } from '../../../shared/src/config/client'
|
||||
|
||||
const config = createClientConfig({
|
||||
VITE_API_URL: import.meta.env.VITE_API_URL,
|
||||
VITE_SERVER_PORT: import.meta.env.VITE_SERVER_PORT,
|
||||
VITE_OPENCODE_PORT: import.meta.env.VITE_OPENCODE_PORT,
|
||||
VITE_MAX_FILE_SIZE_MB: import.meta.env.VITE_MAX_FILE_SIZE_MB,
|
||||
VITE_MAX_UPLOAD_SIZE_MB: import.meta.env.VITE_MAX_UPLOAD_SIZE_MB,
|
||||
})
|
||||
|
||||
export const API_BASE_URL = config.API_BASE_URL
|
||||
export const OPENCODE_API_ENDPOINT = `${config.API_BASE_URL}/api/opencode`
|
||||
export const SERVER_PORT = config.SERVER_PORT
|
||||
export const OPENCODE_PORT = config.OPENCODE_PORT
|
||||
export const FILE_LIMITS = config.FILE_LIMITS
|
||||
|
||||
export { DEFAULTS, ALLOWED_MIME_TYPES, GIT_PROVIDERS }
|
||||
export default config
|
||||
@@ -1 +0,0 @@
|
||||
export { API_BASE_URL, OPENCODE_API_ENDPOINT } from '@/config'
|
||||
@@ -8,7 +8,7 @@ import { BranchSwitcher } from "@/components/repo/BranchSwitcher";
|
||||
import { SwitchConfigDialog } from "@/components/repo/SwitchConfigDialog";
|
||||
import { BackButton } from "@/components/ui/back-button";
|
||||
import { useCreateSession } from "@/hooks/useOpenCode";
|
||||
import { OPENCODE_API_ENDPOINT } from "@/constants/api";
|
||||
import { OPENCODE_API_ENDPOINT } from "@/config";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
|
||||
@@ -10,7 +10,7 @@ import { SessionList } from "@/components/session/SessionList";
|
||||
import { FileBrowserSheet } from "@/components/file-browser/FileBrowserSheet";
|
||||
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
|
||||
import { useSession, useMessages, useAbortSession } from "@/hooks/useOpenCode";
|
||||
import { OPENCODE_API_ENDPOINT } from "@/constants/api";
|
||||
import { OPENCODE_API_ENDPOINT } from "@/config";
|
||||
import { useSSE } from "@/hooks/useSSE";
|
||||
import { useSettings } from "@/hooks/useSettings";
|
||||
import { useKeyboardShortcuts } from "@/hooks/useKeyboardShortcuts";
|
||||
|
||||
Generated
-353
@@ -1,353 +0,0 @@
|
||||
{
|
||||
"name": "opencode-webui",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "opencode-webui",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"class-variance-authority": "^0.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"concurrently": "^9.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-regex": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-styles": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-convert": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/chalk": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
"supports-color": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/chalk/node_modules/supports-color": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"has-flag": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/class-variance-authority": {
|
||||
"version": "0.7.1",
|
||||
"resolved": "https://registry.npmjs.org/class-variance-authority/-/class-variance-authority-0.7.1.tgz",
|
||||
"integrity": "sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"clsx": "^2.1.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://polar.sh/cva"
|
||||
}
|
||||
},
|
||||
"node_modules/cliui": {
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
|
||||
"integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"string-width": "^4.2.0",
|
||||
"strip-ansi": "^6.0.1",
|
||||
"wrap-ansi": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/clsx": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",
|
||||
"integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/color-convert": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-name": "~1.1.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/color-name": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/concurrently": {
|
||||
"version": "9.2.1",
|
||||
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.2.1.tgz",
|
||||
"integrity": "sha512-fsfrO0MxV64Znoy8/l1vVIjjHa29SZyyqPgQBwhiDcaW8wJc2W3XWVOGx4M3oJBnv/zdUZIIp1gDeS98GzP8Ng==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"chalk": "4.1.2",
|
||||
"rxjs": "7.8.2",
|
||||
"shell-quote": "1.8.3",
|
||||
"supports-color": "8.1.1",
|
||||
"tree-kill": "1.2.2",
|
||||
"yargs": "17.7.2"
|
||||
},
|
||||
"bin": {
|
||||
"conc": "dist/bin/concurrently.js",
|
||||
"concurrently": "dist/bin/concurrently.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/open-cli-tools/concurrently?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/escalade": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
|
||||
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/get-caller-file": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
||||
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": "6.* || 8.* || >= 10.*"
|
||||
}
|
||||
},
|
||||
"node_modules/has-flag": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/is-fullwidth-code-point": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
||||
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/rxjs": {
|
||||
"version": "7.8.2",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz",
|
||||
"integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"tslib": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/shell-quote": {
|
||||
"version": "1.8.3",
|
||||
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz",
|
||||
"integrity": "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/string-width": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emoji-regex": "^8.0.0",
|
||||
"is-fullwidth-code-point": "^3.0.0",
|
||||
"strip-ansi": "^6.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/strip-ansi": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
||||
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^5.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/supports-color": {
|
||||
"version": "8.1.1",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
|
||||
"integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"has-flag": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/supports-color?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/tree-kill": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
|
||||
"integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"tree-kill": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"dev": true,
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/wrap-ansi": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
||||
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.0.0",
|
||||
"string-width": "^4.1.0",
|
||||
"strip-ansi": "^6.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/y18n": {
|
||||
"version": "5.0.8",
|
||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
||||
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/yargs": {
|
||||
"version": "17.7.2",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
|
||||
"integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cliui": "^8.0.1",
|
||||
"escalade": "^3.1.1",
|
||||
"get-caller-file": "^2.0.5",
|
||||
"require-directory": "^2.1.1",
|
||||
"string-width": "^4.2.3",
|
||||
"y18n": "^5.0.5",
|
||||
"yargs-parser": "^21.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/yargs-parser": {
|
||||
"version": "21.1.1",
|
||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
|
||||
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-12
@@ -3,21 +3,17 @@
|
||||
"version": "0.25",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"workspaces": [
|
||||
"shared",
|
||||
"backend",
|
||||
"frontend"
|
||||
],
|
||||
"packageManager": "pnpm@9.15.0",
|
||||
"scripts": {
|
||||
"predev": "bash scripts/setup-dev.sh",
|
||||
"dev": "concurrently \"npm:dev:backend\" \"npm:dev:frontend\"",
|
||||
"dev": "concurrently \"pnpm:dev:backend\" \"pnpm:dev:frontend\"",
|
||||
"dev:backend": "bun --watch backend/src/index.ts",
|
||||
"dev:frontend": "cd frontend && npm run dev",
|
||||
"build": "npm run build:backend && npm run build:frontend",
|
||||
"build:backend": "cd backend && bun run build",
|
||||
"build:frontend": "cd frontend && npm run build",
|
||||
"test": "npm run test:backend",
|
||||
"test:backend": "cd backend && bun test",
|
||||
"dev:frontend": "pnpm --filter frontend dev",
|
||||
"build": "pnpm run build:backend && pnpm run build:frontend",
|
||||
"build:backend": "pnpm --filter backend build",
|
||||
"build:frontend": "pnpm --filter frontend build",
|
||||
"test": "pnpm run test:backend",
|
||||
"test:backend": "pnpm --filter backend test",
|
||||
"generate:openapi": "bun scripts/generate-openapi.ts",
|
||||
"docker:build": "docker-compose build",
|
||||
"docker:up": "docker-compose up -d",
|
||||
|
||||
Generated
+4937
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,4 @@
|
||||
packages:
|
||||
- 'shared'
|
||||
- 'backend'
|
||||
- 'frontend'
|
||||
+3
-1
@@ -15,9 +15,11 @@
|
||||
"./config/client": "./src/config/client.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^17.2.3",
|
||||
"zod": "^4.1.12"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"dotenv": "^17.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { DEFAULTS, ALLOWED_MIME_TYPES, GIT_PROVIDERS } from './defaults'
|
||||
|
||||
export interface ClientConfig {
|
||||
API_BASE_URL: string
|
||||
SERVER_PORT: number
|
||||
OPENCODE_PORT: number
|
||||
FILE_LIMITS: {
|
||||
MAX_SIZE_BYTES: number
|
||||
MAX_UPLOAD_SIZE_BYTES: number
|
||||
}
|
||||
}
|
||||
|
||||
export function createClientConfig(env: {
|
||||
VITE_API_URL?: string
|
||||
VITE_SERVER_PORT?: string
|
||||
VITE_OPENCODE_PORT?: string
|
||||
VITE_MAX_FILE_SIZE_MB?: string
|
||||
VITE_MAX_UPLOAD_SIZE_MB?: string
|
||||
}): ClientConfig {
|
||||
const maxFileSizeMB = env.VITE_MAX_FILE_SIZE_MB
|
||||
? parseInt(env.VITE_MAX_FILE_SIZE_MB, 10)
|
||||
: DEFAULTS.FILE_LIMITS.MAX_SIZE_MB
|
||||
|
||||
const maxUploadSizeMB = env.VITE_MAX_UPLOAD_SIZE_MB
|
||||
? parseInt(env.VITE_MAX_UPLOAD_SIZE_MB, 10)
|
||||
: DEFAULTS.FILE_LIMITS.MAX_UPLOAD_SIZE_MB
|
||||
|
||||
const serverPort = env.VITE_SERVER_PORT
|
||||
? parseInt(env.VITE_SERVER_PORT, 10)
|
||||
: DEFAULTS.SERVER.PORT
|
||||
|
||||
return {
|
||||
API_BASE_URL: env.VITE_API_URL || `http://localhost:${serverPort}`,
|
||||
SERVER_PORT: serverPort,
|
||||
OPENCODE_PORT: env.VITE_OPENCODE_PORT
|
||||
? parseInt(env.VITE_OPENCODE_PORT, 10)
|
||||
: DEFAULTS.OPENCODE.PORT,
|
||||
FILE_LIMITS: {
|
||||
MAX_SIZE_BYTES: maxFileSizeMB * 1024 * 1024,
|
||||
MAX_UPLOAD_SIZE_BYTES: maxUploadSizeMB * 1024 * 1024,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export { DEFAULTS, ALLOWED_MIME_TYPES, GIT_PROVIDERS }
|
||||
@@ -0,0 +1,71 @@
|
||||
export const DEFAULTS = {
|
||||
SERVER: {
|
||||
PORT: 5003,
|
||||
HOST: '0.0.0.0',
|
||||
CORS_ORIGIN: 'http://localhost:5173',
|
||||
},
|
||||
|
||||
FRONTEND: {
|
||||
PORT: 5173,
|
||||
HOST: '0.0.0.0',
|
||||
},
|
||||
|
||||
OPENCODE: {
|
||||
PORT: 5551,
|
||||
HOST: '127.0.0.1',
|
||||
},
|
||||
|
||||
DATABASE: {
|
||||
PATH: './data/opencode.db',
|
||||
},
|
||||
|
||||
WORKSPACE: {
|
||||
BASE_PATH: './workspace',
|
||||
REPOS_DIR: 'repos',
|
||||
CONFIG_DIR: '.config/opencode',
|
||||
AUTH_FILE: '.opencode/state/opencode/auth.json',
|
||||
},
|
||||
|
||||
TIMEOUTS: {
|
||||
PROCESS_START_WAIT_MS: 2000,
|
||||
PROCESS_VERIFY_WAIT_MS: 1000,
|
||||
HEALTH_CHECK_INTERVAL_MS: 5000,
|
||||
HEALTH_CHECK_TIMEOUT_MS: 30000,
|
||||
},
|
||||
|
||||
FILE_LIMITS: {
|
||||
MAX_SIZE_MB: 50,
|
||||
MAX_UPLOAD_SIZE_MB: 50,
|
||||
},
|
||||
|
||||
LOGGING: {
|
||||
DEBUG: false,
|
||||
LOG_LEVEL: 'info',
|
||||
},
|
||||
} as const
|
||||
|
||||
export const ALLOWED_MIME_TYPES = [
|
||||
'text/plain',
|
||||
'text/html',
|
||||
'text/css',
|
||||
'text/javascript',
|
||||
'text/typescript',
|
||||
'application/json',
|
||||
'application/xml',
|
||||
'image/png',
|
||||
'image/jpeg',
|
||||
'image/gif',
|
||||
'image/svg+xml',
|
||||
'application/pdf',
|
||||
'application/zip',
|
||||
] as const
|
||||
|
||||
export const GIT_PROVIDERS = {
|
||||
GITHUB: 'github.com',
|
||||
GITLAB: 'gitlab.com',
|
||||
BITBUCKET: 'bitbucket.org',
|
||||
} as const
|
||||
|
||||
export type Config = typeof DEFAULTS
|
||||
export type AllowedMimeType = (typeof ALLOWED_MIME_TYPES)[number]
|
||||
export type GitProvider = (typeof GIT_PROVIDERS)[keyof typeof GIT_PROVIDERS]
|
||||
@@ -0,0 +1,113 @@
|
||||
import path from 'path'
|
||||
import os from 'os'
|
||||
import { DEFAULTS } from './defaults'
|
||||
|
||||
try {
|
||||
const { config } = await import('dotenv')
|
||||
config({ path: path.resolve(process.cwd(), '.env') })
|
||||
} catch {
|
||||
// dotenv not available (e.g., in production Docker), env vars already set
|
||||
}
|
||||
|
||||
const getEnvString = (key: string, defaultValue: string): string => {
|
||||
return process.env[key] ?? defaultValue
|
||||
}
|
||||
|
||||
const getEnvNumber = (key: string, defaultValue: number): number => {
|
||||
const value = process.env[key]
|
||||
return value ? parseInt(value, 10) : defaultValue
|
||||
}
|
||||
|
||||
const getEnvBoolean = (key: string, defaultValue: boolean): boolean => {
|
||||
const value = process.env[key]
|
||||
if (value === undefined) return defaultValue
|
||||
return value === 'true' || value === '1'
|
||||
}
|
||||
|
||||
const resolveWorkspacePath = (): string => {
|
||||
const envPath = process.env.WORKSPACE_PATH
|
||||
if (envPath) {
|
||||
if (envPath.startsWith('~')) {
|
||||
return path.join(os.homedir(), envPath.slice(1))
|
||||
}
|
||||
return path.resolve(envPath)
|
||||
}
|
||||
return path.resolve(DEFAULTS.WORKSPACE.BASE_PATH)
|
||||
}
|
||||
|
||||
const workspaceBasePath = resolveWorkspacePath()
|
||||
|
||||
export const ENV = {
|
||||
SERVER: {
|
||||
PORT: getEnvNumber('PORT', DEFAULTS.SERVER.PORT),
|
||||
HOST: getEnvString('HOST', DEFAULTS.SERVER.HOST),
|
||||
CORS_ORIGIN: getEnvString('CORS_ORIGIN', DEFAULTS.SERVER.CORS_ORIGIN),
|
||||
NODE_ENV: getEnvString('NODE_ENV', 'development'),
|
||||
},
|
||||
|
||||
OPENCODE: {
|
||||
PORT: getEnvNumber('OPENCODE_SERVER_PORT', DEFAULTS.OPENCODE.PORT),
|
||||
HOST: getEnvString('OPENCODE_HOST', DEFAULTS.OPENCODE.HOST),
|
||||
},
|
||||
|
||||
DATABASE: {
|
||||
PATH: getEnvString('DATABASE_PATH', DEFAULTS.DATABASE.PATH),
|
||||
},
|
||||
|
||||
WORKSPACE: {
|
||||
BASE_PATH: workspaceBasePath,
|
||||
REPOS_DIR: DEFAULTS.WORKSPACE.REPOS_DIR,
|
||||
CONFIG_DIR: DEFAULTS.WORKSPACE.CONFIG_DIR,
|
||||
AUTH_FILE: DEFAULTS.WORKSPACE.AUTH_FILE,
|
||||
},
|
||||
|
||||
TIMEOUTS: {
|
||||
PROCESS_START_WAIT_MS: getEnvNumber('PROCESS_START_WAIT_MS', DEFAULTS.TIMEOUTS.PROCESS_START_WAIT_MS),
|
||||
PROCESS_VERIFY_WAIT_MS: getEnvNumber('PROCESS_VERIFY_WAIT_MS', DEFAULTS.TIMEOUTS.PROCESS_VERIFY_WAIT_MS),
|
||||
HEALTH_CHECK_INTERVAL_MS: getEnvNumber('HEALTH_CHECK_INTERVAL_MS', DEFAULTS.TIMEOUTS.HEALTH_CHECK_INTERVAL_MS),
|
||||
HEALTH_CHECK_TIMEOUT_MS: getEnvNumber('HEALTH_CHECK_TIMEOUT_MS', DEFAULTS.TIMEOUTS.HEALTH_CHECK_TIMEOUT_MS),
|
||||
},
|
||||
|
||||
FILE_LIMITS: {
|
||||
MAX_SIZE_BYTES: getEnvNumber('MAX_FILE_SIZE_MB', DEFAULTS.FILE_LIMITS.MAX_SIZE_MB) * 1024 * 1024,
|
||||
MAX_UPLOAD_SIZE_BYTES: getEnvNumber('MAX_UPLOAD_SIZE_MB', DEFAULTS.FILE_LIMITS.MAX_UPLOAD_SIZE_MB) * 1024 * 1024,
|
||||
},
|
||||
|
||||
LOGGING: {
|
||||
DEBUG: getEnvBoolean('DEBUG', DEFAULTS.LOGGING.DEBUG),
|
||||
LOG_LEVEL: getEnvString('LOG_LEVEL', DEFAULTS.LOGGING.LOG_LEVEL),
|
||||
},
|
||||
} as const
|
||||
|
||||
export const getWorkspacePath = () => ENV.WORKSPACE.BASE_PATH
|
||||
export const getReposPath = () => path.join(ENV.WORKSPACE.BASE_PATH, ENV.WORKSPACE.REPOS_DIR)
|
||||
export const getConfigPath = () => path.join(ENV.WORKSPACE.BASE_PATH, ENV.WORKSPACE.CONFIG_DIR)
|
||||
export const getOpenCodeConfigFilePath = () => path.join(ENV.WORKSPACE.BASE_PATH, ENV.WORKSPACE.CONFIG_DIR, 'opencode.json')
|
||||
export const getAuthPath = () => path.join(ENV.WORKSPACE.BASE_PATH, ENV.WORKSPACE.AUTH_FILE)
|
||||
export const getDatabasePath = () => ENV.DATABASE.PATH
|
||||
|
||||
export const getApiUrl = (port: number = ENV.SERVER.PORT): string => {
|
||||
const host = ENV.SERVER.HOST
|
||||
|
||||
if (host === '0.0.0.0') {
|
||||
const interfaces = os.networkInterfaces()
|
||||
const ips = Object.values(interfaces)
|
||||
.flat()
|
||||
.filter(info => info && !info.internal && info.family === 'IPv4')
|
||||
.map(info => info!.address)
|
||||
|
||||
if (ips.length > 0) {
|
||||
return `http://${ips[0]}:${port}`
|
||||
}
|
||||
|
||||
return `http://localhost:${port}`
|
||||
}
|
||||
|
||||
return `http://${host}:${port}`
|
||||
}
|
||||
|
||||
export const SERVER_CONFIG = ENV.SERVER
|
||||
export const OPENCODE_CONFIG = ENV.OPENCODE
|
||||
export const FILE_LIMITS = ENV.FILE_LIMITS
|
||||
export const TIMEOUTS = ENV.TIMEOUTS
|
||||
export const WORKSPACE = ENV.WORKSPACE
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from './defaults'
|
||||
export * from './env'
|
||||
export * from './client'
|
||||
Reference in new issue
Block a user