Skip to content

Commit

Permalink
[#27] Remove b-script support
Browse files Browse the repository at this point in the history
Improve README
Improve benchmarks cabal section
Remove 'module Main where' in benchmarks
  • Loading branch information
vrom911 committed Aug 30, 2018
1 parent c5d7ebe commit acf8137
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 220 deletions.
136 changes: 61 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
>
> Christopher Reeve
Summoner is the tool for creating completely configured production Haskell projects.
Summoner is the tool for creating fully configured production Haskell projects.

## Demo

Expand All @@ -22,15 +22,16 @@ Summoner is the tool for creating completely configured production Haskell proje

### Prerequisites

To start using it make sure you have next tools installed on your machine:
To start using it make sure you have the next tools installed on your machine:

* [`Stack`](http://haskellstack.org) or [`cabal`](https://www.haskell.org/cabal/)
* [`git`](https://git-scm.com)
* [`hub`](https://github.com/github/hub)
* [`curl`](https://curl.haxx.se)

### Installation

Installation process can be done with one simple command:
The installation process can be done with the one simple command:

$ cabal new-install summoner

Expand All @@ -44,21 +45,24 @@ You can turn on the bash auto-completion by running the following command:
$ source <(summon --bash-completion-script `which summon`)
```

After that you can call `summon new` with required command line options, follow
the instructions that will appear, and a new project would be created in a subfolder
as well as a repository under your github account (if requested).
After that, you can call `summon` with the required command. To create a
project, use `summon new` command specifying the prefered CLI options, follow
the instructions during the interactive process of the project creation, and a
new project would be created in a subfolder as well as a repository under your
GitHub account (if requested).

### Usage

There are several options how to set particular configurations:
There are several options how to set particular configurations for the new projects:

1. Default configuration file (`~/.summoner.toml`).
2. Explicitly specified configuration file by `--file FILENAME` option (used instead of default one if specified).
2. Explicitly specified configuration file by `--file FILENAME` option (used
instead of the default one if specified).
3. Options that are stated by CLI arguments.
4. Interactively inputed answers during work of the `summon` command
(for the options that were not specified on previous steps).

So the configuration uses [`Partial Options Monoid Pattern`](https://medium.com/@jonathangfischoff/the-partial-options-monoid-pattern-31914a71fc67).
So, the configuration uses [`Partial Options Monoid Pattern`](https://medium.com/@jonathangfischoff/the-partial-options-monoid-pattern-31914a71fc67).

If none of the mentioned above cases used then the configuration will be built interactively.

Expand Down Expand Up @@ -92,15 +96,14 @@ Here is the list of the options that could be configured for your needs:
* `private``true` if you want to create private repositories by default,
`false` if you don't. Ignored if `github = false`.
If not specified it would be asked during each run of the `summoner`.
* `bscript``true` if you want to include [build script](#build-script) by default,
`false` if you don't. If not specified it would be asked during each run of the `summoner`.
* `lib``true` if you want to create `src` folder with dummy `Lib.hs` file and library target by default,
`false` if you don't. If not specified it would be asked during each run of the `summoner`.
* `exe``true` if you want to create `app` folder with dummy `Main.hs` file and executable target by default,
`false` if you don't. If not specified it would be asked during each run of the `summoner`.
* `test``true` if you want to create `test` folder with dummy `Spec.hs` file and test target by default,
`false` if you don't. If not specified it would be asked during each run of the `summoner`.
* `bench``true` if you want to create `benchmark` folder with `Main.hs` file with [`gauge`](https://hackage.haskell.org/package/gauge) library usage example by default,
* `bench``true` if you want to create `benchmark` folder with `Main.hs` file with [`gauge`](https://hackage.haskell.org/package/gauge)
library usage example by default,
`false` if you don't. If not specified it would be asked during each run of the `summoner`.
* `extensions` – List of the default extensions to add into `default-extensions` section in the `.cabal`.
* `warnings` – List of the default checks and warnings to add into `ghc-options` section in the `.cabal`.
Expand All @@ -122,31 +125,42 @@ Should be specified inside `[prelude]` table.

###### Examples

See example of [configuration for projects of `Kowainik` organization](https://github.com/kowainik/org/blob/master/.summoner.toml).
See an example of [the configuration for projects of the `Kowainik` organization](https://github.com/kowainik/org/blob/master/.summoner.toml).

By default the `summoner` will look for the configuration file (`.summoner.toml`) in home directory.
By default, the `summoner` looks for the configuration file (`.summoner.toml`) in home directory.

The other way to specify some particular `.toml` file is `summon new PROJECTNAME --file FILEPATH` command.

##### CLI

Available commands:

```
Usage:
summon COMMAND
Set up your own Haskell project
Available commands:
new Create a new Haskell project
show Show available licenses or ghc versions
---------------
----- new -----
---------------
summon new PROJECT_NAME [--cabal] [--stack] [--ignore-config]
[with [OPTIONS]] [without [OPTIONS]]
[-f|--file FILENAME] [--prelude-package PACKAGE_NAME]
[--prelude-module MODULE_NAME]
Available global options:
-h, --help Show this help text
-v, --version Show summoner's version
```

**`summon new`** command:

```
Usage:
summon new PROJECT_NAME [--cabal] [--stack] [--ignore-config]
[with [OPTIONS]] [without [OPTIONS]]
[-f|--file FILENAME]
[--prelude-package PACKAGE_NAME]
[--prelude-module MODULE_NAME]
Available options:
-h, --help Show this help text
--ignore-config Ignore configuration file
--cabal Cabal support for the project
--stack Stack support for the project
Expand All @@ -169,40 +183,40 @@ Available command options:
-p, --private Create private GitHub repository
-c, --travis Travis CI integration
-w, --app-veyor AppVeyor CI integration
-s, --script Build script
-l, --library Library target
-e, --exec Executable target
-t, --test Tests
-b, --benchmark Benchmarks
```

----------------
----- show -----
----------------
**`summon show`** command:

summon show COMMAND [LICENSE_NAME]
Show command. (Support licenses, license and ghcs)
```
Usage:
summon show COMMAND
Show supported licenses or ghc versions
Available commands:
ghc Show available ghc versions
license Show available licenses
license [LICENSE_NAME] Show specific license text
Available global options:
Available options:
-h, --help Show this help text
```

The options to be enabled/disabled can be specified while running the command.
If any of applicable command options wasn't tagged as enabled/disabled then
the question will be asked during the work of the script.
If any of the applicable command options wasn't tagged as enabled/disabled, then
the question is asked during the work of the tool.

For example,

```
summon new my-project with -letgcspw without -b --prelude-package relude --prelude-module Relude
summon new my-project with -letgcpw without -b --prelude-package relude --prelude-module Relude
```
will create fully functional project which uses custom prelude `relude`, contains
library, executable file, tests, [build script](#build-script)
and create private repository on [github](https://github.com)

creates the fully functional project which uses custom prelude `relude`, contains
library, executable file, tests and create private repository on [github](https://github.com)
integrated with `Travis-CI`, `AppVeyor-CI`, but benchmarks won't be attached to this one.

But when calling this command
Expand All @@ -211,21 +225,13 @@ But when calling this command
summon new my-project
```

the tool will ask about every particular option, rather you'd like to have it
the tool asks about every particular option, rather you'd like to have it
or not in your project.

### Note

This tool was tested with next settings:

stack version 1.6.1
git version 2.11.0
hub version 2.2.9

## Features

If you're running the `summoner` with all options enabled a project with the following
hierarchy will be created:
hierarchy is created:

```
project-name
Expand All @@ -249,20 +255,21 @@ project-name
├── .gitignore
└── .travis.yml
```
and also repository with one commit at master will be added with enabled `Travis-CI` for that.

Moreover, a repository with one commit at master is added with enabled Travis CI for that.

## GHC options

The following warning checks are added by default to every stanza:
The `-Wall` option is added to every stanza.

The following warning checks are added by default to executable, tests and benchmark stanzas:

-Wall
-threaded
-rtsopts
-with-rtsopts=-N

If `--file` option is not used, then

the following ghc-options are added to executable, test-suite and benchmark stanza.
If warnings are not explicitly stated in the configuration file, then the
following ghc-options are added to all stanzas.

-Wincomplete-uni-patterns
-Wincomplete-record-updates
Expand All @@ -273,35 +280,14 @@ the following ghc-options are added to executable, test-suite and benchmark stan
-Wmissing-export-lists (ghc >= 8.4.1)
-Wpartial-fields (ghc >= 8.4.1)

and the following ghc-options are added to benchmark stanza.

-02

### Build script

The `b` script builds the project in a way that is convenient for developers.
It passes the right flags into right places, builds the project with --fast,
tidies up and highlights error messages in GHC output.

#### Usage

```
./b build whole project with all targets
./b -c do stack clean
./b -t build and run tests
./b -b build and run benchmarks
./b --nix use nix to build package
```

## Change log

[List of changes](https://github.com/kowainik/summoner/blob/master/CHANGELOG.md).
[List of changes](CHANGELOG.md).

## Acknowledgments

This project was inspired by [Aelve/new-hs](https://github.com/aelve/new-hs#readme),
which is the tool with the same goal but it's using
[`cabal`](https://www.haskell.org/cabal/) for creating projects.
which is the tool with the same goal but it's only for creating cabal projects.

Icons made by [Nikita Golubev](https://www.flaticon.com/authors/nikita-golubev)
from [Flaticon](https://www.flaticon.com/) is licensed by
Expand Down
14 changes: 5 additions & 9 deletions src/Summoner/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ summonerP = subparser
<> command "show" (info (helper <*> showP) $ progDesc "Show supported licenses or ghc versions")

----------------------------------------------------------------------------
-- New command parsers
-- Show command parsers
----------------------------------------------------------------------------

-- | Parses options of the @show@ command.
Expand All @@ -178,6 +178,10 @@ licenseText :: Parser ShowOpts
licenseText = LicenseList <$> optional
(strArgument (metavar "LICENSE_NAME" <> help "Show specific license text"))

----------------------------------------------------------------------------
-- New command parsers
----------------------------------------------------------------------------

-- | Parses options of the @new@ command.
newP :: Parser Command
newP = do
Expand All @@ -204,7 +208,6 @@ targetsP d = do
cTravis <- travisP d
cAppVey <- appVeyorP d
cPrivate <- privateP d
cScript <- scriptP d
cLib <- libraryP d
cExe <- execP d
cTest <- testP d
Expand All @@ -214,7 +217,6 @@ targetsP d = do
, cTravis = cTravis
, cAppVey = cAppVey
, cPrivate= cPrivate
, cScript = cScript
, cLib = cLib
, cExe = cExe
, cTest = cTest
Expand Down Expand Up @@ -245,12 +247,6 @@ privateP d = flag Idk d
<> short 'p'
<> help "Private repository"

scriptP :: Decision -> Parser Decision
scriptP d = flag Idk d
$ long "script"
<> short 's'
<> help "Build script for convenience"

libraryP :: Decision -> Parser Decision
libraryP d = flag Idk d
$ long "library"
Expand Down
4 changes: 0 additions & 4 deletions src/Summoner/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ data ConfigP (p :: Phase) = Config
, cTravis :: Decision
, cAppVey :: Decision
, cPrivate :: Decision
, cScript :: Decision
, cLib :: Decision
, cExe :: Decision
, cTest :: Decision
Expand Down Expand Up @@ -122,7 +121,6 @@ defaultConfig = Config
, cTravis = Idk
, cAppVey = Idk
, cPrivate = Idk
, cScript = Idk
, cLib = Idk
, cExe = Idk
, cTest = Idk
Expand All @@ -148,7 +146,6 @@ configT = Config
<*> decision "travis" .= cTravis
<*> decision "appveyor" .= cAppVey
<*> decision "private" .= cPrivate
<*> decision "bscript" .= cScript
<*> decision "lib" .= cLib
<*> decision "exe" .= cExe
<*> decision "test" .= cTest
Expand Down Expand Up @@ -223,7 +220,6 @@ finalise Config{..} = Config
<*> pure cTravis
<*> pure cAppVey
<*> pure cPrivate
<*> pure cScript
<*> pure cLib
<*> pure cExe
<*> pure cTest
Expand Down
7 changes: 0 additions & 7 deletions src/Summoner/Project.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Relude.Extra.Enum (universe)

import NeatInterpolation (text)
import System.Directory (setCurrentDirectory)
import System.Info (os)

import Summoner.Ansi (errorMessage, infoMessage, successMessage)
import Summoner.Config (Config, ConfigP (..))
Expand Down Expand Up @@ -53,7 +52,6 @@ generateProject projectName Config{..} = do
travis <- ifGithub github "Travis CI integration" cTravis
appVey <- ifGithub (stack && github) "AppVeyor CI integration" cAppVey
privat <- ifGithub github "private repository" cPrivate
script <- decisionToBool cScript "build script"
isLib <- decisionToBool cLib "library target"
isExe <- let target = "executable target" in
if isLib
Expand Down Expand Up @@ -93,8 +91,6 @@ generateProject projectName Config{..} = do

-- create stack project
createProjectDirectory projectData
-- make b executable
when script doScriptCommand
-- create github repository and commit
when github $ doGithubCommands projectData privat

Expand All @@ -112,9 +108,6 @@ generateProject projectName Config{..} = do
putTextLn $ showTree tree
setCurrentDirectory (toString repo)

doScriptCommand :: IO ()
doScriptCommand = when (os /= "mingw32") ("chmod" ["+x", "b"])

doGithubCommands :: ProjectData -> Bool -> IO ()
doGithubCommands ProjectData{..} private = do
-- Create the repository on Github.
Expand Down
1 change: 0 additions & 1 deletion src/Summoner/ProjectData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ data ProjectData = ProjectData
, github :: Bool -- ^ github repository
, travis :: Bool -- ^ Travis CI integration
, appVey :: Bool -- ^ AppVeyor CI integration
, script :: Bool -- ^ build script
, isLib :: Bool -- ^ is library
, isExe :: Bool -- ^ is executable
, test :: Bool -- ^ add tests
Expand Down
Loading

0 comments on commit acf8137

Please sign in to comment.