dotenv-extended 2.9.0 → 3.0.1
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/README.md +60 -25
- package/dotenv-extended.d.ts +1 -1
- package/lib/bin/cli.js +224 -0
- package/lib/bin/index.js +222 -46
- package/lib/config.js +176 -30
- package/lib/index.js +155 -66
- package/package.json +56 -57
- package/CHANGELOG.md +0 -72
- package/CONTRIBUTING.md +0 -33
- package/lib/utils/config-from-env.js +0 -28
- package/lib/utils/load-environment-file.js +0 -30
- package/lib/utils/parse-command.js +0 -49
package/CHANGELOG.md
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## 2.9.0 - 2020.09.30
|
|
4
|
-
- Missing values in schema now default to empty strings for `errorOnRegex` (thanks @FokkeZB)
|
|
5
|
-
- Minor modernization and refactoring of unit tests
|
|
6
|
-
|
|
7
|
-
## 2.8.0 - 2020.03.25
|
|
8
|
-
- Update dependencies while retaining compatibility with Node 6
|
|
9
|
-
- Add ability to configure through environment variables (thanks @Levino)
|
|
10
|
-
- Remove `@types/dotenv` as a dependency
|
|
11
|
-
- Add Node 12 to travis-ci tests
|
|
12
|
-
- General code cleanup/modernizing
|
|
13
|
-
|
|
14
|
-
## 2.7.1 - 2019.12.30
|
|
15
|
-
- Update README to include `import` syntax
|
|
16
|
-
|
|
17
|
-
## 2.7.0 - 2019.12.13
|
|
18
|
-
- fix: check for extra keys needs to be specific to schema
|
|
19
|
-
|
|
20
|
-
## 2.5.0 - 2019.10.27
|
|
21
|
-
- Update dependencies and remove useless dependencies (thanks @webdevium)
|
|
22
|
-
- Modernize and streamline build process
|
|
23
|
-
|
|
24
|
-
## 2.4.0 - 2019.03.01
|
|
25
|
-
- Add ability to put regexs in the `.env.schema` file to validate and limit the values that can be added to the `.evn` and `.env.defaults` files (thanks @epiphone)
|
|
26
|
-
|
|
27
|
-
## 2.3.0 - 2018.09.13
|
|
28
|
-
- Add error checking flag to include process.env when it checks for required variables (thanks @Vija02)
|
|
29
|
-
|
|
30
|
-
## 2.2.0 - 2018.08.07
|
|
31
|
-
- Remove support for end-of-life versions of node (4, 5, 7, 9)
|
|
32
|
-
- Require node >=6.0.0
|
|
33
|
-
- Update package dependencies
|
|
34
|
-
|
|
35
|
-
## 2.1.0 - 2018.08.07
|
|
36
|
-
- Expose entire process.env to command called with CLI
|
|
37
|
-
|
|
38
|
-
## 2.0.2 - 2018.04.16
|
|
39
|
-
- Fix markdown header (thanks @vvo)
|
|
40
|
-
- Update package dependencies (thanks @gregswindle)
|
|
41
|
-
- Add node versions 8 and 9 to travis versions to test
|
|
42
|
-
|
|
43
|
-
## 2.0.1 - 2017.05.30
|
|
44
|
-
- Add TypeScript definitions (thanks @toverux)
|
|
45
|
-
|
|
46
|
-
## 2.0.0 - 2017.04.26
|
|
47
|
-
- Add binary for injecting .env variables into non-node scripts
|
|
48
|
-
|
|
49
|
-
## 1.0.4 - 2016.10.23
|
|
50
|
-
- Replace `winston` library with generic `console` (Thanks @bostrom)
|
|
51
|
-
|
|
52
|
-
## 1.0.3 - 2016.08.06
|
|
53
|
-
- Fix comma-space typo in thrown error (Thanks @niftylettuce)
|
|
54
|
-
|
|
55
|
-
## 1.0.2 - 2016.08.04
|
|
56
|
-
- Add `default` export to simplify ES6 imports
|
|
57
|
-
|
|
58
|
-
## 1.0.1 - 2016.05.10
|
|
59
|
-
- Add ability to load .env files from command line
|
|
60
|
-
- Update dependencies
|
|
61
|
-
|
|
62
|
-
## 1.0.0 - 2016.02.15
|
|
63
|
-
|
|
64
|
-
- Correct documentation error
|
|
65
|
-
- Update dependencies
|
|
66
|
-
|
|
67
|
-
## 0.1.1 - 2016.02.10
|
|
68
|
-
- Remove errant ide files from package
|
|
69
|
-
- Add prepublish npm script
|
|
70
|
-
|
|
71
|
-
## 0.1.0 - 2016.02.09
|
|
72
|
-
- Initial release
|
package/CONTRIBUTING.md
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# Contributing
|
|
2
|
-
|
|
3
|
-
1. Fork it and clone it
|
|
4
|
-
1. Checkout the `develop` branch
|
|
5
|
-
1. `npm install`
|
|
6
|
-
1. Create your feature branch (`git checkout -b my-new-feature`)
|
|
7
|
-
1. Add your feature code and supporting unit tests
|
|
8
|
-
1. `npm test`
|
|
9
|
-
1. Commit your changes
|
|
10
|
-
1. Push to the branch (`git push origin my-new-feature`)
|
|
11
|
-
1. Create new Pull Request from your feature branch to the main `develop` branch
|
|
12
|
-
|
|
13
|
-
## Testing
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
npm test
|
|
17
|
-
```
|
|
18
|
-
or
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
gulp unittest
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Code Style
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
npm run lint
|
|
28
|
-
```
|
|
29
|
-
or
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
gulp lint
|
|
33
|
-
```
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = exports.getConfigFromEnv = void 0;
|
|
7
|
-
|
|
8
|
-
var _autoParse = _interopRequireDefault(require("auto-parse"));
|
|
9
|
-
|
|
10
|
-
var _camelcase = _interopRequireDefault(require("camelcase"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
|
-
var getConfigFromEnv = function getConfigFromEnv(env) {
|
|
15
|
-
var config = {};
|
|
16
|
-
Object.keys(env).forEach(function (key) {
|
|
17
|
-
var curr = key.split('DOTENV_CONFIG_');
|
|
18
|
-
|
|
19
|
-
if (curr.length === 2 && curr[0] === '' && curr[1].length) {
|
|
20
|
-
config[(0, _camelcase["default"])(curr[1])] = (0, _autoParse["default"])(env[key]);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
return config;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
exports.getConfigFromEnv = getConfigFromEnv;
|
|
27
|
-
var _default = getConfigFromEnv;
|
|
28
|
-
exports["default"] = _default;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = exports.loadEnvironmentFile = void 0;
|
|
7
|
-
|
|
8
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
-
|
|
10
|
-
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
|
-
var loadEnvironmentFile = function loadEnvironmentFile(path, encoding, silent) {
|
|
15
|
-
try {
|
|
16
|
-
var data = _fs["default"].readFileSync(path, encoding);
|
|
17
|
-
|
|
18
|
-
return _dotenv["default"].parse(data);
|
|
19
|
-
} catch (err) {
|
|
20
|
-
if (!silent) {
|
|
21
|
-
console.error(err.message);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return {};
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
exports.loadEnvironmentFile = loadEnvironmentFile;
|
|
29
|
-
var _default = loadEnvironmentFile;
|
|
30
|
-
exports["default"] = _default;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = exports.parseCommand = void 0;
|
|
7
|
-
|
|
8
|
-
var _autoParse = _interopRequireDefault(require("auto-parse"));
|
|
9
|
-
|
|
10
|
-
var _camelcase = _interopRequireDefault(require("camelcase"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Created by Keith Morris on 4/26/17.
|
|
16
|
-
*/
|
|
17
|
-
var dotEnvFlagRegex = /^--(.+)=(.+)/;
|
|
18
|
-
/**
|
|
19
|
-
* First parses config variables for dotenv-extended then selects the next item as the command and everything after that
|
|
20
|
-
* are considered arguments for the command
|
|
21
|
-
*
|
|
22
|
-
* @param args
|
|
23
|
-
* @returns {[Object,String,Array]}
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
var parseCommand = function parseCommand(args) {
|
|
27
|
-
var config = {};
|
|
28
|
-
var command = null;
|
|
29
|
-
var commandArgs = [];
|
|
30
|
-
|
|
31
|
-
for (var i = 0; i < args.length; i++) {
|
|
32
|
-
var match = dotEnvFlagRegex.exec(args[i]);
|
|
33
|
-
|
|
34
|
-
if (match) {
|
|
35
|
-
config[(0, _camelcase["default"])(match[1])] = (0, _autoParse["default"])(match[2]);
|
|
36
|
-
} else {
|
|
37
|
-
// No more env setters, the rest of the line must be the command and args
|
|
38
|
-
command = args[i];
|
|
39
|
-
commandArgs = args.slice(i + 1);
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return [config, command, commandArgs];
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
exports.parseCommand = parseCommand;
|
|
48
|
-
var _default = parseCommand;
|
|
49
|
-
exports["default"] = _default;
|