版博士V2.0程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

96 wiersze
2.9 KiB

  1. import { JITI } from 'jiti';
  2. import { JITIOptions } from 'jiti/dist/types';
  3. interface DotenvOptions {
  4. /**
  5. * The project root directory (either absolute or relative to the current working directory).
  6. */
  7. cwd: string;
  8. /**
  9. * What file to look in for environment variables (either absolute or relative
  10. * to the current working directory). For example, `.env`.
  11. */
  12. fileName?: string;
  13. /**
  14. * Whether to interpolate variables within .env.
  15. *
  16. * @example
  17. * ```env
  18. * BASE_DIR="/test"
  19. * # resolves to "/test/further"
  20. * ANOTHER_DIR="${BASE_DIR}/further"
  21. * ```
  22. */
  23. interpolate?: boolean;
  24. /**
  25. * An object describing environment variables (key, value pairs).
  26. */
  27. env?: NodeJS.ProcessEnv;
  28. }
  29. type Env = typeof process.env;
  30. /**
  31. * Load and interpolate environment variables into `process.env`.
  32. * If you need more control (or access to the values), consider using `loadDotenv` instead
  33. *
  34. */
  35. declare function setupDotenv(options: DotenvOptions): Promise<Env>;
  36. /** Load environment variables into an object. */
  37. declare function loadDotenv(options: DotenvOptions): Promise<Env>;
  38. type UserInputConfig = Record<string, any>;
  39. interface ConfigLayerMeta {
  40. name?: string;
  41. [key: string]: any;
  42. }
  43. interface C12InputConfig {
  44. $test?: UserInputConfig;
  45. $development?: UserInputConfig;
  46. $production?: UserInputConfig;
  47. $env?: Record<string, UserInputConfig>;
  48. $meta?: ConfigLayerMeta;
  49. }
  50. interface InputConfig extends C12InputConfig, UserInputConfig {
  51. }
  52. interface SourceOptions {
  53. meta?: ConfigLayerMeta;
  54. overrides?: UserInputConfig;
  55. [key: string]: any;
  56. }
  57. interface ConfigLayer<T extends InputConfig = InputConfig> {
  58. config: T | null;
  59. source?: string;
  60. sourceOptions?: SourceOptions;
  61. meta?: ConfigLayerMeta;
  62. cwd?: string;
  63. configFile?: string;
  64. }
  65. interface ResolvedConfig<T extends InputConfig = InputConfig> extends ConfigLayer<T> {
  66. layers?: ConfigLayer<T>[];
  67. cwd?: string;
  68. }
  69. interface ResolveConfigOptions {
  70. cwd: string;
  71. }
  72. interface LoadConfigOptions<T extends InputConfig = InputConfig> {
  73. name?: string;
  74. cwd?: string;
  75. configFile?: string;
  76. rcFile?: false | string;
  77. globalRc?: boolean;
  78. dotenv?: boolean | DotenvOptions;
  79. envName?: string | false;
  80. packageJson?: boolean | string | string[];
  81. defaults?: T;
  82. defaultConfig?: T;
  83. overrides?: T;
  84. resolve?: (id: string, options: LoadConfigOptions) => null | ResolvedConfig | Promise<ResolvedConfig | null>;
  85. jiti?: JITI;
  86. jitiOptions?: JITIOptions;
  87. extend?: false | {
  88. extendKey?: string | string[];
  89. };
  90. }
  91. declare function loadConfig<T extends InputConfig = InputConfig>(options: LoadConfigOptions<T>): Promise<ResolvedConfig<T>>;
  92. export { C12InputConfig, ConfigLayer, ConfigLayerMeta, DotenvOptions, Env, InputConfig, LoadConfigOptions, ResolveConfigOptions, ResolvedConfig, SourceOptions, UserInputConfig, loadConfig, loadDotenv, setupDotenv };