From c10fce2687d1345e3abf49d399a8abfa9c17bed1 Mon Sep 17 00:00:00 2001 From: Dmitry Kovanikov Date: Tue, 5 Mar 2019 22:54:31 +0800 Subject: [PATCH 1/3] [#269] Use 'ghc-options' instead of 'warnings' Resolves #269 --- README.md | 4 +- summoner-cli/CHANGELOG.md | 2 + summoner-cli/src/Summoner/Config.hs | 46 +++++++++++---------- summoner-cli/src/Summoner/Project.hs | 6 ++- summoner-cli/src/Summoner/Settings.hs | 2 +- summoner-cli/src/Summoner/Template/Cabal.hs | 14 +++---- summoner-cli/summoner.cabal | 8 ++-- summoner-cli/test/Test/Golden.hs | 4 +- summoner-cli/test/Test/TomlSpec.hs | 11 ++--- summoner-tui/CHANGELOG.md | 5 +++ summoner-tui/src/Summoner/Tui/Kit.hs | 8 ++-- summoner-tui/summoner-tui.cabal | 4 +- 12 files changed, 65 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index a52ac226..8a4b41da 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ Below you can see highlighted features in different categories. + Ability to include your `.stylish-haskell.yaml` file. + Usage of the `ghc-options` field with sensible defaults. - If warnings are not explicitly stated in the configuration file, then the following list of GHC flags is added to all stanzas: + If `ghc-options` are not explicitly stated in the configuration file, then the following list of GHC flags is added to all stanzas: ``` -Wall @@ -330,7 +330,7 @@ Here is the list of the options that can be configured to suit your needs. If op | `test` | Bool | Create `test` folder with simple `Spec.hs` file and test target? | | `bench` | Bool | Create `benchmark` folder with `Main.hs` file with [`gauge`](https://hackage.haskell.org/package/gauge) library usage example? | | `extensions` | [Text] | List of the default extensions to add into `default-extensions` section in the `.cabal`. | -| `warnings` | [Text] | List of the default checks and warnings to add into `ghc-options` section in the `.cabal`. | +| `ghc-options` | [Text] | List of the default GHC options to add into `ghc-options` section in the `.cabal`. | | `stylish.*` | Text | `stylish.file` to provide the absolute file path OR `stylish.url` to download the `.stylish-haskell.yaml` file to use in the project. | | `contributing.*` | Text | `contributing.file` to provide the absolute file path OR `contributing.url` download OR `contribuint.link` to link the `CONTRIBUTING.md` file to use in the project. | |`[prelude]` | | | diff --git a/summoner-cli/CHANGELOG.md b/summoner-cli/CHANGELOG.md index 0a1c4d48..13c6b81e 100644 --- a/summoner-cli/CHANGELOG.md +++ b/summoner-cli/CHANGELOG.md @@ -22,6 +22,8 @@ The changelog is available [on GitHub][2]. Allow users to extend the .gitignore file. * [#285](https://github.com/kowainik/summoner/issues/285): Implement `summon script` command. +* [#269](https://github.com/kowainik/summoner/issues/269): + Introduce `ghc-options` configuration parameter. Deprecate `warnings` TOML parameter. ## 1.2.0 — Nov 30, 2018 diff --git a/summoner-cli/src/Summoner/Config.hs b/summoner-cli/src/Summoner/Config.hs index f39fa2f9..a8ab76b3 100644 --- a/summoner-cli/src/Summoner/Config.hs +++ b/summoner-cli/src/Summoner/Config.hs @@ -40,27 +40,28 @@ data Phase = Partial | Final -- | Potentially incomplete configuration. data ConfigP (p :: Phase) = Config - { cOwner :: p :- Text - , cFullName :: p :- Text - , cEmail :: p :- Text - , cLicense :: p :- LicenseName - , cGhcVer :: p :- [GhcVer] - , cCabal :: Decision - , cStack :: Decision - , cGitHub :: Decision - , cTravis :: Decision - , cAppVey :: Decision - , cPrivate :: Decision - , cLib :: Decision - , cExe :: Decision - , cTest :: Decision - , cBench :: Decision - , cPrelude :: Last CustomPrelude - , cExtensions :: [Text] - , cWarnings :: [Text] - , cGitignore :: [Text] - , cStylish :: Last Source - , cContributing :: Last Source + { cOwner :: !(p :- Text) + , cFullName :: !(p :- Text) + , cEmail :: !(p :- Text) + , cLicense :: !(p :- LicenseName) + , cGhcVer :: !(p :- [GhcVer]) + , cCabal :: !Decision + , cStack :: !Decision + , cGitHub :: !Decision + , cTravis :: !Decision + , cAppVey :: !Decision + , cPrivate :: !Decision + , cLib :: !Decision + , cExe :: !Decision + , cTest :: !Decision + , cBench :: !Decision + , cPrelude :: !(Last CustomPrelude) + , cExtensions :: ![Text] + , cWarnings :: ![Text] + , cGhcOptions :: ![Text] -- ^ GHC options to add every stanza + , cGitignore :: ![Text] + , cStylish :: !(Last Source) + , cContributing :: !(Last Source) } deriving (Generic) deriving instance @@ -123,6 +124,7 @@ defaultConfig = Config , cPrelude = Last Nothing , cExtensions = [] , cWarnings = [] + , cGhcOptions = [] , cGitignore = [] , cStylish = Last Nothing , cContributing = Last Nothing @@ -149,6 +151,7 @@ configT = Config <*> lastT preludeT "prelude" .= cPrelude <*> textArr "extensions" .= cExtensions <*> textArr "warnings" .= cWarnings + <*> textArr "ghc-options" .= cGhcOptions <*> textArr "gitignore" .= cGitignore <*> lastT sourceT "stylish" .= cStylish <*> lastT sourceT "contributing" .= cContributing @@ -208,6 +211,7 @@ finalise Config{..} = Config <*> pure cPrelude <*> pure cExtensions <*> pure cWarnings + <*> pure cGhcOptions <*> pure cGitignore <*> pure cStylish <*> pure cContributing diff --git a/summoner-cli/src/Summoner/Project.hs b/summoner-cli/src/Summoner/Project.hs index 921f5704..129477f5 100644 --- a/summoner-cli/src/Summoner/Project.hs +++ b/summoner-cli/src/Summoner/Project.hs @@ -39,6 +39,9 @@ generateProject -> Config -- ^ Given configurations. -> IO () generateProject settingsNoUpload isOffline projectName Config{..} = do + unless (null cWarnings) $ + warningMessage "'warnings' field in TOML config is deprecated. Rename it to 'ghc-options'." + settingsRepo <- checkUniqueName projectName -- decide cabal stack or both (settingsCabal, settingsStack) <- getCabalStack (cCabal, cStack) @@ -86,9 +89,10 @@ generateProject settingsNoUpload isOffline projectName Config{..} = do Just _ -> "base-noprelude" let settingsExtensions = cExtensions - let settingsWarnings = cWarnings + let settingsGhcOptions = cWarnings ++ cGhcOptions let settingsGitignore = cGitignore + putTextLn $ "The project will be created with GHC-" <> showGhcVer defaultGHC settingsTestedVersions <- sortNub . (defaultGHC :) <$> case cGhcVer of [] -> do diff --git a/summoner-cli/src/Summoner/Settings.hs b/summoner-cli/src/Summoner/Settings.hs index 65167deb..a7d2f601 100644 --- a/summoner-cli/src/Summoner/Settings.hs +++ b/summoner-cli/src/Summoner/Settings.hs @@ -50,7 +50,7 @@ data Settings = Settings , settingsBaseType :: !Text -- ^ Base library to use , settingsPrelude :: !(Maybe CustomPrelude) -- ^ custom prelude to be used , settingsExtensions :: ![Text] -- ^ default extensions - , settingsWarnings :: ![Text] -- ^ default warnings + , settingsGhcOptions :: ![Text] -- ^ default GHC options , settingsGitignore :: ![Text] -- ^ .gitignore file , settingsCabal :: !Bool , settingsStack :: !Bool diff --git a/summoner-cli/src/Summoner/Template/Cabal.hs b/summoner-cli/src/Summoner/Template/Cabal.hs index 750a5df7..ea40cae7 100644 --- a/summoner-cli/src/Summoner/Template/Cabal.hs +++ b/summoner-cli/src/Summoner/Template/Cabal.hs @@ -172,22 +172,22 @@ cabalFile Settings{..} = File (toString settingsRepo ++ ".cabal") cabalFileConte <> "\n" ghcOptions :: Text - ghcOptions = case settingsWarnings of - [] -> defaultWarnings + ghcOptions = case settingsGhcOptions of + [] -> defaultGhcOptions xs -> T.intercalate "\n" xs - defaultWarnings :: Text - defaultWarnings = + defaultGhcOptions :: Text + defaultGhcOptions = [text| -Wincomplete-uni-patterns -Wincomplete-record-updates -Wcompat -Widentities - $versionWarnings + $versionGhcOptions |] - versionWarnings :: Text - versionWarnings + versionGhcOptions :: Text + versionGhcOptions = memptyIfFalse (settingsTestedVersions `hasLeast` Ghc801) "-Wredundant-constraints\n" <> memptyIfFalse (settingsTestedVersions `hasLeast` Ghc822) diff --git a/summoner-cli/summoner.cabal b/summoner-cli/summoner.cabal index 3c73ef89..7f697a03 100644 --- a/summoner-cli/summoner.cabal +++ b/summoner-cli/summoner.cabal @@ -1,6 +1,6 @@ -cabal-version: 2.0 +cabal-version: 2.4 name: summoner -version: 1.2.0 +version: 1.3.0 synopsis: Tool for scaffolding completely configured production Haskell projects. description: Tool for scaffolding completely configured production Haskell projects. See [README.md](https://github.com/kowainik/summoner#-summoner) for details. @@ -10,13 +10,13 @@ license: MPL-2.0 license-file: LICENSE author: Kowainik maintainer: xrom.xkov@gmail.com -copyright: 2018 Kowainik +copyright: 2018-2019 Kowainik category: CLI, CLI Tool, Development build-type: Simple stability: stable extra-doc-files: README.md , CHANGELOG.md -data-dir: test/golden +extra-source-files: test/golden/** tested-with: GHC == 8.2.2 , GHC == 8.4.4 , GHC == 8.6.3 diff --git a/summoner-cli/test/Test/Golden.hs b/summoner-cli/test/Test/Golden.hs index db5c89f4..2fc5be0a 100644 --- a/summoner-cli/test/Test/Golden.hs +++ b/summoner-cli/test/Test/Golden.hs @@ -70,7 +70,7 @@ fullProject = Settings , settingsPrelude = Just $ CustomPrelude "relude" "Relude" , settingsExtensions = ["ConstraintKinds", "LambdaCase", "OverloadedStrings"] , settingsGitignore = [".secret"] - , settingsWarnings = ["-Wcompat", "-Widentities"] + , settingsGhcOptions = ["-Wcompat", "-Widentities"] , settingsCabal = True , settingsStack = True , settingsStylish = Just "This is stylish-haskell.yaml\n" @@ -126,7 +126,7 @@ smallProject = Settings , settingsBaseType = "base" , settingsPrelude = Nothing , settingsExtensions = [] - , settingsWarnings = [] + , settingsGhcOptions = [] , settingsGitignore = [] , settingsCabal = True , settingsStack = False diff --git a/summoner-cli/test/Test/TomlSpec.hs b/summoner-cli/test/Test/TomlSpec.hs index 44f5fe93..0ad807f4 100644 --- a/summoner-cli/test/Test/TomlSpec.hs +++ b/summoner-cli/test/Test/TomlSpec.hs @@ -50,11 +50,11 @@ genSource = do genPartialConfig :: MonadGen m => m PartialConfig genPartialConfig = do - cOwner <- Last . Just <$> genText - cFullName <- Last . Just <$> genText - cEmail <- Last . Just <$> genText - cLicense <- Last . Just <$> genLicense - cGhcVer <- Last . Just <$> genGhcVerArr + cOwner <- Last <$> Gen.maybe genText + cFullName <- Last <$> Gen.maybe genText + cEmail <- Last <$> Gen.maybe genText + cLicense <- Last <$> Gen.maybe genLicense + cGhcVer <- Last <$> Gen.maybe genGhcVerArr cCabal <- genDecision cStack <- genDecision cGitHub <- genDecision @@ -68,6 +68,7 @@ genPartialConfig = do cPrelude <- Last <$> Gen.maybe genCustomPrelude cExtensions <- genTextArr cWarnings <- genTextArr + cGhcOptions <- genTextArr cGitignore <- genTextArr cStylish <- Last <$> Gen.maybe genSource cContributing <- Last <$> Gen.maybe genSource diff --git a/summoner-tui/CHANGELOG.md b/summoner-tui/CHANGELOG.md index 3716619d..e4a47958 100644 --- a/summoner-tui/CHANGELOG.md +++ b/summoner-tui/CHANGELOG.md @@ -3,6 +3,11 @@ `summoner-tui` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +## Unreleased: 0.1.0 + +* [#285](https://github.com/kowainik/summoner/issues/285): + Implement `summon script` command. + ## 0.0.0 — Nov 30, 2018 * [#208](https://github.com/kowainik/summoner/issues/208): diff --git a/summoner-tui/src/Summoner/Tui/Kit.hs b/summoner-tui/src/Summoner/Tui/Kit.hs index 2fd5d44b..2919da37 100644 --- a/summoner-tui/src/Summoner/Tui/Kit.hs +++ b/summoner-tui/src/Summoner/Tui/Kit.hs @@ -28,7 +28,7 @@ module Summoner.Tui.Kit , projectMeta , gitHub , extensions - , warnings + , ghcOptions , stylish , contributing , offline @@ -90,7 +90,7 @@ data SummonKit = SummonKit , summonKitProjectMeta :: !ProjectMeta , summonKitGitHub :: !GitHub , summonKitExtensions :: ![Text] -- ^ Can be recieved from the config file. - , summonKitWarnings :: ![Text] -- ^ Can be recieved from the config file. + , summonKitGhcOptions :: ![Text] -- ^ Can be recieved from the config file. , summonKitGitignore :: ![Text] -- ^ Received from the config file. , summonKitStylish :: !(Maybe Source) -- ^ Can be recieved from the config file. , summonKitContributing :: !(Maybe Source) -- ^ Can be recieved from the config file. @@ -176,7 +176,7 @@ summonKitToSettings sk = Settings , settingsBaseType = baseT , settingsPrelude = cP , settingsExtensions = sk ^. extensions - , settingsWarnings = sk ^. warnings + , settingsGhcOptions = sk ^. ghcOptions , settingsGitignore = sk ^. gitignore , settingsCabal = sk ^. cabal , settingsStack = sk ^. stack @@ -259,7 +259,7 @@ configToSummonKit cRepo cNoUpload cOffline cConfigFile Config{..} = SummonKit , gitHubAppVeyor = toBool cAppVey && kitStack } , summonKitExtensions = cExtensions - , summonKitWarnings = cWarnings + , summonKitGhcOptions = cWarnings ++ cGhcOptions , summonKitGitignore = cGitignore , summonKitStylish = getLast cStylish , summonKitContributing = getLast cContributing diff --git a/summoner-tui/summoner-tui.cabal b/summoner-tui/summoner-tui.cabal index 91af3281..51356f18 100644 --- a/summoner-tui/summoner-tui.cabal +++ b/summoner-tui/summoner-tui.cabal @@ -1,6 +1,6 @@ cabal-version: 2.0 name: summoner-tui -version: 0.0.0 +version: 0.1.0 synopsis: Tool for scaffolding completely configured production Haskell projects using TUI. description: : Tool for scaffolding completely configured production Haskell projects using TUI. See [README.md](https://github.com/kowainik/summoner#-summoner) for details. @@ -45,7 +45,7 @@ library , microlens ^>= 0.4 , microlens-th ^>= 0.4 , relude ^>= 0.4.0 - , summoner ^>= 1.2.0 + , summoner ^>= 1.3.0 , text ^>= 1.2.3.0 , vty ^>= 5.25 From cfdbafc60926cb25c4f4ae1d7ea794d124e50523 Mon Sep 17 00:00:00 2001 From: Dmitry Kovanikov Date: Wed, 6 Mar 2019 00:08:42 +0800 Subject: [PATCH 2/3] Fix CI and improve error message --- summoner-cli/src/Summoner/Project.hs | 2 +- summoner-cli/summoner.cabal | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/summoner-cli/src/Summoner/Project.hs b/summoner-cli/src/Summoner/Project.hs index 129477f5..06d099c2 100644 --- a/summoner-cli/src/Summoner/Project.hs +++ b/summoner-cli/src/Summoner/Project.hs @@ -40,7 +40,7 @@ generateProject -> IO () generateProject settingsNoUpload isOffline projectName Config{..} = do unless (null cWarnings) $ - warningMessage "'warnings' field in TOML config is deprecated. Rename it to 'ghc-options'." + warningMessage "Please, rename 'warings' field if you use one, it will be removed in the very next release. Use 'ghc-options' instead." settingsRepo <- checkUniqueName projectName -- decide cabal stack or both diff --git a/summoner-cli/summoner.cabal b/summoner-cli/summoner.cabal index 7f697a03..3cd1e5ee 100644 --- a/summoner-cli/summoner.cabal +++ b/summoner-cli/summoner.cabal @@ -1,4 +1,4 @@ -cabal-version: 2.4 +cabal-version: 2.0 name: summoner version: 1.3.0 synopsis: Tool for scaffolding completely configured production Haskell projects. @@ -16,7 +16,6 @@ build-type: Simple stability: stable extra-doc-files: README.md , CHANGELOG.md -extra-source-files: test/golden/** tested-with: GHC == 8.2.2 , GHC == 8.4.4 , GHC == 8.6.3 From e40bdd1e65ca8ff3340ff5ed4afd60bdcd089a7c Mon Sep 17 00:00:00 2001 From: ChShersh Date: Wed, 6 Mar 2019 09:53:27 +0800 Subject: [PATCH 3/3] Update changelog --- summoner-cli/CHANGELOG.md | 5 ++++- summoner-cli/src/Summoner/Project.hs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/summoner-cli/CHANGELOG.md b/summoner-cli/CHANGELOG.md index 13c6b81e..78da5bd9 100644 --- a/summoner-cli/CHANGELOG.md +++ b/summoner-cli/CHANGELOG.md @@ -23,7 +23,10 @@ The changelog is available [on GitHub][2]. * [#285](https://github.com/kowainik/summoner/issues/285): Implement `summon script` command. * [#269](https://github.com/kowainik/summoner/issues/269): - Introduce `ghc-options` configuration parameter. Deprecate `warnings` TOML parameter. + __Important:__ Introduce `ghc-options` configuration parameter. Deprecate `warnings` field in TOML file. + + _Migration guide:_ Please, rename `warnings` field if you use one, it will be + removed in the very next release. Use `ghc-options` instead. ## 1.2.0 — Nov 30, 2018 diff --git a/summoner-cli/src/Summoner/Project.hs b/summoner-cli/src/Summoner/Project.hs index 06d099c2..7726c1b9 100644 --- a/summoner-cli/src/Summoner/Project.hs +++ b/summoner-cli/src/Summoner/Project.hs @@ -40,7 +40,7 @@ generateProject -> IO () generateProject settingsNoUpload isOffline projectName Config{..} = do unless (null cWarnings) $ - warningMessage "Please, rename 'warings' field if you use one, it will be removed in the very next release. Use 'ghc-options' instead." + warningMessage "Please, rename 'warnings' field if you use one, it will be removed in the very next release. Use 'ghc-options' instead." settingsRepo <- checkUniqueName projectName -- decide cabal stack or both