feat: add app-create and frp commands
This commit is contained in:
@@ -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 || "",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user