@platformatic/config
Advanced tools
Comparing version 1.36.2 to 1.37.0
@@ -58,3 +58,2 @@ import { type InstanceOptions } from 'ajv' | ||
getSerializer(): ISerializer | ||
purgeEnv(): IEnv | ||
replaceEnv(configString: string): string | ||
@@ -61,0 +60,0 @@ parse(): Promise<void> |
@@ -11,10 +11,5 @@ 'use strict' | ||
const args = parseArgs(_args, deepmerge({ all: true })({ | ||
string: ['allow-env'], | ||
default: { | ||
allowEnv: '' // The default is set in ConfigManager | ||
}, | ||
alias: { | ||
v: 'version', | ||
c: 'config', | ||
allowEnv: ['allow-env', 'E'] | ||
c: 'config' | ||
} | ||
@@ -36,3 +31,2 @@ }, minimistConfig)) | ||
config: args.config, | ||
allowEnv: args.allowEnv, | ||
overrides | ||
@@ -39,0 +33,0 @@ }) |
@@ -31,7 +31,2 @@ 'use strict' | ||
this.envWhitelist = opts.envWhitelist || [] | ||
if (typeof this.envWhitelist === 'string') { | ||
this.envWhitelist = opts.envWhitelist.split(',') | ||
} | ||
if (!opts.source) { | ||
@@ -57,3 +52,3 @@ throw new errors.SourceMissingError() | ||
this._originalEnv = opts.env || {} | ||
this.env = this.purgeEnv(this._originalEnv) | ||
this.env = { ...process.env, ...this._originalEnv } | ||
this._onMissingEnv = opts.onMissingEnv | ||
@@ -74,16 +69,2 @@ if (typeof opts.transformConfig === 'function') { | ||
purgeEnv (providedEnvironment) { | ||
const env = { | ||
...process.env, | ||
...providedEnvironment | ||
} | ||
const purged = {} | ||
for (const key in env) { | ||
if (this.#isEnvVariable(key)) { | ||
purged[key] = env[key] | ||
} | ||
} | ||
return purged | ||
} | ||
async replaceEnv (configString) { | ||
@@ -118,3 +99,3 @@ /* istanbul ignore next */ | ||
} | ||
let env = { ...this._originalEnv } | ||
let env = { ...process.env, ...this._originalEnv } | ||
if (dotEnvPath) { | ||
@@ -125,3 +106,3 @@ const data = await readFile(dotEnvPath, 'utf-8') | ||
} | ||
this.env = this.purgeEnv(env) | ||
this.env = env | ||
@@ -149,15 +130,2 @@ const escapeJSONstring = ({ key, value }) => { | ||
/** | ||
* Checks if a key starts with `PLT_` or is in the whitelist. | ||
* With respect for wildcard ala `MY_NS_*` | ||
* @param {string} key | ||
*/ | ||
#isEnvVariable (key) { | ||
const isInWhitelist = this.envWhitelist.some((whitelisted) => | ||
(whitelisted.endsWith('*') && key.startsWith(whitelisted.slice(0, -1))) || whitelisted === key | ||
) | ||
return key.startsWith('PLT_') || isInWhitelist | ||
} | ||
_transformConfig () {} | ||
@@ -230,7 +198,3 @@ | ||
if (err.name === 'MissingValueError') { | ||
if (!this.#isEnvVariable(err.key)) { | ||
throw new errors.InvalidPlaceholderError(err.key, err.key) | ||
} else { | ||
throw new errors.EnvVarMissingError(err.key) | ||
} | ||
throw new errors.EnvVarMissingError(err.key) | ||
} | ||
@@ -237,0 +201,0 @@ const newerr = new errors.CannotParseConfigFileError(err.message) |
@@ -234,8 +234,5 @@ 'use strict' | ||
const envWhitelist = opts.allowEnv ? opts.allowEnv : configManagerConfig.envWhitelist | ||
const configManager = new ConfigManager({ | ||
source: configFile, | ||
...configManagerConfig, | ||
envWhitelist | ||
...configManagerConfig | ||
}) | ||
@@ -242,0 +239,0 @@ |
{ | ||
"name": "@platformatic/config", | ||
"version": "1.36.2", | ||
"version": "1.37.0", | ||
"description": "Platformatic DB Config Manager", | ||
@@ -19,3 +19,3 @@ "main": "index.js", | ||
"@matteo.collina/tspl": "^0.1.1", | ||
"borp": "^0.12.0", | ||
"borp": "^0.13.0", | ||
"c8": "^9.1.0", | ||
@@ -40,3 +40,3 @@ "fastify": "^4.26.2", | ||
"semver": "^7.6.0", | ||
"@platformatic/utils": "1.36.2" | ||
"@platformatic/utils": "1.37.0" | ||
}, | ||
@@ -43,0 +43,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40463
783
5
+ Added@platformatic/utils@1.37.0(transitive)
- Removed@platformatic/utils@1.36.2(transitive)
Updated@platformatic/utils@1.37.0