feat: update ev cli

This commit is contained in:
2025-05-18 17:59:54 +08:00
parent e9eedcd1bd
commit a05f2cd291
15 changed files with 484 additions and 585 deletions

View File

@@ -48,14 +48,19 @@ type DeleteAppOptions = {
id: string;
type?: appType;
appName?: string;
yes?: boolean;
};
export class AppDownload {
config: AssistantConfig;
constructor(config: AssistantConfig) {
this.config = config;
}
async getRegistry() {
return this.config.getRegistry();
}
async downloadApp(opts: DownloadAppOptions) {
const { id, type = 'web', force } = opts;
const { id, type = 'web', force, yes } = opts;
const configDir = this.config.configDir;
this.config?.checkMounted();
const appsDir = this.config.configPath?.appsDir;
@@ -100,7 +105,7 @@ export class AppDownload {
return confirm;
}
async deleteApp(opts: DeleteAppOptions) {
const { id, type = 'web' } = opts;
const { id, type = 'web', yes = false } = opts;
const appName = opts?.appName || id.split('/').pop();
this.config?.checkMounted();
const appsDir = this.config.configPath?.appsDir;
@@ -119,10 +124,12 @@ export class AppDownload {
deletePath = appPath;
}
if (deletePath && checkFileExists(deletePath)) {
const confirm = await this.confirm(`是否删除 ${deletePath} 应用?`);
if (!confirm) {
console.log('取消删除应用');
return;
if (!yes) {
const confirm = await this.confirm(`是否删除 ${deletePath} 应用?`);
if (!confirm) {
console.log('取消删除应用');
return;
}
}
fs.rmSync(deletePath, { recursive: true });
isDelete = true;

View File

@@ -2,7 +2,7 @@ import { fileProxy, httpProxy, createApiProxy, wsProxy } from '@/module/assistan
import http from 'http';
import { LocalProxy } from './local-proxy.ts';
import { assistantConfig, app } from '@/app.ts';
import { log } from '@/module/logger.ts';
import { log, logger } from '@/module/logger.ts';
const localProxy = new LocalProxy({
assistantConfig,
});
@@ -21,6 +21,7 @@ export const proxyRoute = async (req: http.IncomingMessage, res: http.ServerResp
return;
}
if (pathname.startsWith('/client')) {
logger.info('url', { url: req.url });
console.debug('handle by router');
return;
}
@@ -74,7 +75,7 @@ export const proxyRoute = async (req: http.IncomingMessage, res: http.ServerResp
indexPath: localProxyProxy.indexPath,
});
}
const creatCenterProxy = createApiProxy(_assistantConfig?.pageApi || 'https://kevisual.cn', ['/root']);
const creatCenterProxy = createApiProxy(_assistantConfig?.pageApi || 'https://kevisual.cn', ['/root', '/' + _user]);
const centerProxy = creatCenterProxy.find((item) => pathname.startsWith(item.path));
if (centerProxy) {
return httpProxy(req, res, {