-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'add-unit-tests' into unit-tests-for-aws-secrets-manager
- Loading branch information
Showing
27 changed files
with
6,897 additions
and
2,569 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
* @iansu | ||
* @iansu @Neo-Malcolm-Fischer @AD-Blue |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
**/build | ||
**/coverage | ||
**/node_modules | ||
.eslintrc.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = { | ||
extends: ['eslint-config-neo/config-backend'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint'], | ||
parserOptions: { | ||
project: ['./tsconfig.cjs.json', './test/tsconfig.json'], | ||
sourceType: 'module', | ||
}, | ||
rules: { | ||
jest: 'off', | ||
'jest/no-commented-out-tests': 'off', | ||
'jest/no-deprecated-functions': 'off', | ||
'jest/valid-expect': 'off', | ||
'jest/valid-expect-in-promise': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "config-dug", | ||
"version": "2.0.0-alpha.0", | ||
"version": "2.0.0-alpha.1", | ||
"description": "Config management library for Node.js with support for multiple environments, config files, environment variables and plugins", | ||
"author": "Neo Financial Engineering <[email protected]>", | ||
"license": "MIT", | ||
|
@@ -41,19 +41,27 @@ | |
"build": "tsc -b tsconfig.cjs.json tsconfig.esm.json tsconfig.types.json", | ||
"watch": "tsc -b tsconfig.cjs.json tsconfig.esm.json tsconfig.types.json --watch", | ||
"clean": "rimraf build", | ||
"prepublishOnly": "npm run clean && npm run build", | ||
"test": "vitest run --config ./test/vitest.config.ts" | ||
"format": "prettier --write \"**/*.{ts,tsx,js,json,graphql,md}\"", | ||
"format:check": "prettier --debug-check \"**/*.{ts,tsx,js,json,graphql,md}\"", | ||
"lint": "eslint .", | ||
"test": "NODE_ENV=test TZ=UTC vitest run --config vite.config.js --isolate=false", | ||
"prepublishOnly": "npm run clean && npm run build" | ||
}, | ||
"dependencies": { | ||
"chalk": "^4.1.2", | ||
"change-case": "^4.1.2", | ||
"debug": "^4.3.4", | ||
"zod": "^3.21.4" | ||
"ms": "^2.1.3", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@tsconfig/node18": "^1.0.3", | ||
"@types/debug": "^4.1.7", | ||
"@types/node": "^18.11.18", | ||
"eslint-config-neo": "^0.12.0", | ||
"typescript": "^5.0.4" | ||
}, | ||
"optionalDependencies": { | ||
"@rollup/rollup-linux-x64-gnu": "^4.9.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Implementation from https://www.npmjs.com/package/change-case | ||
import * as changeCase from 'change-case'; | ||
import { UntypedConfig } from '../config-dug'; | ||
|
||
export enum KeyStyle { | ||
camelCase = 'camelCase', | ||
capitalCase = 'capitalCase', | ||
constantCase = 'constantCase', | ||
dotCase = 'dotCase', | ||
noCase = 'noCase', | ||
pascalCase = 'pascalCase', | ||
pathCase = 'pathCase', | ||
sentenceCase = 'sentenceCase', | ||
snakeCase = 'snakeCase', | ||
} | ||
|
||
const isObject = (object: unknown) => object !== null && typeof object === 'object'; | ||
|
||
function changeKeysFactory<Options extends changeCase.Options = changeCase.Options>( | ||
changeCase: (input: string, options?: changeCase.Options) => string | ||
): (object: UntypedConfig, depth?: number, options?: Options) => UntypedConfig { | ||
return function changeKeys(object: UntypedConfig, depth = 1, options?: Options): UntypedConfig { | ||
if (depth === 0 || !isObject(object)) return {}; | ||
|
||
const result: Record<string, unknown> = Object.create(Object.getPrototypeOf(object)); | ||
|
||
Object.keys(object as object).forEach((key) => { | ||
const value = (object as Record<string, unknown>)[key]; | ||
const changedKey = changeCase(key, options); | ||
result[changedKey] = value; | ||
}); | ||
|
||
return result; | ||
}; | ||
} | ||
|
||
export const camelCase = changeKeysFactory(changeCase.camelCase); | ||
export const capitalCase = changeKeysFactory(changeCase.capitalCase); | ||
export const constantCase = changeKeysFactory(changeCase.constantCase); | ||
export const dotCase = changeKeysFactory(changeCase.dotCase); | ||
export const noCase = changeKeysFactory(changeCase.noCase); | ||
export const pascalCase = changeKeysFactory(changeCase.pascalCase); | ||
export const pathCase = changeKeysFactory(changeCase.pathCase); | ||
export const sentenceCase = changeKeysFactory(changeCase.sentenceCase); | ||
export const snakeCase = changeKeysFactory(changeCase.snakeCase); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.