hinit 0.2.0 → 0.2.1
raw patch · 8 files changed
+77/−27 lines, 8 filesdep +optics-coredep −generic-lensdep −lens
Dependencies added: optics-core
Dependencies removed: generic-lens, lens
Files
- CHANGELOG.md +6/−0
- data/templates/haskell/flake.nix +31/−0
- data/templates/haskell/template.toml +5/−0
- data/templates/haskell/{{ project }}.cabal +25/−14
- hinit.cabal +4/−4
- src/Hinit/License.hs +4/−6
- src/Hinit/Process.hs +0/−1
- src/Hinit/Template/Config.hs +2/−2
CHANGELOG.md view
@@ -1,5 +1,11 @@ # hinit +## 0.2.1++* Switch to optics-core+* Various changes to the bundled haskell template+* Use the `unsafeRender` function provided by spdx-license+ ## 0.2.0 (2020-12-24) * Add nix flake to the bundled haskell template
+ data/templates/haskell/flake.nix view
@@ -0,0 +1,31 @@+{+ inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;+ inputs.flake-utils.url = github:poscat0x04/flake-utils;++ outputs = { self, nixpkgs, flake-utils, ... }: with flake-utils;+ eachDefaultSystem (+ system:+ let+ pkgs = import nixpkgs { inherit system; overlays = [ self.overlay ]; };+ in+ with pkgs;+ {+ devShell = {{ project }}-dev.envFunc { withHoogle = true; };+ defaultPackage = {{ project }};+ }+ ) // {+ overlay = self: super:+ let+ hpkgs = super.haskellPackages;+ {{ project }} = hpkgs.callCabal2nix "{{ project }}" ./. {};+ in+ with super; with haskell.lib;+ {+ inherit {{ project }};+ {{ project }}-dev = addBuildTools {{ project }} [+ haskell-language-server+ cabal-install+ ];+ };+ };+}
data/templates/haskell/template.toml view
@@ -35,6 +35,11 @@ """ name = "isProject" +[[options]]+default = true+desc = "whether to add an \"expand src\" comment used by cabal-fmt"+name = "cabal-fmt"+ [[optionals]] ignores = [ "cabal.project",
data/templates/haskell/{{ project }}.cabal view
@@ -1,21 +1,21 @@-cabal-version: 3.0-name: {{ project }}-version: {{ version }}+cabal-version: 3.0+name: {{ project }}+version: {{ version }} -- synopsis: -- description: -- category:-license: {{ license }}-license-file: LICENSE-author: {{ name }}-maintainer: {{ name }} <{{ email }}>-copyright: Copyright (c) {{ name }} {{ year }}-stability: alpha-homepage: https://github.com/{{ github_username }}/{{ project }}-bug-reports: https://github.com/{{ github_username }}/{{ project }}/issues+license: {{ license }}+license-file: LICENSE+author: {{ name }}+maintainer: {{ name }} <{{ email }}>+copyright: Copyright (c) {{ name }} {{ year }}+stability: alpha+homepage: https://github.com/{{ github_username }}/{{ project }}+bug-reports: https://github.com/{{ github_username }}/{{ project }}/issues extra-doc-files:- README.md CHANGELOG.md+ README.md common common-attrs build-depends:@@ -27,35 +27,46 @@ BangPatterns ConstraintKinds DataKinds+ DefaultSignatures DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable+ DerivingStrategies+ DuplicateRecordFields EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies+ GADTs+ GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MultiWayIf+ NamedFieldPuns OverloadedStrings PartialTypeSignatures PatternSynonyms+ QuantifiedConstraints RecordWildCards- DuplicateRecordFields+ RoleAnnotations ScopedTypeVariables+ StandaloneKindSignatures TupleSections TypeApplications TypeFamilies+ TypeFamilyDependencies TypeOperators- UnicodeSyntax ViewPatterns library import: common-attrs build-depends: +{{#cabal-fmt}}+ -- cabal-fmt: expand src+{{/cabal-fmt}} exposed-modules: other-modules:
hinit.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: hinit-version: 0.2.0+version: 0.2.1 synopsis: Generic project initialization tool description: hinit is a generic project initialization tool similar to cookiecutter.@@ -18,13 +18,14 @@ CHANGELOG.md README.md -tested-with: GHC ==8.10.2+tested-with: GHC ==8.10.* data-dir: data data-files: licenses/*.txt templates/haskell/**/*.hs templates/haskell/*.cabal templates/haskell/*.md+ templates/haskell/*.nix templates/haskell/.gitignore templates/haskell/cabal.project templates/haskell/hie.yaml@@ -74,12 +75,11 @@ , containers ^>=0.6.2 , directory ^>=1.3.6 , exceptions ^>=0.10.4- , generic-lens ^>=2.0.0 , Glob ^>=0.10.1 , haskeline ^>=0.8.1- , lens ^>=4.19 , megaparsec ^>=9.0.0 , mustache ^>=2.3.1+ , optics-core ^>=0.3.0 , optparse-applicative >=0.15.1 && <1.17 , parser-combinators ^>=1.2.1 , path >=0.7.0 && <0.9
src/Hinit/License.hs view
@@ -46,10 +46,8 @@ initializeLicense :: (Has (Lift IO) sig m) => LicenseId -> Context -> Path a Dir -> m () initializeLicense licenseId ctx projectPath = do- let targetFile = projectPath </> [relfile|LICENSE|] licenseFile <- getLicenseFile licenseId- let spdxCtx = buildSPDXContext ctx- let mRendered = render spdxCtx licenseFile- case mRendered of- Right rendered -> sendIO $ T.writeFile (toFilePath targetFile) rendered- Left e -> error [i|impossible, failed to render license: #{e}|]+ let targetFile = projectPath </> [relfile|LICENSE|]+ spdxCtx = buildSPDXContext ctx+ rendered = unsafeRender spdxCtx licenseFile+ sendIO $ T.writeFile (toFilePath targetFile) rendered
src/Hinit/Process.hs view
@@ -3,7 +3,6 @@ import Control.Effect.Lift import Control.Effect.Terminal import Control.Effect.Throw-import Control.Monad import Data.Maybe import Data.Text.Prettyprint.Doc import Hinit.Errors
src/Hinit/Template/Config.hs view
@@ -8,11 +8,11 @@ module Hinit.Template.Config where import Control.Applicative-import Control.Lens ((^.), _1, _2, _3)-import Data.Generics.Labels () import Data.String.Interpolate import Data.Text (Text, pack, unpack)+import Data.Tuple.Optics import GHC.Generics+import Optics.Operators import System.FilePath.Glob ( Pattern, compile,