update
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
export type ProxyInfo = {
|
||||
/**
|
||||
* 代理路径, 比如/root/center, 匹配的路径
|
||||
* 代理路径, 比如/root/home, 匹配的路径
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@ import { LocalProxy, LocalProxyOpts } from './index.ts';
|
||||
import http from 'node:http';
|
||||
import { fileProxy } from './proxy/file-proxy.ts';
|
||||
const localProxy = new LocalProxy({});
|
||||
let home = '/root/center';
|
||||
let home = '/root/home';
|
||||
export const initProxy = (data: LocalProxyOpts & { home?: string }) => {
|
||||
localProxy.pagesDir = data.pagesDir || '';
|
||||
localProxy.watch = data.watch ?? false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export type ProxyInfo = {
|
||||
/**
|
||||
* 代理路径, 比如/root/center, 匹配的路径
|
||||
* 代理路径, 比如/root/home, 匹配的路径
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
|
||||
@@ -10,6 +10,7 @@ export type AssistantInitOptions = {
|
||||
path?: string;
|
||||
init?: boolean;
|
||||
};
|
||||
const randomId = () => Math.random().toString(36).substring(2, 8);
|
||||
/**
|
||||
* 助手初始化类
|
||||
* @class AssistantInit
|
||||
@@ -41,6 +42,7 @@ export class AssistantInit extends AssistantConfig {
|
||||
this.createEnvConfig();
|
||||
this.createOtherConfig();
|
||||
this.initPnpm();
|
||||
this.initIgnore();
|
||||
}
|
||||
get query() {
|
||||
if (!this.#query) {
|
||||
@@ -153,10 +155,46 @@ export class AssistantInit extends AssistantConfig {
|
||||
create,
|
||||
};
|
||||
}
|
||||
initIgnore() {
|
||||
const gitignorePath = path.join(this.configDir, '.gitignore');
|
||||
let content = '';
|
||||
if (checkFileExists(gitignorePath, true)) {
|
||||
content = fs.readFileSync(gitignorePath, 'utf-8');
|
||||
}
|
||||
const ignoreLines = [
|
||||
'node_modules',
|
||||
'.DS_Store',
|
||||
'dist',
|
||||
'pack-dist',
|
||||
'cache-file',
|
||||
'build',
|
||||
'apps/**/node_modules/',
|
||||
'pages/**/node_modules/',
|
||||
'.env',
|
||||
'!.env*development',
|
||||
'.pnpm-store',
|
||||
'.vite',
|
||||
'.astro'
|
||||
];
|
||||
let updated = false;
|
||||
ignoreLines.forEach((line) => {
|
||||
if (!content.includes(line)) {
|
||||
content += `\n${line}`;
|
||||
updated = true;
|
||||
}
|
||||
});
|
||||
if (updated) {
|
||||
fs.writeFileSync(gitignorePath, content.trim() + '\n');
|
||||
console.log(chalk.green('.gitignore 文件更新成功'));
|
||||
}
|
||||
}
|
||||
protected getDefaultInitAssistantConfig() {
|
||||
const id = randomId();
|
||||
return {
|
||||
id,
|
||||
description: '助手配置文件',
|
||||
home: '/root/center',
|
||||
docs: "https://kevisual.cn/root/cli-docs/",
|
||||
home: '/root/home',
|
||||
proxy: [],
|
||||
apiProxyList: [],
|
||||
share: {
|
||||
|
||||
@@ -58,7 +58,7 @@ export const proxyRoute = async (req: http.IncomingMessage, res: http.ServerResp
|
||||
return res.end(`Not Found [${proxyApi.path}] rootPath`);
|
||||
}
|
||||
return fileProxy(req, res, {
|
||||
path: proxyApi.path, // 代理路径, 比如/root/center
|
||||
path: proxyApi.path, // 代理路径, 比如/root/home
|
||||
rootPath: proxyApi.rootPath,
|
||||
...proxyApi,
|
||||
indexPath: _indexPath, // 首页路径
|
||||
|
||||
Reference in New Issue
Block a user