config 1.29.2 → 1.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/History.md +20 -0
- package/README.md +4 -4
- package/lib/config.js +73 -43
- package/package.json +3 -4
- package/ISSUE_TEMPLATE.md +0 -24
package/History.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
1.31.0 / 2018-05-22
|
|
2
|
+
===================
|
|
3
|
+
|
|
4
|
+
* Load new coffeescript module instead of coffee-script - bastbijl
|
|
5
|
+
|
|
6
|
+
1.30.0 / 2018-02-26
|
|
7
|
+
===================
|
|
8
|
+
|
|
9
|
+
* Support for nested raw() in javascript configurations - patrickpilch
|
|
10
|
+
|
|
11
|
+
1.29.4 / 2018-02-03
|
|
12
|
+
===================
|
|
13
|
+
|
|
14
|
+
* Re-publish - last changes didn't make it to npm
|
|
15
|
+
|
|
16
|
+
1.29.3 / 2018-02-03
|
|
17
|
+
===================
|
|
18
|
+
|
|
19
|
+
* Added soft dependencies so transpilers don't include everything - gewentao
|
|
20
|
+
|
|
1
21
|
1.29.2 / 2018-01-12
|
|
2
22
|
===================
|
|
3
23
|
|
package/README.md
CHANGED
|
@@ -155,15 +155,15 @@ Contributors
|
|
|
155
155
|
</tr><tr><td><img src=https://avatars2.githubusercontent.com/u/1246875?v=4><a href="https://github.com/jaylynch">jaylynch</a></td>
|
|
156
156
|
<td><img src=https://avatars1.githubusercontent.com/u/145742?v=4><a href="https://github.com/jberrisch">jberrisch</a></td>
|
|
157
157
|
<td><img src=https://avatars1.githubusercontent.com/u/9355665?v=4><a href="https://github.com/kgoerlitz">kgoerlitz</a></td>
|
|
158
|
+
<td><img src=https://avatars3.githubusercontent.com/u/8650543?v=4><a href="https://github.com/leonardovillela">leonardovillela</a></td>
|
|
158
159
|
<td><img src=https://avatars3.githubusercontent.com/u/1918551?v=4><a href="https://github.com/nitzan-shaked">nitzan-shaked</a></td>
|
|
159
160
|
<td><img src=https://avatars3.githubusercontent.com/u/3058150?v=4><a href="https://github.com/robertrossmann">robertrossmann</a></td>
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
</tr><tr><td><img src=https://avatars2.githubusercontent.com/u/498929?v=4><a href="https://github.com/roncli">roncli</a></td>
|
|
162
|
+
<td><img src=https://avatars2.githubusercontent.com/u/1355559?v=4><a href="https://github.com/superoven">superoven</a></td>
|
|
162
163
|
<td><img src=https://avatars2.githubusercontent.com/u/54934?v=4><a href="https://github.com/wmertens">wmertens</a></td>
|
|
163
164
|
<td><img src=https://avatars3.githubusercontent.com/u/2842176?v=4><a href="https://github.com/XadillaX">XadillaX</a></td>
|
|
164
165
|
<td><img src=https://avatars1.githubusercontent.com/u/4425455?v=4><a href="https://github.com/ncuillery">ncuillery</a></td>
|
|
165
|
-
<td><img src=https://
|
|
166
|
-
<td><img src=https://avatars3.githubusercontent.com/u/270632?v=4><a href="https://github.com/thetalecrafter">thetalecrafter</a></td>
|
|
166
|
+
<td><img src=https://avatars0.githubusercontent.com/u/2015295?v=4><a href="https://github.com/patrickpilch">patrickpilch</a></td>
|
|
167
167
|
</tr></table>
|
|
168
168
|
|
|
169
169
|
License
|
package/lib/config.js
CHANGED
|
@@ -32,6 +32,20 @@ var DEFAULT_CLONE_DEPTH = 20,
|
|
|
32
32
|
checkMutability = true, // Check for mutability/immutability on first get
|
|
33
33
|
gitCryptTestRegex = /^.GITCRYPT/; // regular expression to test for gitcrypt files.
|
|
34
34
|
|
|
35
|
+
// Define soft dependencies so transpilers don't include everything
|
|
36
|
+
var COFFEE_2_DEP = "coffeescript",
|
|
37
|
+
COFFEE_DEP = "coffee-script",
|
|
38
|
+
ICED_DEP = "iced-coffee-script",
|
|
39
|
+
JS_YAML_DEP = "js-yaml",
|
|
40
|
+
YAML_DEP = "yaml",
|
|
41
|
+
JSON5_DEP = "json5",
|
|
42
|
+
HJSON_DEP = "hjson",
|
|
43
|
+
TOML_DEP = "toml",
|
|
44
|
+
CSON_DEP = "cson",
|
|
45
|
+
PPARSER_DEP = "properties",
|
|
46
|
+
XML_DEP = "x2js",
|
|
47
|
+
TS_DEP = "ts-node";
|
|
48
|
+
|
|
35
49
|
/**
|
|
36
50
|
* <p>Application Configurations</p>
|
|
37
51
|
*
|
|
@@ -173,13 +187,6 @@ Config.prototype.get = function(property) {
|
|
|
173
187
|
if(property === null || property === undefined){
|
|
174
188
|
throw new Error("Calling config.get with null or undefined argument");
|
|
175
189
|
}
|
|
176
|
-
var t = this,
|
|
177
|
-
value = getImpl(t, property);
|
|
178
|
-
|
|
179
|
-
// Produce an exception if the property doesn't exist
|
|
180
|
-
if (value === undefined) {
|
|
181
|
-
throw new Error('Configuration property "' + property + '" is not defined');
|
|
182
|
-
}
|
|
183
190
|
|
|
184
191
|
// Make configurations immutable after first get (unless disabled)
|
|
185
192
|
if (checkMutability) {
|
|
@@ -188,9 +195,12 @@ Config.prototype.get = function(property) {
|
|
|
188
195
|
}
|
|
189
196
|
checkMutability = false;
|
|
190
197
|
}
|
|
198
|
+
var t = this,
|
|
199
|
+
value = getImpl(t, property);
|
|
191
200
|
|
|
192
|
-
if
|
|
193
|
-
|
|
201
|
+
// Produce an exception if the property doesn't exist
|
|
202
|
+
if (value === undefined) {
|
|
203
|
+
throw new Error('Configuration property "' + property + '" is not defined');
|
|
194
204
|
}
|
|
195
205
|
|
|
196
206
|
// Return the value
|
|
@@ -539,7 +549,13 @@ util.makeImmutable = function(object, property, value) {
|
|
|
539
549
|
var propertyName = properties[i],
|
|
540
550
|
value = object[propertyName];
|
|
541
551
|
|
|
542
|
-
if (
|
|
552
|
+
if (value instanceof RawConfig) {
|
|
553
|
+
Object.defineProperty(object, propertyName, {
|
|
554
|
+
value: value.resolve(),
|
|
555
|
+
writable: false,
|
|
556
|
+
configurable: false
|
|
557
|
+
});
|
|
558
|
+
} else {
|
|
543
559
|
Object.defineProperty(object, propertyName, {
|
|
544
560
|
value: value,
|
|
545
561
|
writable : false,
|
|
@@ -646,6 +662,9 @@ util.loadFileConfigs = function(configDir) {
|
|
|
646
662
|
// Override, NODE_ENV if NODE_CONFIG_ENV is specified.
|
|
647
663
|
NODE_ENV = util.initParam('NODE_CONFIG_ENV', NODE_ENV);
|
|
648
664
|
|
|
665
|
+
// Split files name, for loading multiple files.
|
|
666
|
+
NODE_ENV = NODE_ENV.split(',');
|
|
667
|
+
|
|
649
668
|
CONFIG_DIR = configDir || util.initParam('NODE_CONFIG_DIR', Path.join( process.cwd(), 'config') );
|
|
650
669
|
if (CONFIG_DIR.indexOf('.') === 0) {
|
|
651
670
|
CONFIG_DIR = Path.join(process.cwd() , CONFIG_DIR);
|
|
@@ -676,22 +695,26 @@ util.loadFileConfigs = function(configDir) {
|
|
|
676
695
|
env.HOSTNAME = hostName;
|
|
677
696
|
|
|
678
697
|
// Read each file in turn
|
|
679
|
-
var baseNames = ['default'
|
|
698
|
+
var baseNames = ['default'].concat(NODE_ENV);
|
|
680
699
|
|
|
681
700
|
// #236: Also add full hostname when they are different.
|
|
682
701
|
if ( hostName ) {
|
|
683
702
|
var firstDomain = hostName.split('.')[0];
|
|
684
703
|
|
|
685
|
-
|
|
686
|
-
|
|
704
|
+
NODE_ENV.forEach(function(env) {
|
|
705
|
+
// Backward compatibility
|
|
706
|
+
baseNames.push(firstDomain, firstDomain + '-' + env);
|
|
687
707
|
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
708
|
+
// Add full hostname when it is not the same
|
|
709
|
+
if ( hostName != firstDomain ) {
|
|
710
|
+
baseNames.push(hostName, hostName + '-' + env);
|
|
711
|
+
}
|
|
712
|
+
});
|
|
692
713
|
}
|
|
693
714
|
|
|
694
|
-
|
|
715
|
+
NODE_ENV.forEach(function(env) {
|
|
716
|
+
baseNames.push('local', 'local-' + env);
|
|
717
|
+
});
|
|
695
718
|
|
|
696
719
|
var extNames = ['js', 'ts', 'json', 'json5', 'hjson', 'toml', 'coffee', 'iced', 'yaml', 'yml', 'cson', 'properties', 'xml'];
|
|
697
720
|
baseNames.forEach(function(baseName) {
|
|
@@ -876,7 +899,7 @@ util.parseFile = function(fullFilename) {
|
|
|
876
899
|
}
|
|
877
900
|
else if (extension === 'ts') {
|
|
878
901
|
if (!require.extensions['.ts']) {
|
|
879
|
-
require(
|
|
902
|
+
require(TS_DEP).register({
|
|
880
903
|
lazy: true,
|
|
881
904
|
compilerOptions: {
|
|
882
905
|
allowJs: true,
|
|
@@ -904,7 +927,14 @@ util.parseFile = function(fullFilename) {
|
|
|
904
927
|
// Coffee = require("coffee-script");
|
|
905
928
|
//}
|
|
906
929
|
|
|
907
|
-
|
|
930
|
+
try {
|
|
931
|
+
// Try to load coffeescript
|
|
932
|
+
Coffee = require(COFFEE_2_DEP);
|
|
933
|
+
}
|
|
934
|
+
catch (e) {
|
|
935
|
+
// If it doesn't exist, try to load it using the deprecated module name
|
|
936
|
+
Coffee = require(COFFEE_DEP);
|
|
937
|
+
}
|
|
908
938
|
|
|
909
939
|
// coffee-script >= 1.7.0 requires explicit registration for require() to work
|
|
910
940
|
if (Coffee.register) {
|
|
@@ -915,7 +945,7 @@ util.parseFile = function(fullFilename) {
|
|
|
915
945
|
configObject = require(fullFilename);
|
|
916
946
|
}
|
|
917
947
|
else if (extension === 'iced') {
|
|
918
|
-
Iced = require(
|
|
948
|
+
Iced = require(ICED_DEP);
|
|
919
949
|
|
|
920
950
|
// coffee-script >= 1.7.0 requires explicit registration for require() to work
|
|
921
951
|
if (Iced.register) {
|
|
@@ -981,12 +1011,12 @@ util.parseString = function (content, format) {
|
|
|
981
1011
|
// Lazy loading
|
|
982
1012
|
try {
|
|
983
1013
|
// Try to load the better js-yaml module
|
|
984
|
-
Yaml = require(
|
|
1014
|
+
Yaml = require(JS_YAML_DEP);
|
|
985
1015
|
}
|
|
986
1016
|
catch (e) {
|
|
987
1017
|
try {
|
|
988
1018
|
// If it doesn't exist, load the fallback visionmedia yaml module.
|
|
989
|
-
VisionmediaYaml = require(
|
|
1019
|
+
VisionmediaYaml = require(YAML_DEP);
|
|
990
1020
|
}
|
|
991
1021
|
catch (e) { }
|
|
992
1022
|
}
|
|
@@ -1017,7 +1047,7 @@ util.parseString = function (content, format) {
|
|
|
1017
1047
|
}
|
|
1018
1048
|
|
|
1019
1049
|
if (!JSON5) {
|
|
1020
|
-
JSON5 = require(
|
|
1050
|
+
JSON5 = require(JSON5_DEP);
|
|
1021
1051
|
}
|
|
1022
1052
|
|
|
1023
1053
|
configObject = JSON5.parse(content);
|
|
@@ -1026,7 +1056,7 @@ util.parseString = function (content, format) {
|
|
|
1026
1056
|
else if (format === 'json5') {
|
|
1027
1057
|
|
|
1028
1058
|
if (!JSON5) {
|
|
1029
|
-
JSON5 = require(
|
|
1059
|
+
JSON5 = require(JSON5_DEP);
|
|
1030
1060
|
}
|
|
1031
1061
|
|
|
1032
1062
|
configObject = JSON5.parse(content);
|
|
@@ -1034,7 +1064,7 @@ util.parseString = function (content, format) {
|
|
|
1034
1064
|
} else if (format === 'hjson') {
|
|
1035
1065
|
|
|
1036
1066
|
if (!HJSON) {
|
|
1037
|
-
HJSON = require(
|
|
1067
|
+
HJSON = require(HJSON_DEP);
|
|
1038
1068
|
}
|
|
1039
1069
|
|
|
1040
1070
|
configObject = HJSON.parse(content);
|
|
@@ -1042,14 +1072,14 @@ util.parseString = function (content, format) {
|
|
|
1042
1072
|
} else if (format === 'toml') {
|
|
1043
1073
|
|
|
1044
1074
|
if(!TOML) {
|
|
1045
|
-
TOML = require(
|
|
1075
|
+
TOML = require(TOML_DEP);
|
|
1046
1076
|
}
|
|
1047
1077
|
|
|
1048
1078
|
configObject = TOML.parse(content);
|
|
1049
1079
|
}
|
|
1050
1080
|
else if (format === 'cson') {
|
|
1051
1081
|
if (!CSON) {
|
|
1052
|
-
CSON = require(
|
|
1082
|
+
CSON = require(CSON_DEP);
|
|
1053
1083
|
}
|
|
1054
1084
|
// Allow comments in CSON files
|
|
1055
1085
|
if (typeof CSON.parseSync === 'function') {
|
|
@@ -1060,13 +1090,13 @@ util.parseString = function (content, format) {
|
|
|
1060
1090
|
}
|
|
1061
1091
|
else if (format === 'properties') {
|
|
1062
1092
|
if (!PPARSER) {
|
|
1063
|
-
PPARSER = require(
|
|
1093
|
+
PPARSER = require(PPARSER_DEP);
|
|
1064
1094
|
}
|
|
1065
1095
|
configObject = PPARSER.parse(content, { namespaces: true, variables: true, sections: true });
|
|
1066
1096
|
} else if (format === 'xml') {
|
|
1067
1097
|
|
|
1068
1098
|
if (!XML) {
|
|
1069
|
-
XML = require(
|
|
1099
|
+
XML = require(XML_DEP);
|
|
1070
1100
|
}
|
|
1071
1101
|
|
|
1072
1102
|
var x2js = new XML();
|
|
@@ -1696,15 +1726,20 @@ util.runStrictnessChecks = function (config) {
|
|
|
1696
1726
|
return Path.basename(src.name);
|
|
1697
1727
|
});
|
|
1698
1728
|
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1729
|
+
NODE_ENV.forEach(function(env) {
|
|
1730
|
+
// Throw an exception if there's no explicit config file for NODE_ENV
|
|
1731
|
+
var anyFilesMatchEnv = sourceFilenames.some(function (filename) {
|
|
1732
|
+
return filename.match(env);
|
|
1733
|
+
});
|
|
1734
|
+
// development is special-cased because it's the default value
|
|
1735
|
+
if (env && (env !== 'development') && !anyFilesMatchEnv) {
|
|
1736
|
+
_warnOrThrow("NODE_ENV value of '"+env+"' did not match any deployment config file names.");
|
|
1737
|
+
}
|
|
1738
|
+
// Throw if NODE_ENV matches' default' or 'local'
|
|
1739
|
+
if ((env === 'default') || (env === 'local')) {
|
|
1740
|
+
_warnOrThrow("NODE_ENV value of '"+env+"' is ambiguous.");
|
|
1741
|
+
}
|
|
1703
1742
|
});
|
|
1704
|
-
// development is special-cased because it's the default value
|
|
1705
|
-
if (NODE_ENV && (NODE_ENV !== 'development') && !anyFilesMatchEnv) {
|
|
1706
|
-
_warnOrThrow("NODE_ENV value of '"+NODE_ENV+"' did not match any deployment config file names.");
|
|
1707
|
-
}
|
|
1708
1743
|
|
|
1709
1744
|
// Throw an exception if there's no explict config file for NODE_APP_INSTANCE
|
|
1710
1745
|
var anyFilesMatchInstance = sourceFilenames.some(function (filename) {
|
|
@@ -1714,11 +1749,6 @@ util.runStrictnessChecks = function (config) {
|
|
|
1714
1749
|
_warnOrThrow("NODE_APP_INSTANCE value of '"+APP_INSTANCE+"' did not match any instance config file names.");
|
|
1715
1750
|
}
|
|
1716
1751
|
|
|
1717
|
-
// Throw if NODE_ENV matches' default' or 'local'
|
|
1718
|
-
if ((NODE_ENV === 'default') || (NODE_ENV === 'local')) {
|
|
1719
|
-
_warnOrThrow("NODE_ENV value of '"+NODE_ENV+"' is ambiguous.");
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1722
1752
|
function _warnOrThrow (msg) {
|
|
1723
1753
|
var beStrict = process.env.NODE_CONFIG_STRICT_MODE;
|
|
1724
1754
|
var prefix = beStrict ? 'FATAL: ' : 'WARNING: ';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.0",
|
|
4
4
|
"main": "./lib/config.js",
|
|
5
5
|
"description": "Configuration control for production node deployments",
|
|
6
6
|
"author": "Loren West <open_source@lorenwest.com>",
|
|
@@ -19,12 +19,11 @@
|
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"json5": "0.
|
|
23
|
-
"os-homedir": "1.0.2"
|
|
22
|
+
"json5": "^1.0.1"
|
|
24
23
|
},
|
|
25
24
|
"devDependencies": {
|
|
26
25
|
"@types/node": "^7.0.8",
|
|
27
|
-
"
|
|
26
|
+
"coffeescript": "2.2.4",
|
|
28
27
|
"cson": "^3.0.1",
|
|
29
28
|
"hjson": "^1.2.0",
|
|
30
29
|
"js-yaml": "^3.2.2",
|
package/ISSUE_TEMPLATE.md
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
**Note: for support questions, please use [StackOverflow](https://stackoverflow.com/questions/tagged/node-config) and tag your question with `node-config`**. *This repository's issues are reserved for feature requests and bug reports.*
|
|
2
|
-
|
|
3
|
-
Before submitting a bug report, please search the issue tracker the wiki first. Many issues have already been discussed.
|
|
4
|
-
|
|
5
|
-
The wiki is located at: https://github.com/lorenwest/node-config/wiki
|
|
6
|
-
|
|
7
|
-
### I'm submitting a ...
|
|
8
|
-
- [ ] bug report
|
|
9
|
-
- [ ] feature request
|
|
10
|
-
- [ ] support request or question => Please do not submit support request or questions here, see note at the top of this template.
|
|
11
|
-
|
|
12
|
-
### What is the current behavior?
|
|
13
|
-
*If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem*:
|
|
14
|
-
|
|
15
|
-
### What is the expected behavior?
|
|
16
|
-
|
|
17
|
-
### Please tell us about your environment:
|
|
18
|
-
|
|
19
|
-
- node-config version: x.x.x
|
|
20
|
-
- node-version: x.x.x
|
|
21
|
-
|
|
22
|
-
### Other information
|
|
23
|
-
|
|
24
|
-
(e.g. are you using an environment besides Node.js?)
|