Skip to content

Commit fe94de6

Browse files
authored
fix: update dependencies (#80)
1 parent 7b6abe6 commit fe94de6

7 files changed

+72
-71
lines changed

.eslintrc.js

-21
This file was deleted.

.eslintrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"globals": {
3+
"fixtureFile": true
4+
},
5+
"extends": "@adobe/eslint-config-aio-lib-config"
6+
}

package.json

+10-6
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,22 @@
2929
"js-yaml": "^3.13.0"
3030
},
3131
"devDependencies": {
32+
"@adobe/eslint-config-aio-lib-config": "^2.0.0",
3233
"babel-runtime": "^6.26.0",
3334
"eslint": "^8.38.0",
34-
"eslint-config-standard": "^14.1.0",
35-
"eslint-plugin-import": "^2.16.0",
36-
"eslint-plugin-jest": "23.13.2",
37-
"eslint-plugin-node": "^11.0.0",
38-
"eslint-plugin-promise": "^4.0.1",
35+
"eslint-config-standard": "^17.0.0",
36+
"eslint-plugin-import": "^2.27.5",
37+
"eslint-plugin-jest": "^23.20.0",
38+
"eslint-plugin-jsdoc": "^37.9.7",
39+
"eslint-plugin-n": "^15.7.0",
40+
"eslint-plugin-node": "^11.1.0",
41+
"eslint-plugin-promise": "^6.1.1",
3942
"eslint-plugin-standard": "^4.0.0",
4043
"jest": "^29.5.0",
4144
"jest-plugin-fs": "^2.9.0",
4245
"jsdoc-to-markdown": "^5.0.3",
4346
"mock-stdin": "^1.0.0",
44-
"tsd-jsdoc": "^2.4.0"
47+
"tsd-jsdoc": "^2.4.0",
48+
"typescript": "^5.0.4"
4549
}
4650
}

src/Config.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ const { merge, loadFile, saveFile, getValue, setValue } = require('./util')
1919
/**
2020
* read a file and log exceptions to debug
2121
*
22-
* @param {String} file
22+
* @param {string} file
2323
* @param {Function} debugFn
24+
* @returns {object}
25+
* @private
2426
*/
2527
const readFile = (file) => {
2628
debug(`reading config: ${file}`)
@@ -35,7 +37,7 @@ const readFile = (file) => {
3537
}
3638

3739
class Config {
38-
reload() {
40+
reload () {
3941
dotenv(true)
4042
// get the env var and use it as the config root key
4143
// this could be aio or wxp or whatever
@@ -74,7 +76,7 @@ class Config {
7476
return this
7577
}
7678

77-
get(key = '', source) {
79+
get (key = '', source) {
7880
this.values || this.reload()
7981
let vals = this.values
8082

@@ -87,7 +89,7 @@ class Config {
8789
return JSON.parse(JSON.stringify(value))
8890
}
8991

90-
set(key, value, local = false) {
92+
set (key, value, local = false) {
9193
this.values || this.reload()
9294

9395
const config = (local) ? this.local : this.global

src/dotenv.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ const dotenv = require('dotenv')
2020
/**
2121
* parse file for environmental variables
2222
*
23-
* @param {String} file filepath to parse
23+
* @param {string} file filepath to parse
24+
* @private
2425
*/
2526
const parse = (file) => {
2627
checkForDuplicates(file)
@@ -31,7 +32,7 @@ const parse = (file) => {
3132
/**
3233
* parse file for environmental variables and log debug message for duplicate definitions
3334
*
34-
* @param {String} file filepath to parse
35+
* @param {string} file filepath to parse
3536
*/
3637
const checkForDuplicates = (file) => {
3738
try {
@@ -40,7 +41,7 @@ const checkForDuplicates = (file) => {
4041
const buf = Buffer.from(fs.readFileSync(file, 'utf-8'))
4142
const obj = {}
4243
const dupKeys = []
43-
buf.toString().split(NEWLINES_MATCH).forEach(function(line, idx) {
44+
buf.toString().split(NEWLINES_MATCH).forEach(function (line, idx) {
4445
const keyValueArr = line.match(RE_INI_KEY_VAL)
4546
if (keyValueArr != null) {
4647
const key = keyValueArr[1]
@@ -68,10 +69,10 @@ const checkForDuplicates = (file) => {
6869
/**
6970
* returns all keys in o1 that arent in o2
7071
*
71-
* @param {Object} o1
72-
* @param {Object} o2
73-
*
74-
* @return {Array} array of keys
72+
* @param {object} o1
73+
* @param {object} o2
74+
* @returns {Array} array of keys
75+
* @private
7576
*/
7677
const diff = (o1, o2) => Object.keys(o1).filter(k => !(k in o2))
7778

@@ -88,7 +89,7 @@ const clear = () => {
8889
}
8990
}
9091

91-
module.exports = function(force = false) {
92+
module.exports = function (force = false) {
9293
const file = path.join(process.cwd(), '.env')
9394
if (force || global[envFile] !== file) {
9495
try {

src/index.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ class ConfigAPI {
2525
*
2626
* @param {string} [key=''] the key to get the value from
2727
* @param {string} [source] 'global', 'local', or 'env'. Defaults to searching the consolidated config.
28+
* @returns {string|object} the config value
2829
*/
29-
get(key, source) {
30+
get (key, source) {
3031
return config.get(key, source)
3132
}
3233

@@ -36,8 +37,9 @@ class ConfigAPI {
3637
* @param {string} key the key to set the value to
3738
* @param {string} value the value to save for the key
3839
* @param {boolean} [local=false] Set to true to save the value in the local config. Defaults to false (save to global config).
40+
* @returns {object} the Config object itself
3941
*/
40-
set(key, value, local) {
42+
set (key, value, local) {
4143
return config.set(key, value, local) && this
4244
}
4345

@@ -46,35 +48,38 @@ class ConfigAPI {
4648
*
4749
* @param {string} key the key to delete the value from
4850
* @param {boolean} [local=false] Set to true to delete the value in the local config. Defaults to false (save to global config).
51+
* @returns {object} the Config object itself
4952
*/
50-
delete(key, local) {
53+
delete (key, local) {
5154
return config.set(key, null, local) && this
5255
}
5356

5457
/**
5558
* Reload the Config from all the config file(s)
59+
*
60+
* @returns {object} the Config object itself, if reload was successful
5661
*/
57-
reload() {
62+
reload () {
5863
return config.reload() && this
5964
}
6065

6166
/**
6267
* Pipe data from stdin.
6368
*
6469
* @function
65-
* @return {Promise<string>}
70+
* @returns {Promise<string>} tje pipe
6671
*/
67-
get getPipedData() {
72+
get getPipedData () {
6873
return pipe
6974
}
7075

7176
/**
7277
* Hoists variables in the ./.env file to process.env
7378
*
7479
* @function
75-
* @param {Object} the dotenv object
80+
* @returns {object} the dotenv object
7681
*/
77-
get dotenv() {
82+
get dotenv () {
7883
return dotenv
7984
}
8085
}

src/util.js

+28-24
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const deepmerge = require('deepmerge')
1919
/**
2020
* Support for mkdir -p.
2121
*
22-
* @param {String} dir the folder to create
22+
* @param {string} dir the folder to create
2323
*/
2424
const mkdirp = dir => {
2525
dir = dir || ''
@@ -33,18 +33,18 @@ const mkdirp = dir => {
3333
/**
3434
* Get property from object with case insensitivity.
3535
*
36-
* @param {Object} obj
37-
* @param {String} key
36+
* @param {object} obj
37+
* @param {string} key
38+
* @private
3839
*/
3940
const getProp = (obj, key) => obj[Object.keys(obj).find(k => k.toLowerCase() === key.toLowerCase())]
4041

4142
/**
4243
* Get a value in an object by dot notation.
4344
*
44-
* @param {String} key
45-
* @param {Object} obj
46-
*
47-
* @return {Object}
45+
* @param {object} obj the object to get the value for the key from
46+
* @param {string} key the key
47+
* @returns {object} the value
4848
*/
4949
const getValue = (obj, key) => {
5050
const keys = (key || '').toString().split('.')
@@ -54,11 +54,10 @@ const getValue = (obj, key) => {
5454
/**
5555
* Set a value by dot notation.
5656
*
57-
* @param {String} key
58-
* @param {String} value
59-
* @param {Object} [obj]
60-
*
61-
* @return {Object}
57+
* @param {string} key the key
58+
* @param {string} value the value to set
59+
* @param {object} [obj] the object to set the value for the key to
60+
* @returns {object} the transformed object
6261
*/
6362
const setValue = (key, value, obj) => {
6463
const parts = (key || '').split('.').filter(o => o.trim())
@@ -79,8 +78,7 @@ const setValue = (key, value, obj) => {
7978
* Deep merge a collection of objs returning a new object.
8079
*
8180
* @param {Array} objs array of objects
82-
*
83-
* @return {Object}
81+
* @returns {object} the merged object
8482
*/
8583
const merge = (...objs) => {
8684
// array merge strategy (replace)
@@ -94,9 +92,8 @@ const merge = (...objs) => {
9492
/**
9593
* Remove empty leaves from an object.
9694
*
97-
* @param {Object} obj
98-
*
99-
* @return {Object}
95+
* @param {object} obj the object to shake
96+
* @returns {object} the object with empty leaves removed
10097
*/
10198
const shake = obj => {
10299
const shakeObject = o => {
@@ -119,9 +116,8 @@ const shake = obj => {
119116
/**
120117
* Deserialise from a file.
121118
*
122-
* @param {String} file
123-
*
124-
* @return {Object}
119+
* @param {string} file the file to load
120+
* @returns {object} object containing the file contents and format
125121
*/
126122
const loadFile = (file) => {
127123
const contents = fs.readFileSync(file, 'utf-8').trim()
@@ -147,9 +143,10 @@ const loadFile = (file) => {
147143
/**
148144
* yaml serialise an object to a file.
149145
*
150-
* @param {String} file
151-
* @param {Object} obj
152-
* @param {String} format
146+
* @param {string} file the file to save to
147+
* @param {object} obj the object to save
148+
* @param {string} format the format of the file to save
149+
* @returns {object} true if the file was written successfully
153150
*/
154151
const saveFile = (file, obj, format) => {
155152
obj = obj || {}
@@ -170,4 +167,11 @@ const saveFile = (file, obj, format) => {
170167
return true
171168
}
172169

173-
module.exports = { mkdirp, getValue, setValue, merge, loadFile, saveFile }
170+
module.exports = {
171+
mkdirp,
172+
getValue,
173+
setValue,
174+
merge,
175+
loadFile,
176+
saveFile
177+
}

0 commit comments

Comments
 (0)