packages feed

dotenv 0.11.0.2 → 0.12.0.0

raw patch · 7 files changed

+94/−8 lines, 7 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

+ Configuration.Dotenv: [configDryRun] :: Config -> Bool
+ Configuration.Dotenv.Internal: [configDryRun] :: Config -> Bool
- Configuration.Dotenv: Config :: [FilePath] -> [FilePath] -> Bool -> Bool -> Bool -> Config
+ Configuration.Dotenv: Config :: [FilePath] -> [FilePath] -> Bool -> Bool -> Bool -> Bool -> Config
- Configuration.Dotenv.Internal: Config :: [FilePath] -> [FilePath] -> Bool -> Bool -> Bool -> Config
+ Configuration.Dotenv.Internal: Config :: [FilePath] -> [FilePath] -> Bool -> Bool -> Bool -> Bool -> Config

Files

CHANGELOG.md view
@@ -1,4 +1,12 @@ ## MASTER+## Dotenv 0.12.0.0+### Modified+* Ensure support from GHC 8.10 up to GHC 9.6++### Possible breaking change+* New attribute for `Config` data type to print env vars without actually+running the command (kudos to @flandrade).+ ## Dotenv 0.11.0.2 ### Modified * Allow optparse-applicative 0.18
README.md view
@@ -1,4 +1,7 @@ [![Build Status](https://github.com/stackbuilders/dotenv-hs/actions/workflows/build.yml/badge.svg)](https://github.com/stackbuilders/dotenv-hs/actions/workflows/build.yml)[![Hackage](https://img.shields.io/hackage/v/dotenv.svg)](http://hackage.haskell.org/package/dotenv)+<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->+[![All Contributors](https://img.shields.io/badge/all_contributors-23-orange.svg?style=flat-square)](#contributors-)+<!-- ALL-CONTRIBUTORS-BADGE:END -->  # Dotenv files for Haskell @@ -122,6 +125,8 @@ A `False` in the `configVerbose` means that Dotenv will not print any message when loading the envs. A `True` means that Dotenv will print a message when a variable is loaded. +When `configDryRyn` is `True`, Dotenv will print out the loaded environment variables without executing the program.+ A `False` on `allowDuplicates` means that Dotenv will not allow duplicate keys, and instead it will throw an error. A `True` means that Dotenv will allow duplicate keys, and it will use the last one defined in the file (default behavior). @@ -181,12 +186,14 @@ ```  This will fail:+ ```shell $ dotenv -f .env --example .env.example "myprogram --myflag myargument" > dotenv: The following variables are present in .env.example, but not set in the current environment, or .env: BAR ```  This will succeed:+ ```shell $ export BAR=123 # Or you can do something like: "echo 'BAR=123' >> .env" $ dotenv -f .env --example .env.example "myprogram --myflag myargument"@@ -197,6 +204,56 @@ of `myprogram` above you can see what the environment will look like after evaluating multiple Dotenv files. +## Contributors ✨++Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):++<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->+<!-- prettier-ignore-start -->+<!-- markdownlint-disable -->+<table>+  <tbody>+    <tr>+      <td align="center" valign="top" width="14.28%"><a href="https://cristhianmotoche.github.io/"><img src="https://avatars.githubusercontent.com/u/8370088?v=4?s=100" width="100px;" alt="Cristhian Motoche"/><br /><sub><b>Cristhian Motoche</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=CristhianMotoche" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://www.stackbuilders.com/news/author/justin-leitgeb"><img src="https://avatars.githubusercontent.com/u/9977?v=4?s=100" width="100px;" alt="Justin S. Leitgeb"/><br /><sub><b>Justin S. Leitgeb</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=jsl" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://markkarpov.com/"><img src="https://avatars.githubusercontent.com/u/8165792?v=4?s=100" width="100px;" alt="Mark Karpov"/><br /><sub><b>Mark Karpov</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=mrkkrp" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://juancarlos.io/"><img src="https://avatars.githubusercontent.com/u/2164411?v=4?s=100" width="100px;" alt="Juan Paucar"/><br /><sub><b>Juan Paucar</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=juanpaucar" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://github.com/jpvillaisaza"><img src="https://avatars.githubusercontent.com/u/584947?v=4?s=100" width="100px;" alt="Juan Pedro Villa Isaza"/><br /><sub><b>Juan Pedro Villa Isaza</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=jpvillaisaza" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="http://fujimuradaisuke.com/"><img src="https://avatars.githubusercontent.com/u/134072?v=4?s=100" width="100px;" alt="Daisuke Fujimura"/><br /><sub><b>Daisuke Fujimura</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=fujimura" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://github.com/cptrodolfox"><img src="https://avatars.githubusercontent.com/u/20303685?v=4?s=100" width="100px;" alt="William R. Arellano"/><br /><sub><b>William R. Arellano</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=cptrodolfox" title="Code">💻</a></td>+    </tr>+    <tr>+      <td align="center" valign="top" width="14.28%"><a href="https://dbalseiro.github.io/"><img src="https://avatars.githubusercontent.com/u/2053849?v=4?s=100" width="100px;" alt="Diego Balseiro"/><br /><sub><b>Diego Balseiro</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=dbalseiro" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://github.com/fefi95"><img src="https://avatars.githubusercontent.com/u/12057338?v=4?s=100" width="100px;" alt="Stefani Castellanos"/><br /><sub><b>Stefani Castellanos</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=fefi95" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://wikipedia.org/"><img src="https://avatars.githubusercontent.com/u/2220440?v=4?s=100" width="100px;" alt="Götz"/><br /><sub><b>Götz</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=goetzc" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://oleg.fi/"><img src="https://avatars.githubusercontent.com/u/51087?v=4?s=100" width="100px;" alt="Oleg Grenrus"/><br /><sub><b>Oleg Grenrus</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=phadej" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://github.com/sestrella"><img src="https://avatars.githubusercontent.com/u/2049686?v=4?s=100" width="100px;" alt="Sebastián Estrella"/><br /><sub><b>Sebastián Estrella</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=sestrella" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://git.sr.ht/~habibalamin"><img src="https://avatars.githubusercontent.com/u/1415293?v=4?s=100" width="100px;" alt="Habib Alamin"/><br /><sub><b>Habib Alamin</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=habibalamin" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://github.com/FranzGB"><img src="https://avatars.githubusercontent.com/u/46214532?v=4?s=100" width="100px;" alt="Franz Guzmán"/><br /><sub><b>Franz Guzmán</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=FranzGB" title="Code">💻</a></td>+    </tr>+    <tr>+      <td align="center" valign="top" width="14.28%"><a href="https://brisb.in/"><img src="https://avatars.githubusercontent.com/u/50812?v=4?s=100" width="100px;" alt="Pat Brisbin"/><br /><sub><b>Pat Brisbin</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=pbrisbin" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://github.com/aloussase"><img src="https://avatars.githubusercontent.com/u/84427521?v=4?s=100" width="100px;" alt="Alexander Goussas"/><br /><sub><b>Alexander Goussas</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=aloussase" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://github.com/alexisbcc"><img src="https://avatars.githubusercontent.com/u/38666191?v=4?s=100" width="100px;" alt="Alexis Crespo"/><br /><sub><b>Alexis Crespo</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=alexisbcc" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://github.com/anddriex"><img src="https://avatars.githubusercontent.com/u/42983405?v=4?s=100" width="100px;" alt="Andres Perez"/><br /><sub><b>Andres Perez</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=anddriex" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://github.com/ibarrae"><img src="https://avatars.githubusercontent.com/u/22796877?v=4?s=100" width="100px;" alt="Esteban Ibarra"/><br /><sub><b>Esteban Ibarra</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=ibarrae" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="http://ferandrade.com/"><img src="https://avatars.githubusercontent.com/u/6790161?v=4?s=100" width="100px;" alt="Fernanda Andrade"/><br /><sub><b>Fernanda Andrade</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=flandrade" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://github.com/Jagl257"><img src="https://avatars.githubusercontent.com/u/27145248?v=4?s=100" width="100px;" alt="Jorge Guerra Landázuri"/><br /><sub><b>Jorge Guerra Landázuri</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=Jagl257" title="Code">💻</a></td>+    </tr>+    <tr>+      <td align="center" valign="top" width="14.28%"><a href="https://matsubara0507.github.io/whoami"><img src="https://avatars.githubusercontent.com/u/10684493?v=4?s=100" width="100px;" alt="MATSUBARA Nobutada"/><br /><sub><b>MATSUBARA Nobutada</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=matsubara0507" title="Code">💻</a></td>+      <td align="center" valign="top" width="14.28%"><a href="https://github.com/wojtekmach"><img src="https://avatars.githubusercontent.com/u/76071?v=4?s=100" width="100px;" alt="Wojtek Mach"/><br /><sub><b>Wojtek Mach</b></sub></a><br /><a href="https://github.com/stackbuilders/dotenv-hs/commits?author=wojtekmach" title="Code">💻</a></td>+    </tr>+  </tbody>+</table>++<!-- markdownlint-restore -->+<!-- prettier-ignore-end -->++<!-- ALL-CONTRIBUTORS-LIST:END -->++This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!+ ## License  MIT, see [the LICENSE file](LICENSE).@@ -206,5 +263,6 @@ Do you want to contribute to this project? Please take a look at our [contributing guideline](/docs/CONTRIBUTING.md) to know how you can help us build it.  ---+ <img src="https://cdn.stackbuilders.com/media/images/Sb-supports.original.png" alt="Stack Builders" width="50%"></img> [Check out our libraries](https://github.com/stackbuilders/) | [Join our team](https://www.stackbuilders.com/join-us/)
app/Main.hs view
@@ -20,6 +20,7 @@   , dotenvExampleFiles :: [String]   , override           :: Bool   , verbose            :: Bool+  , dryRun             :: Bool   , duplicates         :: Bool   , program            :: String   , args               :: [String]@@ -33,6 +34,7 @@           { configExamplePath = dotenvExampleFiles           , configOverride = override           , configVerbose = verbose+          , configDryRun = dryRun           , allowDuplicates = duplicates           , configPath =               if null dotenvFiles@@ -40,8 +42,10 @@                 else dotenvFiles           }    in do-     loadFile configDotenv-     system (program ++ concatMap (" " ++) args) >>= exitWith+    loadFile configDotenv+    if configDryRun configDotenv+      then putStrLn "[INFO]: Dry run mode enabled. Not executing the program."+      else system (program ++ concatMap (" " ++) args) >>= exitWith        where          opts = info (helper <*> versionOption <*> config)            ( fullDesc@@ -72,6 +76,9 @@       <*> switch (  long "verbose"                   <> help "Specify this flag to print out the variables loaded and other useful insights" )++     <*> switch (  long "dry-run"+                  <> help "Specify this flag to print out the variables loaded without executing the program" )       <*> flag True False (  long "no-dups"                   <> short 'D'
dotenv.cabal view
@@ -1,5 +1,5 @@ name:                dotenv-version:             0.11.0.2+version:             0.12.0.0 synopsis:            Loads environment variables from dotenv files homepage:            https://github.com/stackbuilders/dotenv-hs description:@@ -34,6 +34,7 @@ license:             MIT license-file:        LICENSE author:              Justin Leitgeb+tested-with:         ghc ==8.10 ghc ==9.0 ghc ==9.2 ghc ==9.4 ghc ==9.6 maintainer:          hackage@stackbuilders.com copyright:           2015-Present Stack Builders Inc. category:            Configuration@@ -62,7 +63,7 @@  executable dotenv   main-is:             Main.hs-  build-depends:         base >= 4.9 && < 5.0+  build-depends:         base >= 4.14 && < 5.0                        , base-compat >= 0.4                        , dotenv                        , optparse-applicative >= 0.11 && < 0.19
spec/Configuration/DotenvSpec.hs view
@@ -77,7 +77,7 @@       lookupEnv "FOO" `shouldReturn` Nothing       lookupEnv "BAR" `shouldReturn` Nothing -      loadFile (Config ["spec/fixtures/.dotenv.dup"] [] False False True)+      loadFile (Config ["spec/fixtures/.dotenv.dup"] [] False False False True)        lookupEnv "FOO" `shouldReturn` Just "last"       lookupEnv "BAR" `shouldReturn` Just "tender"@@ -165,8 +165,14 @@         loadFile sampleConfig { allowDuplicates = False }         lookupEnv "DOTENV" `shouldReturn` Just "true" +  describe "onConfigDryRun" $ after_ clearEnvs $+    context "when dry-run is enabled " $+      it "loads the variables" $ do+        loadFile sampleConfig { configPath = ["spec/fixtures/.dotenv"], configDryRun = True }+        lookupEnv "DOTENV" `shouldReturn` Just "true"+ sampleConfig :: Config-sampleConfig = Config ["spec/fixtures/.dotenv"] [] False False True+sampleConfig = Config ["spec/fixtures/.dotenv"] [] False False False True  clearEnvs :: IO () clearEnvs =
src/Configuration/Dotenv.hs view
@@ -128,9 +128,13 @@ info :: MonadIO m => (String, String) -> DotEnv m () info (key, value) = do   Config {..} <- ask-  when configVerbose $+  when (configVerbose || configDryRun) $     lift . liftIO $-    putStrLn $ "[INFO]: Load env '" ++ key ++ "' with value '" ++ value ++ "'"+    putStrLn $ infoStr (key, value)++-- | The function prints out the variables+infoStr :: (String, String) -> String+infoStr (key, value) =  "[INFO]: Load env '" ++ key ++ "' with value '" ++ value ++ "'"  -- | The helper allows to avoid exceptions in the case of missing files and -- perform some action instead.
src/Configuration/Dotenv/Types.hs view
@@ -23,6 +23,7 @@   , configExamplePath :: [FilePath] -- ^ The paths for the .env.example files   , configOverride    :: Bool     -- ^ Flag to allow override env variables   , configVerbose     :: Bool     -- ^ Flag to log the loaded variables and other useful information+  , configDryRun      :: Bool     -- ^ Flag to print out the variables loaded without executing the program   , allowDuplicates   :: Bool     -- ^ Flag to allow duplicate variables   } deriving (Eq, Show) @@ -35,6 +36,7 @@     , configOverride = False     , configPath = [ ".env" ]     , configVerbose = False+    , configDryRun = False     , allowDuplicates = True     }