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

electrode-confippet

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electrode-confippet - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

lib/load-config.d.ts

53

lib/compose-config.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const Path = __importStar(require("path"));
const fs = __importStar(require("fs"));
const lodash_1 = __importDefault(require("lodash"));
const assert_1 = __importDefault(require("assert"));
const default_compose_opts_1 = __importDefault(require("./default-compose-opts"));
const provider_types_1 = __importDefault(require("./provider-types"));
const process_config_1 = __importDefault(require("./process-config"));
const util_1 = __importDefault(require("./util"));
const tslib_1 = require("tslib");
const Path = tslib_1.__importStar(require("path"));
const fs = tslib_1.__importStar(require("fs"));
const lodash_1 = tslib_1.__importDefault(require("lodash"));
const assert_1 = tslib_1.__importDefault(require("assert"));
const default_compose_opts_1 = tslib_1.__importDefault(require("./default-compose-opts"));
const provider_types_1 = tslib_1.__importDefault(require("./provider-types"));
const process_config_1 = tslib_1.__importDefault(require("./process-config"));
const util_1 = tslib_1.__importDefault(require("./util"));
/* eslint-disable max-statements */

@@ -38,3 +17,4 @@ function composeConfigDir(dir, data, options) {

const load = (key, provider) => {
const found = exts.map((ext) => {
const found = exts
.map((ext) => {
const fullF = Path.join(dir, `${provider.name}.${ext}`);

@@ -47,3 +27,4 @@ if (fs.existsSync(fullF)) {

return undefined;
}).filter((x) => x);
})
.filter((x) => x);
if (lodash_1.default.isEmpty(found)) {

@@ -72,4 +53,5 @@ const msg = `Config provider ${key}: no file ${provider.name} of ` +

assert_1.default(p.type, "config provider type must be specified");
return p.type !== provider_types_1.default.disabled && (p.name || p.handler) &&
(x === undefined ? true : !filterOff(x));
return (p.type !== provider_types_1.default.disabled &&
(p.name || p.handler) &&
(x === undefined ? true : !filterOff(x)));
};

@@ -87,3 +69,4 @@ const num = (x) => {

assert_1.default(list.length > 0, "config providers empty");
list.sort((a, b) => order(providers[a]) - order(providers[b]))
list
.sort((a, b) => order(providers[a]) - order(providers[b]))
.forEach((k) => {

@@ -90,0 +73,0 @@ const p = providers[k];

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const provider_types_1 = __importDefault(require("./provider-types"));
const util_1 = __importDefault(require("./util"));
const tslib_1 = require("tslib");
const provider_types_1 = tslib_1.__importDefault(require("./provider-types"));
const util_1 = tslib_1.__importDefault(require("./util"));
const envOrder = 1000;

@@ -12,3 +10,3 @@ const confippetEnvOrder = 2000;

dir: "config",
extSearch: ["json", "yaml", "js"],
extSearch: ["json", "yaml", "js", "ts"],
extHandlers: require("./ext-handlers"),

@@ -15,0 +13,0 @@ failMissing: true,

@@ -1,7 +0,16 @@

/// <reference types="node" />
/**
* Load a config partial from a JS module
*
* @param fullFilePath full path to the the file
*
* @returns If it's an ES6 module and has `default`, then `default` is returned,
* else returns the module as config partial.
*/
declare function loadJs(fullFilePath: string): unknown;
declare const _default: {
json: NodeRequire;
js: NodeRequire;
yaml: (fullF: any) => any;
json: typeof loadJs;
js: typeof loadJs;
yaml: (fullDirPath: string) => any;
ts: typeof loadJs;
};
export = _default;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
const jsYaml = __importStar(require("js-yaml"));
const fs = __importStar(require("fs"));
const tslib_1 = require("tslib");
const jsYaml = tslib_1.__importStar(require("js-yaml"));
const fs = tslib_1.__importStar(require("fs"));
/**
* Load a config partial from a JS module
*
* @param fullFilePath full path to the the file
*
* @returns If it's an ES6 module and has `default`, then `default` is returned,
* else returns the module as config partial.
*/
function loadJs(fullFilePath) {
const configMod = require(fullFilePath);
if (configMod.__esModule) {
if (configMod.hasOwnProperty("default")) {
return configMod.default;
}
else {
// will be using the whole module as config partial, so hide the ES module flag
try {
Object.defineProperty(configMod, "__esModule", { enumerable: false });
}
catch (_a) {
// oh well, can't hide it
}
}
}
return configMod;
}
module.exports = {
json: require,
js: require,
yaml: (fullF) => jsYaml.load(fs.readFileSync(fullF, "utf8"))
json: loadJs,
js: loadJs,
yaml: (fullDirPath) => jsYaml.load(fs.readFileSync(fullDirPath, "utf8")),
ts: loadJs,
};
//# sourceMappingURL=ext-handlers.js.map

@@ -1,2 +0,1 @@

/// <reference types="node" />
import processConfig from "./process-config";

@@ -20,5 +19,6 @@ import composeConfig from "./compose-config";

extHandlers: {
json: NodeRequire;
js: NodeRequire;
yaml: (fullF: any) => any;
json: (fullFilePath: string) => unknown;
js: (fullFilePath: string) => unknown;
yaml: (fullDirPath: string) => any;
ts: (fullFilePath: string) => unknown;
};

@@ -31,4 +31,4 @@ util: {

};
loadConfig: (composeOptions: any, defaults: any, refresh: any) => any;
loadConfig: (options: import("./load-config").LoadOptions, defaults?: unknown, refresh?: boolean) => any;
};
export = confippet;
"use strict";
/* eslint-disable global-require */
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const process_config_1 = __importDefault(require("./process-config"));
const compose_config_1 = __importDefault(require("./compose-config"));
const preset_config_1 = __importDefault(require("./preset-config"));
const store_1 = __importDefault(require("./store"));
const provider_types_1 = __importDefault(require("./provider-types"));
const util_1 = __importDefault(require("./util"));
const ext_handlers_1 = __importDefault(require("./ext-handlers"));
const loadconfig_1 = require("./loadconfig");
const tslib_1 = require("tslib");
const process_config_1 = tslib_1.__importDefault(require("./process-config"));
const compose_config_1 = tslib_1.__importDefault(require("./compose-config"));
const preset_config_1 = tslib_1.__importDefault(require("./preset-config"));
const store_1 = tslib_1.__importDefault(require("./store"));
const provider_types_1 = tslib_1.__importDefault(require("./provider-types"));
const util_1 = tslib_1.__importDefault(require("./util"));
const ext_handlers_1 = tslib_1.__importDefault(require("./ext-handlers"));
const load_config_1 = require("./load-config");
const confippet = {

@@ -22,3 +20,3 @@ processConfig: process_config_1.default,

util: util_1.default,
loadConfig: loadconfig_1.loadConfig,
loadConfig: load_config_1.loadConfig,
};

@@ -25,0 +23,0 @@ Object.defineProperty(confippet, "config", {

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const util_1 = __importDefault(require("./util"));
const tslib_1 = require("tslib");
const util_1 = tslib_1.__importDefault(require("./util"));
function load(config, options) {

@@ -7,0 +5,0 @@ options = options || {};

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const lodash_1 = __importDefault(require("lodash"));
const fs = __importStar(require("fs"));
const tslib_1 = require("tslib");
const lodash_1 = tslib_1.__importDefault(require("lodash"));
const fs = tslib_1.__importStar(require("fs"));
function processObj(obj, data) {

@@ -27,0 +6,0 @@ const depthPath = data.depth.join(".");

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const _ = __importStar(require("lodash"));
const process_config_1 = __importDefault(require("./process-config"));
const compose_config_1 = __importDefault(require("./compose-config"));
const util_1 = __importDefault(require("./util"));
const tslib_1 = require("tslib");
const _ = tslib_1.__importStar(require("lodash"));
const process_config_1 = tslib_1.__importDefault(require("./process-config"));
const compose_config_1 = tslib_1.__importDefault(require("./compose-config"));
const util_1 = tslib_1.__importDefault(require("./util"));
function hideProperties(obj, props) {

@@ -29,0 +8,0 @@ props.forEach((prop) => {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
const _ = __importStar(require("lodash"));
const tslib_1 = require("tslib");
const _ = tslib_1.__importStar(require("lodash"));
const util = {
replaceArray: (a, b) => _.isArray(b) && b || undefined,
replaceArray: (a, b) => (_.isArray(b) && b) || undefined,
merge: function (...args) {

@@ -25,0 +7,0 @@ Array.prototype.push.call(args, util.replaceArray);

{
"name": "electrode-confippet",
"version": "1.6.0",
"version": "1.7.0",
"description": "Managing NodeJS application configuration",
"main": "lib/index.js",
"scripts": {
"build": "tsc",
"test": "xrun --serial [build, xarc/test-only]",
"check": "xrun --serial [build, xarc/check]",
"prepublishOnly": "xrun --serial [build, xarc/check]",
"coverage": "xrun --serial [build, xarc/test-cov]"
"build": "rm -rf lib && tsc",
"test": "xrun xarc/test-only",
"check": "xrun --serial build xarc/check",
"prepublishOnly": "xrun [[build, docs], xarc/check]",
"coverage": "xrun --serial build xarc/test-cov",
"docs": "xrun xarc/docs",
"prepare": "npm run build"
},

@@ -25,30 +27,33 @@ "keywords": [],

"js-yaml": "^3.5.3",
"lodash": "^4.13.1"
"lodash": "^4.13.1",
"tslib": "^2.1.0"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@types/chai": "^4.2.11",
"@types/chai": "^4.2.14",
"@types/lodash": "^4.14.168",
"@types/mocha": "^7.0.2",
"@types/node": "^13.7.6",
"@types/sinon": "^9.0.0",
"@types/sinon-chai": "^3.2.4",
"@typescript-eslint/eslint-plugin": "^2.21.0",
"@typescript-eslint/parser": "^2.21.0",
"@xarc/module-dev": "^2.2.5",
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.16",
"@types/sinon": "^9.0.10",
"@types/sinon-chai": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^4.11.0",
"@typescript-eslint/parser": "^4.11.0",
"@xarc/module-dev": "^3.2.1",
"@xarc/run": "^1.0.4",
"babel-eslint": "^10.1.0",
"chai": "^4.2.0",
"eslint": "^6.8.0",
"eslint": "^7.16.0",
"eslint-config-walmart": "^2.2.1",
"eslint-plugin-filenames": "^1.1.0",
"eslint-plugin-jsdoc": "^21.0.0",
"eslint-plugin-jsdoc": "^30.7.9",
"intercept-stdout": "^0.1.2",
"mocha": "^7.1.0",
"nyc": "^15.0.0",
"sinon": "^7.2.6",
"sinon-chai": "^3.3.0",
"source-map-support": "^0.5.16",
"ts-node": "^8.6.2",
"typescript": "^3.8.3"
"mocha": "^8.2.1",
"nyc": "^15.1.0",
"prettier": "^2.2.1",
"sinon": "^9.2.2",
"sinon-chai": "^3.5.0",
"source-map-support": "^0.5.19",
"ts-node": "^9.1.1",
"typedoc": "^0.20.13",
"typescript": "^4.1.3"
},

@@ -60,13 +65,7 @@ "@xarc/module-dev": {

"mocha",
"prettier",
"typedoc",
"typescript"
]
},
"mocha": {
"require": [
"ts-node/register",
"source-map-support/register",
"@xarc/module-dev/config/test/setup.js"
],
"recursive": true
},
"nyc": {

@@ -89,7 +88,7 @@ "extends": [

"gulpfile.js",
"lib/*.ts",
"src",
"test",
"xrun*.js",
"xrun*.ts",
"src",
"lib/*.ts"
"xrun*.ts"
],

@@ -113,3 +112,18 @@ "check-coverage": true,

}
},
"files": [
"lib",
"src"
],
"mocha": {
"require": [
"ts-node/register",
"source-map-support/register",
"@xarc/module-dev/config/test/setup.js"
],
"recursive": true
},
"prettier": {
"printWidth": 100
}
}

@@ -11,11 +11,13 @@ # Electrode Confippet [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]

- [Features](#features)
- [Getting Started](#getting-started)
- [Installation](#installation)
- [Basic Use](#basic-use)
- [Config Composition](#config-composition)
- [Environment Variables](#environment-variables)
- [Using Templates](#using-templates)
- [Usage in Node Modules](#usage-in-node-modules)
- [Customization](#customization)
- [Electrode Confippet ![NPM version](#electrode-confippet-npm-versionnpm-url-build-statustravis-imagetravis-url)
- [Contents](#contents)
- [Features](#features)
- [Getting Started](#getting-started)
- [Installation](#installation)
- [Basic Use](#basic-use)
- [Config Composition](#config-composition)
- [Environment Variables](#environment-variables)
- [Using Templates](#using-templates)
- [Usage in Node Modules](#usage-in-node-modules)
- [Customization](#customization)

@@ -184,8 +186,8 @@ ## Features

context: {
deployment: process.env.NODE_ENV,
},
deployment: process.env.NODE_ENV
}
};
const defaults = {
foo: "bar",
foo: "bar"
};

@@ -229,5 +231,5 @@

order: 300,
type: Confippet.providerTypes.required,
},
},
type: Confippet.providerTypes.required
}
}
});

@@ -234,0 +236,0 @@ ```

@@ -18,16 +18,19 @@ import * as Path from "path";

const load = (key, provider) => {
const found = exts.map((ext) => {
const fullF = Path.join(dir, `${provider.name}.${ext}`);
const found = exts
.map((ext) => {
const fullF = Path.join(dir, `${provider.name}.${ext}`);
if (fs.existsSync(fullF)) {
assert(handlers[ext], `Config handler for extension ${ext} missing`);
util.uMerge(data, handlers[ext](fullF));
return ext;
}
if (fs.existsSync(fullF)) {
assert(handlers[ext], `Config handler for extension ${ext} missing`);
util.uMerge(data, handlers[ext](fullF));
return ext;
}
return undefined;
}).filter((x) => x);
return undefined;
})
.filter((x) => x);
if (_.isEmpty(found)) {
const msg = `Config provider ${key}: no file ${provider.name} of ` +
const msg =
`Config provider ${key}: no file ${provider.name} of ` +
`extensions ${exts} found in ${dir}`;

@@ -56,4 +59,7 @@

assert(p.type, "config provider type must be specified");
return p.type !== providerTypes.disabled && (p.name || p.handler) &&
(x === undefined ? true : !filterOff(x));
return (
p.type !== providerTypes.disabled &&
(p.name || p.handler) &&
(x === undefined ? true : !filterOff(x))
);
};

@@ -77,3 +83,4 @@

list.sort((a, b) => order(providers[a]) - order(providers[b]))
list
.sort((a, b) => order(providers[a]) - order(providers[b]))
.forEach((k) => {

@@ -80,0 +87,0 @@ const p = providers[k];

@@ -6,6 +6,6 @@ import providerTypes from "./provider-types";

const confippetEnvOrder = 2000;
function defaultOpts () {
function defaultOpts() {
return {
dir: "config",
extSearch: ["json", "yaml", "js"],
extSearch: ["json", "yaml", "js", "ts"],
extHandlers: require("./ext-handlers"), // eslint-disable-line

@@ -130,3 +130,3 @@ failMissing: true, // whether fails if a required provider missing

return {env};
return { env };
},

@@ -150,3 +150,2 @@ order: envOrder

}
},

@@ -153,0 +152,0 @@ context: {

import * as jsYaml from "js-yaml";
import * as fs from "fs";
/**
* Load a config partial from a JS module
*
* @param fullFilePath full path to the the file
*
* @returns If it's an ES6 module and has `default`, then `default` is returned,
* else returns the module as config partial.
*/
function loadJs(fullFilePath: string): unknown {
const configMod = require(fullFilePath);
if (configMod.__esModule) {
if (configMod.hasOwnProperty("default")) {
return configMod.default;
} else {
// will be using the whole module as config partial, so hide the ES module flag
try {
Object.defineProperty(configMod, "__esModule", { enumerable: false });
} catch {
// oh well, can't hide it
}
}
}
return configMod;
}
export = {
json: require,
js: require,
yaml: (fullF) => jsYaml.load(fs.readFileSync(fullF, "utf8"))
json: loadJs,
js: loadJs,
yaml: (fullDirPath: string) => jsYaml.load(fs.readFileSync(fullDirPath, "utf8")),
ts: loadJs,
};

@@ -10,3 +10,3 @@ /* eslint-disable global-require */

import extHandlers from "./ext-handlers";
import { loadConfig } from "./loadconfig";
import { loadConfig } from "./load-config";

@@ -13,0 +13,0 @@ const confippet = {

@@ -19,3 +19,2 @@ import _ from "lodash";

if (path.startsWith("-")) {

@@ -38,7 +37,5 @@ return path.substr(1);

});
} else if (_.isUndefined(x)) {
data.missing.push({path: `${depthPath}.${k}`, value: v, tmpl});
data.missing.push({ path: `${depthPath}.${k}`, value: v, tmpl });
return "";
} else {

@@ -101,3 +98,3 @@ const extras = _(refs).drop().map(resolve).value().join("");

const data = {config, context, options, more: 1, missing: [], depth: ["config"]};
const data = { config, context, options, more: 1, missing: [], depth: ["config"] };
const maxRun = 20;

@@ -104,0 +101,0 @@

import * as _ from "lodash";
const util = {
replaceArray: (a, b) => _.isArray(b) && b || undefined,
replaceArray: (a, b) => (_.isArray(b) && b) || undefined,
merge: function (...args) {

@@ -6,0 +6,0 @@ Array.prototype.push.call(args, util.replaceArray);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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