packages feed

summoner-tui 0.1.0 → 1.4.0.0

raw patch · 12 files changed

+668/−159 lines, 12 filesdep −base-nopreludedep ~basedep ~brickdep ~reludenew-uploaderPVP ok

version bump matches the API change (PVP)

Dependencies removed: base-noprelude

Dependency ranges changed: base, brick, relude, summoner, vty

API changes (from Hackage documentation)

+ Summoner.Tui.Kit: [summonKitExtraFiles] :: SummonKit -> ![TreeFs]
+ Summoner.Tui.Kit: instance Summoner.Tui.Kit.HasExtraFiles Summoner.Tui.Kit.SummonKit [Summoner.Tree.TreeFs]
+ Summoner.Tui.Validation: handleAutofill :: KitForm e -> KitForm e
+ Summoner.Tui.Validation: projectDescNewLine :: KitForm e -> KitForm e
- Summoner.Tui.Kit: SummonKit :: !User -> !Project -> !Bool -> !Bool -> !ProjectMeta -> !GitHub -> ![Text] -> ![Text] -> ![Text] -> !Maybe Source -> !Maybe Source -> !Bool -> !Decision -> !Maybe FilePath -> SummonKit
+ Summoner.Tui.Kit: SummonKit :: !User -> !Project -> !Bool -> !Bool -> !ProjectMeta -> !GitHub -> ![Text] -> ![Text] -> ![Text] -> !Maybe Source -> !Maybe Source -> !Bool -> !Decision -> !Maybe FilePath -> ![TreeFs] -> SummonKit
- Summoner.Tui.Kit: configToSummonKit :: Text -> Bool -> Maybe FilePath -> Config -> SummonKit
+ Summoner.Tui.Kit: configToSummonKit :: Text -> Bool -> Maybe FilePath -> [TreeFs] -> Config -> SummonKit

Files

CHANGELOG.md view
@@ -1,25 +1,369 @@ # Changelog -`summoner-tui` uses [PVP Versioning][1].+`summoner` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. -## 0.1.0 — Apr 9, 2019+## 1.4.0.0 – Dec 25, 2019 🎅 -* Upgrade to `summoner-1.3.0`.+* [#339](https://github.com/kowainik/summoner/issues/339):+  Support GHC `8.8.1` in generated projects.+  __Note:__ Stack projects will use `nightly` resolver as the stable one is not+  out at the moment of this issue is implemented.+  (by [@vrom911](https://github.com/vrom911))+* Add `-Wmissing-deriving-strategies` option to GHC version `8.8.1` and upper+  in the generated projects.+  (by [@vrom911](https://github.com/vrom911))+* [#314](https://github.com/kowainik/summoner/issues/314):+  __#CLI__ __#TUI__ Improve `summon(-tui) show ghc` output.+  (by [@gableh](https://github.com/gableh), [@vrom911](https://github.com/vrom911))+* [#316](https://github.com/kowainik/summoner/issues/316):+  Add logos to README bagdes in the generated projects.+  (by [@vrom911](https://github.com/vrom911))+* Generate project of version `0.0.0.0` instead of `0.0.0`.+  (by [@vrom911](https://github.com/vrom911))+* [#322](https://github.com/kowainik/summoner/issues/322):+  Run HLint check before project build in `.travis.yml` file for+  the generated projects.+  (by [@vrom911](https://github.com/vrom911))+* [#382](https://github.com/kowainik/summoner/issues/382):+  Improve error logging when fetching the license from GitHub while generating+  the project.+  (by [@chshersh](https://github.com/chshersh))+* [#255](https://github.com/kowainik/summoner/issues/255):+  __#CLI__ __#TUI__ Autofill prelude module name when package name is typed.+  (by [@yigitozkavci](https://github.com/yigitozkavci))+* [#354](https://github.com/kowainik/summoner/issues/354):+  __#CLI__ __#TUI__ Validate prelude package name and module name in config file, CLI, TUI.+  (by [@yigitozkavci](https://github.com/yigitozkavci), [@vrom911](https://github.com/vrom911))+* [#315](https://github.com/kowainik/summoner/issues/315):+  Remove `-fhide-source-paths` from generated `stack.yaml` file+  as it is implied by the newer version of Stack.+  (by [@bangng](https://github.com/chshersh), [@chshersh](https://github.com/chshersh))+* Add `stack.yaml.lock` to `.gitignore` file in the generated project.+  (by [@vrom911](https://github.com/vrom911))+* [#318](https://github.com/kowainik/summoner/issues/318):+  Support GHC `8.6.5` in generated projects.+  (by [@vrom911](https://github.com/vrom911))+* Remove support of GHC `8.6.4`, `8.6.3`, `8.4.3`. Leave only the latest+  versions of each major release for generated projects.+  (by [@vrom911](https://github.com/vrom911))+* [#333](https://github.com/kowainik/summoner/issues/333):+  Introduce `files` option in the TOML configuration which allows to specify+  custom files. Deprecate `stylish` and `contributing` options.+  (by [@chshersh](https://github.com/chshersh))++  _Migration guide:_ Instead of++  ```toml+  stylish.url = "some url"+  contributing.link = "some link"+  ```++  specify them like this:++  ```toml+  files =+      [ { path = ".stylish-haskell.yaml"+        , url  = "some url"+        }+      , { path = "CONTRIBUTING.md"+        , link = "some link"+        }+      ]+  ```+* [#374](https://github.com/kowainik/summoner/issues/374):+  Remove `warnings` field in the TOML configuration which was deprecated in the previous release.+  (by [@chshersh](https://github.com/chshersh))++  _Migration guide:_ Rename `warnings` field to `ghc-options` instead.+* [#367](https://github.com/kowainik/summoner/issues/367):+  Add `raw` type of custom extra files in the TOML configuration.+  Remove `link` type of file.+  (by [@chshersh](https://github.com/chshersh))++  _Migration guide:_ Replace `link` with `raw` and specify any custom text you+  want.+* Rename `file` config field of `source` to `local` in the TOML configuration.+  (by [@chshersh](https://github.com/chshersh))+* [#327](https://github.com/kowainik/summoner/issues/327):+  Better AppVeyor CI configuration for both `cabal` and `stack` in the generated+  project.+  (by [@chshersh](https://github.com/chshersh))+* [#253](https://github.com/kowainik/summoner/issues/253):+  __#TUI__ Fix new line in the Description field of the form.+  (by [@yigitozkavci](https://github.com/yigitozkavci))+* [#385](https://github.com/kowainik/summoner/issues/385):+  Add golden tests for `summon show ghc` command's output.+  (by [@vrom911](https://github.com/vrom911))+* [#384](https://github.com/kowainik/summoner/issues/384):+  Test golden project build's success.+  (by [@chshersh](https://github.com/chshersh))+* [#318](https://github.com/kowainik/summoner/issues/318):+  Build Summoner multipackage project with GHC `8.6.5`.+  (by [@vrom911](https://github.com/vrom911))+* [#338](https://github.com/kowainik/summoner/issues/338):+  Build Summoner multipackage project with GHC-8.8.1.+  (by [@vrom911](https://github.com/vrom911))+* [#360](https://github.com/kowainik/summoner/issues/360):+  Use mixins with `base` and `relude` in Summoner. Drop `base-noprelude` trick.+  (by [@vrom911](https://github.com/vrom911))+* [#329](https://github.com/kowainik/summoner/issues/329):+  Bump up to `optparse-applicative-0.15`, use custom `ParserPrefs`.+  (by [@vrom911](https://github.com/vrom911))+* [#328](https://github.com/kowainik/summoner/issues/328):+  Upgrade `tomland` bounds to allow `1.1.0.0`.+  (by [@vrom911](https://github.com/vrom911))+* [#373](https://github.com/kowainik/summoner/issues/373):+  Bump up to `tomland-1.2.1.0`.+  (by [@vrom911](https://github.com/vrom911))+* Bump up to `relude-0.6.0.0`.+  (by [@vrom911](https://github.com/vrom911))+* [#337](https://github.com/kowainik/summoner/issues/337):+  Allow `generic-deriving-1.13`.+  (by [@chshersh](https://github.com/chshersh))+* [#341](https://github.com/kowainik/summoner/issues/341):+  Allow `ansi-terminal-0.10`.+  (by [@mpilgrem](https://github.com/mpilgrem))+* [#323](https://github.com/kowainik/summoner/issues/323):+  Allow `tree-diff-0.1`.+  (by [@vrom911](https://github.com/vrom911))+* [#320](https://github.com/kowainik/summoner/issues/320):+  Allow `hedgehog-1.0`.+  (by [@vrom911](https://github.com/vrom911))++## 1.3.0.1 — Apr 10, 2019++* Include golden test files into `extra-source-files`.++## 1.3.0 (TUI: 0.1.0) — Apr 9, 2019+ * [#285](https://github.com/kowainik/summoner/issues/285):-  Implement `summon script` command.+  __#CLI__ __#TUI__ Implement `summon script` command.+* [#151](https://github.com/kowainik/summoner/issues/151),+  [#295](https://github.com/kowainik/summoner/issues/295):+  Add support for GHC-8.6. Make GHC-8.6.4 default.+* [#269](https://github.com/kowainik/summoner/issues/269):+  __Important:__ Introduce `ghc-options` configuration parameter. Deprecate+  `warnings` field in the TOML configuration.++  _Migration guide:_ Please, rename `warnings` field if you use one, it will be+  removed in the very next release. Use `ghc-options` instead.+* [#303](https://github.com/kowainik/summoner/issues/303):+  Add option `noUpload` to the TOML configuration.+* __Important:__ Summoner doesn't add old GHC versions into Travis matrix for+  Stack anymore. See this Stack issue for reasoning:+      https://github.com/commercialhaskell/stack/issues/4488 * [#280](https://github.com/kowainik/summoner/issues/280):-  AppVeyor CI checkbox is no longer disabled when only `cabal` build tool is+  Support build with `cabal-install` on the AppVeyor CI.++  __#TUI__ AppVeyor CI checkbox is no longer disabled when only `cabal` build tool is   selected.+* [#272](https://github.com/kowainik/summoner/issues/272):+  Simplify Travis config for Cabal in the generated project.+* [#275](https://github.com/kowainik/summoner/issues/275):+  Simplify Travis settings/installation process for Stack in the generated+  project.+* [#261](https://github.com/kowainik/summoner/issues/261):+  Guess author login, name and email from `.gitconfig`.+* [#268](https://github.com/kowainik/summoner/issues/268):+  __#CLI__ Simplify process of adding custom prelude in the interactive mode.+* [#282](https://github.com/kowainik/summoner/issues/282):+  Allow users to extend the `.gitignore` file.+* [#286](https://github.com/kowainik/summoner/issues/286),+  [#288](https://github.com/kowainik/summoner/issues/288),+  [#304](https://github.com/kowainik/summoner/issues/304):+  Bump up to `tomland-1.0.0`, `relude-0.5.0`, `shellmet-0.0.1`.+* Drop support for GHC-8.6.3 on CI. Support GHC-8.6.4 on CI.+* __#TUI__ Upgrade to `summoner-1.3.0`. * [#297](https://github.com/kowainik/summoner/issues/297):-  Strip project description.+  __#TUI__ Strip project description. * [#304](https://github.com/kowainik/summoner/issues/304):-  Bump up to `brick-0.47`.+  __#TUI__ Bump up to `brick-0.47`. -## 0.0.0 — Nov 30, 2018+## 1.2.0 (TUI: 0.0.0) — Nov 30, 2018  * [#208](https://github.com/kowainik/summoner/issues/208):-   Implement initial TUI for `summoner`.+  __#TUI__ Implement initial TUI for `summoner`.+* Make `cabal-version: 2.0` default in generated projects.+* [#11](https://github.com/kowainik/summoner/issues/11):+  Support offline mode.+* [#199](https://github.com/kowainik/summoner/issues/199):+  Add `None` license with no `LICENSE` file generation.+  Add licenses short descriptions text during the interactive mode.+  Patch `summon show license` command to show short description about+  each license.+* [#197](https://github.com/kowainik/summoner/issues/197)+  Build with `stack` lts-12.20, and support `GHC` 8.4.4 in+  project generation. Make GHC-8.4.4 the default one for generated project.+* [#37](https://github.com/kowainik/summoner/issues/37):+  Add HLint check on Travis CI in generatd projects.+* [#142](https://github.com/kowainik/summoner/issues/142):+  Add version bounds to `base` in the generated `.cabal` file.+* [#239](https://github.com/kowainik/summoner/issues/239):+  Make categories not mandatory.+* Use `defaultDescription` for project description if not specified.+* [#185](https://github.com/kowainik/summoner/issues/185):+  Add golden tests.+* [#184](https://github.com/kowainik/summoner/issues/184)+  Add `--no-upload` option.+* [#169](https://github.com/kowainik/summoner/issues/169):+  Make AppVeyor use the 64bits version of stack and build for 64 bits.+* [#154](https://github.com/kowainik/summoner/issues/154):+  Add `Link` constructor to `Source` data type.+* [#178](https://github.com/kowainik/summoner/issues/178):+  Remove unnecessary new lines and trailing spaces in most places.+* [#168](https://github.com/kowainik/summoner/issues/168):+  Upgrade `stack` `intall-cabal` option's version to `2.2.0.1` in+  the generated Travis file.+* [#195](https://github.com/kowainik/summoner/issues/195):+  Update prompt questions for CLI.+* Add more documentation to the functions.+* [#155](https://github.com/kowainik/summoner/issues/155):+  Bump up to `tomland-0.5.0`.+* [#202](https://github.com/kowainik/summoner/issues/202):+  Bump up to `relude-0.4.0`.+* Remove `tasty` dependencies from tests.+* Drop support for GHC-8.6.1 on CI. Support GHC-8.6.2 on CI.+* Drop support for GHC-8.4.3 on CI. Build with GHC-8.4.4 on CI.+* Use `defaultDescription` for project description if not specified.++## 1.1.0.1 – Sep 10, 2018++* Bump up `relude` version to `0.3.0`.+* [#146](https://github.com/kowainik/summoner/issues/146):+  Migrate to `base-noprelude`.+* Add -Werror to build option in generated .travis.yml++## 1.1.0++* [#128](https://github.com/kowainik/summoner/issues/128):+  __Important:__ Replace `summon` with `summon new` command.+  To create a project now the following command should be used:+  ```+  summon new my-project+  ```+* [#82](https://github.com/kowainik/summoner/issues/82):+  Add stackage badges.+* [#109](https://github.com/kowainik/summoner/issues/109):+  Fix travis cache directories.+* [#117](https://github.com/kowainik/summoner/issues/117):+  Step into created project properly+* [#110](https://github.com/kowainik/summoner/issues/110):+  Print executing command.+* [#91](https://github.com/kowainik/summoner/issues/91):+  Add warning fields for ghc.+* [#90](https://github.com/kowainik/summoner/issues/90):+  Add TOML test.+* [#120](https://github.com/kowainik/summoner/issues/120):+  Bump up dependencies.+* [#58](https://github.com/kowainik/summoner/issues/58):+  Make `Licence` type safer.+* [#124](https://github.com/kowainik/summoner/issues/124):+  Print directories bold.+* [#130](https://github.com/kowainik/summoner/issues/130):+  Show git revision version under `--version` command.+* [#63](https://github.com/kowainik/summoner/issues/63):+  Add `show ghc`, `show license` and `show license <LICENSE_NAME>` commands.+* [#122](https://github.com/kowainik/summoner/issues/122):+  Remove github link from CHANGELOG when github is not chosen.+* [#35](https://github.com/kowainik/summoner/issues/35):+  Add config option to add `.stylish-haskell.yaml` to your project+  (via URL or file path).+* Bump up `tomland` version to `0.4.0`.+* [#138](https://github.com/kowainik/summoner/issues/138):+  Remove traces of GitHub from `.cabal` file when GitHub integration is disabled.+* [#31](https://github.com/kowainik/summoner/issues/31):+  Add config option to add `CONTRIBUTING.md` to your project+  (via URL or file path).+* [#27](https://github.com/kowainik/summoner/issues/27):+  Remove `b` script.++## 1.0.6++* Use `relude` instead of `universum`.+* [#105](https://github.com/kowainik/summoner/issues/105):+  Add `--ignore-config` option.++## 1.0.5++* [#100](https://github.com/kowainik/summoner/issues/100):+  Bump up to `ghc-8.4.3`. Add support for `Ghc843` in code+  and make it default.+* Make CI badges in README be shown depending on the chosen options.+* [#99](https://github.com/kowainik/summoner/issues/99):+  UseTravis-specific env variable `TRAVIS_BUILD_DIR` in created travis file.+* [#97](https://github.com/kowainik/summoner/issues/97):+  Add cabal to created travis file.+* [#96](https://github.com/kowainik/summoner/issues/96):+  Add option to choose `cabal`, `stack` or both.++## 1.0.4++* Bump up `tomland` to version `0.3`.++## 1.0.3++* [#92](https://github.com/kowainik/summoner/issues/92):+  Remove -fhide-source-paths from generated stack yaml files for+  GHC < 8.2++## 1.0.2++* [#87](https://github.com/kowainik/summoner/issues/87):+  Fix Travis matrix for not default `ghc` versions.++## 1.0.1++* [#85](https://github.com/kowainik/summoner/issues/85):+  Remove `base-noprelude` from dependencies.++## 1.0.0++* __Important:__ Rename `hs-init` to `summoner`. Transform the script into the package.+* [#54](https://github.com/kowainik/summoner/issues/54):+   Rename `on` and `off` commands to `with` and `without`.+* [#48](https://github.com/kowainik/summoner/issues/48):+  - Add ability to write configurations file. Remove `Targets` data type.+    Use `Config` instead for default, file and CLI configurations.+* [#60](https://github.com/kowainik/summoner/issues/60):+  Use custom prelude `universum`.+* [#39](https://github.com/kowainik/summoner/issues/39):+  Add option to use custom prelude in CLI and in `.toml` configuration.+* [#38](https://github.com/kowainik/summoner/issues/38):+  Add option to add default extensions to `.toml` config.+* [#62](https://github.com/kowainik/summoner/issues/62):+  Make some parts of output not only colorful, but also bold. This makes output prettier.+* [#67](https://github.com/kowainik/summoner/issues/67):+  Add `Aswer` data type to handle yes-no CLI questions.+* [#61](https://github.com/kowainik/summoner/issues/61):+  Add CLI `--version` option.+* [#73](https://github.com/kowainik/summoner/issues/73):+  Make custom prelude be table in toml.+* [#74](https://github.com/kowainik/summoner/issues/74):+  Print hierarchy tree for the created project.++# hs-init++## 0.0.4++* Now works on windows systems as well+* Add powershell install script for Windows+++## 0.0.3++* [#45](https://github.com/vrom911/hs-init/issues/45):+  Support AppVeyor CI for created projects.++## 0.0.2++* Use metavar for on-off commands.+* Upgrade `lts` to `10.3`, use `ghc 8.2.2` as default value.++## 0.0.1++* [#36](https://github.com/vrom911/hs-init/issues/36):+  Add option for creating private repositories — `-p | --private`.  [1]: https://pvp.haskell.org [2]: https://github.com/kowainik/summoner/releases
README.md view
@@ -1,9 +1,9 @@ # 🔮 Summoner  ![wizard](https://user-images.githubusercontent.com/8126674/44388234-320aac00-a55a-11e8-879d-5dca68512031.png)-[![Build](https://secure.travis-ci.org/kowainik/summoner.svg)](http://travis-ci.org/kowainik/summoner)+[![Build](https://img.shields.io/travis/kowainik/summoner.svg?logo=travis)](http://travis-ci.org/kowainik/summoner) [![Windows build](https://ci.appveyor.com/api/projects/status/github/kowainik/summoner?branch=master&svg=true)](https://ci.appveyor.com/project/kowainik/summoner)-[![Hackage](https://img.shields.io/hackage/v/summoner.svg)](https://hackage.haskell.org/package/summoner)+[![Hackage](https://img.shields.io/hackage/v/summoner.svg?logo=haskell)](https://hackage.haskell.org/package/summoner) [![MPL-2.0 license](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](https://github.com/kowainik/summoner/blob/master/LICENSE)  > _So many of our dreams at first seem impossible, then they seem improbable, and@@ -14,7 +14,8 @@ Summoner is a tool for scaffolding fully configured batteries-included production-level Haskell projects.  Do you want to create a library that is to be uploaded to Hackage/Stackage, that builds with both Cabal and Stack and supports the latest three major GHC versions?-Or you are building a production application which uses a custom prelude and has CI with Travis Linux and AppVeyors Windows checks?+Or are you building a production application which uses a custom prelude and has CI with Travis Linux and AppVeyors Windows checks?+Maybe do you want to play with your idea in a single module without introducing the whole complexity of the Haskell projects? Summoner can help you do all that with minimal effort from you - it can even upload the project to GitHub if you wish!  By the way, Summoner operates as either CLI or TUI application, so you can choose what you're more comfortable with and install only the required one.@@ -24,13 +25,14 @@ * [Demo](#demo-)     + [TUI demo](#tui-demo-)     + [CLI demo](#cli-demo-)-    + [Scaffolded project structure](#scaffolded-project-structure-)+    + [Examples](#examples-) * [Features](#features-) * [Get started](#get-started-)     + [Prerequisites](#prerequisites-)     + [Installation](#installation-)         + [Summon-TUI](#summon-tui-)           + [TUI: download binary](#tui-download-binary-)+          + [TUI: from Hackage/Stackage](#tui-from-hackagestackage-)           + [TUI: from source](#tui-from-source-)         + [Summon-CLI](#summon-cli-)           + [CLI: download binary](#cli-download-binary-)@@ -47,7 +49,6 @@     + [Build](#build-)     + [Test](#test-)     + [Run](#run-)-* [Changelog](#changelog-) * [Acknowledgments](#acknowledgments-)  ## Demo [↑](#structure)@@ -60,60 +61,38 @@  [![CLI demo](https://asciinema.org/a/214433.png)](https://asciinema.org/a/214433) -### Scaffolded project structure [↑](#structure)--This is an example of the project hierarchy you can get if you're running Summoner with all options enabled:--```-project-name/-├── app/-│   └── Main.hs-├── benchmark/-│   └── Main.hs-├── src/-│   ├── ProjectName.hs-│   └── Prelude.hs-├── test/-│   └── Spec.hs-├── CHANGELOG.md-├── CONTRIBUTING.md-├── LICENSE-├── project-name.cabal-├── README.md-├── Setup.hs-├── stack.yaml-├── appveyor.yml-├── .git-├── .gitignore-├── .stylish-haskell.yaml-└── .travis.yml-```+### Examples  You can also see complete examples in the following folder:  * [`summon-cli/tests/golden`: Examples of scaffolded projects](https://github.com/kowainik/summoner/tree/master/summoner-cli/test/golden) -Directory `smallProject` contains an example of the straightforward package, and `fullProject` shows a generated project with more advanced structure and more features.+Directory `smallProject` contains an example of the straightforward package,+and `fullProject` shows a generated project with more advanced structure and more features.  ## Features [↑](#structure)  Summoner is a tool that combines predefined configurations, command-line arguments and a chosen interface. -To fully understand the power in your hands with the help of Summoner, please check out this section.+To fully understand the power in your hands with the help of Summoner, please read this section.  Below you can see highlighted features in different categories.  ### Project [↑](#structure) +Features related to the structure and content of the generated projects.+ + Support for Cabal and Stack build tools. + Ability to pick stanzas (library, executable, test-suite, benchmark).-+ Option to include an alternative prelude, if desired. The project would then use [`base-noprelude` technique](http://hackage.haskell.org/package/Prelude), and the `Prelude` module would be added to the library target.-+ Whole Hackage-upload checklist support.++ Option to include an alternative prelude, if desired. The project would then+  use [`base-noprelude` technique](http://hackage.haskell.org/package/Prelude),+  and the `Prelude` module would be added to the library target.++ Whole Hackage-upload checklist support (exhaustive `.cabal` file, PVP versioning, GHC options, conventional meta files). + Support for multiple GHC versions, with thoughtful reflection on project meta, base versions (e.g. `base >= 4.9 && < 4.12`), etc. + Ability to create runnable Haskell scripts. + Different license support: MIT, BSD2, BSD3, GPL-2, GPL-3, LGPL-2.1, LGPL-3, AGPL-3, Apache-2.0, MPL-2.0, None (All Rights Reserved license without file). + Creation of the `CHANGELOG.md` file with [PVP versioning policy](https://pvp.haskell.org).-+ Ability to include your `.stylish-haskell.yaml` file.++ Ability to include any custom files (including `.stylish-haskell.yaml`, `CONTRIBUTING.md`, `CODEOWNERS`, etc.). + Usage of the `ghc-options` field with sensible defaults.    If `ghc-options` are not explicitly stated in the configuration file, then the following list of GHC flags is added to all stanzas:@@ -124,10 +103,11 @@   -Wincomplete-record-updates   -Wcompat   -Widentities-  -Wredundant-constraints      (ghc >= 8.0)-  -fhide-source-paths          (ghc >= 8.2.2)-  -Wmissing-export-lists       (ghc >= 8.4.1)-  -Wpartial-fields             (ghc >= 8.4.1)+  -Wredundant-constraints       (GHC >= 8.0)+  -fhide-source-paths           (GHC >= 8.2.2)+  -Wmissing-export-lists        (GHC >= 8.4.1)+  -Wpartial-fields              (GHC >= 8.4.1)+  -Wmissing-deriving-strategies (GHC >= 8.8.1)   ```    Besides, the following GHC options are added to the executable, tests and benchmark stanzas:@@ -146,22 +126,55 @@ + Exhaustive `.gitignore` file. + Formation of the `README` file with Hackage, Stackage and CI badges. + Linking to the GitHub repository in the `.cabal` file.-+ Ability to include your `CONTRIBUTING.md` file.-+ Guessing user credentials from `.gitconfig`.++ Ability to include your custom GitHub meta files: `CONTRIBUTING.md`, `CODEOWNERS`, `.github/pull_request_template.md`, etc.++ Guessing user credentials from the local `.gitconfig` file.  ### CI [↑](#structure)  + Generation of the `.travis.yml` file that runs build and tests on CI under Linux using   [Dead simple Haskell Travis Settings for Cabal and Stack](https://chshersh.github.io/posts/2019-02-25-haskell-travis).++ Generation of the `appveyor.yaml` file which runs build and tests on CI under Windows. + Configuration matrix on CI to build with multiple GHC versions and various build tools. + `-Werror` is enabled on CI not to miss any warnings. + Run HLint checks on CI.-+ Generation of the `appveyor.yaml` file which runs build and tests on CI under Windows.  ### Others [↑](#structure) -+ Ability to create a project in offline mode.++ Ability to create a project in the offline mode.++ Ability to check GHC-specific versions of the corresponding `base` library+  and Stackage snapshot resolver via `summon show ghc` command.++ Carefully collected Haskell project best practices gathered in your projects' scaffold. +### Project structure example [↑](#structure)++This is an example of the project hierarchy you can get if you are running Summoner's `new` command with all options enabled:++```+project-name/+├── app/+│   └── Main.hs+├── benchmark/+│   └── Main.hs+├── src/+│   ├── ProjectName.hs+│   └── Prelude.hs+├── test/+│   └── Spec.hs+├── CHANGELOG.md+├── CONTRIBUTING.md+├── LICENSE+├── project-name.cabal+├── README.md+├── Setup.hs+├── stack.yaml+├── stack-8.6.5.yaml+├── appveyor.yml+├── .git+├── .gitignore+├── .stylish-haskell.yaml+└── .travis.yml+```+ ## Get started [↑](#structure)  ### Prerequisites [↑](#structure)@@ -172,6 +185,13 @@ * [`hub`](https://github.com/github/hub) – to upload the project to GitHub. * [`curl`](https://curl.haxx.se) – to download licenses. +We also have minimal version requirements for build tools:++* [Cabal >= 2.0](https://www.haskell.org/cabal/)+* [Stack >= 2.1](http://haskellstack.org)++However, it is always recommended to use the newest versions of build tools.+ ### Installation [↑](#structure)  Summon contains two executables:@@ -196,6 +216,21 @@ mv summon-cli-linux ~/.local/bin/summon ``` +##### TUI: from Hackage/Stackage [↑](#structure)++Using `cabal`:++```shell+cabal new-update+cabal new-install summoner-tui+```++Using `stack`:++```shell+stack install summoner-tui+```+ ##### TUI: from source [↑](#structure)  Fetch the repo using `cabal`:@@ -323,7 +358,7 @@ | `fullName`       | Text    | Full name.                                                                                                                                                           | | `email`          | Text    | E-mail address.                                                                                                                                                      | | `license`        | License | One of: `MIT`, `BSD2`, `BSD3`, `GPL-2`, `GPL-3`, `LGPL-2.1`, `LGPL-3`, `AGPL-3`, `Apache-2.0`, `MPL-2.0`, `None`.                                                    |-| `ghcVersions`    | [GHC]   | `summoner` uses default `GHC-8.6.4`. However, additionally you can specify other versions. For each version `x.y.z` the `stack-x.y.z.yaml` will be created.          |+| `ghcVersions`    | [GHC]   | `summoner` uses default `GHC-8.8.1`. However, additionally you can specify other versions. For each version `x.y.z` the `stack-x.y.z.yaml` will be created.          | | `github`         | Bool    | Turn on `GitHub` integration by default?                                                                                                                             | | `gitignore`      | [Text]  | List of files you want added to the default `.gitignore`. (Ignored if `github = false`)                                                                              | | `noUpload`       | Bool    | Do not upload to GitHub, but create all GitHub related files if specified (Ignored if `github = false`)                                                              |@@ -336,8 +371,9 @@ | `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`.                                                                             | | `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. |+| `stylish.*`      | Text    | **DEPRECATED** `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    | **DEPRECATED** `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. |+| `files`          | Map FilePath Source  | Custom mapping of files to their sources. Represented as a list of inline tables in TOML in a format like `files = [ { path = "foo", url = "https://..." }, ... ]`. Supported file types: `url`, `local`, `raw`. | |`[prelude]`       |         |                                                                                                                                                                      | | `package`        | Text    | The package name of the custom prelude you'd like to use in the project (doesn't work without `module` field).                                                       | | `module`         | Text    | The module name of the custom prelude you'd like to use in the project (doesn't work without `package` field).                                                       |@@ -505,7 +541,7 @@ #!/usr/bin/env cabal {- cabal: build-depends:-  , base ^>= 4.12.0.0+  , base ^>= 4.13.0.0 -}  main :: IO ()@@ -517,7 +553,7 @@ ```haskell #!/usr/bin/env stack {- stack-  --resolver lts-13.16+  --resolver lts-14.18   script   --package base -}@@ -562,7 +598,7 @@ * Summoner is a multi-package project which has two packages inside: `summoner-cli` and `summoner-tui`. We are supporting the same functionality in both of them, so, if it's possible, you should add/change the code in both of the packages. * Summoner uses the custom prelude [`relude`](https://github.com/kowainik/relude). * We are using the [Kowainik style guide](https://github.com/kowainik/org/blob/master/style-guide.md#haskell-style-guide).-* To sum up, [here is the Contributing guide](https://github.com/kowainik/org/blob/master/CONTRIBUTING.md#contributing-to-the-kowainik-repositories) we use across the repositories.+* To sum up, [here is the Contributing guide](https://github.com/kowainik/.github/blob/master/CONTRIBUTING.md#contributing-to-the-kowainik-repositories) we use across the repositories. * This project is contributor-friendly, so be kind to other people working on the project.  ### Dependencies [↑](#structure)@@ -583,8 +619,15 @@ stack build ``` -for Stack.+for Stack and +```shell=+nix-build -A summoner     # To build the CLI only+nix-build -A summoner-tui # To build the TUI+```++for Nix.+ ### Test [↑](#structure)  Summoner uses the golden tests technique for assuring the correctness of the generated files. For this purpose, we have [the `golden` folder](https://github.com/kowainik/summoner/tree/master/summoner-cli/test/golden) with two sample projects to test against.@@ -595,12 +638,18 @@ cabal new-test all ``` -or+or, if using Stack,  ```shell stack test ``` +or, if using Nix,++```shell+nix-shell --run 'cabal new-test all'+```+ ### Run [↑](#structure)  Building Summoner with the recommended method creates two executables: `summon` and `summon-tui`. To run the compiled executable you can use the following commands:@@ -610,19 +659,19 @@ cabal new-exec summon-tui -- SOME_COMMAND ``` -or+or, if using Stack,  ```shell stack exec summon -- SOME_COMMAND stack exec summon-tui -- SOME_COMMAND ``` -## Changelog [↑](#structure)--Each package has its own changelog:+or, if using Nix, -* [Summoner changelog](https://github.com/kowainik/summoner/blob/master/summoner-cli/CHANGELOG.md#changelog).-* [Summoner-TUI changelog](https://github.com/kowainik/summoner/blob/master/summoner-tui/CHANGELOG.md#changelog).+```shell+nix-shell --run 'cabal new-run summon -- SOME_COMMAND'+nix-shell --run 'cabal new-run summon-tui -- SOME_COMMAND'+```  ## Acknowledgments [↑](#structure) 
app/Tui.hs view
@@ -1,8 +1,9 @@ module Main where -import System.IO (hSetEncoding, stdout, utf8)+import System.IO (hSetEncoding, utf8)  import Summoner.Tui (summonTui)+  main :: IO () main = hSetEncoding stdout utf8 >> summonTui
− src/Prelude.hs
@@ -1,10 +0,0 @@--- | Uses [relude](https://hackage.haskell.org/package/relude) as default Prelude.--module Prelude-       ( module Relude-       , module Relude.Extra-       ) where--import Relude-import Relude.Extra.Enum as Relude.Extra (universe)-import Relude.Extra.Validation as Relude.Extra
src/Summoner/Tui.hs view
@@ -1,9 +1,12 @@ {-# LANGUAGE Rank2Types   #-} {-# LANGUAGE ViewPatterns #-} -{- | This is experimental module.+{- |+Copyright: (c) 2018-2019 Kowainik+SPDX-License-Identifier: MPL-2.0+Maintainer: Kowainik <xrom.xkov@gmail.com> -We are trying to make the TUI app for summoner, but it's WIP.+TUI for the Summoner tool. See demo in the README.md file. -}  module Summoner.Tui@@ -25,20 +28,23 @@ import Brick.Widgets.Edit (editAttr, editFocusedAttr) import Brick.Widgets.List (listSelectedAttr, listSelectedFocusedAttr) import Lens.Micro ((.~), (^.))+import Relude.Extra.Enum (universe) import System.Directory (doesDirectoryExist, doesFileExist, getCurrentDirectory, listDirectory)  import Summoner.Ansi (errorMessage, infoMessage) import Summoner.CLI (Command (..), NewOpts (..), ShowOpts (..), getFinalConfig, runScript, summon)+import Summoner.Config (ConfigP (cFiles)) import Summoner.Decision (Decision (..)) import Summoner.Default (defaultConfigFile)-import Summoner.GhcVer (showGhcVer)+import Summoner.GhcVer (ghcTable) import Summoner.License (License (..), LicenseName, fetchLicense, parseLicenseName,                          showLicenseWithDesc)-import Summoner.Project (initializeProject)+import Summoner.Project (fetchSources, initializeProject) import Summoner.Tui.Field (disabledAttr) import Summoner.Tui.Form (KitForm, SummonForm (..), getCurrentFocus, isActive, mkForm, recreateForm) import Summoner.Tui.Kit-import Summoner.Tui.Validation (ctrlD, formErrorMessages, summonFormValidation)+import Summoner.Tui.Validation (ctrlD, formErrorMessages, handleAutofill, projectDescNewLine,+                                summonFormValidation) import Summoner.Tui.Widget (borderLabel, listInBorder)  import qualified Brick (on)@@ -68,11 +74,13 @@ summonTuiNew newOpts@NewOpts{..} = do     -- configure initial state for TUI application     finalConfig <- getFinalConfig newOpts+    files <- fetchSources newOptsOffline (cFiles finalConfig)     configFilePath <- findConfigFile     let initialKit = configToSummonKit             newOptsProjectName             newOptsOffline             configFilePath+            files             finalConfig      -- run TUI app@@ -110,6 +118,8 @@             _                              -> continue s         else case ev of             VtyEvent V.EvResize {} -> continue s+            VtyEvent (V.EvKey V.KEnter [V.MMeta]) ->+                withForm ev s (validateForm . projectDescNewLine)             VtyEvent (V.EvKey V.KEnter []) ->                 if allFieldsValid s                 then withForm ev s (changeShouldSummon Idk)@@ -122,6 +132,12 @@             VtyEvent (V.EvKey (V.KChar ' ') []) -> case getCurrentFocus s of                 Nothing    -> withFormDef ev s                 Just field -> handleCheckboxActivation ev s field++            -- Run handler for autofill actions+            VtyEvent (V.EvKey key [])+                | keyTriggersAutofill key+                -> withForm ev s (validateForm . handleAutofill)+             MouseDown n _ _ _ -> handleCheckboxActivation ev s n              -- Handle skip of deactivated checkboxes@@ -174,6 +190,12 @@                 then loopWhileInactive ev newForm                 else continue newForm +    -- Autofill is only triggered on characters and backspace keys.+    keyTriggersAutofill :: V.Key -> Bool+    keyTriggersAutofill (V.KChar _) = True+    keyTriggersAutofill V.KBS       = True+    keyTriggersAutofill _           = False+ -- | Draws the form for @new@ command. drawNew :: [FilePath] -> KitForm e -> [Widget SummonForm] drawNew dirs kitForm = case kit ^. shouldSummon of@@ -211,6 +233,7 @@             [ informationBlock             , validationBlock             , configBlock+            , deprecationBlock             , fill ' '             ]       where@@ -224,6 +247,9 @@         infoTxt :: Text -> Widget SummonForm         infoTxt = withAttr "blue-fg" . txtWrap . (<>) " ⓘ  " +        deprecationTxt :: Text -> Widget SummonForm+        deprecationTxt = withAttr "yellow-fg" . txtWrap . (<>) " ⚠  "+         validationBlock :: Widget SummonForm         validationBlock = vBox $ case formErrorMessages dirs kitForm of             []     -> [withAttr "green-fg" $ str " ✔  Project configuration is valid"]@@ -234,13 +260,21 @@             Nothing   -> emptyWidget             Just file -> infoTxt $ toText file <> " file is used" +        deprecationBlock :: Widget SummonForm+        deprecationBlock = case (kit ^. stylish, kit ^. contributing) of+            (Nothing, Nothing) -> emptyWidget+            (s, c) -> vBox $+                [ deprecationTxt "Option 'stylish' is deprecated, use 'files'" | isJust s ]+             ++ [ deprecationTxt "Option 'contributing' is deprecated, use 'files'" | isJust c]+     help, helpBody :: Widget SummonForm     help     = borderLabel "Help" (helpBody <+> fill ' ')     helpBody = vBox-        [ str "• Enter  : create the project"-        , str "• Esc    : quit"-        , str "• Ctrl+d : remove input of the text field"-        , str "• Arrows : up/down arrows to choose license"+        [ str "• Enter     : create the project"+        , str "• Esc       : quit"+        , str "• Ctrl+d    : remove input of the text field"+        , str "• Arrows    : up/down arrows to choose license"+        , str "• Alt+Enter : switch to new line"         ]  ----------------------------------------------------------------------------@@ -258,7 +292,7 @@ runTuiShowGhcVersions = runSimpleApp drawGhcVersions   where     drawGhcVersions :: Widget ()-    drawGhcVersions = listInBorder "Supported GHC versions" 30 0 (map showGhcVer universe)+    drawGhcVersions = listInBorder "Supported GHC versions" 60 0 ghcTable  runTuiShowAllLicenses :: IO () runTuiShowAllLicenses = runSimpleApp drawLicenseNames@@ -336,11 +370,12 @@     , (editFocusedAttr,         V.black `Brick.on` V.white)     , (invalidFormInputAttr,    V.white `Brick.on` V.red)     , (focusedFormInputAttr,    V.black `Brick.on` V.yellow)-    , (listSelectedAttr,        V.black  `Brick.on` V.cyan)+    , (listSelectedAttr,        V.black `Brick.on` V.cyan)     , (listSelectedFocusedAttr, V.black `Brick.on` V.white)     , (disabledAttr,            fg V.brightBlack)     , ("blue-fg",               fg V.blue)     , ("green-fg",              fg V.green)+    , ("yellow-fg",             fg V.yellow)     , ("red-fg",                fg V.brightRed)     , (borderAttr,              fg V.cyan)     , ("tree",                  fg V.cyan)
src/Summoner/Tui/Field.hs view
@@ -1,6 +1,11 @@ {-# LANGUAGE Rank2Types #-} -{- | This modules adds necessary functions for Forms and Form fields+{- |+Copyright: (c) 2018-2019 Kowainik+SPDX-License-Identifier: MPL-2.0+Maintainer: Kowainik <xrom.xkov@gmail.com>++This modules adds necessary functions for Forms and Form fields that are not covered in @brick@ library. -} 
src/Summoner/Tui/Form.hs view
@@ -1,5 +1,11 @@--- | Form layout and form fields data types.+{- |+Copyright: (c) 2018-2019 Kowainik+SPDX-License-Identifier: MPL-2.0+Maintainer: Kowainik <xrom.xkov@gmail.com> +Form layout and form fields data types.+-}+ module Summoner.Tui.Form        ( SummonForm (..)        , KitForm@@ -14,6 +20,7 @@ import Brick.Forms (Form, editField, editTextField, formFocus, formState, listField, newForm,                     setFieldConcat, setFormConcat, setFormFocus, (@@=)) import Lens.Micro ((^.))+import Relude.Extra.Enum (universe)  import Summoner.Default (defaultGHC) import Summoner.GhcVer (parseGhcVer, showGhcVer)@@ -61,7 +68,7 @@     | GitHubPrivate     | GitHubTravis     | GitHubAppVeyor-    deriving (Show, Eq, Ord, Enum, Bounded)+    deriving stock (Show, Eq, Ord, Enum, Bounded)  -- | Alias for type of the @summoner@ form. type KitForm e = Form SummonKit e SummonForm
src/Summoner/Tui/GroupBorder.hs view
@@ -1,10 +1,13 @@ {- |+Copyright: (c) 2018-2019 Kowainik+SPDX-License-Identifier: MPL-2.0+Maintainer: Kowainik <xrom.xkov@gmail.com>+ @Brick@ library helper functions to group checkbox elements inside the form. This is not going to be the part of the library itself, so we will have it in our own libraries. See relevant discussion under the corresponding issue:  * https://github.com/jtdaugherty/brick/issues/190- -}  module Summoner.Tui.GroupBorder@@ -30,7 +33,9 @@ This function unites any amount of the form elements under the one group in bourders with the given group name. Intended to be used for joining check-boxes together, but any other elemens of the form will work the same way.+ __Example:__+ @ ┌─────────────────Form───────────────────┐ │                                        │@@ -40,6 +45,7 @@ │└──────────────────────────────────────┘│ └────────────────────────────────────────┘ @+ **Note:** on an empty list it doesn't create any group or border. -} groupBorder :: String -> [(Int, s -> FormFieldState s e n)] -> [s -> FormFieldState s e n]
src/Summoner/Tui/Kit.hs view
@@ -3,9 +3,13 @@ {-# LANGUAGE Rank2Types             #-} {-# LANGUAGE TemplateHaskell        #-} -{- | This module contains data types to work with application form.-'SummonKit' is the data type containing the values manipulated by the fields-in the form.+{- |+Copyright: (c) 2018-2019 Kowainik+SPDX-License-Identifier: MPL-2.0+Maintainer: Kowainik <xrom.xkov@gmail.com>++This module contains data types to work with application form. 'SummonKit' is+the data type containing the values manipulated by the fields in the form. -}  module Summoner.Tui.Kit@@ -68,14 +72,15 @@ import Lens.Micro.TH (makeFields)  import Summoner.Config (Config, ConfigP (..))+import Summoner.CustomPrelude (CustomPrelude (..)) import Summoner.Decision (Decision (..)) import Summoner.Default (currentYear, defaultDescription, defaultGHC) import Summoner.GhcVer (GhcVer) import Summoner.License (LicenseName (..), customizeLicense, fetchLicense)-import Summoner.Settings (CustomPrelude (..), Settings (..))+import Summoner.Settings (Settings (..)) import Summoner.Source (Source, fetchSource) import Summoner.Template (createProjectTemplate)-import Summoner.Tree (showTree)+import Summoner.Tree (TreeFs, showTree)  import qualified Data.List as List (delete) import qualified Data.Text as T@@ -97,14 +102,15 @@     , summonKitOffline      :: !Bool     , summonKitShouldSummon :: !Decision  -- ^ Check if project needs to be created.     , summonKitConfigFile   :: !(Maybe FilePath)  -- ^ Just if configuration file was used.-    } deriving (Show)+    , summonKitExtraFiles   :: ![TreeFs]  -- ^ Extra files+    } deriving stock (Show)  -- | User information. data User = User     { userOwner    :: !Text  -- ^ GitHub user or organization name.     , userFullName :: !Text     , userEmail    :: !Text-    } deriving (Show)+    } deriving stock (Show)  -- | Project related information data Project = Project@@ -112,7 +118,7 @@     , projectDesc     :: !Text  -- ^ Short project description.     , projectCategory :: !Text  -- ^ Comma-separated. See @Hackage@ for existing category list.     , projectLicense  :: !LicenseName-    } deriving (Show)+    } deriving stock (Show)  -- | Project meta information. data ProjectMeta = ProjectMeta@@ -123,7 +129,7 @@     , projectMetaGhcs          :: ![GhcVer]  -- ^ Default GHC version is always added.     , projectMetaPreludeName   :: !Text     , projectMetaPreludeModule :: !Text-    } deriving (Show)+    } deriving stock (Show)  -- | Github specific information. data GitHub = GitHub@@ -132,7 +138,7 @@     , gitHubPrivate  :: !Bool     , gitHubTravis   :: !Bool     , gitHubAppVeyor :: !Bool-    } deriving (Show)+    } deriving stock (Show)  makeFields ''SummonKit makeFields ''User@@ -157,7 +163,7 @@ summonKitToSettings sk = Settings     { settingsRepo           = T.strip $ sk ^. project . repo     , settingsOwner          = T.strip $ sk ^. user . owner-    , settingsDescription    = T.strip $ sk ^. project . desc+    , settingsDescription    = T.strip . unwords . lines $ sk ^. project . desc     , settingsFullName       = T.strip $ sk ^. user . fullName     , settingsEmail          = T.strip $ sk ^. user . email     , settingsYear           = "20!8"@@ -183,6 +189,7 @@     , settingsStylish        = "" <$ sk ^. stylish     , settingsContributing   = "" <$ sk ^. contributing     , settingsNoUpload       = sk ^. gitHub . noUpload+    , settingsFiles          = sk ^. extraFiles     }   where     isGitHub :: Bool@@ -225,9 +232,10 @@     :: Text  -- ^ Given project name     -> Bool    -- ^  @offline@ mode option     -> Maybe FilePath  -- ^ Configuration file used+    -> [TreeFs]  -- ^ Extra files     -> Config  -- ^ Given configurations.     -> SummonKit-configToSummonKit cRepo cOffline cConfigFile Config{..} = SummonKit+configToSummonKit cRepo cOffline cConfigFile files Config{..} = SummonKit     { summonKitUser  = User         { userOwner    = cOwner         , userFullName = cFullName@@ -258,13 +266,14 @@         , gitHubAppVeyor = toBool cAppVey && kitStack         }     , summonKitExtensions   = cExtensions-    , summonKitGhcOptions   = cWarnings ++ cGhcOptions+    , summonKitGhcOptions   = cGhcOptions     , summonKitGitignore    = cGitignore     , summonKitStylish      = getLast cStylish     , summonKitContributing = getLast cContributing     , summonKitOffline      = cOffline     , summonKitShouldSummon = Nop     , summonKitConfigFile   = cConfigFile+    , summonKitExtraFiles   = files     }   where     kitCabal, kitStack, kitLib, kitExe :: Bool
src/Summoner/Tui/Validation.hs view
@@ -1,16 +1,27 @@ {-# LANGUAGE Rank2Types #-} --- | This module contains function to validate Form fields.+{- |+Copyright: (c) 2018-2019 Kowainik+SPDX-License-Identifier: MPL-2.0+Maintainer: Kowainik <xrom.xkov@gmail.com> +This module contains function to validate Form fields.+-}+ module Summoner.Tui.Validation        ( ctrlD        , summonFormValidation        , formErrorMessages+       , handleAutofill+       , projectDescNewLine        ) where  import Brick.Forms (formState, invalidFields, setFieldValid, setFormFocus)-import Lens.Micro (Lens', (.~), (^.))+import Lens.Micro (Lens', (%~), (.~), (^.))+import Relude.Extra.Enum (universe)+import Relude.Extra.Validation (Validation (..)) +import Summoner.Text (moduleNameValid, packageNameValid, packageToModule) import Summoner.Tui.Form (KitForm, SummonForm (..), getCurrentFocus, mkForm) import Summoner.Tui.Kit @@ -36,6 +47,22 @@         then setFormFocus formField $ mkForm $ formState f & fieldLens .~ nil         else f +handleAutofill :: KitForm e -> KitForm e+handleAutofill f = case getCurrentFocus f of+    Just CustomPreludeName ->+        let curPreludeName = formState f ^. projectMeta . preludeName+            newState = formState f+                & projectMeta . preludeModule .~ packageToModule curPreludeName+        in setFormFocus CustomPreludeName $ mkForm newState+    _ -> f++-- | Adds a newline for project description.+projectDescNewLine :: KitForm e -> KitForm e+projectDescNewLine f =+    if getCurrentFocus f == Just ProjectDesc+    then setFormFocus ProjectDesc $ mkForm $ formState f & project . desc %~ (<> "\n\n")+    else f+ -- | Validates the main @new@ command form. summonFormValidation :: forall e . [FilePath] -> KitForm e -> KitForm e summonFormValidation dirs kitForm = foldr setValidation kitForm universe@@ -64,6 +91,11 @@     | CabalOrStack     -- | At least library or executable should be selected.     | LibOrExe+    -- | Prelude package name should only contain letters, numbers+    -- and hyphens.+    | PreludePackageError+    -- | Prelude module name restrictions check. See 'moduleNameValid'.+    | PreludeModuleError  -- | Show 'FormError' to display later in TUI. showFormError :: FormError -> String@@ -73,6 +105,8 @@     LibOrExe     -> "Choose at least one: Library or Executable"     EmptyFields fields -> "These fields must not be empty: " ++ joinFields fields     OneWord fields -> "These fields should contain exactly one word: " ++ joinFields fields+    PreludePackageError -> "Prelude package should only contain letters, numbers and hyphens"+    PreludeModuleError -> "Prelude module name could only contain dot-separated capitalized letter/numeral fragments. Ex: This.Is.Valid1"   where     joinFields :: NonEmpty SummonForm -> String     joinFields = intercalate ", " . mapMaybe showField . toList@@ -92,11 +126,13 @@ -- | Returns list of all invalid fields according to the error. errorToInvalidFields :: FormError -> NonEmpty SummonForm errorToInvalidFields = \case-    EmptyFields fields -> fields-    OneWord fields     -> fields-    ProjectExist       -> one ProjectName-    CabalOrStack       -> CabalField :| [StackField]-    LibOrExe           -> Lib :| [Exe]+    EmptyFields fields  -> fields+    OneWord fields      -> fields+    ProjectExist        -> one ProjectName+    CabalOrStack        -> CabalField :| [StackField]+    LibOrExe            -> Lib :| [Exe]+    PreludePackageError -> one CustomPreludeName+    PreludeModuleError  -> one CustomPreludeModule  -- | Takes boolean value and error and returns error if predicate 'True'. toError :: Bool -> e -> Validation (NonEmpty e) ()@@ -110,6 +146,8 @@     *> validateProjectExist     *> validateBuildTools     *> validateLibOrExe+    *> validatePreludePackage+    *> validatePreludeModule   where     liftValidation         :: (e -> FormError)@@ -168,6 +206,22 @@     validateLibOrExe = toError         (not $ kit ^. projectMeta . lib  || kit ^. projectMeta . exe)         LibOrExe++    validatePreludePackage :: Validation (NonEmpty FormError) ()+    validatePreludePackage = toError+        (not $ T.null packageName || packageNameValid packageName)+        PreludePackageError+      where+        packageName :: Text+        packageName = kit ^. projectMeta . preludeName++    validatePreludeModule :: Validation (NonEmpty FormError) ()+    validatePreludeModule = toError+        (not $ T.null moduleName || moduleNameValid moduleName)+        PreludeModuleError+      where+        moduleName :: Text+        moduleName  = kit ^. projectMeta . preludeModule  -- | Returns list of error messages according to all invalid fields. formErrorMessages :: [FilePath] -> KitForm e -> [String]
src/Summoner/Tui/Widget.hs view
@@ -1,4 +1,9 @@-{- | This module contains useful helpers to work with 'Widget's+{- |+Copyright: (c) 2018-2019 Kowainik+SPDX-License-Identifier: MPL-2.0+Maintainer: Kowainik <xrom.xkov@gmail.com>++This module contains useful helpers to work with 'Widget's -}  module Summoner.Tui.Widget
summoner-tui.cabal view
@@ -1,6 +1,6 @@-cabal-version:       2.0+cabal-version:       2.4 name:                summoner-tui-version:             0.1.0+version:             1.4.0.0 synopsis:            Tool for scaffolding fully configured batteries-included production-level Haskell projects using TUI. description:         Tool for scaffolding fully configured batteries-included production-level Haskell projects using TUI.                      See [README.md](https://github.com/kowainik/summoner#-summoner) for details.@@ -8,9 +8,9 @@ bug-reports:         https://github.com/kowainik/summoner/issues license:             MPL-2.0 license-file:        LICENSE-author:              Kowainik-maintainer:          xrom.xkov@gmail.com-copyright:           2018-2019 Kowainik+author:              Veronika Romashkina, Dmitrii Kovanikov+maintainer:          Kowainik <xrom.xkov@gmail.com>+copyright:           2018-2020 Kowainik category:            TUI, TUI Tool, Development build-type:          Simple stability:           experimental@@ -18,38 +18,22 @@                    , CHANGELOG.md tested-with:         GHC == 8.2.2                    , GHC == 8.4.4-                   , GHC == 8.6.4+                   , GHC == 8.6.5+                   , GHC == 8.8.1  source-repository head   type:     git   location: git@github.com:kowainik/summoner.git -library-  if os(windows)-    buildable: False-  hs-source-dirs:      src-  exposed-modules:     Summoner.Tui-                         Summoner.Tui.Field-                         Summoner.Tui.Form-                         Summoner.Tui.GroupBorder-                         Summoner.Tui.Kit-                         Summoner.Tui.Validation-                         Summoner.Tui.Widget--  autogen-modules:     Paths_summoner_tui-  other-modules:       Paths_summoner_tui-                       Prelude+common common-options+  build-depends:       base >= 4.10 && < 4.14+                     , relude ^>= 0.6.0.0 -  build-depends:       base-noprelude >= 4.10 && < 4.13-                     , brick ^>= 0.47-                     , directory ^>= 1.3.0.2-                     , filepath ^>= 1.4.1.2-                     , microlens ^>= 0.4-                     , microlens-th ^>= 0.4-                     , relude ^>= 0.5.0-                     , summoner ^>= 1.3.0-                     , text ^>= 1.2.3.0-                     , vty ^>= 5.25+  mixins:              base hiding (Prelude)+                     , relude (Relude as Prelude+                              , Relude.Extra.Enum+                              , Relude.Extra.Validation+                              )    ghc-options:         -Wall                        -Wincomplete-uni-patterns@@ -58,8 +42,12 @@                        -Widentities                        -Wredundant-constraints                        -fhide-source-paths+  if impl(ghc >= 8.8.1)+    ghc-options:       -Wmissing-deriving-strategies+                       -Werror=missing-deriving-strategies    default-extensions:  DeriveGeneric+                       DerivingStrategies                        GeneralizedNewtypeDeriving                        InstanceSigs                        LambdaCase@@ -70,23 +58,39 @@    default-language:    Haskell2010 +library+  import:              common-options+  if os(windows)+    buildable: False+  hs-source-dirs:      src+  exposed-modules:     Summoner.Tui+                         Summoner.Tui.Field+                         Summoner.Tui.Form+                         Summoner.Tui.GroupBorder+                         Summoner.Tui.Kit+                         Summoner.Tui.Validation+                         Summoner.Tui.Widget++  autogen-modules:     Paths_summoner_tui+  other-modules:       Paths_summoner_tui++  build-depends:       brick >= 0.47 && < 0.51+                     , directory ^>= 1.3.0.2+                     , filepath ^>= 1.4.1.2+                     , microlens ^>= 0.4+                     , microlens-th ^>= 0.4+                     , summoner ^>= 1.4.0+                     , text ^>= 1.2.3.0+                     , vty >= 5.25 && < 5.27+ executable summon-tui+  import:              common-options   if os(windows)     buildable: False   hs-source-dirs:      app   main-is:             Tui.hs-  build-depends:       base >= 4.10 && < 4.13-                     , summoner-tui+  build-depends:       summoner-tui -  ghc-options:         -Wall-                       -threaded+  ghc-options:         -threaded                        -rtsopts                        -with-rtsopts=-N-                       -Wincomplete-uni-patterns-                       -Wincomplete-record-updates-                       -Wcompat-                       -Widentities-                       -Wredundant-constraints-                       -fhide-source-paths--  default-language:    Haskell2010