diff --git a/.codacy.yml b/.codacy.yml new file mode 100644 index 0000000..c8a32c0 --- /dev/null +++ b/.codacy.yml @@ -0,0 +1,24 @@ +--- +engines: + rubocop: + exclude_paths: + - "config/test.yml" + base_sub_dir: "test/baseDir" + duplication: + exclude_paths: + - "config/test.yml" + config: + languages: + - "ruby" + - "javascript" +languages: + css: + extensions: + - "-css.resource" +exclude_paths: + - ".bundle/**" + - "spec/**/*" + - "benchmarks/**/*" + - "**.min.js" + - "tests/**/*" + - "node_modules/**/*" \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..c0635e0 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,30 @@ +module.exports = { + parser: "babel-eslint", + env: { + browser: true, + node: true, + es6: true, + jest: true, + }, + extends: [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:jsx-a11y/recommended" + ], + plugins: [ + "react", + "react-hooks", + "jsx-a11y", + ], + rules: { + semi: [2, "never"], + strict: 0, + "react-hooks/rules-of-hooks": "error", + "react-hooks/exhaustive-deps": "warn" + }, + settings: { + react: { + version: "detect" + } + } + } \ No newline at end of file diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..e987065 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,114 @@ +name-template: 'v$RESOLVED_VERSION 🌈' + +tag-template: 'v$RESOLVED_VERSION' + +template: | + ## Changes + $CHANGES + $CONTRIBUTORS +categories: + - title: '💣 Breaking Change' + labels: + - "change" + - "breaking" + - title: '🚀 Features' + labels: + - 'feature' + - 'improvement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'refactor' + - 'security' + - title: '📗 Docs' + labels: + - 'documentation' + - title: '🧪 Tests' + labels: + - "tests" + - title: '🧰 Maintenance' + labels: + - 'maintenance' + - 'chore' + - title: '⬆️ Dependencies' + labels: + - 'dependencies' + +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' + +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. + +version-resolver: + major: + labels: + - 'major' + - 'change' + - 'breaking' + minor: + labels: + - 'minor' + - 'feature' + patch: + labels: + - 'patch' + - 'fix' + - 'chore' + - 'dependencies' + - 'documentation' + - 'maintenance' + - 'refactor' + - 'tests' + default: patch + +exclude-labels: + - 'skip-changelog' + +autolabeler: + - label: 'breaking' + branch: + - '/break.*/' + - '/breaking.*/' + - label: 'documentation' + files: + - '**/*.md' + branch: + - '/docs{0,1}\/.+/' + - '/docs\/.+/' + - '/docs.*/' + - label: 'tests' + branch: + - '/tests\/.+/' + - '/tests.*/' + - label: 'chore' + branch: + - '/chore\/.+/' + - 'chore.*' + - label: 'fix' + branch: + - '/fix\/.+/' + - '/fix.*/' + - '/bugfix.*/' + - '/bug.*/' + - '/hot.*/' + - '/hotfix.*/' + - '/sec.*/' + - '/security.*/' + title: + - '/fix/i' + - label: 'feature' + branch: + - '/enh\/.+/' + - '/enhancement\/.+/' + - '/feature.*/' + - '/feat.*/' + - '/improvement.*/' + title: + - '/feat/i' + - label: 'dependencies' + #files: + #- 'go.mod' + #- 'go.sum' + #- 'vendor*' + branch: + - '/deps\/.+/' + - '/dependabot.*/' \ No newline at end of file diff --git a/.github/workflows/action-analyser.yml b/.github/workflows/action-analyser.yml index 7fe76b6..3517e17 100644 --- a/.github/workflows/action-analyser.yml +++ b/.github/workflows/action-analyser.yml @@ -1,8 +1,10 @@ name: Action security analysis on: - push: - branches: [master, main] + pull_request: + branches: [ main ] + paths-ignore: + - README.md schedule: - cron: '15 7 * * 2' @@ -21,23 +23,18 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis - name: Run Codacy Analysis CLI - uses: codacy/codacy-analysis-cli-action@d840f886c4bd4edc059706d09c6a1586111c540b + uses: codacy/codacy-analysis-cli-action@0de770495bd94bdac1ba7d5043a72b252ddbeec3 with: - # Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository - # You can also omit the token and run the tools that support default configurations - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - verbose: true output: results.sarif format: sarif + verbose: true # Adjust severity of non-security issues - gh-code-scanning-compat: true + gh-code-scanning-compat: false # Force 0 exit code to allow SARIF file generation # This will handover control about PR rejection to the GitHub side max-allowed-issues: 2147483647 - # Upload the SARIF file generated in the previous step - name: Upload SARIF results file uses: github/codeql-action/upload-sarif@v1 diff --git a/.github/workflows/action-ci.yaml b/.github/workflows/action-ci.yaml index 3ca86d9..6b442e1 100644 --- a/.github/workflows/action-ci.yaml +++ b/.github/workflows/action-ci.yaml @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v3.0.0 with: node-version: ${{ matrix.node-version }} cache: 'npm' diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..90a025d --- /dev/null +++ b/.jshintrc @@ -0,0 +1,4 @@ +{ + "esversion": 6, + "asi": true +} \ No newline at end of file diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..a6ca62c --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,8 @@ +{ + "line-length": false, + "no-inline-html": { + "allowed_elements": [ + "a" + ] + } + } diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 84e2d5e..3e775cb 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -1,5 +1,5 @@ { - "name": "action-send-mail", + "name": "smpt-notifier", "lockfileVersion": 2, "requires": true, "packages": { @@ -96,9 +96,12 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "node_modules/dotenv": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-1.2.0.tgz", - "integrity": "sha1-fNc+FuB/BXyAchR6W8OoZ38KtcY=" + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.0.tgz", + "integrity": "sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q==", + "engines": { + "node": ">=12" + } }, "node_modules/emoji-regex": { "version": "8.0.0", diff --git a/node_modules/dotenv/.editorconfig b/node_modules/dotenv/.editorconfig deleted file mode 100644 index 5d12634..0000000 --- a/node_modules/dotenv/.editorconfig +++ /dev/null @@ -1,13 +0,0 @@ -# editorconfig.org -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false diff --git a/node_modules/dotenv/.npmignore b/node_modules/dotenv/.npmignore deleted file mode 100644 index 519e4f2..0000000 --- a/node_modules/dotenv/.npmignore +++ /dev/null @@ -1,12 +0,0 @@ -# Coverage directory used by tools like istanbul -coverage - -# Dependency directory -# Commenting this out is preferred by some people, see -# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- -node_modules - -# Users Environment Variables -.lock-wscript - -.DS_Store diff --git a/node_modules/dotenv/.travis.yml b/node_modules/dotenv/.travis.yml deleted file mode 100644 index ba0b144..0000000 --- a/node_modules/dotenv/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: node_js - -node_js: - - iojs - - 0.12 - - 0.10 diff --git a/node_modules/dotenv/CHANGELOG.md b/node_modules/dotenv/CHANGELOG.md new file mode 100644 index 0000000..b500edd --- /dev/null +++ b/node_modules/dotenv/CHANGELOG.md @@ -0,0 +1,347 @@ +# Changelog + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [Unreleased](https://github.com/motdotla/dotenv/compare/v16.0.0...master) + +## [16.0.0](https://github.com/motdotla/dotenv/compare/v15.0.1...v16.0.0) (2022-02-02) + +### Added + +- _Breaking:_ Backtick support 🎉 (template literals). If you had values containing the backtick character, please quote those values with either single or double quotes. + +## [15.0.1](https://github.com/motdotla/dotenv/compare/v15.0.0...v15.0.1) (2022-02-02) + +### Changed + +- Properly parse empty single or double quoted values 🐞 ([#614](https://github.com/motdotla/dotenv/pull/614)) + +## [15.0.0](https://github.com/motdotla/dotenv/compare/v14.3.2...v15.0.0) (2022-01-31) + +`v15.0.0` is a major new release with some important breaking changes. + +### Added + +- _Breaking:_ Multiline parsing support (just works. no need for the flag.) + +### Changed + +- _Breaking:_ `#` marks the beginning of a comment (UNLESS the value is wrapped in quotes. Please update your `.env` files to wrap in quotes any values containing `#`. For example: `SECRET_HASH="something-with-a-#-hash"`). + +..Understandably, (as some teams have noted) this is tedious to do across the entire team. To make it less tedious, we recommend using [dotenv cli](https://github.com/dotenv-org/cli) going forward. It's an optional plugin that will keep your `.env` files in sync between machines, environments, or team members. + +### Removed + +- _Breaking:_ Remove multiline option (just works out of the box now. no need for the flag.) + +## [14.3.2](https://github.com/motdotla/dotenv/compare/v14.3.1...v14.3.2) (2022-01-25) + +### Changed + +- Preserve backwards compatibility on values containing `#` 🐞 ([#603](https://github.com/motdotla/dotenv/pull/603)) + +## [14.3.1](https://github.com/motdotla/dotenv/compare/v14.3.0...v14.3.1) (2022-01-25) + +### Changed + +- Preserve backwards compatibility on exports by re-introducing the prior in-place exports 🐞 ([#606](https://github.com/motdotla/dotenv/pull/606)) + +## [14.3.0](https://github.com/motdotla/dotenv/compare/v14.2.0...v14.3.0) (2022-01-24) + +### Added + +- Add `multiline` option 🎉 ([#486](https://github.com/motdotla/dotenv/pull/486)) + +## [14.2.0](https://github.com/motdotla/dotenv/compare/v14.1.1...v14.2.0) (2022-01-17) + +### Added + +- Add `dotenv_config_override` cli option +- Add `DOTENV_CONFIG_OVERRIDE` command line env option + +## [14.1.1](https://github.com/motdotla/dotenv/compare/v14.1.0...v14.1.1) (2022-01-17) + +### Added + +- Add React gotcha to FAQ on README + +## [14.1.0](https://github.com/motdotla/dotenv/compare/v14.0.1...v14.1.0) (2022-01-17) + +### Added + +- Add `override` option 🎉 ([#595](https://github.com/motdotla/dotenv/pull/595)) + +## [14.0.1](https://github.com/motdotla/dotenv/compare/v14.0.0...v14.0.1) (2022-01-16) + +### Added + +- Log error on failure to load `.env` file ([#594](https://github.com/motdotla/dotenv/pull/594)) + +## [14.0.0](https://github.com/motdotla/dotenv/compare/v13.0.1...v14.0.0) (2022-01-16) + +### Added + +- _Breaking:_ Support inline comments for the parser 🎉 ([#568](https://github.com/motdotla/dotenv/pull/568)) + +## [13.0.1](https://github.com/motdotla/dotenv/compare/v13.0.0...v13.0.1) (2022-01-16) + +### Changed + +* Hide comments and newlines from debug output ([#404](https://github.com/motdotla/dotenv/pull/404)) + +## [13.0.0](https://github.com/motdotla/dotenv/compare/v12.0.4...v13.0.0) (2022-01-16) + +### Added + +* _Breaking:_ Add type file for `config.js` ([#539](https://github.com/motdotla/dotenv/pull/539)) + +## [12.0.4](https://github.com/motdotla/dotenv/compare/v12.0.3...v12.0.4) (2022-01-16) + +### Changed + +* README updates +* Minor order adjustment to package json format + +## [12.0.3](https://github.com/motdotla/dotenv/compare/v12.0.2...v12.0.3) (2022-01-15) + +### Changed + +* Simplified jsdoc for consistency across editors + +## [12.0.2](https://github.com/motdotla/dotenv/compare/v12.0.1...v12.0.2) (2022-01-15) + +### Changed + +* Improve embedded jsdoc type documentation + +## [12.0.1](https://github.com/motdotla/dotenv/compare/v12.0.0...v12.0.1) (2022-01-15) + +### Changed + +* README updates and clarifications + +## [12.0.0](https://github.com/motdotla/dotenv/compare/v11.0.0...v12.0.0) (2022-01-15) + +### Removed + +- _Breaking:_ drop support for Flow static type checker ([#584](https://github.com/motdotla/dotenv/pull/584)) + +### Changed + +- Move types/index.d.ts to lib/main.d.ts ([#585](https://github.com/motdotla/dotenv/pull/585)) +- Typescript cleanup ([#587](https://github.com/motdotla/dotenv/pull/587)) +- Explicit typescript inclusion in package.json ([#566](https://github.com/motdotla/dotenv/pull/566)) + +## [11.0.0](https://github.com/motdotla/dotenv/compare/v10.0.0...v11.0.0) (2022-01-11) + +### Changed + +- _Breaking:_ drop support for Node v10 ([#558](https://github.com/motdotla/dotenv/pull/558)) +- Patch debug option ([#550](https://github.com/motdotla/dotenv/pull/550)) + +## [10.0.0](https://github.com/motdotla/dotenv/compare/v9.0.2...v10.0.0) (2021-05-20) + +### Added + +- Add generic support to parse function +- Allow for import "dotenv/config.js" +- Add support to resolve home directory in path via ~ + +## [9.0.2](https://github.com/motdotla/dotenv/compare/v9.0.1...v9.0.2) (2021-05-10) + +### Changed + +- Support windows newlines with debug mode + +## [9.0.1](https://github.com/motdotla/dotenv/compare/v9.0.0...v9.0.1) (2021-05-08) + +### Changed + +- Updates to README + +## [9.0.0](https://github.com/motdotla/dotenv/compare/v8.6.0...v9.0.0) (2021-05-05) + +### Changed + +- _Breaking:_ drop support for Node v8 + +## [8.6.0](https://github.com/motdotla/dotenv/compare/v8.5.1...v8.6.0) (2021-05-05) + +### Added + +- define package.json in exports + +## [8.5.1](https://github.com/motdotla/dotenv/compare/v8.5.0...v8.5.1) (2021-05-05) + +### Changed + +- updated dev dependencies via npm audit + +## [8.5.0](https://github.com/motdotla/dotenv/compare/v8.4.0...v8.5.0) (2021-05-05) + +### Added + +- allow for `import "dotenv/config"` + +## [8.4.0](https://github.com/motdotla/dotenv/compare/v8.3.0...v8.4.0) (2021-05-05) + +### Changed + +- point to exact types file to work with VS Code + +## [8.3.0](https://github.com/motdotla/dotenv/compare/v8.2.0...v8.3.0) (2021-05-05) + +### Changed + +- _Breaking:_ drop support for Node v8 (mistake to be released as minor bump. later bumped to 9.0.0. see above.) + +## [8.2.0](https://github.com/motdotla/dotenv/compare/v8.1.0...v8.2.0) (2019-10-16) + +### Added + +- TypeScript types + +## [8.1.0](https://github.com/motdotla/dotenv/compare/v8.0.0...v8.1.0) (2019-08-18) + +### Changed + +- _Breaking:_ drop support for Node v6 ([#392](https://github.com/motdotla/dotenv/issues/392)) + +# [8.0.0](https://github.com/motdotla/dotenv/compare/v7.0.0...v8.0.0) (2019-05-02) + +### Changed + +- _Breaking:_ drop support for Node v6 ([#302](https://github.com/motdotla/dotenv/issues/392)) + +## [7.0.0] - 2019-03-12 + +### Fixed + +- Fix removing unbalanced quotes ([#376](https://github.com/motdotla/dotenv/pull/376)) + +### Removed + +- Removed `load` alias for `config` for consistency throughout code and documentation. + +## [6.2.0] - 2018-12-03 + +### Added + +- Support preload configuration via environment variables ([#351](https://github.com/motdotla/dotenv/issues/351)) + +## [6.1.0] - 2018-10-08 + +### Added + +- `debug` option for `config` and `parse` methods will turn on logging + +## [6.0.0] - 2018-06-02 + +### Changed + +- _Breaking:_ drop support for Node v4 ([#304](https://github.com/motdotla/dotenv/pull/304)) + +## [5.0.0] - 2018-01-29 + +### Added + +- Testing against Node v8 and v9 +- Documentation on trim behavior of values +- Documentation on how to use with `import` + +### Changed + +- _Breaking_: default `path` is now `path.resolve(process.cwd(), '.env')` +- _Breaking_: does not write over keys already in `process.env` if the key has a falsy value +- using `const` and `let` instead of `var` + +### Removed + +- Testing against Node v7 + +## [4.0.0] - 2016-12-23 + +### Changed + +- Return Object with parsed content or error instead of false ([#165](https://github.com/motdotla/dotenv/pull/165)). + +### Removed + +- `verbose` option removed in favor of returning result. + +## [3.0.0] - 2016-12-20 + +### Added + +- `verbose` option will log any error messages. Off by default. +- parses email addresses correctly +- allow importing config method directly in ES6 + +### Changed + +- Suppress error messages by default ([#154](https://github.com/motdotla/dotenv/pull/154)) +- Ignoring more files for NPM to make package download smaller + +### Fixed + +- False positive test due to case-sensitive variable ([#124](https://github.com/motdotla/dotenv/pull/124)) + +### Removed + +- `silent` option removed in favor of `verbose` + +## [2.0.0] - 2016-01-20 + +### Added + +- CHANGELOG to ["make it easier for users and contributors to see precisely what notable changes have been made between each release"](http://keepachangelog.com/). Linked to from README +- LICENSE to be more explicit about what was defined in `package.json`. Linked to from README +- Testing nodejs v4 on travis-ci +- added examples of how to use dotenv in different ways +- return parsed object on success rather than boolean true + +### Changed + +- README has shorter description not referencing ruby gem since we don't have or want feature parity + +### Removed + +- Variable expansion and escaping so environment variables are encouraged to be fully orthogonal + +## [1.2.0] - 2015-06-20 + +### Added + +- Preload hook to require dotenv without including it in your code + +### Changed + +- clarified license to be "BSD-2-Clause" in `package.json` + +### Fixed + +- retain spaces in string vars + +## [1.1.0] - 2015-03-31 + +### Added + +- Silent option to silence `console.log` when `.env` missing + +## [1.0.0] - 2015-03-13 + +### Removed + +- support for multiple `.env` files. should always use one `.env` file for the current environment + +[7.0.0]: https://github.com/motdotla/dotenv/compare/v6.2.0...v7.0.0 +[6.2.0]: https://github.com/motdotla/dotenv/compare/v6.1.0...v6.2.0 +[6.1.0]: https://github.com/motdotla/dotenv/compare/v6.0.0...v6.1.0 +[6.0.0]: https://github.com/motdotla/dotenv/compare/v5.0.0...v6.0.0 +[5.0.0]: https://github.com/motdotla/dotenv/compare/v4.0.0...v5.0.0 +[4.0.0]: https://github.com/motdotla/dotenv/compare/v3.0.0...v4.0.0 +[3.0.0]: https://github.com/motdotla/dotenv/compare/v2.0.0...v3.0.0 +[2.0.0]: https://github.com/motdotla/dotenv/compare/v1.2.0...v2.0.0 +[1.2.0]: https://github.com/motdotla/dotenv/compare/v1.1.0...v1.2.0 +[1.1.0]: https://github.com/motdotla/dotenv/compare/v1.0.0...v1.1.0 +[1.0.0]: https://github.com/motdotla/dotenv/compare/v0.4.0...v1.0.0 diff --git a/node_modules/dotenv/Contributing.md b/node_modules/dotenv/Contributing.md deleted file mode 100644 index 04552a9..0000000 --- a/node_modules/dotenv/Contributing.md +++ /dev/null @@ -1,25 +0,0 @@ -# Contributing - -1. Fork it -2. `npm install` -3. Create your feature branch (`git checkout -b my-new-feature`) -4. Commit your changes (`git commit -am 'Added some feature'`) -5. `npm test` -6. Push to the branch (`git push origin my-new-feature`) -7. Create new Pull Request - -## Testing - -We use [lab](https://github.com/hapijs/lab) and [should](https://github.com/shouldjs/should.js) to write BDD test. Run our test suite with this command: - -``` -npm test -``` - -## Code Style - -We use [standard](https://www.npmjs.com/package/standard) and [editorconfig](http://editorconfig.org) to maintain code style and best practices. Please make sure your PR adheres to the guides by running: - -``` -npm run lint -``` diff --git a/node_modules/dotenv/LICENSE b/node_modules/dotenv/LICENSE new file mode 100644 index 0000000..c430ad8 --- /dev/null +++ b/node_modules/dotenv/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2015, Scott Motte +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/dotenv/README.md b/node_modules/dotenv/README.md index de32426..0b32567 100644 --- a/node_modules/dotenv/README.md +++ b/node_modules/dotenv/README.md @@ -1,66 +1,108 @@ +

+Announcement 📣
From the makers that brought you Dotenv, introducing Dotenv Sync.
Sync your .env files between machines, environments, and team members.
Join the early access list.💛 +

+ # dotenv dotenv -Dotenv loads environment variables from `.env` into `ENV` (process.env). +Dotenv is a zero-dependency module that loads environment variables from a `.env` file into [`process.env`](https://nodejs.org/docs/latest/api/process.html#process_process_env). Storing configuration in the environment separate from code is based on [The Twelve-Factor App](http://12factor.net/config) methodology. [![BuildStatus](https://img.shields.io/travis/motdotla/dotenv/master.svg?style=flat-square)](https://travis-ci.org/motdotla/dotenv) +[![Build status](https://ci.appveyor.com/api/projects/status/github/motdotla/dotenv?svg=true)](https://ci.appveyor.com/project/motdotla/dotenv/branch/master) [![NPM version](https://img.shields.io/npm/v/dotenv.svg?style=flat-square)](https://www.npmjs.com/package/dotenv) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) - -> "Storing [configuration in the environment](http://www.12factor.net/config) -> is one of the tenets of a [twelve-factor app](http://www.12factor.net/). -> Anything that is likely to change between deployment environments–such as -> resource handles for databases or credentials for external services–should be -> extracted from the code into environment variables. -> -> But it is not always practical to set environment variables on development -> machines or continuous integration servers where multiple projects are run. -> Dotenv loads variables from a `.env` file into ENV when the environment is -> bootstrapped." -> -> [Brandon Keepers' Dotenv in Ruby](https://github.com/bkeepers/dotenv) +[![Coverage Status](https://img.shields.io/coveralls/motdotla/dotenv/master.svg?style=flat-square)](https://coveralls.io/github/motdotla/dotenv?branch=coverall-intergration) +[![LICENSE](https://img.shields.io/github/license/motdotla/dotenv.svg)](LICENSE) +[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) +[![Rate on Openbase](https://badges.openbase.com/js/rating/dotenv.svg)](https://openbase.com/js/dotenv) ## Install ```bash +# install locally (recommended) npm install dotenv --save ``` +Or installing with yarn? `yarn add dotenv` + ## Usage -As early as possible in your application, require and load dotenv. +Create a `.env` file in the root of your project: + +```dosini +S3_BUCKET="YOURS3BUCKET" +SECRET_KEY="YOURSECRETKEYGOESHERE" +``` + +As early as possible in your application, import and configure dotenv: + +```javascript +require('dotenv').config() +console.log(process.env) // remove this after you've confirmed it working +``` + +.. or using ES6? + +```javascript +import 'dotenv/config' // see https://github.com/motdotla/dotenv#how-do-i-use-dotenv-with-import +import express from 'express' +``` + +That's it. `process.env` now has the keys and values you defined in your `.env` file: ```javascript -require('dotenv').load(); +require('dotenv').config() + +... + +s3.getBucketCors({Bucket: process.env.S3_BUCKET}, function(err, data) {}) +``` + +### Multiline values + +If you need multiline variables, for example private keys, those are now supported (`>= v15.0.0`) with line breaks: + +```dosini +PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY----- +... +Kh9NV... +... +-----END DSA PRIVATE KEY-----" ``` -Create a `.env` file in the root directory of your project. Add -environment-specific variables on new lines in the form of `NAME=VALUE`. -For example: +Alternatively, you can double quote strings and use the `\n` character: +```dosini +PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\Kh9NV...\n-----END DSA PRIVATE KEY-----\n" ``` -DB_HOST=localhost -DB_USER=root -DB_PASS=s1mpl3 + +### Comments + +Comments may be added to your file on their own line or inline: + +```dosini +# This is a comment +SECRET_KEY=YOURSECRETKEYGOESHERE # comment +SECRET_HASH="something-with-a-#-hash" ``` -That's it. +Comments begin where a `#` exists, so if your value contains a `#` please wrap it in quotes. This is a breaking change from `>= v15.0.0` and on. + +### Parsing -`process.env` now has the keys and values you defined in your `.env` file. +The engine which parses the contents of your file containing environment variables is available to use. It accepts a String or Buffer and will return an Object with the parsed keys and values. ```javascript -db.connect({ - host: process.env.DB_HOST, - username: process.env.DB_USER, - password: process.env.DB_PASS -}); +const dotenv = require('dotenv') +const buf = Buffer.from('BASIC=basic') +const config = dotenv.parse(buf) // will return an object +console.log(typeof config, config) // object { BASIC : 'basic' } ``` ### Preload -If you are using iojs-v1.6.0 or later, you can use the `--require` (`-r`) command line option to preload dotenv. By doing this, you do not need to require and load dotenv in your application code. - +You can use the `--require` (`-r`) [command line option](https://nodejs.org/api/cli.html#cli_r_require_module) to preload dotenv. By doing this, you do not need to require and load dotenv in your application code. ```bash $ node -r dotenv/config your_script.js @@ -69,130 +111,296 @@ $ node -r dotenv/config your_script.js The configuration options below are supported as command line arguments in the format `dotenv_config_