refactor: 重构部署功能
This commit is contained in:
@@ -27,6 +27,6 @@ async function initializeApp() {
|
|||||||
|
|
||||||
// 启动应用
|
// 启动应用
|
||||||
initializeApp().catch((error) => {
|
initializeApp().catch((error) => {
|
||||||
console.error('Failed to start application:', error);
|
log.error('APP', 'Failed to start application:', error);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import type { Context } from 'koa';
|
import type { Context } from 'koa';
|
||||||
import { Controller, Get } from '../../decorators/route.ts';
|
import { Controller, Get } from '../../decorators/route.ts';
|
||||||
import { gitea } from '../../libs/gitea.ts';
|
import { gitea } from '../../libs/gitea.ts';
|
||||||
|
import { log } from '../../libs/logger.ts';
|
||||||
import { prisma } from '../../libs/prisma.ts';
|
import { prisma } from '../../libs/prisma.ts';
|
||||||
import { BusinessError } from '../../middlewares/exception.ts';
|
import { BusinessError } from '../../middlewares/exception.ts';
|
||||||
import { getBranchesQuerySchema, getCommitsQuerySchema } from './dto.ts';
|
import { getBranchesQuerySchema, getCommitsQuerySchema } from './dto.ts';
|
||||||
|
|
||||||
|
const TAG = 'Git';
|
||||||
|
|
||||||
@Controller('/git')
|
@Controller('/git')
|
||||||
export class GitController {
|
export class GitController {
|
||||||
@Get('/commits')
|
@Get('/commits')
|
||||||
@@ -30,7 +33,7 @@ export class GitController {
|
|||||||
|
|
||||||
// Get access token from session
|
// Get access token from session
|
||||||
const accessToken = ctx.session?.gitea?.access_token;
|
const accessToken = ctx.session?.gitea?.access_token;
|
||||||
console.log('Access token present:', !!accessToken);
|
log.debug(TAG, 'Access token present: %s', !!accessToken);
|
||||||
|
|
||||||
if (!accessToken) {
|
if (!accessToken) {
|
||||||
throw new BusinessError(
|
throw new BusinessError(
|
||||||
@@ -44,7 +47,7 @@ export class GitController {
|
|||||||
const commits = await gitea.getCommits(owner, repo, accessToken, branch);
|
const commits = await gitea.getCommits(owner, repo, accessToken, branch);
|
||||||
return commits;
|
return commits;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch commits:', error);
|
log.error(TAG, 'Failed to fetch commits:', error);
|
||||||
throw new BusinessError('Failed to fetch commits from Gitea', 1005, 500);
|
throw new BusinessError('Failed to fetch commits from Gitea', 1005, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,7 +83,7 @@ export class GitController {
|
|||||||
const branches = await gitea.getBranches(owner, repo, accessToken);
|
const branches = await gitea.getBranches(owner, repo, accessToken);
|
||||||
return branches;
|
return branches;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch branches:', error);
|
log.error(TAG, 'Failed to fetch branches:', error);
|
||||||
throw new BusinessError('Failed to fetch branches from Gitea', 1006, 500);
|
throw new BusinessError('Failed to fetch branches from Gitea', 1006, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export class PipelineController {
|
|||||||
const templates = await getAvailableTemplates();
|
const templates = await getAvailableTemplates();
|
||||||
return templates;
|
return templates;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to get templates:', error);
|
log.error('pipeline', 'Failed to get templates:', error);
|
||||||
throw new BusinessError('获取模板失败', 3002, 500);
|
throw new BusinessError('获取模板失败', 3002, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ export class PipelineController {
|
|||||||
log.info('pipeline', 'Created pipeline from template: %s', pipeline.name);
|
log.info('pipeline', 'Created pipeline from template: %s', pipeline.name);
|
||||||
return pipeline;
|
return pipeline;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to create pipeline from template:', error);
|
log.error('pipeline', 'Failed to create pipeline from template:', error);
|
||||||
if (error instanceof BusinessError) {
|
if (error instanceof BusinessError) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,27 +68,21 @@ export class ProjectController {
|
|||||||
throw new BusinessError('项目不存在', 1002, 404);
|
throw new BusinessError('项目不存在', 1002, 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取工作目录状态信息
|
// 获取工作目录状态信息(不包含目录大小)
|
||||||
let workspaceStatus = null;
|
let workspaceStatus = null;
|
||||||
if (project.projectDir) {
|
if (project.projectDir) {
|
||||||
try {
|
try {
|
||||||
const status = await GitManager.checkWorkspaceStatus(
|
const status = await GitManager.checkWorkspaceStatus(
|
||||||
project.projectDir,
|
project.projectDir,
|
||||||
);
|
);
|
||||||
let size = 0;
|
|
||||||
let gitInfo = null;
|
let gitInfo = null;
|
||||||
|
|
||||||
if (status.exists && !status.isEmpty) {
|
|
||||||
size = await GitManager.getDirectorySize(project.projectDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status.hasGit) {
|
if (status.hasGit) {
|
||||||
gitInfo = await GitManager.getGitInfo(project.projectDir);
|
gitInfo = await GitManager.getGitInfo(project.projectDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
workspaceStatus = {
|
workspaceStatus = {
|
||||||
...status,
|
...status,
|
||||||
size,
|
|
||||||
gitInfo,
|
gitInfo,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { PipelineRunner } from '../runners/index.ts';
|
import { PipelineRunner } from '../runners/index.ts';
|
||||||
import { prisma } from './prisma.ts';
|
import { prisma } from './prisma.ts';
|
||||||
|
import { log } from '../libs/logger.ts';
|
||||||
|
|
||||||
|
const TAG = 'Queue';
|
||||||
// 存储正在运行的部署任务
|
// 存储正在运行的部署任务
|
||||||
const runningDeployments = new Set<number>();
|
const runningDeployments = new Set<number>();
|
||||||
|
|
||||||
@@ -40,14 +42,14 @@ export class ExecutionQueue {
|
|||||||
* 初始化执行队列,包括恢复未完成的任务
|
* 初始化执行队列,包括恢复未完成的任务
|
||||||
*/
|
*/
|
||||||
public async initialize(): Promise<void> {
|
public async initialize(): Promise<void> {
|
||||||
console.log('Initializing execution queue...');
|
log.info(TAG, 'Initializing execution queue...');
|
||||||
// 恢复未完成的任务
|
// 恢复未完成的任务
|
||||||
await this.recoverPendingDeployments();
|
await this.recoverPendingDeployments();
|
||||||
|
|
||||||
// 启动定时轮询
|
// 启动定时轮询
|
||||||
this.startPolling();
|
this.startPolling();
|
||||||
|
|
||||||
console.log('Execution queue initialized');
|
log.info(TAG, 'Execution queue initialized');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,7 +57,7 @@ export class ExecutionQueue {
|
|||||||
*/
|
*/
|
||||||
private async recoverPendingDeployments(): Promise<void> {
|
private async recoverPendingDeployments(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
console.log('Recovering pending deployments from database...');
|
log.info(TAG, 'Recovering pending deployments from database...');
|
||||||
|
|
||||||
// 查询数据库中状态为pending的部署任务
|
// 查询数据库中状态为pending的部署任务
|
||||||
const pendingDeployments = await prisma.deployment.findMany({
|
const pendingDeployments = await prisma.deployment.findMany({
|
||||||
@@ -69,16 +71,16 @@ export class ExecutionQueue {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`Found ${pendingDeployments.length} pending deployments`);
|
log.info(TAG, `Found ${pendingDeployments.length} pending deployments`);
|
||||||
|
|
||||||
// 将这些任务添加到执行队列中
|
// 将这些任务添加到执行队列中
|
||||||
for (const deployment of pendingDeployments) {
|
for (const deployment of pendingDeployments) {
|
||||||
await this.addTask(deployment.id, deployment.pipelineId);
|
await this.addTask(deployment.id, deployment.pipelineId);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Pending deployments recovery completed');
|
log.info(TAG, 'Pending deployments recovery completed');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to recover pending deployments:', error);
|
log.error(TAG, 'Failed to recover pending deployments:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,12 +89,12 @@ export class ExecutionQueue {
|
|||||||
*/
|
*/
|
||||||
private startPolling(): void {
|
private startPolling(): void {
|
||||||
if (this.isPolling) {
|
if (this.isPolling) {
|
||||||
console.log('Polling is already running');
|
log.info(TAG, 'Polling is already running');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isPolling = true;
|
this.isPolling = true;
|
||||||
console.log(`Starting polling with interval ${POLLING_INTERVAL}ms`);
|
log.info(TAG, `Starting polling with interval ${POLLING_INTERVAL}ms`);
|
||||||
|
|
||||||
// 立即执行一次检查
|
// 立即执行一次检查
|
||||||
this.checkPendingDeployments();
|
this.checkPendingDeployments();
|
||||||
@@ -111,7 +113,7 @@ export class ExecutionQueue {
|
|||||||
clearInterval(pollingTimer);
|
clearInterval(pollingTimer);
|
||||||
pollingTimer = null;
|
pollingTimer = null;
|
||||||
this.isPolling = false;
|
this.isPolling = false;
|
||||||
console.log('Polling stopped');
|
log.info(TAG, 'Polling stopped');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +122,7 @@ export class ExecutionQueue {
|
|||||||
*/
|
*/
|
||||||
private async checkPendingDeployments(): Promise<void> {
|
private async checkPendingDeployments(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
console.log('Checking for pending deployments in database...');
|
log.info(TAG, 'Checking for pending deployments in database...');
|
||||||
|
|
||||||
// 查询数据库中状态为pending的部署任务
|
// 查询数据库中状态为pending的部署任务
|
||||||
const pendingDeployments = await prisma.deployment.findMany({
|
const pendingDeployments = await prisma.deployment.findMany({
|
||||||
@@ -134,7 +136,8 @@ export class ExecutionQueue {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(
|
log.info(
|
||||||
|
TAG,
|
||||||
`Found ${pendingDeployments.length} pending deployments in polling`,
|
`Found ${pendingDeployments.length} pending deployments in polling`,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -142,14 +145,15 @@ export class ExecutionQueue {
|
|||||||
for (const deployment of pendingDeployments) {
|
for (const deployment of pendingDeployments) {
|
||||||
// 检查是否已经在运行队列中
|
// 检查是否已经在运行队列中
|
||||||
if (!runningDeployments.has(deployment.id)) {
|
if (!runningDeployments.has(deployment.id)) {
|
||||||
console.log(
|
log.info(
|
||||||
|
TAG,
|
||||||
`Adding deployment ${deployment.id} to queue from polling`,
|
`Adding deployment ${deployment.id} to queue from polling`,
|
||||||
);
|
);
|
||||||
await this.addTask(deployment.id, deployment.pipelineId);
|
await this.addTask(deployment.id, deployment.pipelineId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to check pending deployments:', error);
|
log.error(TAG, 'Failed to check pending deployments:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +168,7 @@ export class ExecutionQueue {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// 检查是否已经在运行队列中
|
// 检查是否已经在运行队列中
|
||||||
if (runningDeployments.has(deploymentId)) {
|
if (runningDeployments.has(deploymentId)) {
|
||||||
console.log(`Deployment ${deploymentId} is already queued or running`);
|
log.info(TAG, `Deployment ${deploymentId} is already queued or running`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +198,7 @@ export class ExecutionQueue {
|
|||||||
// 执行流水线
|
// 执行流水线
|
||||||
await this.executePipeline(task.deploymentId, task.pipelineId);
|
await this.executePipeline(task.deploymentId, task.pipelineId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('执行流水线失败:', error);
|
log.error(TAG, '执行流水线失败:', error);
|
||||||
// 这里可以添加更多的错误处理逻辑
|
// 这里可以添加更多的错误处理逻辑
|
||||||
} finally {
|
} finally {
|
||||||
// 从运行队列中移除
|
// 从运行队列中移除
|
||||||
@@ -245,7 +249,7 @@ export class ExecutionQueue {
|
|||||||
);
|
);
|
||||||
await runner.run(pipelineId);
|
await runner.run(pipelineId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('执行流水线失败:', error);
|
log.error(TAG, '执行流水线失败:', error);
|
||||||
// 错误处理可以在这里添加,比如更新部署状态为失败
|
// 错误处理可以在这里添加,比如更新部署状态为失败
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
import { log } from './logger.ts';
|
||||||
|
|
||||||
|
const TAG = 'Gitea';
|
||||||
|
|
||||||
interface TokenResponse {
|
interface TokenResponse {
|
||||||
access_token: string;
|
access_token: string;
|
||||||
token_type: string;
|
token_type: string;
|
||||||
@@ -43,7 +47,7 @@ class Gitea {
|
|||||||
|
|
||||||
async getToken(code: string) {
|
async getToken(code: string) {
|
||||||
const { giteaUrl, clientId, clientSecret, redirectUri } = this.config;
|
const { giteaUrl, clientId, clientSecret, redirectUri } = this.config;
|
||||||
console.log('this.config', this.config);
|
log.debug(TAG, 'Gitea token request started');
|
||||||
const response = await fetch(`${giteaUrl}/login/oauth/access_token`, {
|
const response = await fetch(`${giteaUrl}/login/oauth/access_token`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: this.getHeaders(),
|
headers: this.getHeaders(),
|
||||||
@@ -56,7 +60,15 @@ class Gitea {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
console.log(await response.json());
|
const payload = await response
|
||||||
|
.json()
|
||||||
|
.catch(() => null as unknown);
|
||||||
|
log.error(
|
||||||
|
TAG,
|
||||||
|
'Gitea token request failed: status=%d payload=%o',
|
||||||
|
response.status,
|
||||||
|
payload,
|
||||||
|
);
|
||||||
throw new Error(`Fetch failed: ${response.status}`);
|
throw new Error(`Fetch failed: ${response.status}`);
|
||||||
}
|
}
|
||||||
return (await response.json()) as TokenResponse;
|
return (await response.json()) as TokenResponse;
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import { prisma } from './prisma.ts';
|
import { prisma } from './prisma.ts';
|
||||||
|
import { log } from './logger.ts';
|
||||||
|
|
||||||
|
const TAG = 'PipelineTemplate';
|
||||||
|
|
||||||
// 默认流水线模板
|
// 默认流水线模板
|
||||||
export interface PipelineTemplate {
|
export interface PipelineTemplate {
|
||||||
@@ -52,7 +55,7 @@ export const DEFAULT_PIPELINE_TEMPLATES: PipelineTemplate[] = [
|
|||||||
* 初始化系统默认流水线模板
|
* 初始化系统默认流水线模板
|
||||||
*/
|
*/
|
||||||
export async function initializePipelineTemplates(): Promise<void> {
|
export async function initializePipelineTemplates(): Promise<void> {
|
||||||
console.log('Initializing pipeline templates...');
|
log.info(TAG, 'Initializing pipeline templates...');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 检查是否已经存在模板流水线
|
// 检查是否已经存在模板流水线
|
||||||
@@ -67,7 +70,7 @@ export async function initializePipelineTemplates(): Promise<void> {
|
|||||||
|
|
||||||
// 如果没有现有的模板,则创建默认模板
|
// 如果没有现有的模板,则创建默认模板
|
||||||
if (existingTemplates.length === 0) {
|
if (existingTemplates.length === 0) {
|
||||||
console.log('Creating default pipeline templates...');
|
log.info(TAG, 'Creating default pipeline templates...');
|
||||||
|
|
||||||
for (const template of DEFAULT_PIPELINE_TEMPLATES) {
|
for (const template of DEFAULT_PIPELINE_TEMPLATES) {
|
||||||
// 创建模板流水线(使用负数ID表示模板)
|
// 创建模板流水线(使用负数ID表示模板)
|
||||||
@@ -97,15 +100,15 @@ export async function initializePipelineTemplates(): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Created template: ${template.name}`);
|
log.info(TAG, `Created template: ${template.name}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('Pipeline templates already exist, skipping initialization');
|
log.info(TAG, 'Pipeline templates already exist, skipping initialization');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Pipeline templates initialization completed');
|
log.info(TAG, 'Pipeline templates initialization completed');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to initialize pipeline templates:', error);
|
log.error(TAG, 'Failed to initialize pipeline templates:', error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,7 +139,7 @@ export async function getAvailableTemplates(): Promise<
|
|||||||
description: template.description || '',
|
description: template.description || '',
|
||||||
}));
|
}));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to get pipeline templates:', error);
|
log.error(TAG, 'Failed to get pipeline templates:', error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,12 +208,10 @@ export async function createPipelineFromTemplate(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
log.info(TAG, `Created pipeline from template ${templateId}: ${newPipeline.name}`);
|
||||||
`Created pipeline from template ${templateId}: ${newPipeline.name}`,
|
|
||||||
);
|
|
||||||
return newPipeline.id;
|
return newPipeline.id;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to create pipeline from template:', error);
|
log.error(TAG, 'Failed to create pipeline from template:', error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import {
|
|||||||
type RouteMetadata,
|
type RouteMetadata,
|
||||||
} from '../decorators/route.ts';
|
} from '../decorators/route.ts';
|
||||||
import { createSuccessResponse } from '../middlewares/exception.ts';
|
import { createSuccessResponse } from '../middlewares/exception.ts';
|
||||||
|
import { log } from './logger.ts';
|
||||||
|
|
||||||
|
const TAG = 'RouteScanner';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 控制器类型
|
* 控制器类型
|
||||||
@@ -79,7 +82,7 @@ export class RouteScanner {
|
|||||||
this.router.patch(fullPath, handler);
|
this.router.patch(fullPath, handler);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.warn(`未支持的HTTP方法: ${route.method}`);
|
log.info(TAG, `未支持的HTTP方法: ${route.method}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -221,7 +221,7 @@ export class PipelineRunner {
|
|||||||
const userEnvVars = JSON.parse(deployment.envVars);
|
const userEnvVars = JSON.parse(deployment.envVars);
|
||||||
Object.assign(envVars, userEnvVars);
|
Object.assign(envVars, userEnvVars);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('解析环境变量失败:', error);
|
log.error(this.TAG, '解析环境变量失败:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -729,20 +729,6 @@ function ProjectDetailPage() {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取选中的流水线
|
|
||||||
const _selectedPipeline = pipelines.find(
|
|
||||||
(pipeline) => pipeline.id === selectedPipelineId,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 格式化文件大小
|
|
||||||
const formatSize = (bytes: number): string => {
|
|
||||||
if (bytes === 0) return '0 B';
|
|
||||||
const k = 1024;
|
|
||||||
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
||||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
||||||
return `${(bytes / k ** i).toFixed(2)} ${sizes[i]}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 获取工作目录状态标签
|
// 获取工作目录状态标签
|
||||||
const getWorkspaceStatusTag = (
|
const getWorkspaceStatusTag = (
|
||||||
status: string,
|
status: string,
|
||||||
@@ -784,12 +770,6 @@ function ProjectDetailPage() {
|
|||||||
label: '状态',
|
label: '状态',
|
||||||
value: <Tag color={statusInfo.color}>{statusInfo.text}</Tag>,
|
value: <Tag color={statusInfo.color}>{statusInfo.text}</Tag>,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: '目录大小',
|
|
||||||
value: workspaceStatus.size
|
|
||||||
? formatSize(workspaceStatus.size)
|
|
||||||
: '-',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: '当前分支',
|
label: '当前分支',
|
||||||
value: workspaceStatus.gitInfo?.branch || '-',
|
value: workspaceStatus.gitInfo?.branch || '-',
|
||||||
@@ -797,7 +777,7 @@ function ProjectDetailPage() {
|
|||||||
{
|
{
|
||||||
label: '最后提交',
|
label: '最后提交',
|
||||||
value: workspaceStatus.gitInfo?.lastCommit ? (
|
value: workspaceStatus.gitInfo?.lastCommit ? (
|
||||||
<Space direction="vertical" size="mini">
|
<Space size="small">
|
||||||
<Typography.Text code>
|
<Typography.Text code>
|
||||||
{workspaceStatus.gitInfo.lastCommit}
|
{workspaceStatus.gitInfo.lastCommit}
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Collapse,
|
|
||||||
Form,
|
Form,
|
||||||
Input,
|
Input,
|
||||||
Message,
|
Message,
|
||||||
Modal,
|
Modal,
|
||||||
} from '@arco-design/web-react';
|
} from '@arco-design/web-react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import EnvPresetsEditor from '../../detail/components/EnvPresetsEditor';
|
|
||||||
import type { Project } from '../../types';
|
import type { Project } from '../../types';
|
||||||
import { projectService } from '../service';
|
import { projectService } from '../service';
|
||||||
|
|
||||||
@@ -30,15 +28,7 @@ function CreateProjectModal({
|
|||||||
const values = await form.validate();
|
const values = await form.validate();
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
// 序列化环境预设
|
const newProject = await projectService.create(values);
|
||||||
const submitData = {
|
|
||||||
...values,
|
|
||||||
envPresets: values.envPresets
|
|
||||||
? JSON.stringify(values.envPresets)
|
|
||||||
: undefined,
|
|
||||||
};
|
|
||||||
|
|
||||||
const newProject = await projectService.create(submitData);
|
|
||||||
|
|
||||||
Message.success('项目创建成功');
|
Message.success('项目创建成功');
|
||||||
onSuccess(newProject);
|
onSuccess(newProject);
|
||||||
@@ -142,14 +132,6 @@ function CreateProjectModal({
|
|||||||
>
|
>
|
||||||
<Input placeholder="请输入绝对路径,如: /data/projects/my-app" />
|
<Input placeholder="请输入绝对路径,如: /data/projects/my-app" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Collapse defaultActiveKey={[]} style={{ marginTop: 16 }}>
|
|
||||||
<Collapse.Item header="环境变量预设配置(可选)" name="envPresets">
|
|
||||||
<Form.Item field="envPresets" noStyle>
|
|
||||||
<EnvPresetsEditor />
|
|
||||||
</Form.Item>
|
|
||||||
</Collapse.Item>
|
|
||||||
</Collapse>
|
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -102,22 +102,25 @@ related:
|
|||||||
|
|
||||||
### 已完成(后端)
|
### 已完成(后端)
|
||||||
|
|
||||||
- ✅ Prisma Schema:在 Project 表添加 `envPresets` 字段(String? 类型,存储 JSON)
|
- [x] Prisma Schema:在 Project 表添加 `envPresets` 字段(String? 类型,存储 JSON)
|
||||||
- ✅ 移除部署创建/重试接口中的 `sparseCheckoutPaths` 写入
|
- [x] 移除部署创建/重试接口中的 `sparseCheckoutPaths` 写入
|
||||||
- ✅ 在部署创建接口添加环境校验:验证 env 是否在项目 envPresets 的 options 中
|
- [x] 在部署创建接口添加环境校验:验证 env 是否在项目 envPresets 的 options 中
|
||||||
- ✅ 更新 project DTO 和 controller 支持 envPresets 读写
|
- [x] 更新 project DTO 和 controller 支持 envPresets 读写
|
||||||
- ✅ 移除 pipeline-runner 中的 `SPARSE_CHECKOUT_PATHS` 环境变量
|
- [x] 移除 pipeline-runner 中的 `SPARSE_CHECKOUT_PATHS` 环境变量
|
||||||
- ✅ 生成 Prisma Client
|
- [x] 生成 Prisma Client
|
||||||
|
- [x] 移除项目详情接口中的目录大小计算(保留工作目录状态其他信息)
|
||||||
|
|
||||||
### 已完成(前端)
|
### 已完成(前端)
|
||||||
|
|
||||||
- ✅ 创建 EnvPresetsEditor 组件(支持单选、多选、输入框类型)
|
- [x] 创建 EnvPresetsEditor 组件(支持单选、多选、输入框类型)
|
||||||
- ✅ 在 CreateProjectModal 和 EditProjectModal 中集成环境预设编辑器
|
- [x] 在 CreateProjectModal 和 EditProjectModal 中集成环境预设编辑器
|
||||||
- ✅ 从 DeployModal 移除稀疏检出表单项
|
- [x] 从 DeployModal 移除稀疏检出表单项
|
||||||
- ✅ 在 DeployModal 中从项目 envPresets 读取环境选项并展示
|
- [x] 在 DeployModal 中从项目 envPresets 读取环境选项并展示
|
||||||
- ✅ 移除 DeployModal 中的动态环境变量列表(envVars Form.List)
|
- [x] 移除 DeployModal 中的动态环境变量列表(envVars Form.List)
|
||||||
- ✅ 从类型定义中移除 sparseCheckoutPaths 字段
|
- [x] 从类型定义中移除 sparseCheckoutPaths 字段
|
||||||
- ✅ 在项目详情页项目设置 tab 中添加环境变量预设的查看和编辑功能
|
- [x] 在项目详情页项目设置 tab 中添加环境变量预设的查看和编辑功能
|
||||||
|
- [x] 移除创建项目时增加环境变量预设的功能,因为编辑环境变量预设的功能放到了项目编详细页面
|
||||||
|
- [x] 移除项目详情页项目设置 tab 中的目录大小显示(保留工作目录状态、当前分支、最后提交等信息)
|
||||||
|
|
||||||
### 待定问题
|
### 待定问题
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user