mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 15:09:19 +08:00
feat: 调整部署脚本
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
import { input, password as pwPrompt, select } from '@inquirer/prompts';
|
||||
|
||||
import { loadConfig, saveConfig, updateServiceServerConfig, getServiceConfig, getSshKeyPath, syncServerKeyAuth } from './config.js';
|
||||
import { loadConfig, saveConfig, updateServiceServerConfig, getServiceConfig, getSshKeyPath, syncServerKeyAuth, resolveServiceDeployPath } from './config.js';
|
||||
import {
|
||||
buildAndDeployServices,
|
||||
buildServicesOnly,
|
||||
@@ -61,12 +61,14 @@ async function selectServices(): Promise<Service[]> {
|
||||
return [selected as Service];
|
||||
}
|
||||
|
||||
function showServiceHosts(config: { services: Record<string, Record<string, { server: { host: string; deployPath: string } }>>; currentEnv: string }): string {
|
||||
function showServiceHosts(config: Awaited<ReturnType<typeof loadConfig>>): string {
|
||||
const env = config.currentEnv;
|
||||
const services: Service[] = ['frontend', 'backend', 'license'];
|
||||
return services.map((s) =>
|
||||
` ${SERVICE_LABELS[s]}: ${config.services[s][env].server.host}:${config.services[s][env].server.deployPath}`
|
||||
).join('\n');
|
||||
return services.map((s) => {
|
||||
const cfg = config.services[s][env];
|
||||
const resolved = resolveServiceDeployPath(cfg, s, env);
|
||||
return ` ${SERVICE_LABELS[s]}: ${cfg.server.host} → ${resolved}`;
|
||||
}).join('\n');
|
||||
}
|
||||
|
||||
async function configureService() {
|
||||
@@ -80,7 +82,8 @@ async function configureService() {
|
||||
printBox(`${SERVICE_LABELS[service]} · ${ENV_LABELS[env]} 配置`, [
|
||||
`服务器: ${srv.host}:${srv.port}`,
|
||||
`用户: ${srv.username}`,
|
||||
`部署目录: ${srv.deployPath}`,
|
||||
`部署根目录: ${srv.deployPath}`,
|
||||
`实际目录: ${resolveServiceDeployPath(cfg, service, env)}`,
|
||||
`端口: ${cfg.port}`,
|
||||
`认证方式: ${srv.authType === 'key' ? '密钥' : '密码'}`,
|
||||
].join('\n'));
|
||||
@@ -92,7 +95,7 @@ async function configureService() {
|
||||
{ name: '修改端口', value: 'port' },
|
||||
{ name: '修改服务端口', value: 'svcPort' },
|
||||
{ name: '修改用户名', value: 'username' },
|
||||
{ name: '修改部署目录', value: 'deployPath' },
|
||||
{ name: '修改部署根目录', value: 'deployPath' },
|
||||
{ name: '测试 SSH 连接', value: 'test' },
|
||||
{ name: '配置 SSH 密钥 (首次免密)', value: 'setupKey' },
|
||||
{ name: '返回', value: 'back' },
|
||||
@@ -122,7 +125,13 @@ async function configureService() {
|
||||
break;
|
||||
}
|
||||
case 'deployPath': {
|
||||
const d = await input({ message: '部署目录', default: srv.deployPath });
|
||||
const hint = service === 'frontend'
|
||||
? `部署根目录(实际为 根目录/ecom-dmb-${env}/index)`
|
||||
: `部署根目录(实际为 根目录/ecom-dmb/${service}/${env})`;
|
||||
const d = await input({
|
||||
message: hint,
|
||||
default: srv.deployPath,
|
||||
});
|
||||
await updateServiceServerConfig(service, env, { deployPath: d });
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user