packages feed

headroom 0.2.2.0 → 0.2.2.1

raw patch · 15 files changed

+51/−41 lines, 15 filesdep −template-haskellPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies removed: template-haskell

API changes (from Hackage documentation)

- Headroom.Command.Init: [pCurrentDir] :: Paths -> !FilePath
- Headroom.Command.Init: Paths :: !FilePath -> !FilePath -> !FilePath -> Paths
+ Headroom.Command.Init: Paths :: !FilePath -> !FilePath -> Paths

Files

CHANGELOG.md view
@@ -1,6 +1,9 @@ # Changelog All notable changes to this project will be documented in this file. +## 0.2.2.1 (released 2020-05-08)+- Minor improves in generated `.headroom.config` in `init` mode+ ## 0.2.2.0 (released 2020-05-04) - [#45] Add `-c|--check-headers` command line option - Bump _LTS Haskell_ to `15.11`
embedded/config-file.yaml view
@@ -16,6 +16,12 @@ ## times for more than one path). source-paths: [] +## Allows to define list of regular expressions that will be matched against+## 'source-paths' and such paths will be excluded from processing. Same as+## '-e|--excluded-path=REGEX' command line argument (can be used multiple times+## for more than one path).+excluded-paths: []+ ## Paths to template files (either files or directories), ## same as '-t|--template-path=PATH' command line argument (can be used multiple ## times for more than one path).
embedded/license/bsd3/c.mustache view
@@ -11,7 +11,7 @@  * 2. 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.- * 3. Neither the name of mosquitto nor the names of its+ * 3. Neither the name of copyright holder nor the names of its  *    contributors may be used to endorse or promote products derived from  *    this software without specific prior written permission.  *
embedded/license/bsd3/cpp.mustache view
@@ -11,7 +11,7 @@  * 2. 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.- * 3. Neither the name of mosquitto nor the names of its+ * 3. Neither the name of copyright holder nor the names of its  *    contributors may be used to endorse or promote products derived from  *    this software without specific prior written permission.  *
embedded/license/bsd3/css.mustache view
@@ -11,7 +11,7 @@  * 2. 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.- * 3. Neither the name of mosquitto nor the names of its+ * 3. Neither the name of copyright holder nor the names of its  *    contributors may be used to endorse or promote products derived from  *    this software without specific prior written permission.  *
embedded/license/bsd3/html.mustache view
@@ -11,7 +11,7 @@   2. 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.-  3. Neither the name of mosquitto nor the names of its+  3. Neither the name of copyright holder nor the names of its      contributors may be used to endorse or promote products derived from      this software without specific prior written permission.   
embedded/license/bsd3/java.mustache view
@@ -11,7 +11,7 @@  * 2. 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.- * 3. Neither the name of mosquitto nor the names of its+ * 3. Neither the name of copyright holder nor the names of its  *    contributors may be used to endorse or promote products derived from  *    this software without specific prior written permission.  *
embedded/license/bsd3/js.mustache view
@@ -11,7 +11,7 @@  * 2. 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.- * 3. Neither the name of mosquitto nor the names of its+ * 3. Neither the name of copyright holder nor the names of its  *    contributors may be used to endorse or promote products derived from  *    this software without specific prior written permission.  *
embedded/license/bsd3/rust.mustache view
@@ -10,7 +10,7 @@  * 2. 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.- * 3. Neither the name of mosquitto nor the names of its+ * 3. Neither the name of copyright holder nor the names of its  *    contributors may be used to endorse or promote products derived from  *    this software without specific prior written permission.  *
embedded/license/bsd3/scala.mustache view
@@ -11,7 +11,7 @@  * 2. 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.- * 3. Neither the name of mosquitto nor the names of its+ * 3. Neither the name of copyright holder nor the names of its  *    contributors may be used to endorse or promote products derived from  *    this software without specific prior written permission.  *
embedded/license/bsd3/shell.mustache view
@@ -10,7 +10,7 @@ # 2. 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.-# 3. Neither the name of mosquitto nor the names of its+# 3. Neither the name of copyright holder nor the names of its #    contributors may be used to endorse or promote products derived from #    this software without specific prior written permission. #
headroom.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: headroom-version: 0.2.2.0+version: 0.2.2.1 license: BSD-3-Clause license-file: LICENSE copyright: Copyright (c) 2019-2020 Vaclav Svejcar@@ -151,7 +151,6 @@         optparse-applicative >=0.15.1.0,         pcre-light >=0.4.1.0,         rio >=0.1.15.1,-        template-haskell >=2.15.0.0,         time >=1.9.3,         yaml >=0.11.3.0 
src/Headroom/Command/Init.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NoImplicitPrelude     #-} {-# LANGUAGE OverloadedStrings     #-}+{-# LANGUAGE RecordWildCards       #-} {-# LANGUAGE TupleSections         #-} {-# LANGUAGE TypeApplications      #-} @@ -42,10 +43,10 @@                                                 , doesFileExist                                                 , fileExtension                                                 , findFiles-                                                , getCurrentDirectory                                                 ) import           Headroom.FileType              ( fileTypeByExt ) import           Headroom.Meta                  ( TemplateType )+import           Headroom.Serialization         ( prettyPrintYAML ) import           Headroom.Template              ( Template(..) ) import           Headroom.Types                 ( ApplicationError(..)                                                 , CommandInitError(..)@@ -61,6 +62,7 @@ import qualified RIO.Char                      as C import           RIO.FilePath                   ( (</>) ) import qualified RIO.List                      as L+import qualified RIO.Map                       as M import qualified RIO.NonEmpty                  as NE import qualified RIO.Text                      as T import qualified RIO.Text.Partial              as TP@@ -76,8 +78,7 @@  -- | Paths to various locations of file system. data Paths = Paths-  { pCurrentDir   :: !FilePath-  , pConfigFile   :: !FilePath+  { pConfigFile   :: !FilePath   , pTemplatesDir :: !FilePath   } @@ -94,9 +95,7 @@  env' :: CommandInitOptions -> LogFunc -> IO Env env' opts logFunc = do-  currentDir <- getCurrentDirectory-  let paths = Paths { pCurrentDir   = currentDir-                    , pConfigFile   = ".headroom.yaml"+  let paths = Paths { pConfigFile   = ".headroom.yaml"                     , pTemplatesDir = "headroom-templates"                     }   pure $ Env { envLogFunc = logFunc, envInitOptions = opts, envPaths = paths }@@ -138,10 +137,9 @@                 => [FileType]                 -> RIO env () createTemplates fileTypes = do-  opts  <- viewL-  paths <- viewL-  let templatesDir = pCurrentDir paths </> pTemplatesDir paths-  mapM_ (\(p, lf) -> createTemplate templatesDir lf p)+  opts       <- viewL+  Paths {..} <- viewL+  mapM_ (\(p, lf) -> createTemplate pTemplatesDir lf p)         (zipWithProgress $ fmap (cioLicenseType opts, ) fileTypes)  createTemplate :: (HasLogFunc env)@@ -161,36 +159,32 @@ createConfigFile :: (Has CommandInitOptions env, HasLogFunc env, Has Paths env)                  => RIO env () createConfigFile = do-  opts  <- viewL-  paths <- viewL-  let filePath = pCurrentDir paths </> pConfigFile paths-  logInfo $ "Creating YAML config file in " <> fromString filePath-  writeFileUtf8 filePath (configuration opts paths)+  opts         <- viewL+  p@Paths {..} <- viewL+  logInfo $ "Creating YAML config file in " <> fromString pConfigFile+  writeFileUtf8 pConfigFile (configuration opts p)  where   configuration opts paths =     let withSourcePaths = TP.replace           "source-paths: []"-          ("source-paths: " <> toYamlList (T.pack <$> cioSourcePaths opts))-          configFileStub+          (toYamlList "source-paths" $ cioSourcePaths opts)         withTemplatePaths = TP.replace           "template-paths: []"-          ("template-paths: " <> toYamlList [T.pack $ pTemplatesDir paths])-          withSourcePaths-    in  withTemplatePaths-  toYamlList items = mconcat-    ["[ ", T.intercalate ", " (fmap (\i -> "\"" <> i <> "\"") items), " ]"]+          (toYamlList "template-paths" [pTemplatesDir paths])+    in  withTemplatePaths . withSourcePaths $ configFileStub+  toYamlList field list =+    T.stripEnd . prettyPrintYAML $ M.fromList [(field :: Text, list)]  -- | Checks whether application config file already exists. doesAppConfigExist :: (HasLogFunc env, Has Paths env) => RIO env Bool doesAppConfigExist = do-  paths <- viewL+  Paths {..} <- viewL   logInfo "Verifying that there's no existing Headroom configuration..."-  doesFileExist $ pCurrentDir paths </> pConfigFile paths+  doesFileExist pConfigFile  -- | Creates directory for template files. makeTemplatesDir :: (HasLogFunc env, Has Paths env) => RIO env () makeTemplatesDir = do-  paths <- viewL-  let templatesDir = pCurrentDir paths </> pTemplatesDir paths-  logInfo $ "Creating directory for templates in " <> fromString templatesDir-  createDirectory templatesDir+  Paths {..} <- viewL+  logInfo $ "Creating directory for templates in " <> fromString pTemplatesDir+  createDirectory pTemplatesDir
test/Headroom/Command/InitSpec.hs view
@@ -36,7 +36,6 @@     { cioSourcePaths = ["test-data" </> "test-traverse"]     , cioLicenseType = BSD3     }-  paths = Paths { pCurrentDir   = "."-                , pConfigFile   = "test-data" </> "configs" </> "full.yaml"+  paths = Paths { pConfigFile   = "test-data" </> "configs" </> "full.yaml"                 , pTemplatesDir = "headroom-templates"                 }
test/Headroom/SerializationSpec.hs view
@@ -7,6 +7,7 @@  import           Headroom.Serialization import           RIO+import qualified RIO.Map                       as M import           Test.Hspec  @@ -19,8 +20,16 @@     it "removes prefix and keeps case for 'prURLField'" $ do       dropFieldPrefix "prURLField" `shouldBe` "URLField" +   describe "symbolCase" $ do     it "replaces camel cased string into symbol cased" $ do       let input    = "camelCasedValue"           expected = "camel-cased-value"       symbolCase '-' input `shouldBe` expected+++  describe "prettyPrintYAML" $ do+    it "pretty prints YAML" $ do+      let input    = M.fromList [("foo" :: Text, ["bar"] :: [Text])]+          expected = "foo:\n- bar\n"+      prettyPrintYAML input `shouldBe` expected