Node.js support:
- Dropped: 14, 16
- Maintenance: 18
- Active: 20
- Current: 22
Feature: Add types numberArray and stringOneOfArray
Feature: Allow config to be provided as p.env(schema, config)
. Previously config was only providable at instantiation new MyEnv(config)
. Now if both are provided they are shallow merged with instance config taking priority.
Feature: Export a PEnvBase base class from which all p.env classes descend. This allows us to do prototype-based sanity checks like MyEnv.prototype instanceof PEnvBase
and myEnv instanceof PEnvBase
in advanced use cases.
Advanced breaking: Simplify the names of several advanced types e.g. PEnvEnvConfig --> PEnvConfig, PEnvAbstractEnv --> PEnv. This is only breaking if you're using these advanced types directly in your code.
Internal: Add official support for Node.js 18, 19. Upgrade dependencies.
Feature: Field factory p.date
for parsing environment variables as Date
Feature: Field factory p.bigint
for parsing environment variables as bigint
Feature: Field factory p.json
for parsing environment variable values as JSON
Feature: "string one of" field type where the value in the environment must be one of the allowed values
Breaking: Rename PEnvAbstractType
-> PEnvAbstractFieldType
. This is only a breaking change if you've defined custom types.
Fix: Make abstract the class returned by pEnvAbstractEnvFactory
Fix: Remove @carnesen/p-dev as dependency. How'd that get in there?
Breaking: Adopt a class-based schema interface and discard the POJO one.
// Was
const appEnvSchema = p.schema({ FOO: p.string({ default: "bar" }) });
const appEnv = schema.parse();
// Is
const AppEnv = p.env({ FOO: p.string({ default: "bar" }) });
const appEnv = new AppEnv();
This makes it easier to use p-env with dependency injection frameworks.
Breaking: Change PEnvAbstractType interface to only have a single public method safeParse (was protected and called safeParseInternal). This is only a breaking change if you've implemented your own custom concrete types or if you were using the individual field "parse" method.
Breaking: Change PEnvAbstractType method name from _safeParse to safeParseInternal. This is only a breaking change if you're using a custom PEnvAbstractType subclass.
Fix: Redact environment value in error messages and logs if the type has config.secret === true
.
Breaking: Tweak the logger API one more time for real. Now it's e.g.
const schema = p.schema(shape, { logger });
const env = schema.parseProcessEnv();
// OR
const schema = p.schema(shape);
const env = schema.parseProcessEnv({ logger })
Breaking: Tweak logger API one more time. Now it's e.g.:
const schema = p.schema({}).setLogger(console)
Feature: Support comma-separated string[]
-valued variables as p.stringArray
Feature: Support for logging environment variables in PEnvSchema#parseProcessEnv
Breaking: Change argument of PEnvSchema#parseProcessEnv from [processEnv] to [{log, processEnv}]
Initial release with schema support for boolean, number, and string fields.