@adonisjs/env 6.0.1 → 6.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -139,6 +139,18 @@ editor.add('HOST', 'localhost')
139
139
  await editor.save()
140
140
  ```
141
141
 
142
+ You can also insert an empty value for the `.env.example` file by setting the last argument to `true`.
143
+
144
+ ```ts
145
+ editor.add('SECRET_VARIABLE', 'secret-value', true)
146
+ ```
147
+
148
+ This will add the following line to the `.env.example` file.
149
+
150
+ ```env
151
+ SECRET_VARIABLE=
152
+ ```
153
+
142
154
  ## Known Exceptions
143
155
 
144
156
  ### E_INVALID_ENV_VARIABLES
@@ -93,4 +93,4 @@ export {
93
93
  debug_default,
94
94
  EnvLoader
95
95
  };
96
- //# sourceMappingURL=chunk-H6UKLEIO.js.map
96
+ //# sourceMappingURL=chunk-VIQ26ZGM.js.map
package/build/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  EnvLoader,
3
3
  __export,
4
4
  debug_default
5
- } from "./chunk-H6UKLEIO.js";
5
+ } from "./chunk-VIQ26ZGM.js";
6
6
 
7
7
  // src/env.ts
8
8
  import { schema as envSchema } from "@poppinss/validator-lite";
@@ -160,27 +160,26 @@ var EnvParser = class _EnvParser {
160
160
  const envCollection = dotenv.parse(this.#envContents.trim());
161
161
  const identifiers = Object.keys(_EnvParser.#identifiers);
162
162
  let result = {};
163
- $keyLoop:
164
- for (const key in envCollection) {
165
- const value = this.#getValue(key, envCollection);
166
- if (value.includes(":")) {
167
- for (const identifier of identifiers) {
168
- if (value.startsWith(`${identifier}:`)) {
169
- result[key] = await _EnvParser.#identifiers[identifier](
170
- value.substring(identifier.length + 1)
171
- );
172
- continue $keyLoop;
173
- }
174
- if (value.startsWith(`${identifier}\\:`)) {
175
- result[key] = identifier + value.substring(identifier.length + 1);
176
- continue $keyLoop;
177
- }
163
+ $keyLoop: for (const key in envCollection) {
164
+ const value = this.#getValue(key, envCollection);
165
+ if (value.includes(":")) {
166
+ for (const identifier of identifiers) {
167
+ if (value.startsWith(`${identifier}:`)) {
168
+ result[key] = await _EnvParser.#identifiers[identifier](
169
+ value.substring(identifier.length + 1)
170
+ );
171
+ continue $keyLoop;
172
+ }
173
+ if (value.startsWith(`${identifier}\\:`)) {
174
+ result[key] = identifier + value.substring(identifier.length + 1);
175
+ continue $keyLoop;
178
176
  }
179
- result[key] = value;
180
- } else {
181
- result[key] = value;
182
177
  }
178
+ result[key] = value;
179
+ } else {
180
+ result[key] = value;
183
181
  }
182
+ }
184
183
  return result;
185
184
  }
186
185
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/env.ts","../src/errors.ts","../src/validator.ts","../src/parser.ts","../src/processor.ts"],"sourcesContent":["/*\n * @adonisjs/env\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { schema as envSchema, type ValidateFn } from '@poppinss/validator-lite'\nimport { EnvValidator } from './validator.js'\nimport { EnvProcessor } from './processor.js'\nimport { EnvParser } from './parser.js'\n\n/**\n * A wrapper over \"process.env\" with types information.\n *\n * ```ts\n * const validate = Env.rules({\n * PORT: Env.schema.number()\n * })\n *\n * const validatedEnvVars = validate(process.env)\n *\n * const env = new EnvValues(validatedEnvVars)\n * env.get('PORT') // type === number\n * ```\n */\nexport class Env<EnvValues extends Record<string, any>> {\n /**\n * A cache of env values\n */\n #values: EnvValues\n\n constructor(values: EnvValues) {\n this.#values = values\n }\n\n /**\n * Create an instance of the env class by validating the\n * environment variables. Also, the `.env` files are\n * loaded from the appRoot\n */\n static async create<Schema extends { [key: string]: ValidateFn<unknown> }>(\n appRoot: URL,\n schema: Schema\n ): Promise<\n Env<{\n [K in keyof Schema]: ReturnType<Schema[K]>\n }>\n > {\n const values = await new EnvProcessor(appRoot).process()\n const validator = this.rules(schema)\n return new Env(validator.validate(values))\n }\n\n /**\n * Define an identifier for any environment value. The callback is invoked\n * when the value match the identifier to modify its interpolation.\n */\n static identifier(name: string, callback: (value: string) => Promise<string> | string): void {\n EnvParser.identifier(name, callback)\n }\n\n /**\n * Remove an identifier\n */\n static removeIdentifier(name: string): void {\n EnvParser.removeIdentifier(name)\n }\n\n /**\n * The schema builder for defining validation rules\n */\n static schema = envSchema\n\n /**\n * Define the validation rules for validating environment\n * variables. The return value is an instance of the\n * env validator\n */\n static rules<T extends { [key: string]: ValidateFn<unknown> }>(schema: T): EnvValidator<T> {\n const validator = new EnvValidator<T>(schema)\n return validator\n }\n\n /**\n * Get the value of an environment variable by key. The values are\n * lookedup inside the validated environment and \"process.env\"\n * is used as a fallback.\n *\n * The second param is the default value, which is returned when\n * the environment variable does not exist.\n *\n * ```ts\n * Env.get('PORT')\n *\n * // With default value\n * Env.get('PORT', 3000)\n * ```\n */\n get<K extends keyof EnvValues>(key: K): EnvValues[K]\n get<K extends keyof EnvValues>(\n key: K,\n defaultValue: Exclude<EnvValues[K], undefined>\n ): Exclude<EnvValues[K], undefined>\n get(key: string): string | undefined\n get(key: string, defaultValue: string): string\n get(key: string, defaultValue?: any): any {\n /**\n * Return cached value\n */\n if (this.#values[key] !== undefined) {\n return this.#values[key]\n }\n\n /**\n * Get value from \"process.env\" and update the cache\n */\n const envValue = process.env[key]\n if (envValue) {\n return envValue\n }\n\n /**\n * Return default value when unable to lookup any other value\n */\n return defaultValue\n }\n\n /**\n * Update/set value of an environment variable.\n *\n * The value is not casted/validated using the validator, so make sure\n * to set the correct data type.\n *\n * ```ts\n * Env.set('PORT', 3000)\n *\n * Env.get('PORT') === 3000 // true\n * process.env.PORT === '3000' // true\n * ```\n */\n set<K extends keyof EnvValues>(key: K, value: EnvValues[K]): void\n set(key: string, value: string): void\n set(key: string | keyof EnvValues, value: any): void {\n this.#values[key] = value\n process.env[key as string] = value\n }\n}\n","/*\n * @adonisjs/env\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { createError, Exception } from '@poppinss/utils'\n\n/**\n * Exception raised when one or more env variables\n * are invalid\n */\nexport const E_INVALID_ENV_VARIABLES = class EnvValidationException extends Exception {\n static message = 'Validation failed for one or more environment variables'\n static code = 'E_INVALID_ENV_VARIABLES'\n help: string = ''\n}\n\nexport const E_IDENTIFIER_ALREADY_DEFINED = createError<[string]>(\n 'The identifier \"%s\" is already defined',\n 'E_IDENTIFIER_ALREADY_DEFINED',\n 500\n)\n","/*\n * @adonisjs/env\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { Exception } from '@poppinss/utils'\nimport { ValidateFn } from '@poppinss/validator-lite'\n\nimport { E_INVALID_ENV_VARIABLES } from './errors.js'\n\n/**\n * Exposes the API to validate environment variables against a\n * pre-defined schema.\n *\n * The class is not exported in the main API and used internally.\n */\nexport class EnvValidator<Schema extends { [key: string]: ValidateFn<unknown> }> {\n #schema: Schema\n #error: Exception\n\n constructor(schema: Schema) {\n this.#schema = schema\n this.#error = new E_INVALID_ENV_VARIABLES()\n }\n\n /**\n * Accepts an object of values to validate against the pre-defined\n * schema.\n *\n * The return value is a merged copy of the original object and the\n * values mutated by the schema validator.\n */\n validate(values: { [K: string]: string | undefined }): {\n [K in keyof Schema]: ReturnType<Schema[K]>\n } {\n const help: string[] = []\n\n const validated = Object.keys(this.#schema).reduce(\n (result, key) => {\n const value = process.env[key] || values[key]\n\n try {\n result[key] = this.#schema[key](key, value) as any\n } catch (error) {\n help.push(`- ${error.message}`)\n }\n return result\n },\n { ...values }\n ) as { [K in keyof Schema]: ReturnType<Schema[K]> }\n\n if (help.length) {\n this.#error.help = help.join('\\n')\n throw this.#error\n }\n\n return validated\n }\n}\n","/*\n * @adonisjs/env\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport dotenv, { DotenvParseOutput } from 'dotenv'\nimport { E_IDENTIFIER_ALREADY_DEFINED } from './errors.js'\n\n/**\n * Env parser parses the environment variables from a string formatted\n * as a key-value pair seperated using an `=`. For example:\n *\n * ```dotenv\n * PORT=3333\n * HOST=127.0.0.1\n * ```\n *\n * The variables can reference other environment variables as well using `$`.\n * For example:\n *\n * ```dotenv\n * PORT=3333\n * REDIS_PORT=$PORT\n * ```\n *\n * The variables using characters other than letters can wrap variable\n * named inside a curly brace.\n *\n * ```dotenv\n * APP-PORT=3333\n * REDIS_PORT=${APP-PORT}\n * ```\n *\n * You can escape the `$` sign with a backtick.\n *\n * ```dotenv\n * REDIS_PASSWORD=foo\\$123\n * ```\n *\n * ## Usage\n *\n * ```ts\n * const parser = new EnvParser(envContents)\n * const output = parser.parse()\n *\n * // The output is a key-value pair\n * ```\n */\nexport class EnvParser {\n #envContents: string\n #preferProcessEnv: boolean = true\n static #identifiers: Record<string, (value: string) => Promise<string> | string> = {}\n\n constructor(envContents: string, options?: { ignoreProcessEnv: boolean }) {\n if (options?.ignoreProcessEnv) {\n this.#preferProcessEnv = false\n }\n\n this.#envContents = envContents\n }\n\n /**\n * Define an identifier for any environment value. The callback is invoked\n * when the value match the identifier to modify its interpolation.\n */\n static identifier(name: string, callback: (value: string) => Promise<string> | string): void {\n if (this.#identifiers[name]) {\n throw new E_IDENTIFIER_ALREADY_DEFINED([name])\n }\n\n this.#identifiers[name] = callback\n }\n\n /**\n * Remove an identifier\n */\n static removeIdentifier(name: string): void {\n delete this.#identifiers[name]\n }\n\n /**\n * Returns the value from the parsed object\n */\n #getValue(key: string, parsed: DotenvParseOutput): string {\n if (this.#preferProcessEnv && process.env[key]) {\n return process.env[key]!\n }\n\n if (parsed[key]) {\n return this.#interpolate(parsed[key], parsed)\n }\n\n return process.env[key] || ''\n }\n\n /**\n * Interpolating the token wrapped inside the mustache braces.\n */\n #interpolateMustache(token: string, parsed: DotenvParseOutput) {\n /**\n * Finding the closing brace. If closing brace is missing, we\n * consider the block as a normal string\n */\n const closingBrace = token.indexOf('}')\n if (closingBrace === -1) {\n return token\n }\n\n /**\n * Then we pull everything until the closing brace, except\n * the opening brace and trim off all white spaces.\n */\n const varReference = token.slice(1, closingBrace).trim()\n\n /**\n * Getting the value of the reference inside the braces\n */\n return `${this.#getValue(varReference, parsed)}${token.slice(closingBrace + 1)}`\n }\n\n /**\n * Interpolating the variable reference starting with a\n * `$`. We only capture numbers,letter and underscore.\n * For other characters, one can use the mustache\n * braces.\n */\n #interpolateVariable(token: string, parsed: any) {\n return token.replace(/[a-zA-Z0-9_]+/, (key) => {\n return this.#getValue(key, parsed)\n })\n }\n\n /**\n * Interpolates the referenced values\n */\n #interpolate(value: string, parsed: DotenvParseOutput): string {\n const tokens = value.split('$')\n\n let newValue = ''\n let skipNextToken = true\n\n tokens.forEach((token) => {\n /**\n * If the value is an escaped sequence, then we replace it\n * with a `$` and then skip the next token.\n */\n if (token === '\\\\') {\n newValue += '$'\n skipNextToken = true\n return\n }\n\n /**\n * Use the value as it is when \"skipNextToken\" is set to true.\n */\n if (skipNextToken) {\n /**\n * Replace the ending escape sequence with a $\n */\n newValue += token.replace(/\\\\$/, '$')\n /**\n * and then skip the next token if it ends with escape sequence\n */\n if (token.endsWith('\\\\')) {\n return\n }\n } else {\n /**\n * Handle mustache block\n */\n if (token.startsWith('{')) {\n newValue += this.#interpolateMustache(token, parsed)\n return\n }\n\n /**\n * Process all words as variable\n */\n newValue += this.#interpolateVariable(token, parsed)\n }\n\n /**\n * Process next token\n */\n skipNextToken = false\n })\n\n return newValue\n }\n\n /**\n * Parse the env string to an object of environment variables.\n */\n async parse(): Promise<DotenvParseOutput> {\n const envCollection = dotenv.parse(this.#envContents.trim())\n const identifiers = Object.keys(EnvParser.#identifiers)\n let result: DotenvParseOutput = {}\n\n $keyLoop: for (const key in envCollection) {\n const value = this.#getValue(key, envCollection)\n\n if (value.includes(':')) {\n for (const identifier of identifiers) {\n if (value.startsWith(`${identifier}:`)) {\n result[key] = await EnvParser.#identifiers[identifier](\n value.substring(identifier.length + 1)\n )\n\n continue $keyLoop\n }\n\n if (value.startsWith(`${identifier}\\\\:`)) {\n result[key] = identifier + value.substring(identifier.length + 1)\n\n continue $keyLoop\n }\n }\n\n result[key] = value\n } else {\n result[key] = value\n }\n }\n\n return result\n }\n}\n","/*\n * @adonisjs/application\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport debug from './debug.js'\nimport { EnvParser } from './parser.js'\nimport { EnvLoader } from './loader.js'\n\n/**\n * Env processors loads, parses and process environment variables.\n */\nexport class EnvProcessor {\n /**\n * App root is needed to load files\n */\n #appRoot: URL\n\n constructor(appRoot: URL) {\n this.#appRoot = appRoot\n }\n\n /**\n * Parse env variables from raw contents\n */\n async #processContents(envContents: string, store: Record<string, any>) {\n /**\n * Collected env variables\n */\n if (!envContents.trim()) {\n return store\n }\n\n const parser = new EnvParser(envContents)\n const values = await parser.parse()\n\n Object.keys(values).forEach((key) => {\n let value = process.env[key]\n\n if (!value) {\n value = values[key]\n process.env[key] = values[key]\n }\n\n if (!store[key]) {\n store[key] = value\n }\n })\n\n return store\n }\n\n /**\n * Parse env variables by loading dot files.\n */\n async #loadAndProcessDotFiles() {\n const loader = new EnvLoader(this.#appRoot)\n const envFiles = await loader.load()\n\n if (debug.enabled) {\n debug(\n 'processing .env files (priority from top to bottom) %O',\n envFiles.map((file) => file.path)\n )\n }\n\n /**\n * Collected env variables\n */\n const envValues: Record<string, any> = {}\n await Promise.all(envFiles.map(({ contents }) => this.#processContents(contents, envValues)))\n return envValues\n }\n\n /**\n * Process env variables\n */\n async process() {\n return this.#loadAndProcessDotFiles()\n }\n}\n"],"mappings":";;;;;;;AASA,SAAS,UAAU,iBAAkC;;;ACTrD;AAAA;AAAA;AAAA;AAAA;AASA,SAAS,aAAa,iBAAiB;AAMhC,IAAM,0BAA0B,MAAM,+BAA+B,UAAU;AAAA,EACpF,OAAO,UAAU;AAAA,EACjB,OAAO,OAAO;AAAA,EACd,OAAe;AACjB;AAEO,IAAM,+BAA+B;AAAA,EAC1C;AAAA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,IAAI;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhB,OAAO,MAAwD,QAA4B;AACzF,UAAM,YAAY,IAAI,aAAgB,MAAM;AAC5C,WAAO;AAAA,EACT;AAAA,EAwBA,IAAI,KAAa,cAAyB;AAIxC,QAAI,KAAK,QAAQ,GAAG,MAAM,QAAW;AACnC,aAAO,KAAK,QAAQ,GAAG;AAAA,IACzB;AAKA,UAAM,WAAW,QAAQ,IAAI,GAAG;AAChC,QAAI,UAAU;AACZ,aAAO;AAAA,IACT;AAKA,WAAO;AAAA,EACT;AAAA,EAiBA,IAAI,KAA+B,OAAkB;AACnD,SAAK,QAAQ,GAAG,IAAI;AACpB,YAAQ,IAAI,GAAa,IAAI;AAAA,EAC/B;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/env.ts","../src/errors.ts","../src/validator.ts","../src/parser.ts","../src/processor.ts"],"sourcesContent":["/*\n * @adonisjs/env\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { schema as envSchema } from '@poppinss/validator-lite'\nimport { EnvValidator } from './validator.js'\nimport { EnvProcessor } from './processor.js'\nimport { EnvParser } from './parser.js'\nimport type { ValidateFn } from '@poppinss/validator-lite/types'\n\n/**\n * A wrapper over \"process.env\" with types information.\n *\n * ```ts\n * const validate = Env.rules({\n * PORT: Env.schema.number()\n * })\n *\n * const validatedEnvVars = validate(process.env)\n *\n * const env = new EnvValues(validatedEnvVars)\n * env.get('PORT') // type === number\n * ```\n */\nexport class Env<EnvValues extends Record<string, any>> {\n /**\n * A cache of env values\n */\n #values: EnvValues\n\n constructor(values: EnvValues) {\n this.#values = values\n }\n\n /**\n * Create an instance of the env class by validating the\n * environment variables. Also, the `.env` files are\n * loaded from the appRoot\n */\n static async create<Schema extends { [key: string]: ValidateFn<unknown> }>(\n appRoot: URL,\n schema: Schema\n ): Promise<\n Env<{\n [K in keyof Schema]: ReturnType<Schema[K]>\n }>\n > {\n const values = await new EnvProcessor(appRoot).process()\n const validator = this.rules(schema)\n return new Env(validator.validate(values))\n }\n\n /**\n * Define an identifier for any environment value. The callback is invoked\n * when the value match the identifier to modify its interpolation.\n */\n static identifier(name: string, callback: (value: string) => Promise<string> | string): void {\n EnvParser.identifier(name, callback)\n }\n\n /**\n * Remove an identifier\n */\n static removeIdentifier(name: string): void {\n EnvParser.removeIdentifier(name)\n }\n\n /**\n * The schema builder for defining validation rules\n */\n static schema: typeof envSchema = envSchema\n\n /**\n * Define the validation rules for validating environment\n * variables. The return value is an instance of the\n * env validator\n */\n static rules<T extends { [key: string]: ValidateFn<unknown> }>(schema: T): EnvValidator<T> {\n const validator = new EnvValidator<T>(schema)\n return validator\n }\n\n /**\n * Get the value of an environment variable by key. The values are\n * looked up inside the validated environment and \"process.env\"\n * is used as a fallback.\n *\n * The second param is the default value, which is returned when\n * the environment variable does not exist.\n *\n * ```ts\n * Env.get('PORT')\n *\n * // With default value\n * Env.get('PORT', 3000)\n * ```\n */\n get<K extends keyof EnvValues>(key: K): EnvValues[K]\n get<K extends keyof EnvValues>(\n key: K,\n defaultValue: Exclude<EnvValues[K], undefined>\n ): Exclude<EnvValues[K], undefined>\n get(key: string): string | undefined\n get(key: string, defaultValue: string): string\n get(key: string, defaultValue?: any): any {\n /**\n * Return cached value\n */\n if (this.#values[key] !== undefined) {\n return this.#values[key]\n }\n\n /**\n * Get value from \"process.env\" and update the cache\n */\n const envValue = process.env[key]\n if (envValue) {\n return envValue\n }\n\n /**\n * Return default value when unable to lookup any other value\n */\n return defaultValue\n }\n\n /**\n * Update/set value of an environment variable.\n *\n * The value is not casted/validated using the validator, so make sure\n * to set the correct data type.\n *\n * ```ts\n * Env.set('PORT', 3000)\n *\n * Env.get('PORT') === 3000 // true\n * process.env.PORT === '3000' // true\n * ```\n */\n set<K extends keyof EnvValues>(key: K, value: EnvValues[K]): void\n set(key: string, value: string): void\n set(key: string | keyof EnvValues, value: any): void {\n this.#values[key] = value\n process.env[key as string] = value\n }\n}\n","/*\n * @adonisjs/env\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { createError, Exception } from '@poppinss/utils'\n\n/**\n * Exception raised when one or more env variables\n * are invalid\n */\nexport const E_INVALID_ENV_VARIABLES = class EnvValidationException extends Exception {\n static message = 'Validation failed for one or more environment variables'\n static code = 'E_INVALID_ENV_VARIABLES'\n help: string = ''\n}\n\nexport const E_IDENTIFIER_ALREADY_DEFINED = createError<[string]>(\n 'The identifier \"%s\" is already defined',\n 'E_IDENTIFIER_ALREADY_DEFINED',\n 500\n)\n","/*\n * @adonisjs/env\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { Exception } from '@poppinss/utils'\nimport type { ValidateFn } from '@poppinss/validator-lite/types'\n\nimport { E_INVALID_ENV_VARIABLES } from './errors.js'\n\n/**\n * Exposes the API to validate environment variables against a\n * pre-defined schema.\n *\n * The class is not exported in the main API and used internally.\n */\nexport class EnvValidator<Schema extends { [key: string]: ValidateFn<unknown> }> {\n #schema: Schema\n #error: Exception\n\n constructor(schema: Schema) {\n this.#schema = schema\n this.#error = new E_INVALID_ENV_VARIABLES()\n }\n\n /**\n * Accepts an object of values to validate against the pre-defined\n * schema.\n *\n * The return value is a merged copy of the original object and the\n * values mutated by the schema validator.\n */\n validate(values: { [K: string]: string | undefined }): {\n [K in keyof Schema]: ReturnType<Schema[K]>\n } {\n const help: string[] = []\n\n const validated = Object.keys(this.#schema).reduce(\n (result, key) => {\n const value = process.env[key] || values[key]\n\n try {\n result[key] = this.#schema[key](key, value) as any\n } catch (error) {\n help.push(`- ${error.message}`)\n }\n return result\n },\n { ...values }\n ) as { [K in keyof Schema]: ReturnType<Schema[K]> }\n\n if (help.length) {\n this.#error.help = help.join('\\n')\n throw this.#error\n }\n\n return validated\n }\n}\n","/*\n * @adonisjs/env\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport dotenv, { DotenvParseOutput } from 'dotenv'\nimport { E_IDENTIFIER_ALREADY_DEFINED } from './errors.js'\n\n/**\n * Env parser parses the environment variables from a string formatted\n * as a key-value pair seperated using an `=`. For example:\n *\n * ```dotenv\n * PORT=3333\n * HOST=127.0.0.1\n * ```\n *\n * The variables can reference other environment variables as well using `$`.\n * For example:\n *\n * ```dotenv\n * PORT=3333\n * REDIS_PORT=$PORT\n * ```\n *\n * The variables using characters other than letters can wrap variable\n * named inside a curly brace.\n *\n * ```dotenv\n * APP-PORT=3333\n * REDIS_PORT=${APP-PORT}\n * ```\n *\n * You can escape the `$` sign with a backtick.\n *\n * ```dotenv\n * REDIS_PASSWORD=foo\\$123\n * ```\n *\n * ## Usage\n *\n * ```ts\n * const parser = new EnvParser(envContents)\n * const output = parser.parse()\n *\n * // The output is a key-value pair\n * ```\n */\nexport class EnvParser {\n #envContents: string\n #preferProcessEnv: boolean = true\n static #identifiers: Record<string, (value: string) => Promise<string> | string> = {}\n\n constructor(envContents: string, options?: { ignoreProcessEnv: boolean }) {\n if (options?.ignoreProcessEnv) {\n this.#preferProcessEnv = false\n }\n\n this.#envContents = envContents\n }\n\n /**\n * Define an identifier for any environment value. The callback is invoked\n * when the value match the identifier to modify its interpolation.\n */\n static identifier(name: string, callback: (value: string) => Promise<string> | string): void {\n if (this.#identifiers[name]) {\n throw new E_IDENTIFIER_ALREADY_DEFINED([name])\n }\n\n this.#identifiers[name] = callback\n }\n\n /**\n * Remove an identifier\n */\n static removeIdentifier(name: string): void {\n delete this.#identifiers[name]\n }\n\n /**\n * Returns the value from the parsed object\n */\n #getValue(key: string, parsed: DotenvParseOutput): string {\n if (this.#preferProcessEnv && process.env[key]) {\n return process.env[key]!\n }\n\n if (parsed[key]) {\n return this.#interpolate(parsed[key], parsed)\n }\n\n return process.env[key] || ''\n }\n\n /**\n * Interpolating the token wrapped inside the mustache braces.\n */\n #interpolateMustache(token: string, parsed: DotenvParseOutput) {\n /**\n * Finding the closing brace. If closing brace is missing, we\n * consider the block as a normal string\n */\n const closingBrace = token.indexOf('}')\n if (closingBrace === -1) {\n return token\n }\n\n /**\n * Then we pull everything until the closing brace, except\n * the opening brace and trim off all white spaces.\n */\n const varReference = token.slice(1, closingBrace).trim()\n\n /**\n * Getting the value of the reference inside the braces\n */\n return `${this.#getValue(varReference, parsed)}${token.slice(closingBrace + 1)}`\n }\n\n /**\n * Interpolating the variable reference starting with a\n * `$`. We only capture numbers,letter and underscore.\n * For other characters, one can use the mustache\n * braces.\n */\n #interpolateVariable(token: string, parsed: any) {\n return token.replace(/[a-zA-Z0-9_]+/, (key) => {\n return this.#getValue(key, parsed)\n })\n }\n\n /**\n * Interpolates the referenced values\n */\n #interpolate(value: string, parsed: DotenvParseOutput): string {\n const tokens = value.split('$')\n\n let newValue = ''\n let skipNextToken = true\n\n tokens.forEach((token) => {\n /**\n * If the value is an escaped sequence, then we replace it\n * with a `$` and then skip the next token.\n */\n if (token === '\\\\') {\n newValue += '$'\n skipNextToken = true\n return\n }\n\n /**\n * Use the value as it is when \"skipNextToken\" is set to true.\n */\n if (skipNextToken) {\n /**\n * Replace the ending escape sequence with a $\n */\n newValue += token.replace(/\\\\$/, '$')\n /**\n * and then skip the next token if it ends with escape sequence\n */\n if (token.endsWith('\\\\')) {\n return\n }\n } else {\n /**\n * Handle mustache block\n */\n if (token.startsWith('{')) {\n newValue += this.#interpolateMustache(token, parsed)\n return\n }\n\n /**\n * Process all words as variable\n */\n newValue += this.#interpolateVariable(token, parsed)\n }\n\n /**\n * Process next token\n */\n skipNextToken = false\n })\n\n return newValue\n }\n\n /**\n * Parse the env string to an object of environment variables.\n */\n async parse(): Promise<DotenvParseOutput> {\n const envCollection = dotenv.parse(this.#envContents.trim())\n const identifiers = Object.keys(EnvParser.#identifiers)\n let result: DotenvParseOutput = {}\n\n $keyLoop: for (const key in envCollection) {\n const value = this.#getValue(key, envCollection)\n\n if (value.includes(':')) {\n for (const identifier of identifiers) {\n if (value.startsWith(`${identifier}:`)) {\n result[key] = await EnvParser.#identifiers[identifier](\n value.substring(identifier.length + 1)\n )\n\n continue $keyLoop\n }\n\n if (value.startsWith(`${identifier}\\\\:`)) {\n result[key] = identifier + value.substring(identifier.length + 1)\n\n continue $keyLoop\n }\n }\n\n result[key] = value\n } else {\n result[key] = value\n }\n }\n\n return result\n }\n}\n","/*\n * @adonisjs/application\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport debug from './debug.js'\nimport { EnvParser } from './parser.js'\nimport { EnvLoader } from './loader.js'\n\n/**\n * Env processors loads, parses and process environment variables.\n */\nexport class EnvProcessor {\n /**\n * App root is needed to load files\n */\n #appRoot: URL\n\n constructor(appRoot: URL) {\n this.#appRoot = appRoot\n }\n\n /**\n * Parse env variables from raw contents\n */\n async #processContents(envContents: string, store: Record<string, any>) {\n /**\n * Collected env variables\n */\n if (!envContents.trim()) {\n return store\n }\n\n const parser = new EnvParser(envContents)\n const values = await parser.parse()\n\n Object.keys(values).forEach((key) => {\n let value = process.env[key]\n\n if (!value) {\n value = values[key]\n process.env[key] = values[key]\n }\n\n if (!store[key]) {\n store[key] = value\n }\n })\n\n return store\n }\n\n /**\n * Parse env variables by loading dot files.\n */\n async #loadAndProcessDotFiles() {\n const loader = new EnvLoader(this.#appRoot)\n const envFiles = await loader.load()\n\n if (debug.enabled) {\n debug(\n 'processing .env files (priority from top to bottom) %O',\n envFiles.map((file) => file.path)\n )\n }\n\n /**\n * Collected env variables\n */\n const envValues: Record<string, any> = {}\n await Promise.all(envFiles.map(({ contents }) => this.#processContents(contents, envValues)))\n return envValues\n }\n\n /**\n * Process env variables\n */\n async process() {\n return this.#loadAndProcessDotFiles()\n }\n}\n"],"mappings":";;;;;;;AASA,SAAS,UAAU,iBAAiB;;;ACTpC;AAAA;AAAA;AAAA;AA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;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,WAAW,MAAc,UAA6D;AAC3F,cAAU,WAAW,MAAM,QAAQ;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAiB,MAAoB;AAC1C,cAAU,iBAAiB,IAAI;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,SAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOlC,OAAO,MAAwD,QAA4B;AACzF,UAAM,YAAY,IAAI,aAAgB,MAAM;AAC5C,WAAO;AAAA,EACT;AAAA,EAwBA,IAAI,KAAa,cAAyB;AAIxC,QAAI,KAAK,QAAQ,GAAG,MAAM,QAAW;AACnC,aAAO,KAAK,QAAQ,GAAG;AAAA,IACzB;AAKA,UAAM,WAAW,QAAQ,IAAI,GAAG;AAChC,QAAI,UAAU;AACZ,aAAO;AAAA,IACT;AAKA,WAAO;AAAA,EACT;AAAA,EAiBA,IAAI,KAA+B,OAAkB;AACnD,SAAK,QAAQ,GAAG,IAAI;AACpB,YAAQ,IAAI,GAAa,IAAI;AAAA,EAC/B;AACF;","names":[]}
@@ -1,3 +1,2 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  declare const _default: import("util").DebugLogger;
3
2
  export default _default;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  export declare class EnvEditor {
3
2
  #private;
4
3
  /**
@@ -14,8 +13,10 @@ export declare class EnvEditor {
14
13
  load(): Promise<void>;
15
14
  /**
16
15
  * Add key-value pair to the dot-env files.
16
+ * If `withEmptyExampleValue` is true then the key will be added with an empty value
17
+ * to the `.env.example` file.
17
18
  */
18
- add(key: string, value: string | number | boolean): void;
19
+ add(key: string, value: string | number | boolean, withEmptyExampleValue?: boolean): void;
19
20
  toJSON(): {
20
21
  contents: string[];
21
22
  path: string;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EnvLoader
3
- } from "../chunk-H6UKLEIO.js";
3
+ } from "../chunk-VIQ26ZGM.js";
4
4
 
5
5
  // src/editor.ts
6
6
  import splitLines from "split-lines";
@@ -40,12 +40,18 @@ var EnvEditor = class _EnvEditor {
40
40
  }
41
41
  /**
42
42
  * Add key-value pair to the dot-env files.
43
+ * If `withEmptyExampleValue` is true then the key will be added with an empty value
44
+ * to the `.env.example` file.
43
45
  */
44
- add(key, value) {
46
+ add(key, value, withEmptyExampleValue = false) {
45
47
  this.#files.forEach((file) => {
46
48
  let entryIndex = file.contents.findIndex((line) => line.startsWith(`${key}=`));
47
49
  entryIndex = entryIndex === -1 ? file.contents.length : entryIndex;
48
- lodash.set(file.contents, entryIndex, `${key}=${String(value)}`);
50
+ if (withEmptyExampleValue && file.path.endsWith(".env.example")) {
51
+ lodash.set(file.contents, entryIndex, `${key}=`);
52
+ } else {
53
+ lodash.set(file.contents, entryIndex, `${key}=${value}`);
54
+ }
49
55
  });
50
56
  }
51
57
  toJSON() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/editor.ts"],"sourcesContent":["/*\n * @adonisjs/env\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport splitLines from 'split-lines'\nimport lodash from '@poppinss/utils/lodash'\nimport { writeFile } from 'node:fs/promises'\n\nimport { EnvLoader } from './loader.js'\n\nexport class EnvEditor {\n #appRoot: URL\n #loader: EnvLoader\n #files: { contents: string[]; path: string }[] = []\n\n /**\n * Creates an instance of env editor and loads .env files\n * contents.\n */\n static async create(appRoot: URL) {\n const editor = new EnvEditor(appRoot)\n await editor.load()\n\n return editor\n }\n\n constructor(appRoot: URL) {\n this.#appRoot = appRoot\n this.#loader = new EnvLoader(this.#appRoot, true)\n }\n\n /**\n * Loads .env files for editing. Only \".env\" and \".env.example\"\n * files are picked for editing.\n */\n async load() {\n const envFiles = await this.#loader.load()\n\n this.#files = envFiles\n .filter(\n (envFile) =>\n envFile.fileExists &&\n (envFile.path.endsWith('.env') || envFile.path.endsWith('.env.example'))\n )\n .map((envFile) => {\n return {\n contents: splitLines(envFile.contents.trim()),\n path: envFile.path,\n }\n })\n }\n\n /**\n * Add key-value pair to the dot-env files.\n */\n add(key: string, value: string | number | boolean) {\n this.#files.forEach((file) => {\n let entryIndex = file.contents.findIndex((line) => line.startsWith(`${key}=`))\n\n entryIndex = entryIndex === -1 ? file.contents.length : entryIndex\n lodash.set(file.contents, entryIndex, `${key}=${String(value)}`)\n })\n }\n\n toJSON() {\n return this.#files\n }\n\n /**\n * Save changes to the disk\n */\n async save() {\n await Promise.all(\n this.#files.map((file) => {\n return writeFile(file.path, file.contents.join('\\n'))\n })\n )\n }\n}\n"],"mappings":";;;;;AASA,OAAO,gBAAgB;AACvB,OAAO,YAAY;AACnB,SAAS,iBAAiB;AAInB,IAAM,YAAN,MAAM,WAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA,SAAiD,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlD,aAAa,OAAO,SAAc;AAChC,UAAM,SAAS,IAAI,WAAU,OAAO;AACpC,UAAM,OAAO,KAAK;AAElB,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,SAAc;AACxB,SAAK,WAAW;AAChB,SAAK,UAAU,IAAI,UAAU,KAAK,UAAU,IAAI;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO;AACX,UAAM,WAAW,MAAM,KAAK,QAAQ,KAAK;AAEzC,SAAK,SAAS,SACX;AAAA,MACC,CAAC,YACC,QAAQ,eACP,QAAQ,KAAK,SAAS,MAAM,KAAK,QAAQ,KAAK,SAAS,cAAc;AAAA,IAC1E,EACC,IAAI,CAAC,YAAY;AAChB,aAAO;AAAA,QACL,UAAU,WAAW,QAAQ,SAAS,KAAK,CAAC;AAAA,QAC5C,MAAM,QAAQ;AAAA,MAChB;AAAA,IACF,CAAC;AAAA,EACL;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,KAAa,OAAkC;AACjD,SAAK,OAAO,QAAQ,CAAC,SAAS;AAC5B,UAAI,aAAa,KAAK,SAAS,UAAU,CAAC,SAAS,KAAK,WAAW,GAAG,GAAG,GAAG,CAAC;AAE7E,mBAAa,eAAe,KAAK,KAAK,SAAS,SAAS;AACxD,aAAO,IAAI,KAAK,UAAU,YAAY,GAAG,GAAG,IAAI,OAAO,KAAK,CAAC,EAAE;AAAA,IACjE,CAAC;AAAA,EACH;AAAA,EAEA,SAAS;AACP,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAO;AACX,UAAM,QAAQ;AAAA,MACZ,KAAK,OAAO,IAAI,CAAC,SAAS;AACxB,eAAO,UAAU,KAAK,MAAM,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,MACtD,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/editor.ts"],"sourcesContent":["/*\n * @adonisjs/env\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport splitLines from 'split-lines'\nimport lodash from '@poppinss/utils/lodash'\nimport { writeFile } from 'node:fs/promises'\n\nimport { EnvLoader } from './loader.js'\n\nexport class EnvEditor {\n #appRoot: URL\n #loader: EnvLoader\n #files: { contents: string[]; path: string }[] = []\n\n /**\n * Creates an instance of env editor and loads .env files\n * contents.\n */\n static async create(appRoot: URL) {\n const editor = new EnvEditor(appRoot)\n await editor.load()\n\n return editor\n }\n\n constructor(appRoot: URL) {\n this.#appRoot = appRoot\n this.#loader = new EnvLoader(this.#appRoot, true)\n }\n\n /**\n * Loads .env files for editing. Only \".env\" and \".env.example\"\n * files are picked for editing.\n */\n async load() {\n const envFiles = await this.#loader.load()\n\n this.#files = envFiles\n .filter(\n (envFile) =>\n envFile.fileExists &&\n (envFile.path.endsWith('.env') || envFile.path.endsWith('.env.example'))\n )\n .map((envFile) => {\n return {\n contents: splitLines(envFile.contents.trim()),\n path: envFile.path,\n }\n })\n }\n\n /**\n * Add key-value pair to the dot-env files.\n * If `withEmptyExampleValue` is true then the key will be added with an empty value\n * to the `.env.example` file.\n */\n add(key: string, value: string | number | boolean, withEmptyExampleValue = false) {\n this.#files.forEach((file) => {\n let entryIndex = file.contents.findIndex((line) => line.startsWith(`${key}=`))\n\n entryIndex = entryIndex === -1 ? file.contents.length : entryIndex\n\n if (withEmptyExampleValue && file.path.endsWith('.env.example')) {\n lodash.set(file.contents, entryIndex, `${key}=`)\n } else {\n lodash.set(file.contents, entryIndex, `${key}=${value}`)\n }\n })\n }\n\n toJSON() {\n return this.#files\n }\n\n /**\n * Save changes to the disk\n */\n async save() {\n await Promise.all(\n this.#files.map((file) => {\n return writeFile(file.path, file.contents.join('\\n'))\n })\n )\n }\n}\n"],"mappings":";;;;;AASA,OAAO,gBAAgB;AACvB,OAAO,YAAY;AACnB,SAAS,iBAAiB;AAInB,IAAM,YAAN,MAAM,WAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA,SAAiD,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlD,aAAa,OAAO,SAAc;AAChC,UAAM,SAAS,IAAI,WAAU,OAAO;AACpC,UAAM,OAAO,KAAK;AAElB,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,SAAc;AACxB,SAAK,WAAW;AAChB,SAAK,UAAU,IAAI,UAAU,KAAK,UAAU,IAAI;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO;AACX,UAAM,WAAW,MAAM,KAAK,QAAQ,KAAK;AAEzC,SAAK,SAAS,SACX;AAAA,MACC,CAAC,YACC,QAAQ,eACP,QAAQ,KAAK,SAAS,MAAM,KAAK,QAAQ,KAAK,SAAS,cAAc;AAAA,IAC1E,EACC,IAAI,CAAC,YAAY;AAChB,aAAO;AAAA,QACL,UAAU,WAAW,QAAQ,SAAS,KAAK,CAAC;AAAA,QAC5C,MAAM,QAAQ;AAAA,MAChB;AAAA,IACF,CAAC;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,KAAa,OAAkC,wBAAwB,OAAO;AAChF,SAAK,OAAO,QAAQ,CAAC,SAAS;AAC5B,UAAI,aAAa,KAAK,SAAS,UAAU,CAAC,SAAS,KAAK,WAAW,GAAG,GAAG,GAAG,CAAC;AAE7E,mBAAa,eAAe,KAAK,KAAK,SAAS,SAAS;AAExD,UAAI,yBAAyB,KAAK,KAAK,SAAS,cAAc,GAAG;AAC/D,eAAO,IAAI,KAAK,UAAU,YAAY,GAAG,GAAG,GAAG;AAAA,MACjD,OAAO;AACL,eAAO,IAAI,KAAK,UAAU,YAAY,GAAG,GAAG,IAAI,KAAK,EAAE;AAAA,MACzD;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,SAAS;AACP,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAO;AACX,UAAM,QAAQ;AAAA,MACZ,KAAK,OAAO,IAAI,CAAC,SAAS;AACxB,eAAO,UAAU,KAAK,MAAM,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,MACtD,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import { type ValidateFn } from '@poppinss/validator-lite';
1
+ import { schema as envSchema } from '@poppinss/validator-lite';
3
2
  import { EnvValidator } from './validator.js';
3
+ import type { ValidateFn } from '@poppinss/validator-lite/types';
4
4
  /**
5
5
  * A wrapper over "process.env" with types information.
6
6
  *
@@ -40,12 +40,7 @@ export declare class Env<EnvValues extends Record<string, any>> {
40
40
  /**
41
41
  * The schema builder for defining validation rules
42
42
  */
43
- static schema: {
44
- number: typeof import("@poppinss/validator-lite/build/src/schema/number.js").number;
45
- string: typeof import("@poppinss/validator-lite/build/src/schema/string.js").string;
46
- boolean: typeof import("@poppinss/validator-lite/build/src/schema/boolean.js").boolean;
47
- enum: typeof import("@poppinss/validator-lite/build/src/schema/oneOf.js").oneOf;
48
- };
43
+ static schema: typeof envSchema;
49
44
  /**
50
45
  * Define the validation rules for validating environment
51
46
  * variables. The return value is an instance of the
@@ -56,7 +51,7 @@ export declare class Env<EnvValues extends Record<string, any>> {
56
51
  }>(schema: T): EnvValidator<T>;
57
52
  /**
58
53
  * Get the value of an environment variable by key. The values are
59
- * lookedup inside the validated environment and "process.env"
54
+ * looked up inside the validated environment and "process.env"
60
55
  * is used as a fallback.
61
56
  *
62
57
  * The second param is the default value, which is returned when
@@ -1,30 +1,29 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import { Exception } from '@poppinss/utils';
3
2
  /**
4
3
  * Exception raised when one or more env variables
5
4
  * are invalid
6
5
  */
7
6
  export declare const E_INVALID_ENV_VARIABLES: {
8
- new (message?: string | undefined, options?: (ErrorOptions & {
9
- code?: string | undefined;
10
- status?: number | undefined;
11
- }) | undefined): {
7
+ new (message?: string, options?: ErrorOptions & {
8
+ code?: string;
9
+ status?: number;
10
+ }): {
12
11
  help: string;
13
12
  name: string;
14
- code?: string | undefined;
13
+ code?: string;
15
14
  status: number;
16
15
  toString(): string;
17
16
  readonly [Symbol.toStringTag]: string;
18
17
  message: string;
19
- stack?: string | undefined;
18
+ stack?: string;
20
19
  cause?: unknown;
21
20
  };
22
21
  message: string;
23
22
  code: string;
24
- help?: string | undefined;
25
- status?: number | undefined;
26
- captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
23
+ help?: string;
24
+ status?: number;
25
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
27
26
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
28
27
  stackTraceLimit: number;
29
28
  };
30
- export declare const E_IDENTIFIER_ALREADY_DEFINED: new (args: [string], options?: ErrorOptions | undefined) => Exception;
29
+ export declare const E_IDENTIFIER_ALREADY_DEFINED: new (args: [string], options?: ErrorOptions) => Exception;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  /**
3
2
  * Read the contents of one or more dot-env files. Following is how the files
4
3
  * are read.
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  /**
3
2
  * Env processors loads, parses and process environment variables.
4
3
  */
@@ -1,4 +1,4 @@
1
- import { ValidateFn } from '@poppinss/validator-lite';
1
+ import type { ValidateFn } from '@poppinss/validator-lite/types';
2
2
  /**
3
3
  * Exposes the API to validate environment variables against a
4
4
  * pre-defined schema.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonisjs/env",
3
- "version": "6.0.1",
3
+ "version": "6.1.1",
4
4
  "description": "Environment variable manager for Node.js",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
@@ -28,45 +28,48 @@
28
28
  "release": "release-it",
29
29
  "version": "npm run build",
30
30
  "prepublishOnly": "npm run build",
31
- "lint": "eslint . --ext=.ts",
31
+ "lint": "eslint .",
32
32
  "format": "prettier --write .",
33
- "sync-labels": "github-label-sync --labels .github/labels.json adonisjs/env",
34
- "quick:test": "node --loader=ts-node/esm bin/test.ts"
33
+ "quick:test": "node --import=ts-node-maintained/register/esm bin/test.ts"
35
34
  },
36
35
  "keywords": [
37
36
  "env",
38
37
  "adonisjs"
39
38
  ],
40
- "author": "virk,adonisjs",
39
+ "author": "Harminder Virk <virk@adonisjs.com>",
40
+ "contributors": [
41
+ "Romain Lanz <romain.lanz@pm.me>",
42
+ "Julien Ripouteau <julien@ripouteau.com>"
43
+ ],
41
44
  "license": "MIT",
42
45
  "devDependencies": {
43
- "@adonisjs/eslint-config": "^1.3.0",
44
- "@adonisjs/prettier-config": "^1.3.0",
45
- "@adonisjs/tsconfig": "^1.3.0",
46
- "@commitlint/cli": "^19.2.2",
47
- "@commitlint/config-conventional": "^19.2.2",
48
- "@japa/assert": "^3.0.0",
49
- "@japa/expect-type": "^2.0.2",
50
- "@japa/file-system": "^2.3.0",
51
- "@japa/runner": "^3.1.4",
52
- "@swc/core": "^1.4.16",
53
- "@types/node": "^20.12.7",
54
- "c8": "^9.1.0",
46
+ "@adonisjs/eslint-config": "^2.0.0-beta.7",
47
+ "@adonisjs/prettier-config": "^1.4.0",
48
+ "@adonisjs/tsconfig": "^1.4.0",
49
+ "@commitlint/cli": "^19.6.1",
50
+ "@commitlint/config-conventional": "^19.6.0",
51
+ "@japa/assert": "^4.0.1",
52
+ "@japa/expect-type": "^2.0.3",
53
+ "@japa/file-system": "^2.3.2",
54
+ "@japa/runner": "^4.1.0",
55
+ "@release-it/conventional-changelog": "^10.0.0",
56
+ "@swc/core": "^1.10.7",
57
+ "@types/node": "^20.17.12",
58
+ "c8": "^10.1.3",
55
59
  "cross-env": "^7.0.3",
56
- "del-cli": "^5.1.0",
57
- "eslint": "^8.56.0",
58
- "github-label-sync": "^2.3.1",
59
- "husky": "^9.0.11",
60
- "prettier": "^3.2.5",
61
- "release-it": "^17.2.0",
62
- "ts-node": "^10.9.2",
63
- "tsup": "^8.0.2",
64
- "typescript": "^5.4.5"
60
+ "del-cli": "^6.0.0",
61
+ "eslint": "^9.18.0",
62
+ "husky": "^9.1.7",
63
+ "prettier": "^3.4.2",
64
+ "release-it": "^18.1.1",
65
+ "ts-node-maintained": "^10.9.4",
66
+ "tsup": "^8.3.5",
67
+ "typescript": "^5.7.3"
65
68
  },
66
69
  "dependencies": {
67
- "@poppinss/utils": "^6.7.3",
68
- "@poppinss/validator-lite": "^1.0.3",
69
- "dotenv": "^16.4.5",
70
+ "@poppinss/utils": "^6.9.2",
71
+ "@poppinss/validator-lite": "^2.0.1",
72
+ "dotenv": "^16.4.7",
70
73
  "split-lines": "^3.0.0"
71
74
  },
72
75
  "repository": {
@@ -88,19 +91,26 @@
88
91
  },
89
92
  "release-it": {
90
93
  "git": {
94
+ "requireCleanWorkingDir": true,
95
+ "requireUpstream": true,
91
96
  "commitMessage": "chore(release): ${version}",
92
97
  "tagAnnotation": "v${version}",
98
+ "push": true,
93
99
  "tagName": "v${version}"
94
100
  },
95
- "hooks": {
96
- "before:init": [
97
- "npm test"
98
- ]
99
- },
100
101
  "github": {
101
- "release": true,
102
- "releaseName": "v${version}",
103
- "web": true
102
+ "release": true
103
+ },
104
+ "npm": {
105
+ "publish": true,
106
+ "skipChecks": true
107
+ },
108
+ "plugins": {
109
+ "@release-it/conventional-changelog": {
110
+ "preset": {
111
+ "name": "angular"
112
+ }
113
+ }
104
114
  }
105
115
  },
106
116
  "c8": {