Reset project to README only

This commit is contained in:
2026-05-01 23:14:23 +09:00
parent 53777be675
commit 10e0dd75db
33 changed files with 0 additions and 4155 deletions

View File

@@ -1,100 +0,0 @@
import { existsSync } from "node:fs";
import { spawnSync } from "node:child_process";
import path from "node:path";
import type { AppConfig } from "./config.js";
export interface PythonLaunch {
command: string;
args: string[];
source: "venv" | "configured" | "system";
}
function splitCommandSpec(spec: string): string[] {
return spec.match(/(?:[^\s"]+|"[^"]*")+/g)?.map((part) => part.replace(/^"|"$/g, "")) ?? [];
}
function canRun(command: string, args: string[]): boolean {
const result = spawnSync(command, [...args, "--version"], {
encoding: "utf8",
shell: process.platform === "win32",
});
return result.error == null && result.status === 0;
}
export function resolveLocalAiVenvPath(config: AppConfig): string {
return path.resolve(process.cwd(), config.LOCAL_AI_VENV_PATH);
}
export function resolveLocalAiCachePath(config: AppConfig): string {
return path.resolve(process.cwd(), config.LOCAL_AI_CACHE_DIR);
}
export function resolveLocalAiTtsModelPath(config: AppConfig): string {
return path.resolve(process.cwd(), config.LOCAL_TTS_MODEL_PATH);
}
export function resolveLocalAiTtsVoicesPath(config: AppConfig): string {
return path.resolve(process.cwd(), config.LOCAL_TTS_VOICES_PATH);
}
export function resolveVenvPythonPath(config: AppConfig): string {
const venvPath = resolveLocalAiVenvPath(config);
return process.platform === "win32"
? path.join(venvPath, "Scripts", "python.exe")
: path.join(venvPath, "bin", "python");
}
export function resolvePythonLaunch(config: AppConfig, options?: { preferVenv?: boolean }): PythonLaunch {
const preferVenv = options?.preferVenv ?? true;
const venvPython = resolveVenvPythonPath(config);
if (preferVenv && existsSync(venvPython)) {
return {
command: venvPython,
args: [],
source: "venv",
};
}
const configured = config.LOCAL_AI_PYTHON ? splitCommandSpec(config.LOCAL_AI_PYTHON) : [];
if (configured.length > 0 && canRun(configured[0]!, configured.slice(1))) {
return {
command: configured[0]!,
args: configured.slice(1),
source: "configured",
};
}
const candidates =
process.platform === "win32"
? [
["py", "-3"],
["python"],
["python3"],
]
: [
["python3"],
["python"],
];
for (const [command, ...args] of candidates) {
if (canRun(command, args)) {
return {
command,
args,
source: "system",
};
}
}
throw new Error(
[
"Python 실행 파일을 찾지 못했습니다.",
"1. Python 3.11 이상을 설치",
"2. Windows면 `py -3 --version` 이 되는지 먼저 확인",
"3. 되면 `.env` 에 `LOCAL_AI_PYTHON=py -3` 설정",
"4. 그 다음 `bun run setup:local-ai` 실행",
].join("\n"),
);
}