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

@spinajs/configuration

Package Overview
Dependencies
Maintainers
1
Versions
285
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spinajs/configuration - npm Package Compare versions

Comparing version 1.1.4 to 1.1.6

6

lib/config/configuration.js

@@ -1,8 +0,10 @@

module.exports = {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const config = {
configuration: {
isDevelopment: process.env.NODE_ENV === "development",
isProduction: process.env.NODE_ENV === "production",
isElectron: process.version.hasOwnProperty("electron")
}
};
exports.default = config;
//# sourceMappingURL=configuration.js.map

@@ -98,3 +98,3 @@ "use strict";

dir(toJoin) {
return (0, path_1.normalize)((0, path_1.join)((0, path_1.resolve)(this.BaseDir), toJoin));
return (0, path_1.normalize)((0, path_1.join)((0, path_1.resolve)(this.AppBaseDir), toJoin));
}

@@ -101,0 +101,0 @@ /**

@@ -12,6 +12,4 @@ export declare abstract class ConfigurationSource {

BaseDir: string;
/**
* Default dirs to check for configuration files
*/
protected CONFIG_DIRS: string[];
protected CommonDirs: string[];
protected BasePath: string;
constructor(RunApp?: string, CustomConfigPaths?: string[], appBaseDir?: string);

@@ -21,14 +19,6 @@ protected load(extension: string, callback: (file: string) => any): {};

export declare class JsFileSource extends BaseFileSource {
/**
* Default dirs to check for configuration files
*/
protected CONFIG_DIRS: string[];
Load(): Promise<any>;
}
export declare class JsonFileSource extends BaseFileSource {
/**
* Default dirs to check for configuration files
*/
protected CONFIG_DIRS: string[];
Load(): Promise<any>;
}

@@ -36,2 +36,3 @@ "use strict";

const path = __importStar(require("path"));
const log_1 = require("@spinajs/log/lib/log");
function mergeArrays(target, source) {

@@ -42,15 +43,2 @@ if (_.isArray(target)) {

}
const DEFAULT_CONFIG_DIRS = [
// this module path
(0, path_1.normalize)((0, path_1.join)((0, path_1.resolve)(__dirname), '/../config')),
// for tests, in src dir
(0, path_1.normalize)((0, path_1.join)((0, path_1.resolve)(__dirname), '/config')),
// other @spinajs modules paths
'node_modules/@spinajs/*/lib/config',
// project paths - last to allow overwrite @spinajs conf
'lib/config',
'dist/config',
'build/config',
'config',
];
class ConfigurationSource {

@@ -69,18 +57,27 @@ }

this.BaseDir = './';
/**
* Default dirs to check for configuration files
*/
this.CONFIG_DIRS = [];
this.CommonDirs = [
// this module path
(0, path_1.normalize)((0, path_1.join)((0, path_1.resolve)(__dirname), '/../config')),
// for tests, in src dir
(0, path_1.normalize)((0, path_1.join)((0, path_1.resolve)(__dirname), '/config')),
// other @spinajs modules paths
'node_modules/@spinajs/*/lib/config',
// project paths - last to allow overwrite @spinajs conf
'lib/config',
'dist/config',
'build/config',
'config',
];
this.BasePath = "";
this.BasePath = (0, util_1.findBasePath)(process.cwd());
}
load(extension, callback) {
const config = {};
let dirs = this.CONFIG_DIRS;
const basePath = (0, util_1.findBasePath)(process.cwd());
if (this.RunApp) {
dirs = dirs.concat([(0, path_1.join)(this.appBaseDir, `/${this.RunApp}/config`)]);
this.CommonDirs = this.CommonDirs.concat([(0, path_1.join)(this.appBaseDir, `/${this.RunApp}/config`)]);
}
if (this.CustomConfigPaths) {
dirs = dirs.concat(this.CustomConfigPaths);
this.CommonDirs = this.CommonDirs.concat(this.CustomConfigPaths);
}
dirs.map(f => path.isAbsolute(f) ? f : (0, path_1.join)(basePath, f))
this.CommonDirs.map(f => path.isAbsolute(f) ? f : (0, path_1.join)(this.BasePath, f))
// get all config files

@@ -97,3 +94,3 @@ .map(d => glob_1.glob.sync(path.join(d, `/**/${extension}`)))

// load & merge configs
.map((c) => _.mergeWith(config, c, mergeArrays));
.map((c) => { var _a; return _.mergeWith(config, (_a = c.default) !== null && _a !== void 0 ? _a : c, mergeArrays); });
return config;

@@ -104,9 +101,2 @@ }

let JsFileSource = class JsFileSource extends BaseFileSource {
constructor() {
super(...arguments);
/**
* Default dirs to check for configuration files
*/
this.CONFIG_DIRS = DEFAULT_CONFIG_DIRS;
}
async Load() {

@@ -124,2 +114,3 @@ const common = this.load('!(*.dev|*.prod).js', _load);

function _load(file) {
log_1.Log.trace(`Trying to load file ${file}`, "Configuration");
(0, util_1.uncache)(file);

@@ -135,9 +126,2 @@ return require(file);

let JsonFileSource = class JsonFileSource extends BaseFileSource {
constructor() {
super(...arguments);
/**
* Default dirs to check for configuration files
*/
this.CONFIG_DIRS = DEFAULT_CONFIG_DIRS;
}
async Load() {

@@ -156,2 +140,3 @@ const common = this.load('!(*.dev|*.prod).json', _load);

try {
log_1.Log.trace(`Trying to load file ${file}`, "Configuration");
return JSON.parse(fs.readFileSync(file, "utf-8"));

@@ -158,0 +143,0 @@ }

@@ -29,6 +29,2 @@ import { AsyncModule } from '@spinajs/di';

/**
* Configuration base dir, where to look for app config
*/
BaseDir: string;
/**
* Current running app name

@@ -35,0 +31,0 @@ */

{
"name": "@spinajs/configuration",
"version": "1.1.4",
"version": "1.1.6",
"description": "framework configuration module",

@@ -44,3 +44,3 @@ "main": "lib/index.js",

"@spinajs/exceptions": "^1.0.5",
"@spinajs/log": "^1.1.0",
"@spinajs/log": "^1.1.5",
"glob": "^7.1.4",

@@ -47,0 +47,0 @@ "lodash": "^4.17.14"

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