Summary
Replace the internal EnvVarParser utility class with the published auto-envparse npm package (v1.1.0). The EnvVarParser was extracted into a standalone library and is now available on npm.
Package: https://www.npmjs.com/package/auto-envparse
Repository: https://github.com/vlavrynovych/auto-envparse
Motivation
The EnvVarParser functionality is valuable beyond MSR and has been published as a standalone, reusable library. Using the npm package:
- Eliminates code duplication
- Provides versioned, tested dependency
- Allows other projects to benefit from the same functionality
- Simplifies MSR maintenance (one less internal utility to maintain)
Scope
Changes Required
-
Add Dependency
- Add
auto-envparse@^1.1.0 to package.json dependencies
-
Remove Internal Implementation
- Delete
src/util/EnvVarParser.ts (implementation now in npm package)
- Update
src/util/index.ts to remove EnvVarParser export
-
Update ConfigLoader
- Replace local import with package import in
src/util/ConfigLoader.ts
- Update API calls to match auto-envparse API (see API Mapping below)
-
Update Documentation
- Update
/docs/guides/environment-variables.md to mention MSR uses auto-envparse library
- Add note that EnvVarParser is now available as standalone package
- Update API documentation if needed
-
Verify Tests
- Keep
test/unit/util/EnvVarParser.test.ts as integration test
- Ensure all existing tests pass (verifies auto-envparse works correctly in MSR)
- Update test imports to use auto-envparse
- Update
test/unit/util/UtilIndex.test.ts to reflect removed export
API Mapping
The auto-envparse API has been simplified and renamed:
Main Parsing Method
Before (MSR EnvVarParser):
import { EnvVarParser } from '../util/EnvVarParser';
// Parse environment variables into config object
EnvVarParser.parse(config, 'MSR', overrides);
After (auto-envparse):
import parseEnv, { parse } from 'auto-envparse';
// Option 1: Use default export
parseEnv(config, 'MSR', overrides);
// Option 2: Use named export (shorter)
parse(config, 'MSR', overrides);
Nested Object Loading
Before:
const logging = EnvVarParser.loadNestedFromEnv('MSR_LOGGING', {
enabled: false,
path: './logs'
});
After:
// Use the same parse function with a separate config object
const logging = {
enabled: false,
path: './logs'
};
parse(logging, 'MSR_LOGGING');
Utility Functions
Before:
EnvVarParser.coerceValue(value, 'boolean');
EnvVarParser.parseBoolean(value);
EnvVarParser.parseNumber(value);
EnvVarParser.toSnakeCase(str);
After:
// These were internal utilities and are not exposed in auto-envparse
// Use the main parse() function instead, which handles coercion automatically
parse(config, prefix);
Enum Validation (New Feature)
New in auto-envparse:
import { enumValidator } from 'auto-envparse';
const overrides = new Map();
overrides.set('environment', enumValidator('environment',
['development', 'staging', 'production'],
{ caseSensitive: false }
));
parse(config, 'APP', overrides);
Class Instance Creation (New Feature)
New in auto-envparse:
import { createFrom } from 'auto-envparse';
class DatabaseConfig {
host = 'localhost';
port = 5432;
ssl = false;
}
const dbConfig = createFrom(DatabaseConfig, 'DB');
Testing Strategy
-
Keep Existing Tests
test/unit/util/EnvVarParser.test.ts remains as integration test
- Update imports to use
auto-envparse package
- Verify all 17+ tests continue passing
-
API Changes in Tests
- Replace
EnvVarParser.parse() with parse() from auto-envparse
- Replace
EnvVarParser.loadNestedFromEnv() with separate config + parse()
- Remove tests for internal utility methods (coerceValue, parseBoolean, etc.) - these are internal to auto-envparse
-
Coverage Requirements
- Maintain 100% coverage for ConfigLoader.ts
- Integration test coverage maintained
- All 1257+ MSR tests should pass
Files to Modify
Source Files
Test Files
Documentation
ConfigLoader Changes Example
Before:
import { EnvVarParser } from './EnvVarParser';
protected autoApplyEnvironmentVariables(
config: C,
prefix: string,
overrides?: Map<string, (config: C, envVarName: string) => void>
): void {
EnvVarParser.parse(config, prefix, overrides);
}
After:
import { parse } from 'auto-envparse';
protected autoApplyEnvironmentVariables(
config: C,
prefix: string,
overrides?: Map<string, (config: C, envVarName: string) => void>
): void {
parse(config, prefix, overrides);
}
Success Criteria
Breaking Changes
None. This is an internal implementation change. The public API of MSR (ConfigLoader, adapters, etc.) remains unchanged.
Dependencies
New Dependency:
auto-envparse@^1.1.0 (production dependency)
Zero additional transitive dependencies - auto-envparse has zero dependencies.
Related
Notes
- The auto-envparse package was extracted from MSR's EnvVarParser with API improvements
- Main API simplified:
parse(config, prefix, overrides) replaces all methods
- Package adds new features:
createFrom() for class instances, enumValidator() helper
- Package is battle-tested with 100% test coverage and full TypeScript support
- Package follows 12-Factor App principles for configuration
- API is simpler and more intuitive than the original EnvVarParser
Summary
Replace the internal
EnvVarParserutility class with the publishedauto-envparsenpm package (v1.1.0). TheEnvVarParserwas extracted into a standalone library and is now available on npm.Package: https://www.npmjs.com/package/auto-envparse
Repository: https://github.com/vlavrynovych/auto-envparse
Motivation
The
EnvVarParserfunctionality is valuable beyond MSR and has been published as a standalone, reusable library. Using the npm package:Scope
Changes Required
Add Dependency
auto-envparse@^1.1.0topackage.jsondependenciesRemove Internal Implementation
src/util/EnvVarParser.ts(implementation now in npm package)src/util/index.tsto remove EnvVarParser exportUpdate ConfigLoader
src/util/ConfigLoader.tsUpdate Documentation
/docs/guides/environment-variables.mdto mention MSR usesauto-envparselibraryVerify Tests
test/unit/util/EnvVarParser.test.tsas integration testtest/unit/util/UtilIndex.test.tsto reflect removed exportAPI Mapping
The auto-envparse API has been simplified and renamed:
Main Parsing Method
Before (MSR EnvVarParser):
After (auto-envparse):
Nested Object Loading
Before:
After:
Utility Functions
Before:
After:
Enum Validation (New Feature)
New in auto-envparse:
Class Instance Creation (New Feature)
New in auto-envparse:
Testing Strategy
Keep Existing Tests
test/unit/util/EnvVarParser.test.tsremains as integration testauto-envparsepackageAPI Changes in Tests
EnvVarParser.parse()withparse()from auto-envparseEnvVarParser.loadNestedFromEnv()with separate config +parse()Coverage Requirements
Files to Modify
Source Files
package.json- Add auto-envparse@^1.1.0 dependencysrc/util/EnvVarParser.ts- DELETE (replaced by npm package)src/util/ConfigLoader.ts- Update imports and API callssrc/util/index.ts- Remove EnvVarParser exportTest Files
test/unit/util/EnvVarParser.test.ts- Update imports and API callstest/unit/util/UtilIndex.test.ts- Remove EnvVarParser export testDocumentation
/docs/guides/environment-variables.md- Add note about auto-envparse library/docs/api/ConfigLoader.md- Update if EnvVarParser was mentionedConfigLoader Changes Example
Before:
After:
Success Criteria
auto-envparse@^1.1.0added to dependenciessrc/util/EnvVarParser.tsdeletednpm installworks without errorsnpm testworks without errorsBreaking Changes
None. This is an internal implementation change. The public API of MSR (ConfigLoader, adapters, etc.) remains unchanged.
Dependencies
New Dependency:
auto-envparse@^1.1.0(production dependency)Zero additional transitive dependencies - auto-envparse has zero dependencies.
Related
Notes
parse(config, prefix, overrides)replaces all methodscreateFrom()for class instances,enumValidator()helper