Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@platformatic/config

Package Overview
Dependencies
Maintainers
6
Versions
312
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@platformatic/config - npm Package Compare versions

Comparing version 1.11.0 to 1.12.0

4

lib/load-config.js

@@ -9,3 +9,3 @@ 'use strict'

async function loadConfig (minimistConfig, _args, app, overrides = {}) {
async function loadConfig (minimistConfig, _args, app, overrides = {}, replaceEnv = true) {
const args = parseArgs(_args, deepmerge({ all: true })({

@@ -43,3 +43,3 @@ string: ['allow-env'],

const parsingResult = await configManager.parse()
const parsingResult = await configManager.parse(replaceEnv)
if (!parsingResult) {

@@ -46,0 +46,0 @@ const err = new errors.ConfigurationDoesNotValidateAgainstSchemaError()

@@ -19,3 +19,8 @@ 'use strict'

this.pupa = null
this.envWhitelist = opts.envWhitelist || []
if (typeof this.envWhitelist === 'string') {
this.envWhitelist = opts.envWhitelist.split(',')
}
if (!opts.source) {

@@ -64,3 +69,3 @@ throw new errors.SourceMissingError()

for (const key in env) {
if (key.match(/^PLT_/) || this.envWhitelist.includes(key)) {
if (this.#isEnvVariable(key)) {
purged[key] = env[key]

@@ -127,9 +132,26 @@ }

/**
* 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 () {}
async parse () {
async parse (replaceEnv = true) {
try {
if (this.fullPath) {
const configString = await this.load()
this.current = this._parser(await this.replaceEnv(configString))
if (replaceEnv) {
this.current = this._parser(await this.replaceEnv(configString))
} else {
this.current = this._parser(await this.load())
}
// try updating the config format to latest

@@ -167,4 +189,5 @@ try {

} catch (err) {
console.error(err)
if (err.name === 'MissingValueError') {
if (!err.key.match(/^PLT_/) && !this.envWhitelist.includes(err.key)) {
if (!this.#isEnvVariable(err.key)) {
throw new errors.InvalidPlaceholderError(err.key, err.key)

@@ -171,0 +194,0 @@ } else {

{
"name": "@platformatic/config",
"version": "1.11.0",
"version": "1.12.0",
"description": "Platformatic DB Config Manager",

@@ -35,4 +35,4 @@ "main": "index.js",

"undici": "^5.25.4",
"@platformatic/metaconfig": "1.11.0",
"@platformatic/utils": "1.11.0"
"@platformatic/metaconfig": "1.12.0",
"@platformatic/utils": "1.12.0"
},

@@ -39,0 +39,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc