fix the broken package
This commit is contained in:
parent
7fd66b7c76
commit
cf8f8b3e38
3
.gitignore
vendored
3
.gitignore
vendored
@ -131,6 +131,3 @@ dist
|
||||
|
||||
# TODO
|
||||
TODO.md
|
||||
|
||||
# Built libraries
|
||||
/lib
|
||||
|
3
lib/cjs/index.d.ts
vendored
Normal file
3
lib/cjs/index.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export * from "./utils.js";
|
||||
export { default as loadConfig } from "./loadConfig.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
lib/cjs/index.d.ts.map
Normal file
1
lib/cjs/index.d.ts.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
24
lib/cjs/index.js
Normal file
24
lib/cjs/index.js
Normal file
@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.loadConfig = void 0;
|
||||
__exportStar(require("./utils.js"), exports);
|
||||
var loadConfig_js_1 = require("./loadConfig.js");
|
||||
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return __importDefault(loadConfig_js_1).default; } });
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSw2Q0FBMkI7QUFDM0IsaURBQXdEO0FBQS9DLDRIQUFBLE9BQU8sT0FBYyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gXCIuL3V0aWxzLmpzXCI7XG5leHBvcnQgeyBkZWZhdWx0IGFzIGxvYWRDb25maWcgfSBmcm9tIFwiLi9sb2FkQ29uZmlnLmpzXCI7XG4iXX0=
|
5
lib/cjs/loadConfig.d.ts
vendored
Normal file
5
lib/cjs/loadConfig.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
declare const _default: <T>(opts: Partial<T>, envKey: string, localDefaultFilePath?: string) => {
|
||||
[x: string]: any;
|
||||
};
|
||||
export default _default;
|
||||
//# sourceMappingURL=loadConfig.d.ts.map
|
1
lib/cjs/loadConfig.d.ts.map
Normal file
1
lib/cjs/loadConfig.d.ts.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../../src/loadConfig.ts"],"names":[],"mappings":"sDAUS,MAAM;;;AAFf,wBAyCE"}
|
43
lib/cjs/loadConfig.js
Normal file
43
lib/cjs/loadConfig.js
Normal file
@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const utils_1 = require("./utils");
|
||||
exports.default = (opts, envKey, localDefaultFilePath = "") => {
|
||||
const { env } = process, { __dirname } = (0, utils_1.getDirname)(), def = (0, utils_1.readJsonIfExists)(path_1.default.join(__dirname, localDefaultFilePath || "./defaults.json5")),
|
||||
// gets value from ENV || options || defaults (in that order)
|
||||
getVal = (envName) => {
|
||||
const snakeEnvName = `${envKey}_${(0, utils_1.convertCamelToUpperSnakeCase)(envName)}`;
|
||||
if (env[snakeEnvName])
|
||||
return env[snakeEnvName];
|
||||
if (opts[envName])
|
||||
return opts[envName];
|
||||
return def[envName];
|
||||
},
|
||||
// gets array from ENV || options || defaults (in that order)
|
||||
getArray = (envName, optName = "") => {
|
||||
let newEnvName;
|
||||
if (optName === "") {
|
||||
optName = envName;
|
||||
newEnvName = (0, utils_1.convertCamelToUpperSnakeCase)(envName);
|
||||
}
|
||||
newEnvName = `${envKey}_${String(envName)}`;
|
||||
if (env[newEnvName])
|
||||
return env?.[newEnvName]?.split(path_1.default.delimiter);
|
||||
if (Array.isArray(opts[optName]) && opts[optName].length)
|
||||
return opts[optName];
|
||||
return def[optName];
|
||||
};
|
||||
return {
|
||||
...Object.keys(def).reduce((acc, curr) => {
|
||||
if (Array.isArray(def[curr]))
|
||||
acc[curr] = getArray(curr);
|
||||
else
|
||||
acc[curr] = getVal(curr);
|
||||
return acc;
|
||||
}, {}),
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZENvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sb2FkQ29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsZ0RBQXdCO0FBRXhCLG1DQUlpQjtBQUVqQixrQkFBZSxDQUNkLElBQWdCLEVBQ2hCLE1BQWMsRUFDZCxvQkFBb0IsR0FBRyxFQU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BlbnZOYW1lO1xuXHRcdFx0XHRuZXdFbnZOYW1lID0gY29udmVydENhbWVsVG9VcHBlclNuYWtlQ2FzZShlbnZOYW1lIGFzIHN0cmluZyk7XG5cdFx0XHR9XG5cdFx0XHRuZXdFbnZOYW1lID0gYCR7ZW52S2V5fV8ke1N0cmluZyhlbnZOYW1lKX1gO1xuXHRcdFx0aWYgKGVudltuZXdFbnZOYW1lXSlcblx0XHRcdFx0cmV0dXJuIGVudj8uW25ld0Vudk5hbWUgYXMga2V5b2YgdHlwZW9mIGVudl0/LnNwbGl0KHBhdGguZGVsaW1pdGVyKTtcblx0XHRcdGlmIChBcnJheS5pc0FycmF5KG9wdHNbb3B0TmFtZV0pICYmIChvcHRzW29wdE5hbWVdIGFzIFtdKS5sZW5ndGgpXG5cdFx0XHRcdHJldHVybiBvcHRzW29wdE5hbWVdO1xuXHRcdFx0cmV0dXJuIGRlZltvcHROYW1lXTtcblx0XHR9O1xuXG5cdHJldHVybiB7XG5cdFx0Li4uT2JqZWN0LmtleXMoZGVmKS5yZWR1Y2UoKGFjYzogUGFydGlhbDx0eXBlb2YgZGVmPiwgY3VycikgPT4ge1xuXHRcdFx0aWYgKEFycmF5LmlzQXJyYXkoZGVmW2N1cnJdKSkgYWNjW2N1cnJdID0gZ2V0QXJyYXkoY3VyciBhcyBrZXlvZiBUKTtcblx0XHRcdGVsc2UgYWNjW2N1cnJdID0gZ2V0VmFsKGN1cnIgYXMga2V5b2YgVCk7XG5cdFx0XHRyZXR1cm4gYWNjO1xuXHRcdH0sIHt9KSxcblx0fTtcbn07XG4iXX0=
|
16
lib/cjs/utils.d.ts
vendored
Normal file
16
lib/cjs/utils.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/// <reference types="node" />
|
||||
export interface ErrorWithCode {
|
||||
code: string;
|
||||
}
|
||||
export declare const convertCamelToUpperSnakeCase: (str: string) => string;
|
||||
/**
|
||||
* From: https://www.webmanajemen.com/2022/05/use-import-meta-cjs.html
|
||||
*/
|
||||
export declare const getDirname: () => {
|
||||
__dirname: string;
|
||||
__filename: string;
|
||||
};
|
||||
export declare const getTime: () => string;
|
||||
export declare const log: (...msg: unknown[]) => void;
|
||||
export declare const readJsonIfExists: (filePath: string | URL) => any;
|
||||
//# sourceMappingURL=utils.d.ts.map
|
1
lib/cjs/utils.d.ts.map
Normal file
1
lib/cjs/utils.d.ts.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAIA,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,4BAA4B,QAAS,MAAM,WACM,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,UAAU;;;CAYtB,CAAC;AAEF,eAAO,MAAM,OAAO,cAyBnB,CAAC;AAEF,eAAO,MAAM,GAAG,WAAY,OAAO,EAAE,SACgB,CAAC;AAEtD,eAAO,MAAM,gBAAgB,aAAc,MAAM,GAAG,GAAG,QAQtD,CAAC"}
|
67
lib/cjs/utils.js
Normal file
67
lib/cjs/utils.js
Normal file
File diff suppressed because one or more lines are too long
3
lib/esm/index.d.ts
vendored
Normal file
3
lib/esm/index.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export * from "./utils.js";
|
||||
export { default as loadConfig } from "./loadConfig.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
lib/esm/index.d.ts.map
Normal file
1
lib/esm/index.d.ts.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
24
lib/esm/index.js
Normal file
24
lib/esm/index.js
Normal file
@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.loadConfig = void 0;
|
||||
__exportStar(require("./utils.js"), exports);
|
||||
var loadConfig_js_1 = require("./loadConfig.js");
|
||||
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return __importDefault(loadConfig_js_1).default; } });
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSw2Q0FBMkI7QUFDM0IsaURBQXdEO0FBQS9DLDRIQUFBLE9BQU8sT0FBYyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gXCIuL3V0aWxzLmpzXCI7XG5leHBvcnQgeyBkZWZhdWx0IGFzIGxvYWRDb25maWcgfSBmcm9tIFwiLi9sb2FkQ29uZmlnLmpzXCI7XG4iXX0=
|
5
lib/esm/loadConfig.d.ts
vendored
Normal file
5
lib/esm/loadConfig.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
declare const _default: <T>(opts: Partial<T>, envKey: string, localDefaultFilePath?: string) => {
|
||||
[x: string]: any;
|
||||
};
|
||||
export default _default;
|
||||
//# sourceMappingURL=loadConfig.d.ts.map
|
1
lib/esm/loadConfig.d.ts.map
Normal file
1
lib/esm/loadConfig.d.ts.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../../src/loadConfig.ts"],"names":[],"mappings":"sDAUS,MAAM;;;AAFf,wBAyCE"}
|
43
lib/esm/loadConfig.js
Normal file
43
lib/esm/loadConfig.js
Normal file
@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const utils_1 = require("./utils");
|
||||
exports.default = (opts, envKey, localDefaultFilePath = "") => {
|
||||
const { env } = process, { __dirname } = (0, utils_1.getDirname)(), def = (0, utils_1.readJsonIfExists)(path_1.default.join(__dirname, localDefaultFilePath || "./defaults.json5")),
|
||||
// gets value from ENV || options || defaults (in that order)
|
||||
getVal = (envName) => {
|
||||
const snakeEnvName = `${envKey}_${(0, utils_1.convertCamelToUpperSnakeCase)(envName)}`;
|
||||
if (env[snakeEnvName])
|
||||
return env[snakeEnvName];
|
||||
if (opts[envName])
|
||||
return opts[envName];
|
||||
return def[envName];
|
||||
},
|
||||
// gets array from ENV || options || defaults (in that order)
|
||||
getArray = (envName, optName = "") => {
|
||||
let newEnvName;
|
||||
if (optName === "") {
|
||||
optName = envName;
|
||||
newEnvName = (0, utils_1.convertCamelToUpperSnakeCase)(envName);
|
||||
}
|
||||
newEnvName = `${envKey}_${String(envName)}`;
|
||||
if (env[newEnvName])
|
||||
return env?.[newEnvName]?.split(path_1.default.delimiter);
|
||||
if (Array.isArray(opts[optName]) && opts[optName].length)
|
||||
return opts[optName];
|
||||
return def[optName];
|
||||
};
|
||||
return {
|
||||
...Object.keys(def).reduce((acc, curr) => {
|
||||
if (Array.isArray(def[curr]))
|
||||
acc[curr] = getArray(curr);
|
||||
else
|
||||
acc[curr] = getVal(curr);
|
||||
return acc;
|
||||
}, {}),
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZENvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sb2FkQ29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsZ0RBQXdCO0FBRXhCLG1DQUlpQjtBQUVqQixrQkFBZSxDQUNkLElBQWdCLEVBQ2hCLE1BQWMsRUFDZCxvQkFBb0IsR0FBRyxFQUFFLEVBQ3hCLEVBQUU7SUFDSCxNQUFNLEVBQUUsR0FBRyxFQUFFLEdBQUcsT0FBTyxFQUN0QixFQUFFLFNBQVMsRUFBRSxHQUFHLElBQUEsa0JBQVUsR0FBRSxFQUM1QixHQUFHLEdBQUcsSUFBQSx3QkFBZ0IsRUFDckIsY0FBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUUsb0JBQW9CLElBQUksa0JBQWtCLENBQUMsQ0FDaEU7SUFDRCw2REFBNkQ7SUFDN0QsTUFBTSxHQUFHLENBQUMsT0FBZ0IsRUFBRSxFQUFFO1FBQzdCLE1BQU0sWUFBWSxHQUFHLEdBQUcsTUFBTSxJQUFJLElBQUEsb0NBQTRCLEVBQzdELE9BQWlCLENBQ2pCLEVBQUUsQ0FBQztRQUNKLElBQUksR0FBRyxDQUFDLFlBQVksQ0FBQztZQUFFLE9BQU8sR0FBRyxDQUFDLFlBQVksQ0FBQyxDQUFDO1FBQ2hELElBQUksSUFBSSxDQUFDLE9BQU8sQ0FBQztZQUFFLE9BQU8sSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDO1FB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gY3VycikgPT4ge1xuXHRcdFx0aWYgKEFycmF5LmlzQXJyYXkoZGVmW2N1cnJdKSkgYWNjW2N1cnJdID0gZ2V0QXJyYXkoY3VyciBhcyBrZXlvZiBUKTtcblx0XHRcdGVsc2UgYWNjW2N1cnJdID0gZ2V0VmFsKGN1cnIgYXMga2V5b2YgVCk7XG5cdFx0XHRyZXR1cm4gYWNjO1xuXHRcdH0sIHt9KSxcblx0fTtcbn07XG4iXX0=
|
16
lib/esm/utils.d.ts
vendored
Normal file
16
lib/esm/utils.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/// <reference types="node" />
|
||||
export interface ErrorWithCode {
|
||||
code: string;
|
||||
}
|
||||
export declare const convertCamelToUpperSnakeCase: (str: string) => string;
|
||||
/**
|
||||
* From: https://www.webmanajemen.com/2022/05/use-import-meta-cjs.html
|
||||
*/
|
||||
export declare const getDirname: () => {
|
||||
__dirname: string;
|
||||
__filename: string;
|
||||
};
|
||||
export declare const getTime: () => string;
|
||||
export declare const log: (...msg: unknown[]) => void;
|
||||
export declare const readJsonIfExists: (filePath: string | URL) => any;
|
||||
//# sourceMappingURL=utils.d.ts.map
|
1
lib/esm/utils.d.ts.map
Normal file
1
lib/esm/utils.d.ts.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAIA,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,4BAA4B,QAAS,MAAM,WACM,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,UAAU;;;CAYtB,CAAC;AAEF,eAAO,MAAM,OAAO,cAyBnB,CAAC;AAEF,eAAO,MAAM,GAAG,WAAY,OAAO,EAAE,SACgB,CAAC;AAEtD,eAAO,MAAM,gBAAgB,aAAc,MAAM,GAAG,GAAG,QAQtD,CAAC"}
|
67
lib/esm/utils.js
Normal file
67
lib/esm/utils.js
Normal file
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@itsericwoodward/utils",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"description": "A small collection of common libraries and functions the author likes to use in his Node applications.",
|
||||
"main": "./lib/cjs/index.js",
|
||||
"module": "./lib/esm/index.js",
|
||||
|
Loading…
Reference in New Issue
Block a user