@iteam/config
Advanced tools
Comparing version 10.0.1 to 12.0.0
{ | ||
"name": "@iteam/config", | ||
"version": "10.0.1", | ||
"version": "12.0.0", | ||
"main": "src/index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Iteam1337/config.git" | ||
}, | ||
"license": "ISC", | ||
"scripts": { | ||
@@ -11,18 +16,18 @@ "lint": "eslint 'src/**/*.js'", | ||
"dependencies": { | ||
"camelcase": "^5.3.1", | ||
"constant-case": "^2.0.0", | ||
"dot-prop": "^5.1.0" | ||
"camelcase": "5.3.1", | ||
"constant-case": "2.0.0", | ||
"dot-prop": "5.1.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.2.0", | ||
"eslint": "^6.0.1", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-plugin-import": "^2.18.0", | ||
"eslint-plugin-node": "^9.1.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"mocha": "^6.1.4", | ||
"sinon": "^7.3.2", | ||
"sinon-chai": "^3.3.0" | ||
"chai": "4.2.0", | ||
"eslint": "6.0.1", | ||
"eslint-config-standard": "12.0.0", | ||
"eslint-plugin-import": "2.18.0", | ||
"eslint-plugin-node": "9.1.0", | ||
"eslint-plugin-promise": "4.2.1", | ||
"eslint-plugin-standard": "4.0.0", | ||
"mocha": "6.1.4", | ||
"sinon": "7.3.2", | ||
"sinon-chai": "3.3.0" | ||
} | ||
} |
@@ -84,3 +84,3 @@ const utils = require('./utils') | ||
get (value) { | ||
const { mergeDeep, changeCase, identifier } = utils | ||
const { mergeDeep, changeCase, identifier, copy, isObject } = utils | ||
@@ -104,8 +104,21 @@ const key = value | ||
const out = mergeDeep(defaults, mergeDeep(env, file)) | ||
const merged = mergeDeep(copy(defaults), mergeDeep(copy(env), file)) | ||
return changeCase( | ||
secrets ? mergeDeep(out, secrets) : out, | ||
const out = changeCase( | ||
secrets ? mergeDeep(copy(merged), secrets) : merged, | ||
'camel' | ||
) | ||
const cast = utils.type.cast(out, changeCase(defaults, 'camel')) | ||
if ( | ||
!isObject(out) && | ||
!isObject(cast) && | ||
!Array.isArray(out) && | ||
!Array.isArray(cast) | ||
) { | ||
return cast | ||
} | ||
return mergeDeep(out, cast) | ||
} | ||
@@ -112,0 +125,0 @@ } |
const fs = require('fs') | ||
const path = require('path') | ||
const camelCase = require('camelcase') | ||
@@ -18,8 +19,21 @@ const dotProp = require('dot-prop') | ||
fileNames.forEach(fileName => { | ||
const resolved = path.resolve(dir, fileName) | ||
const pathParts = fileName.split(separator).map(key => camelCase(key)) | ||
let stat | ||
try { | ||
stat = fs.statSync(resolved) | ||
} catch (_) { | ||
return | ||
} | ||
if (stat.isDirectory()) { | ||
return | ||
} | ||
dotProp.set( | ||
output, | ||
pathParts.join('.'), | ||
fs.readFileSync(`${dir}${fileName}`, 'utf8').replace(/[\r\n]+$/, '') | ||
fs.readFileSync(resolved, 'utf8').replace(/[\r\n]+$/, '') | ||
) | ||
@@ -35,9 +49,8 @@ }) | ||
return Array.isArray(keys) | ||
? keys | ||
.reduce((result, key) => { | ||
const data = dotProp.get(obj, key.replace(/:/g, '.')) | ||
return data || result | ||
}, false) | ||
? keys.reduce((result, key) => { | ||
const data = dotProp.get(obj, key.replace(/:/g, '.')) | ||
return data || result | ||
}, false) | ||
: dotProp.get(obj, keys) | ||
} | ||
} |
const identifier = require('./identifier') | ||
module.exports = function changeCase (keys, casing = 'snake') { | ||
const changeCase = (keys, casing = 'snake') => { | ||
if (keys === null) { | ||
@@ -27,1 +27,3 @@ return null | ||
} | ||
module.exports = changeCase |
const constant = require('constant-case') | ||
const camel = require('camelcase') | ||
const snake = key => { | ||
return constant(`${key}`).toLowerCase() | ||
} | ||
const snake = key => | ||
constant(`${key}`).toLowerCase() | ||
module.exports = function identifier (key, casing = 'snake') { | ||
return casing.toLowerCase() === 'snake' ? snake(key) : camel(key) | ||
} | ||
const identifier = (key, casing = 'snake') => | ||
casing.toLowerCase() === 'snake' ? snake(key) : camel(key) | ||
module.exports = identifier |
module.exports = { | ||
Config: require('./Config'), | ||
changeCase: require('./changeCase'), | ||
Config: require('./Config'), | ||
isObject: require('./isObject'), | ||
copy: require('./copy'), | ||
identifier: require('./identifier'), | ||
mergeDeep: require('./mergeDeep'), | ||
identifier: require('./identifier') | ||
type: require('./type'), | ||
castString: require('./type/castString'), | ||
isObject: require('./type/isObject'), | ||
toBoolean: require('./type/toBoolean'), | ||
toJSON: require('./type/toJSON') | ||
} |
@@ -1,5 +0,7 @@ | ||
const isObject = require('./isObject') | ||
module.exports = function mergeDeep (writeObject, toCopyFrom) { | ||
const isObject = require('./type/isObject') | ||
const mergeDeep = (writeObject, toCopyFrom) => { | ||
if (!isObject(toCopyFrom) && !isObject(writeObject)) { | ||
return toCopyFrom || writeObject | ||
return typeof toCopyFrom === 'undefined' | ||
? writeObject : toCopyFrom | ||
} | ||
@@ -17,3 +19,3 @@ | ||
if (isObject(toCopyFrom[key])) { | ||
if (!writeObject[key]) { | ||
if (typeof writeObject[key] === 'undefined') { | ||
Object.assign(writeObject, { | ||
@@ -32,1 +34,3 @@ [key]: {} | ||
} | ||
module.exports = mergeDeep |
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
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 8 instances in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
0
5
18344
17
588
+ Addeddot-prop@5.1.0(transitive)
- Removeddot-prop@5.3.0(transitive)
Updatedcamelcase@5.3.1
Updatedconstant-case@2.0.0
Updateddot-prop@5.1.0