module Ribosome.App.NewProject where import qualified Data.Text.IO as Text import Polysemy.Chronos (ChronosTime) import qualified Time import Ribosome.App.Boot (generateBoot) import Ribosome.App.Data (Global (..), NewProject (..), Project (..), unPrintDir) import Ribosome.App.Error (RainbowError) import Ribosome.App.TemplateTree (writeTemplateTree) import Ribosome.App.Templates (newProjectTemplates) import Ribosome.App.UserInput (cmdColor, infoMessage, neovimChunk, pathChunk, pathColor, putStderr) import Ribosome.Host.Path (pathText) newProject :: Members [ChronosTime, Stop RainbowError, Embed IO] r => Global -> NewProject -> Sem r () newProject :: forall (r :: EffectRow). Members '[ChronosTime, Stop RainbowError, Embed IO] r => Global -> NewProject -> Sem r () newProject Global global NewProject {$sel:project:NewProject :: NewProject -> Project project = pro :: Project pro@Project {Maybe Cachix Maybe Github Path Abs Dir Branch ProjectNames $sel:branch:Project :: Project -> Branch $sel:directory:Project :: Project -> Path Abs Dir $sel:cachix:Project :: Project -> Maybe Cachix $sel:github:Project :: Project -> Maybe Github $sel:names:Project :: Project -> ProjectNames branch :: Branch directory :: Path Abs Dir cachix :: Maybe Cachix github :: Maybe Github names :: ProjectNames ..}, PrintDir Maintainer Author FlakeUrl $sel:maintainer:NewProject :: NewProject -> Maintainer $sel:author:NewProject :: NewProject -> Author $sel:printDir:NewProject :: NewProject -> PrintDir $sel:flakeUrl:NewProject :: NewProject -> FlakeUrl maintainer :: Maintainer author :: Author printDir :: PrintDir flakeUrl :: FlakeUrl ..} = do Year year <- Years -> Year forall a b. (Integral a, Num b) => a -> b fromIntegral (Years -> Year) -> (Date -> Years) -> Date -> Year forall b c a. (b -> c) -> (a -> b) -> a -> c . Date -> Years forall t. HasYear t => t -> Years Time.year (Date -> Year) -> Sem r Date -> Sem r Year forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Sem r Date forall t d (r :: EffectRow). Member (Time t d) r => Sem r d Time.today Global -> Path Abs Dir -> TemplateTree -> Sem r () forall (r :: EffectRow). Members '[Stop RainbowError, Embed IO] r => Global -> Path Abs Dir -> TemplateTree -> Sem r () writeTemplateTree Global global Path Abs Dir directory (ProjectNames -> FlakeUrl -> Author -> Maintainer -> Branch -> Maybe Github -> Maybe Cachix -> Year -> TemplateTree newProjectTemplates ProjectNames names FlakeUrl flakeUrl Author author Maintainer maintainer Branch branch Maybe Github github Maybe Cachix cachix Year year) Bool -> Sem r () -> Sem r () forall (f :: * -> *). Applicative f => Bool -> f () -> f () unless (Global global Global -> Getting Bool Global Bool -> Bool forall s a. s -> Getting a s a -> a ^. IsLabel "quiet" (Getting Bool Global Bool) Getting Bool Global Bool #quiet) do [Chunk] -> Sem r () forall (r :: EffectRow). Members '[Stop RainbowError, Embed IO] r => [Chunk] -> Sem r () infoMessage [ Item [Chunk] "🌝 Initialized a ", Item [Chunk] Chunk neovimChunk, Item [Chunk] " plugin project in ", Path Abs Dir -> Chunk forall b t. Path b t -> Chunk pathChunk Path Abs Dir directory, Item [Chunk] "." ] [Chunk] -> Sem r () forall (r :: EffectRow). Members '[Stop RainbowError, Embed IO] r => [Chunk] -> Sem r () infoMessage [ Item [Chunk] "Run ", Chunk -> Chunk cmdColor Chunk "nix build .#static", Item [Chunk] " in that directory to create a statically linked executable in ", Chunk -> Chunk pathColor Chunk "result/bin", Item [Chunk] "." ] Text -> Sem r () forall (r :: EffectRow). Member (Embed IO) r => Text -> Sem r () putStderr Text "" Global -> Project -> Sem r () forall (r :: EffectRow). Members '[Stop RainbowError, Embed IO] r => Global -> Project -> Sem r () generateBoot Global global Project pro Bool -> Sem r () -> Sem r () forall (f :: * -> *). Applicative f => Bool -> f () -> f () when (PrintDir -> Bool unPrintDir PrintDir printDir) (IO () -> Sem r () forall (m :: * -> *) (r :: EffectRow) a. Member (Embed m) r => m a -> Sem r a embed (Text -> IO () Text.putStrLn (Path Abs Dir -> Text forall b t. Path b t -> Text pathText Path Abs Dir directory)))