/**
 * 应用环境检测
 *
 * 
 *
 * 基于 `.env*` 中的 `NEXT_PUBLIC_APP_ENV` 判断当前业务环境。
 *
 * 注意：该变量带 `NEXT_PUBLIC_` 前缀，可同时用于服务端和客户端代码。
 */
export type AppEnv = "development" | "test" | "production";

export class AppEnvUtil {
  private constructor() {}

  static get current(): AppEnv {
    const env = process.env.NEXT_PUBLIC_APP_ENV;
    if (env === "production" || env === "test") return env;
    return "development";
  }

  static isDevelopment(): boolean {
    return AppEnvUtil.current === "development";
  }

  static isProduction(): boolean {
    return AppEnvUtil.current === "production";
  }

  static isTest(): boolean {
    return AppEnvUtil.current === "test";
  }

  static canOutputLogs(): boolean {
    return !AppEnvUtil.isProduction();
  }
}
