split launcher source and build by component
This commit is contained in:
@@ -7,8 +7,10 @@ import { formatDateTime } from '../../lib/date-format';
|
|||||||
import { LoadingModal, useMinimumLoading } from '../operations/operation-utils';
|
import { LoadingModal, useMinimumLoading } from '../operations/operation-utils';
|
||||||
import {
|
import {
|
||||||
createLauncherBuildJob,
|
createLauncherBuildJob,
|
||||||
|
getLauncherSource,
|
||||||
listLauncherBuildJobs,
|
listLauncherBuildJobs,
|
||||||
listLauncherVersions,
|
listLauncherVersions,
|
||||||
|
type LauncherSource,
|
||||||
type LauncherBuildJob,
|
type LauncherBuildJob,
|
||||||
type LauncherVersion
|
type LauncherVersion
|
||||||
} from './launcher-api';
|
} from './launcher-api';
|
||||||
@@ -43,6 +45,7 @@ function jobTime(job: LauncherBuildJob) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const launcherBuildJobPageSize = 3;
|
const launcherBuildJobPageSize = 3;
|
||||||
|
type BuildTarget = 'launcher-client' | 'launcher-backend';
|
||||||
|
|
||||||
function sanitizeObjectKeyPart(value: string) {
|
function sanitizeObjectKeyPart(value: string) {
|
||||||
return value
|
return value
|
||||||
@@ -70,7 +73,9 @@ function launcherArtifactKey(version: string, branch: string, commitSha: string,
|
|||||||
|
|
||||||
export function LauncherBuildPage() {
|
export function LauncherBuildPage() {
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
const [target, setTarget] = useState<BuildTarget>('launcher-client');
|
||||||
const [versions, setVersions] = useState<LauncherVersion[]>([]);
|
const [versions, setVersions] = useState<LauncherVersion[]>([]);
|
||||||
|
const [source, setSource] = useState<LauncherSource | null>(null);
|
||||||
const [version, setVersion] = useState('');
|
const [version, setVersion] = useState('');
|
||||||
const [branch, setBranch] = useState('release');
|
const [branch, setBranch] = useState('release');
|
||||||
const [commitSha, setCommitSha] = useState('');
|
const [commitSha, setCommitSha] = useState('');
|
||||||
@@ -81,10 +86,16 @@ export function LauncherBuildPage() {
|
|||||||
const loadingVisible = useMinimumLoading(loading);
|
const loadingVisible = useMinimumLoading(loading);
|
||||||
|
|
||||||
const activeVersion = useMemo(() => versions.find((item) => item.isActive) ?? versions[0], [versions]);
|
const activeVersion = useMemo(() => versions.find((item) => item.isActive) ?? versions[0], [versions]);
|
||||||
|
const isBackend = target === 'launcher-backend';
|
||||||
|
const backendSource = source?.backend;
|
||||||
|
const clientSource = source?.client;
|
||||||
const artifactName = `autonomy-studio-launcher-${version || activeVersion?.version || '0.0.0'}.deb`;
|
const artifactName = `autonomy-studio-launcher-${version || activeVersion?.version || '0.0.0'}.deb`;
|
||||||
|
const backendImageName = backendSource?.image || 'localhost:5000/studio-launcher-be';
|
||||||
|
const backendImageTag = `${backendImageName.replace(/\/$/, '')}:${version || '0.1.0'}`;
|
||||||
|
const backendDockerfile = backendSource?.dockerfile || 'Dockerfile';
|
||||||
const uploadPath = launcherArtifactKey(version || activeVersion?.version || '0.0.0', branch, commitSha, artifactName);
|
const uploadPath = launcherArtifactKey(version || activeVersion?.version || '0.0.0', branch, commitSha, artifactName);
|
||||||
const downloadUrl = r2PublicBaseUrl ? `${r2PublicBaseUrl.replace(/\/$/, '')}/${encodeObjectKey(uploadPath)}` : '백엔드 R2 설정 기준으로 생성됩니다.';
|
const downloadUrl = r2PublicBaseUrl ? `${r2PublicBaseUrl.replace(/\/$/, '')}/${encodeObjectKey(uploadPath)}` : '백엔드 R2 설정 기준으로 생성됩니다.';
|
||||||
const sortedJobs = useMemo(() => [...jobs].sort((a, b) => jobTime(b) - jobTime(a)), [jobs]);
|
const sortedJobs = useMemo(() => [...jobs].filter((job) => job.target === target).sort((a, b) => jobTime(b) - jobTime(a)), [jobs, target]);
|
||||||
const totalPages = Math.max(1, Math.ceil(sortedJobs.length / launcherBuildJobPageSize));
|
const totalPages = Math.max(1, Math.ceil(sortedJobs.length / launcherBuildJobPageSize));
|
||||||
const currentPage = Math.min(page, totalPages);
|
const currentPage = Math.min(page, totalPages);
|
||||||
const pageStart = (currentPage - 1) * launcherBuildJobPageSize;
|
const pageStart = (currentPage - 1) * launcherBuildJobPageSize;
|
||||||
@@ -93,14 +104,15 @@ export function LauncherBuildPage() {
|
|||||||
|
|
||||||
const refresh = () => {
|
const refresh = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
Promise.all([listLauncherVersions(), listLauncherBuildJobs()])
|
Promise.all([listLauncherVersions(), listLauncherBuildJobs(), getLauncherSource()])
|
||||||
.then(([nextVersions, nextJobs]) => {
|
.then(([nextVersions, nextJobs, nextSource]) => {
|
||||||
setVersions(nextVersions);
|
setVersions(nextVersions);
|
||||||
setJobs(nextJobs);
|
setJobs(nextJobs);
|
||||||
|
setSource(nextSource.source);
|
||||||
const nextVersion = nextVersions.find((item) => item.isActive) ?? nextVersions[0];
|
const nextVersion = nextVersions.find((item) => item.isActive) ?? nextVersions[0];
|
||||||
setVersion(nextVersion?.version ?? '');
|
setVersion(nextVersion?.version ?? '');
|
||||||
setBranch(nextVersion?.branch ?? 'release');
|
setBranch(target === 'launcher-backend' ? nextSource.source.backend?.branch ?? 'release' : nextSource.source.client?.branch ?? nextVersion?.branch ?? 'release');
|
||||||
setCommitSha(nextVersion?.commitSha ?? '');
|
setCommitSha(target === 'launcher-backend' ? nextSource.source.backend?.commitSha ?? '' : nextSource.source.client?.commitSha ?? nextVersion?.commitSha ?? '');
|
||||||
})
|
})
|
||||||
.catch((error: Error) => {
|
.catch((error: Error) => {
|
||||||
toast({ type: 'error', title: '런처 버전 조회 실패', message: error.message });
|
toast({ type: 'error', title: '런처 버전 조회 실패', message: error.message });
|
||||||
@@ -112,6 +124,18 @@ export function LauncherBuildPage() {
|
|||||||
refresh();
|
refresh();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!source) return;
|
||||||
|
if (target === 'launcher-backend') {
|
||||||
|
setBranch(source.backend?.branch ?? 'release');
|
||||||
|
setCommitSha(source.backend?.commitSha ?? '');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setBranch(source.client?.branch ?? activeVersion?.branch ?? 'release');
|
||||||
|
setCommitSha(source.client?.commitSha ?? activeVersion?.commitSha ?? '');
|
||||||
|
}, [activeVersion?.branch, activeVersion?.commitSha, source, target]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!hasActiveJob) return;
|
if (!hasActiveJob) return;
|
||||||
const timer = window.setInterval(() => {
|
const timer = window.setInterval(() => {
|
||||||
@@ -135,14 +159,14 @@ export function LauncherBuildPage() {
|
|||||||
const createJob = () => {
|
const createJob = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
createLauncherBuildJob({
|
createLauncherBuildJob({
|
||||||
target: 'launcher-client',
|
target,
|
||||||
repository: activeVersion?.repository ?? undefined,
|
repository: isBackend ? backendSource?.repository ?? undefined : clientSource?.repository ?? activeVersion?.repository ?? undefined,
|
||||||
branch,
|
branch,
|
||||||
commitSha: commitSha.trim() || undefined,
|
commitSha: commitSha.trim() || undefined,
|
||||||
version: version.trim(),
|
version: version.trim(),
|
||||||
uploadPath,
|
uploadPath: isBackend ? backendDockerfile : uploadPath,
|
||||||
artifact: artifactName,
|
artifact: isBackend ? backendImageName.replace(/^localhost:5000\//, '') : artifactName,
|
||||||
downloadUrl: r2PublicBaseUrl ? downloadUrl : undefined
|
downloadUrl: isBackend ? backendImageTag : r2PublicBaseUrl ? downloadUrl : undefined
|
||||||
})
|
})
|
||||||
.then(({ job }) => {
|
.then(({ job }) => {
|
||||||
setJobs((prev) => [job, ...prev]);
|
setJobs((prev) => [job, ...prev]);
|
||||||
@@ -161,7 +185,7 @@ export function LauncherBuildPage() {
|
|||||||
<PageTitle
|
<PageTitle
|
||||||
eyebrow="런처 운영"
|
eyebrow="런처 운영"
|
||||||
title="빌드 관리"
|
title="빌드 관리"
|
||||||
description="런처 설치 파일을 만들고 내부 파일 서버 업로드 위치를 관리합니다."
|
description="런처 클라이언트 설치 파일과 백엔드 컨테이너 이미지를 구성요소별로 빌드합니다."
|
||||||
actions={
|
actions={
|
||||||
<Button className="h-8 px-3 text-[13px]" onClick={createJob} disabled={!version.trim()}>
|
<Button className="h-8 px-3 text-[13px]" onClick={createJob} disabled={!version.trim()}>
|
||||||
<Play className="size-4" />
|
<Play className="size-4" />
|
||||||
@@ -170,12 +194,21 @@ export function LauncherBuildPage() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<div className="mb-4 flex flex-wrap gap-2">
|
||||||
|
<Button variant={target === 'launcher-client' ? 'default' : 'outline'} onClick={() => setTarget('launcher-client')}>
|
||||||
|
클라이언트
|
||||||
|
</Button>
|
||||||
|
<Button variant={target === 'launcher-backend' ? 'default' : 'outline'} onClick={() => setTarget('launcher-backend')}>
|
||||||
|
백엔드
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="grid gap-4 xl:grid-cols-[420px_minmax(0,1fr)]">
|
<div className="grid gap-4 xl:grid-cols-[420px_minmax(0,1fr)]">
|
||||||
<Card className="min-w-0 overflow-hidden">
|
<Card className="min-w-0 overflow-hidden">
|
||||||
<CardHeader title="빌드 요청" description="브랜치와 커밋 기준으로 런처 설치 파일을 생성합니다." />
|
<CardHeader title="빌드 요청" description={isBackend ? '브랜치와 커밋 기준으로 런처 백엔드 이미지를 빌드하고 레지스트리에 푸시합니다.' : '브랜치와 커밋 기준으로 런처 설치 파일을 생성합니다.'} />
|
||||||
<div className="space-y-4 p-5">
|
<div className="space-y-4 p-5">
|
||||||
<label className="block">
|
<label className="block">
|
||||||
<span className="text-xs font-medium text-muted-foreground">버전</span>
|
<span className="text-xs font-medium text-muted-foreground">{isBackend ? '이미지 태그' : '버전'}</span>
|
||||||
<input className="mt-2 h-9 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground outline-none focus:ring-2 focus:ring-ring" value={version} onChange={(event) => setVersion(event.target.value)} />
|
<input className="mt-2 h-9 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground outline-none focus:ring-2 focus:ring-ring" value={version} onChange={(event) => setVersion(event.target.value)} />
|
||||||
</label>
|
</label>
|
||||||
<label className="block">
|
<label className="block">
|
||||||
@@ -191,18 +224,18 @@ export function LauncherBuildPage() {
|
|||||||
<input className="mt-2 h-9 w-full rounded-md border border-input bg-background px-3 font-mono text-sm text-foreground outline-none placeholder:text-muted-foreground focus:ring-2 focus:ring-ring" value={commitSha} onChange={(event) => setCommitSha(event.target.value)} placeholder="비워두면 브랜치 최신 커밋" />
|
<input className="mt-2 h-9 w-full rounded-md border border-input bg-background px-3 font-mono text-sm text-foreground outline-none placeholder:text-muted-foreground focus:ring-2 focus:ring-ring" value={commitSha} onChange={(event) => setCommitSha(event.target.value)} placeholder="비워두면 브랜치 최신 커밋" />
|
||||||
</label>
|
</label>
|
||||||
<div className="rounded-md border border-border bg-background p-3">
|
<div className="rounded-md border border-border bg-background p-3">
|
||||||
<p className="text-xs text-muted-foreground">예상 산출물</p>
|
<p className="text-xs text-muted-foreground">{isBackend ? '이미지' : '예상 산출물'}</p>
|
||||||
<p className="mt-2 break-all font-mono text-xs text-foreground">{artifactName}</p>
|
<p className="mt-2 break-all font-mono text-xs text-foreground">{isBackend ? backendImageTag : artifactName}</p>
|
||||||
<p className="mt-2 text-xs text-muted-foreground">R2 Object Key</p>
|
<p className="mt-2 text-xs text-muted-foreground">{isBackend ? 'Dockerfile' : 'R2 Object Key'}</p>
|
||||||
<p className="mt-1 break-all font-mono text-xs text-foreground">{uploadPath}</p>
|
<p className="mt-1 break-all font-mono text-xs text-foreground">{isBackend ? backendDockerfile : uploadPath}</p>
|
||||||
<p className="mt-2 text-xs text-muted-foreground">다운로드 URL</p>
|
<p className="mt-2 text-xs text-muted-foreground">{isBackend ? 'Repository' : '다운로드 URL'}</p>
|
||||||
<p className="mt-1 break-all font-mono text-xs text-foreground">{downloadUrl}</p>
|
<p className="mt-1 break-all font-mono text-xs text-foreground">{isBackend ? backendSource?.repository || '-' : downloadUrl}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card className="min-w-0 overflow-hidden">
|
<Card className="min-w-0 overflow-hidden">
|
||||||
<CardHeader title="빌드 작업 목록" description="생성된 런처 빌드 작업과 업로드 계획입니다." />
|
<CardHeader title="빌드 작업 목록" description={isBackend ? '런처 백엔드 이미지 빌드 작업입니다.' : '생성된 런처 클라이언트 빌드 작업과 업로드 계획입니다.'} />
|
||||||
<div className="flex justify-end px-4 pt-4">
|
<div className="flex justify-end px-4 pt-4">
|
||||||
<Button variant="outline" className="h-8 px-3 text-[13px]" onClick={refresh} disabled={loading}>
|
<Button variant="outline" className="h-8 px-3 text-[13px]" onClick={refresh} disabled={loading}>
|
||||||
<RotateCcw className={loading ? 'size-4 animate-spin' : 'size-4'} />
|
<RotateCcw className={loading ? 'size-4 animate-spin' : 'size-4'} />
|
||||||
|
|||||||
@@ -3,57 +3,129 @@ import { useEffect, useMemo, useState } from 'react';
|
|||||||
import { Badge, Button, Card, CardHeader } from '../../components/ui';
|
import { Badge, Button, Card, CardHeader } from '../../components/ui';
|
||||||
import { useToast } from '../../components/toast';
|
import { useToast } from '../../components/toast';
|
||||||
import { PageTitle } from '../../layout/AppLayout';
|
import { PageTitle } from '../../layout/AppLayout';
|
||||||
|
import { cn } from '../../lib/utils';
|
||||||
import type { GiteaRepo } from '../../types/application';
|
import type { GiteaRepo } from '../../types/application';
|
||||||
import { LoadingModal, useMinimumLoading } from '../operations/operation-utils';
|
import { LoadingModal, useMinimumLoading } from '../operations/operation-utils';
|
||||||
import { getLauncherSource, listLauncherVersions, listPlatformRepos, updateLauncherSource, type LauncherVersion } from './launcher-api';
|
import {
|
||||||
|
getLauncherSource,
|
||||||
|
listLauncherVersions,
|
||||||
|
listPlatformRepos,
|
||||||
|
listStudioRepos,
|
||||||
|
updateLauncherSource,
|
||||||
|
type LauncherVersion
|
||||||
|
} from './launcher-api';
|
||||||
|
|
||||||
const giteaBaseUrl = import.meta.env.VITE_GITEA_BASE_URL ?? 'http://localhost:3000';
|
const giteaBaseUrl = import.meta.env.VITE_GITEA_BASE_URL ?? 'http://localhost:3000';
|
||||||
const giteaSshBaseUrl = import.meta.env.VITE_GITEA_SSH_BASE_URL ?? 'ssh://git@localhost:2222';
|
const giteaSshBaseUrl = import.meta.env.VITE_GITEA_SSH_BASE_URL ?? 'ssh://git@localhost:2222';
|
||||||
const giteaAppOrg = import.meta.env.VITE_GITEA_APP_ORG ?? 'platform';
|
const giteaAppOrg = import.meta.env.VITE_GITEA_APP_ORG ?? 'platform';
|
||||||
|
|
||||||
|
type SourceTarget = 'launcher-client' | 'launcher-backend';
|
||||||
|
|
||||||
|
type SourceForm = {
|
||||||
|
repository: string;
|
||||||
|
branch: string;
|
||||||
|
commitSha: string;
|
||||||
|
image: string;
|
||||||
|
dockerfile: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const targetLabels: Record<SourceTarget, { title: string; description: string; defaultOrg: string }> = {
|
||||||
|
'launcher-client': {
|
||||||
|
title: '클라이언트',
|
||||||
|
description: '사용자 PC에 설치되는 Electron .deb 빌드 소스입니다.',
|
||||||
|
defaultOrg: 'platform'
|
||||||
|
},
|
||||||
|
'launcher-backend': {
|
||||||
|
title: '백엔드',
|
||||||
|
description: 'portal-api 런처 백엔드 컨테이너 이미지 빌드 소스입니다.',
|
||||||
|
defaultOrg: 'studio'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function repoFullName(repo: GiteaRepo) {
|
function repoFullName(repo: GiteaRepo) {
|
||||||
return (repo as GiteaRepo & { fullName?: string }).fullName ?? repo.full_name ?? normalizeRepository(repo.name);
|
return (repo as GiteaRepo & { fullName?: string }).fullName ?? repo.full_name ?? normalizeRepository(repo.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeRepository(repository?: string | null) {
|
function normalizeRepository(repository?: string | null, fallbackOrg = giteaAppOrg) {
|
||||||
if (!repository) return '';
|
if (!repository) return '';
|
||||||
const value = repository.replace(/^\/+|\/+$/g, '');
|
const value = repository.replace(/^\/+|\/+$/g, '');
|
||||||
return value.includes('/') ? value : `${giteaAppOrg}/${value}`;
|
return value.includes('/') ? value : `${fallbackOrg}/${value}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function httpCloneUrl(repository?: string | null) {
|
function httpCloneUrl(repository?: string | null, fallbackOrg?: string) {
|
||||||
const normalizedRepository = normalizeRepository(repository);
|
const normalizedRepository = normalizeRepository(repository, fallbackOrg);
|
||||||
return normalizedRepository ? `${giteaBaseUrl.replace(/\/$/, '')}/${normalizedRepository}.git` : '-';
|
return normalizedRepository ? `${giteaBaseUrl.replace(/\/$/, '')}/${normalizedRepository}.git` : '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
function sshCloneUrl(repository?: string | null) {
|
function sshCloneUrl(repository?: string | null, fallbackOrg?: string) {
|
||||||
const normalizedRepository = normalizeRepository(repository);
|
const normalizedRepository = normalizeRepository(repository, fallbackOrg);
|
||||||
return normalizedRepository ? `${giteaSshBaseUrl.replace(/\/$/, '')}/${normalizedRepository}.git` : '-';
|
return normalizedRepository ? `${giteaSshBaseUrl.replace(/\/$/, '')}/${normalizedRepository}.git` : '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function emptyForm(): SourceForm {
|
||||||
|
return {
|
||||||
|
repository: '',
|
||||||
|
branch: 'release',
|
||||||
|
commitSha: '',
|
||||||
|
image: 'localhost:5000/studio-launcher-be',
|
||||||
|
dockerfile: 'Dockerfile'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function LauncherSourcePage() {
|
export function LauncherSourcePage() {
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
const [activeTarget, setActiveTarget] = useState<SourceTarget>('launcher-client');
|
||||||
const [versions, setVersions] = useState<LauncherVersion[]>([]);
|
const [versions, setVersions] = useState<LauncherVersion[]>([]);
|
||||||
const [repos, setRepos] = useState<GiteaRepo[]>([]);
|
const [repos, setRepos] = useState<GiteaRepo[]>([]);
|
||||||
const [repository, setRepository] = useState('');
|
const [forms, setForms] = useState<Record<SourceTarget, SourceForm>>({
|
||||||
const [branch, setBranch] = useState('release');
|
'launcher-client': emptyForm(),
|
||||||
const [commitSha, setCommitSha] = useState('');
|
'launcher-backend': emptyForm()
|
||||||
|
});
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const loadingVisible = useMinimumLoading(loading);
|
const loadingVisible = useMinimumLoading(loading);
|
||||||
|
|
||||||
const activeVersion = useMemo(() => versions.find((version) => version.isActive) ?? versions[0], [versions]);
|
const activeVersion = useMemo(() => versions.find((version) => version.isActive) ?? versions[0], [versions]);
|
||||||
|
const activeForm = forms[activeTarget];
|
||||||
|
const activeTargetMeta = targetLabels[activeTarget];
|
||||||
|
|
||||||
|
const updateForm = (patch: Partial<SourceForm>) => {
|
||||||
|
setForms((prev) => ({
|
||||||
|
...prev,
|
||||||
|
[activeTarget]: {
|
||||||
|
...prev[activeTarget],
|
||||||
|
...patch
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
const refresh = () => {
|
const refresh = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
Promise.all([listLauncherVersions(), listPlatformRepos(), getLauncherSource()])
|
Promise.all([listLauncherVersions(), listPlatformRepos(), listStudioRepos(), getLauncherSource()])
|
||||||
.then(([nextVersions, nextRepos, sourceResult]) => {
|
.then(([nextVersions, platformRepos, studioRepos, sourceResult]) => {
|
||||||
setVersions(nextVersions);
|
const mergedRepos = [...platformRepos, ...studioRepos];
|
||||||
setRepos(nextRepos);
|
|
||||||
const nextVersion = nextVersions.find((version) => version.isActive) ?? nextVersions[0];
|
const nextVersion = nextVersions.find((version) => version.isActive) ?? nextVersions[0];
|
||||||
setRepository(sourceResult.source.repository ?? nextVersion?.repository ?? (nextRepos[0] ? repoFullName(nextRepos[0]) : ''));
|
const clientRepository = sourceResult.source.client?.repository ?? sourceResult.source.repository ?? nextVersion?.repository ?? (platformRepos[0] ? repoFullName(platformRepos[0]) : '');
|
||||||
setBranch(sourceResult.source.branch ?? nextVersion?.branch ?? 'release');
|
const backendRepository = sourceResult.source.backend?.repository ?? (studioRepos[0] ? repoFullName(studioRepos[0]) : '');
|
||||||
setCommitSha(sourceResult.source.commitSha ?? nextVersion?.commitSha ?? '');
|
|
||||||
|
setVersions(nextVersions);
|
||||||
|
setRepos(mergedRepos);
|
||||||
|
setForms({
|
||||||
|
'launcher-client': {
|
||||||
|
repository: clientRepository,
|
||||||
|
branch: sourceResult.source.client?.branch ?? sourceResult.source.branch ?? nextVersion?.branch ?? 'release',
|
||||||
|
commitSha: sourceResult.source.client?.commitSha ?? sourceResult.source.commitSha ?? nextVersion?.commitSha ?? '',
|
||||||
|
image: '',
|
||||||
|
dockerfile: ''
|
||||||
|
},
|
||||||
|
'launcher-backend': {
|
||||||
|
repository: backendRepository,
|
||||||
|
branch: sourceResult.source.backend?.branch ?? 'release',
|
||||||
|
commitSha: sourceResult.source.backend?.commitSha ?? '',
|
||||||
|
image: sourceResult.source.backend?.image ?? 'localhost:5000/studio-launcher-be',
|
||||||
|
dockerfile: sourceResult.source.backend?.dockerfile ?? 'Dockerfile'
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch((error: Error) => {
|
.catch((error: Error) => {
|
||||||
toast({ type: 'error', title: '소스 정보 조회 실패', message: error.message });
|
toast({ type: 'error', title: '소스 정보 조회 실패', message: error.message });
|
||||||
@@ -66,15 +138,18 @@ export function LauncherSourcePage() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const save = () => {
|
const save = () => {
|
||||||
if (!repository.trim()) return;
|
if (!activeForm.repository.trim()) return;
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
updateLauncherSource({
|
updateLauncherSource({
|
||||||
repository: repository.trim(),
|
target: activeTarget,
|
||||||
branch: branch.trim() || undefined,
|
repository: activeForm.repository.trim(),
|
||||||
commitSha: commitSha.trim() || undefined
|
branch: activeForm.branch.trim() || undefined,
|
||||||
|
commitSha: activeForm.commitSha.trim() || undefined,
|
||||||
|
image: activeTarget === 'launcher-backend' ? activeForm.image.trim() || undefined : undefined,
|
||||||
|
dockerfile: activeTarget === 'launcher-backend' ? activeForm.dockerfile.trim() || undefined : undefined
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
toast({ type: 'success', title: '소스 연결', message: '런처 소스 연결을 저장했습니다.' });
|
toast({ type: 'success', title: '소스 연결', message: `${activeTargetMeta.title} 소스 연결을 저장했습니다.` });
|
||||||
refresh();
|
refresh();
|
||||||
})
|
})
|
||||||
.catch((error: Error) => {
|
.catch((error: Error) => {
|
||||||
@@ -93,7 +168,7 @@ export function LauncherSourcePage() {
|
|||||||
<PageTitle
|
<PageTitle
|
||||||
eyebrow="런처 운영"
|
eyebrow="런처 운영"
|
||||||
title="소스 관리"
|
title="소스 관리"
|
||||||
description="런처 클라이언트와 관련 소스 저장소를 연결합니다."
|
description="런처 클라이언트와 백엔드 소스 저장소를 구성요소별로 연결합니다."
|
||||||
actions={
|
actions={
|
||||||
<Button variant="outline" className="h-8 px-3 text-[13px]" onClick={refresh} disabled={loading}>
|
<Button variant="outline" className="h-8 px-3 text-[13px]" onClick={refresh} disabled={loading}>
|
||||||
<RotateCcw className={loading ? 'size-4 animate-spin' : 'size-4'} />
|
<RotateCcw className={loading ? 'size-4 animate-spin' : 'size-4'} />
|
||||||
@@ -102,27 +177,41 @@ export function LauncherSourcePage() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<div className="mb-4 flex flex-wrap gap-2">
|
||||||
|
{(Object.keys(targetLabels) as SourceTarget[]).map((target) => (
|
||||||
|
<Button
|
||||||
|
key={target}
|
||||||
|
variant={activeTarget === target ? 'default' : 'outline'}
|
||||||
|
onClick={() => setActiveTarget(target)}
|
||||||
|
>
|
||||||
|
{targetLabels[target].title}
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="grid gap-4 xl:grid-cols-[minmax(0,620px)_minmax(0,1fr)]">
|
<div className="grid gap-4 xl:grid-cols-[minmax(0,620px)_minmax(0,1fr)]">
|
||||||
<Card className="min-w-0 overflow-hidden">
|
<Card className="min-w-0 overflow-hidden">
|
||||||
<CardHeader title="소스 연결" description="런처 빌드에 사용할 저장소와 기준 브랜치를 선택합니다." />
|
<CardHeader title={`${activeTargetMeta.title} 소스 연결`} description={activeTargetMeta.description} />
|
||||||
<div className="grid gap-4 p-5 md:grid-cols-3">
|
<div className="grid gap-4 p-5 md:grid-cols-3">
|
||||||
<label className="block md:col-span-2">
|
<label className="block md:col-span-2">
|
||||||
<span className="text-xs font-medium text-muted-foreground">저장소</span>
|
<span className="text-xs font-medium text-muted-foreground">저장소</span>
|
||||||
<select
|
<input
|
||||||
className="mt-2 h-9 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground outline-none focus:ring-2 focus:ring-ring"
|
className="mt-2 h-9 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground outline-none placeholder:text-muted-foreground focus:ring-2 focus:ring-ring"
|
||||||
value={repository}
|
value={activeForm.repository}
|
||||||
onChange={(event) => setRepository(event.target.value)}
|
onChange={(event) => updateForm({ repository: event.target.value })}
|
||||||
>
|
list="launcher-source-repositories"
|
||||||
{repos.length === 0 ? <option value="">등록된 저장소 없음</option> : null}
|
placeholder={`${activeTargetMeta.defaultOrg}/repository`}
|
||||||
{repos.map((repo) => <option key={repoFullName(repo)} value={repoFullName(repo)}>{repoFullName(repo)}</option>)}
|
/>
|
||||||
</select>
|
<datalist id="launcher-source-repositories">
|
||||||
|
{repos.map((repo) => <option key={repoFullName(repo)} value={repoFullName(repo)} />)}
|
||||||
|
</datalist>
|
||||||
</label>
|
</label>
|
||||||
<label className="block">
|
<label className="block">
|
||||||
<span className="text-xs font-medium text-muted-foreground">브랜치</span>
|
<span className="text-xs font-medium text-muted-foreground">브랜치</span>
|
||||||
<select
|
<select
|
||||||
className="mt-2 h-9 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground outline-none focus:ring-2 focus:ring-ring"
|
className="mt-2 h-9 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground outline-none focus:ring-2 focus:ring-ring"
|
||||||
value={branch}
|
value={activeForm.branch}
|
||||||
onChange={(event) => setBranch(event.target.value)}
|
onChange={(event) => updateForm({ branch: event.target.value })}
|
||||||
>
|
>
|
||||||
<option value="develop">develop</option>
|
<option value="develop">develop</option>
|
||||||
<option value="release">release</option>
|
<option value="release">release</option>
|
||||||
@@ -133,13 +222,35 @@ export function LauncherSourcePage() {
|
|||||||
<span className="text-xs font-medium text-muted-foreground">Commit SHA</span>
|
<span className="text-xs font-medium text-muted-foreground">Commit SHA</span>
|
||||||
<input
|
<input
|
||||||
className="mt-2 h-9 w-full rounded-md border border-input bg-background px-3 font-mono text-sm text-foreground outline-none placeholder:text-muted-foreground focus:ring-2 focus:ring-ring"
|
className="mt-2 h-9 w-full rounded-md border border-input bg-background px-3 font-mono text-sm text-foreground outline-none placeholder:text-muted-foreground focus:ring-2 focus:ring-ring"
|
||||||
value={commitSha}
|
value={activeForm.commitSha}
|
||||||
onChange={(event) => setCommitSha(event.target.value)}
|
onChange={(event) => updateForm({ commitSha: event.target.value })}
|
||||||
placeholder="비워두면 브랜치 최신 커밋 기준"
|
placeholder="비워두면 브랜치 최신 커밋 기준"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
{activeTarget === 'launcher-backend' ? (
|
||||||
|
<>
|
||||||
|
<label className="block md:col-span-2">
|
||||||
|
<span className="text-xs font-medium text-muted-foreground">이미지 이름</span>
|
||||||
|
<input
|
||||||
|
className="mt-2 h-9 w-full rounded-md border border-input bg-background px-3 font-mono text-sm text-foreground outline-none placeholder:text-muted-foreground focus:ring-2 focus:ring-ring"
|
||||||
|
value={activeForm.image}
|
||||||
|
onChange={(event) => updateForm({ image: event.target.value })}
|
||||||
|
placeholder="localhost:5000/studio-launcher-be"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label className="block">
|
||||||
|
<span className="text-xs font-medium text-muted-foreground">Dockerfile</span>
|
||||||
|
<input
|
||||||
|
className="mt-2 h-9 w-full rounded-md border border-input bg-background px-3 font-mono text-sm text-foreground outline-none placeholder:text-muted-foreground focus:ring-2 focus:ring-ring"
|
||||||
|
value={activeForm.dockerfile}
|
||||||
|
onChange={(event) => updateForm({ dockerfile: event.target.value })}
|
||||||
|
placeholder="Dockerfile"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
<div className="flex justify-end md:col-span-3">
|
<div className="flex justify-end md:col-span-3">
|
||||||
<Button onClick={save} disabled={!repository.trim() || saving}>
|
<Button onClick={save} disabled={!activeForm.repository.trim() || saving}>
|
||||||
<Link2 className="size-4" />
|
<Link2 className="size-4" />
|
||||||
저장
|
저장
|
||||||
</Button>
|
</Button>
|
||||||
@@ -148,17 +259,19 @@ export function LauncherSourcePage() {
|
|||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card className="min-w-0 overflow-hidden">
|
<Card className="min-w-0 overflow-hidden">
|
||||||
<CardHeader title="현재 연결" description="런처 빌드 기준입니다." />
|
<CardHeader title="현재 연결" description={`${activeTargetMeta.title} 빌드 기준입니다.`} />
|
||||||
<div className="space-y-4 p-5 text-sm">
|
<div className="space-y-4 p-5 text-sm">
|
||||||
<div className="flex items-center justify-between gap-3">
|
<div className="flex items-center justify-between gap-3">
|
||||||
<span className="text-muted-foreground">버전</span>
|
<span className="text-muted-foreground">기준</span>
|
||||||
<Badge tone={activeVersion?.isActive ? 'green' : 'neutral'}>{activeVersion?.version ?? '-'}</Badge>
|
<Badge tone={activeTarget === 'launcher-client' && activeVersion?.isActive ? 'green' : 'neutral'}>
|
||||||
|
{activeTarget === 'launcher-client' ? activeVersion?.version ?? '-' : activeForm.image || '-'}
|
||||||
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-xs text-muted-foreground">HTTP Clone URL</p>
|
<p className="text-xs text-muted-foreground">HTTP Clone URL</p>
|
||||||
<div className="mt-2 flex items-center gap-2 rounded-md border border-border bg-background px-3 py-2">
|
<div className="mt-2 flex items-center gap-2 rounded-md border border-border bg-background px-3 py-2">
|
||||||
<p className="min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground">{httpCloneUrl(repository)}</p>
|
<p className="min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground">{httpCloneUrl(activeForm.repository, activeTargetMeta.defaultOrg)}</p>
|
||||||
<Button variant="ghost" className="size-8 px-0" onClick={() => copy(httpCloneUrl(repository))} aria-label="HTTP clone URL 복사">
|
<Button variant="ghost" className="size-8 px-0" onClick={() => copy(httpCloneUrl(activeForm.repository, activeTargetMeta.defaultOrg))} aria-label="HTTP clone URL 복사">
|
||||||
<Copy className="size-4" />
|
<Copy className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -166,14 +279,14 @@ export function LauncherSourcePage() {
|
|||||||
<div>
|
<div>
|
||||||
<p className="text-xs text-muted-foreground">SSH Clone URL</p>
|
<p className="text-xs text-muted-foreground">SSH Clone URL</p>
|
||||||
<div className="mt-2 flex items-center gap-2 rounded-md border border-border bg-background px-3 py-2">
|
<div className="mt-2 flex items-center gap-2 rounded-md border border-border bg-background px-3 py-2">
|
||||||
<p className="min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground">{sshCloneUrl(repository)}</p>
|
<p className="min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground">{sshCloneUrl(activeForm.repository, activeTargetMeta.defaultOrg)}</p>
|
||||||
<Button variant="ghost" className="size-8 px-0" onClick={() => copy(sshCloneUrl(repository))} aria-label="SSH clone URL 복사">
|
<Button variant="ghost" className="size-8 px-0" onClick={() => copy(sshCloneUrl(activeForm.repository, activeTargetMeta.defaultOrg))} aria-label="SSH clone URL 복사">
|
||||||
<Copy className="size-4" />
|
<Copy className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{repository ? (
|
{activeForm.repository ? (
|
||||||
<a className="inline-flex items-center gap-1.5 text-xs text-primary" href={`${giteaBaseUrl.replace(/\/$/, '')}/${normalizeRepository(repository)}`} target="_blank" rel="noreferrer">
|
<a className="inline-flex items-center gap-1.5 text-xs text-primary" href={`${giteaBaseUrl.replace(/\/$/, '')}/${normalizeRepository(activeForm.repository, activeTargetMeta.defaultOrg)}`} target="_blank" rel="noreferrer">
|
||||||
저장소 열기
|
저장소 열기
|
||||||
<ExternalLink className="size-3.5" />
|
<ExternalLink className="size-3.5" />
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -40,6 +40,18 @@ export type LauncherSource = {
|
|||||||
repository?: string | null;
|
repository?: string | null;
|
||||||
branch?: string | null;
|
branch?: string | null;
|
||||||
commitSha?: string | null;
|
commitSha?: string | null;
|
||||||
|
client?: {
|
||||||
|
repository?: string | null;
|
||||||
|
branch?: string | null;
|
||||||
|
commitSha?: string | null;
|
||||||
|
};
|
||||||
|
backend?: {
|
||||||
|
repository?: string | null;
|
||||||
|
branch?: string | null;
|
||||||
|
commitSha?: string | null;
|
||||||
|
image?: string | null;
|
||||||
|
dockerfile?: string | null;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type LauncherAppLink = {
|
export type LauncherAppLink = {
|
||||||
@@ -115,7 +127,14 @@ export function getLauncherSource() {
|
|||||||
return apiRequest<{ source: LauncherSource }>('/launcher/source');
|
return apiRequest<{ source: LauncherSource }>('/launcher/source');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateLauncherSource(input: { repository: string; branch?: string; commitSha?: string }) {
|
export function updateLauncherSource(input: {
|
||||||
|
target?: 'launcher-client' | 'launcher-backend';
|
||||||
|
repository: string;
|
||||||
|
branch?: string;
|
||||||
|
commitSha?: string;
|
||||||
|
image?: string;
|
||||||
|
dockerfile?: string;
|
||||||
|
}) {
|
||||||
return apiRequest<{ source: LauncherSource }>('/launcher/source', {
|
return apiRequest<{ source: LauncherSource }>('/launcher/source', {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
body: JSON.stringify(input)
|
body: JSON.stringify(input)
|
||||||
@@ -127,6 +146,11 @@ export function listPlatformRepos(limit = 50) {
|
|||||||
.then((result) => result.repos);
|
.then((result) => result.repos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function listStudioRepos(limit = 50) {
|
||||||
|
return apiRequest<{ owner: string | null; repos: GiteaRepo[] }>(`/gitea/repos?owner=studio&limit=${limit}`)
|
||||||
|
.then((result) => result.repos);
|
||||||
|
}
|
||||||
|
|
||||||
export function listLauncherBuildJobs() {
|
export function listLauncherBuildJobs() {
|
||||||
return apiRequest<LauncherBuildJob[]>('/launcher/builds');
|
return apiRequest<LauncherBuildJob[]>('/launcher/builds');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user