@spinajs/configuration
Advanced tools
Comparing version 1.0.12 to 1.0.14
@@ -35,2 +35,3 @@ import { IContainer, SyncModule } from '@spinajs/di'; | ||
protected Config: any; | ||
protected CustomConfigPaths: string[]; | ||
/** | ||
@@ -37,0 +38,0 @@ * |
@@ -76,16 +76,18 @@ "use strict"; | ||
// other @spinajs modules paths | ||
path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/orm/lib/config')), | ||
path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/orm-sqlite/lib/config')), | ||
path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/orm-sql/lib/config')), | ||
path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/log/lib/config')), | ||
path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/intl/lib/config')), | ||
path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/cli/lib/config')), | ||
path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/acl/lib/config')), | ||
path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/http/lib/config')), | ||
path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/acl-http/lib/config')), | ||
path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/node_modules/@spinajs/jobs/lib/config')), | ||
'/node_modules/@spinajs/orm/lib/config', | ||
'/node_modules/@spinajs/orm-sqlite/lib/config', | ||
'/node_modules/@spinajs/orm-sql/lib/config', | ||
'/node_modules/@spinajs/log/lib/config', | ||
'/node_modules/@spinajs/intl/lib/config', | ||
'/node_modules/@spinajs/cli/lib/config', | ||
'/node_modules/@spinajs/acl/lib/config', | ||
'/node_modules/@spinajs/http/lib/config', | ||
'/node_modules/@spinajs/acl-http/lib/config', | ||
'/node_modules/@spinajs/jobs/lib/config', | ||
'/node_modules/@spinajs/acl-session-provider-dynamodb/lib/config', | ||
// project paths - last to allow overwrite @spinajs conf | ||
path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/dist/config')), | ||
path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/build/config')), | ||
path_1.normalize(path_1.join(path_1.resolve(__dirname).split(path_1.sep + 'node_modules')[0], '/config')), | ||
'/lib/config', | ||
'/dist/config', | ||
'/build/config', | ||
'/config', | ||
]; | ||
@@ -96,2 +98,3 @@ /** | ||
this.Config = {}; | ||
this.CustomConfigPaths = cfgCustomPaths !== null && cfgCustomPaths !== void 0 ? cfgCustomPaths : []; | ||
this.RunApp = app !== null && app !== void 0 ? app : parseArgv('--app'); | ||
@@ -101,5 +104,2 @@ this.BaseDir = (_a = appBaseDir !== null && appBaseDir !== void 0 ? appBaseDir : parseArgv('--appPath')) !== null && _a !== void 0 ? _a : path_1.join(__dirname, '../apps/'); | ||
log(`Base dir at: ${this.BaseDir}`); | ||
if (cfgCustomPaths) { | ||
this.CONFIG_DIRS = this.CONFIG_DIRS.concat(cfgCustomPaths); | ||
} | ||
function parseArgv(param) { | ||
@@ -136,3 +136,6 @@ const index = process.argv.indexOf(param); | ||
load(extension, callback) { | ||
this.CONFIG_DIRS.filter(filterDirs) | ||
const basePath = this.RunApp ? this.BaseDir : findBasePath(process.cwd()); | ||
this.CONFIG_DIRS.map(f => path_1.join(basePath, f)) | ||
.concat(this.CustomConfigPaths) | ||
.filter(filterDirs) | ||
// get all config files | ||
@@ -154,2 +157,8 @@ .map(d => glob.sync(d + `/**/*.${extension}`)) | ||
.map(_.curry(merge)(this.Config)); | ||
function findBasePath(path) { | ||
if (fs.existsSync(path_1.join(path, 'node_modules'))) { | ||
return path; | ||
} | ||
return findBasePath(path_1.resolve(path, '..')); | ||
} | ||
} | ||
@@ -200,3 +209,3 @@ dir(toJoin) { | ||
log(`Application to run: ${this.RunApp}`); | ||
this.CONFIG_DIRS.push(this.dir(`/${this.RunApp}/config`)); | ||
this.CONFIG_DIRS.push(`./${this.RunApp}/config`); | ||
} | ||
@@ -203,0 +212,0 @@ } |
{ | ||
"name": "@spinajs/configuration", | ||
"version": "1.0.12", | ||
"version": "1.0.14", | ||
"description": "framework configuration module", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
282
17853