feat: add app-create and frp commands

This commit is contained in:
bipproduction
2025-10-07 16:26:23 +08:00
parent 5ef8241989
commit 1f71d34d97
3 changed files with 169 additions and 24 deletions

View File

@@ -11,6 +11,7 @@ interface FrpConfig {
FRP_USER: string;
FRP_SECRET: string;
FRP_PROTO: string;
FRP_AUTH_TOKEN: string;
}
interface ProxyConf {
@@ -30,17 +31,19 @@ interface ProxyResponse {
proxies?: Proxy[];
}
const templateConfig = `
FRP_HOST=""
FRP_USER=""
FRP_SECRET=""
FRP_AUTH_TOKEN=""`;
async function ensureConfigFile(): Promise<void> {
try {
await fs.access(CONFIG_FILE);
} catch {
const template = `
FRP_HOST=""
FRP_USER=""
FRP_SECRET=""
`;
console.error(`❌ Config not found. Template created at: ${CONFIG_FILE}`);
console.log(template);
console.log(templateConfig);
process.exit(1);
}
}
@@ -66,12 +69,19 @@ async function loadConfig(): Promise<FrpConfig> {
conf[key] = value;
}
if (!conf.FRP_HOST || !conf.FRP_USER || !conf.FRP_SECRET || !conf.FRP_AUTH_TOKEN) {
console.error(`❌ Config not found. Template created at: ${CONFIG_FILE}`);
console.log(raw);
process.exit(1);
}
return {
FRP_HOST: conf.FRP_HOST || "",
FRP_PORT: "443",
FRP_USER: conf.FRP_USER || "",
FRP_SECRET: conf.FRP_SECRET || "",
FRP_PROTO: "https",
FRP_AUTH_TOKEN: conf.FRP_AUTH_TOKEN || "",
};
}