@geek/config
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -18,3 +18,2 @@ #!/usr/bin/env node | ||
// const prop1 = config.get('property1'); | ||
// console.error(`prop1: ${JSON.stringify(prop1, null, 2)}`); |
10
index.js
@@ -60,3 +60,3 @@ 'use strict'; | ||
console.error(`options: ${JSON.stringify(options, null, 2)}`); | ||
// console.error(`options: ${JSON.stringify(options, null, 2)}`); | ||
@@ -107,3 +107,3 @@ // project user configs | ||
console.error(`configFiles: ${JSON.stringify(configFiles, null, 2)}`); | ||
// console.error(`configFiles: ${JSON.stringify(configFiles, null, 2)}`); | ||
@@ -117,3 +117,3 @@ const finalConfig = {}; | ||
console.error(`finalConfig: ${JSON.stringify(finalConfig, null, 2)}`); | ||
// console.error(`finalConfig: ${JSON.stringify(finalConfig, null, 2)}`); | ||
@@ -147,5 +147,5 @@ this.store = finalConfig; | ||
const filepath = path.join(options.cwd, `${options.filename}.${options.ext}`); | ||
console.error(`filepath: ${JSON.stringify(filepath, null, 2)}`); | ||
// console.error(`filepath: ${JSON.stringify(filepath, null, 2)}`); | ||
if (! fs.pathExistsSync(filepath)) { | ||
console.error('you are here → file not found'); | ||
// console.error('you are here → file not found'); | ||
return; | ||
@@ -152,0 +152,0 @@ } |
{ | ||
"name": "@geek/config", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Geek Configuration Manager for Node.js - The complete solution for managing config settings for your Node.js application", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,6 +16,30 @@ # @geek/config | ||
```bash | ||
$ npm install @geek/config | ||
npm install @geek/config | ||
``` | ||
## Usage | ||
```JavaScript | ||
const Config = require('@geek/config'); | ||
// single profile | ||
const config1 = new Config({ | ||
cwd: __dirname, | ||
name: 'myapp', | ||
profile: 'dev', | ||
overrides: { property2: 'override-value' }, | ||
defaults: { property9: 'default-value' }, | ||
}); | ||
// multiple profiles | ||
const config2 = new Config({ | ||
cwd: __dirname, | ||
name: 'myapp', | ||
profiles: [ 'dev', 'ios' ], | ||
overrides: { property2: 'override-value' }, | ||
defaults: { property9: 'default-value' }, | ||
}); | ||
``` | ||
## Priority of config files | ||
@@ -28,7 +52,7 @@ | ||
| 2. | **overrides** | `{ "property1": "override-value" }` | parameter: `overrides` | | ||
| 3. | **user environment config file** | `myapp.dev.user.json` | *project directory* | | ||
| 3. | **user profile config file** | `myapp.dev.user.json` | *project directory* | | ||
| 4. | **user config file** | `myapp.user.json` | *project directory* | | ||
| 5. | **project environment config file** | `myapp.dev.project.json` | *project directory* | | ||
| 5. | **project profile config file** | `myapp.dev.project.json` | *project directory* | | ||
| 6. | **project config file** | `myapp.project.json` | *project directory* | | ||
| 7. | **global environment config fil**e | `myapp.dev.global.json` | *home config directory* | | ||
| 7. | **global profile config fil**e | `myapp.dev.global.json` | *home config directory* | | ||
| 8. | **global config file** | `myapp.global.json` | *home config directory* | | ||
@@ -50,3 +74,3 @@ | 9. | **default values** | `{ "property1": "default-value" }` | parameter: `defaults` | | ||
> if passed in environment only: `--environment dev` | ||
> if passed in environment only: `--profile dev` | ||
@@ -84,3 +108,3 @@ - process.env | ||
> if passed in specific config file: `--config mytest.json --environment dev` | ||
> if passed in specific config file: `--config mytest.json --profile dev` | ||
@@ -87,0 +111,0 @@ - process.env |
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
9877
134